#pragma once
#include "Document.h"
#include "QualifiedName.h"
#include "SVGAnimatedString.h"
namespace WebCore {
template<typename OwnerType, typename... BaseTypes>
class SVGAttributeRegistry;
template<typename OwnerType, typename... BaseTypes>
class SVGAttributeOwnerProxyImpl;
class SVGURIReference {
WTF_MAKE_NONCOPYABLE(SVGURIReference);
public:
virtual ~SVGURIReference() = default;
void parseAttribute(const QualifiedName&, const AtomicString&);
static String fragmentIdentifierFromIRIString(const String&, const Document&);
struct TargetElementResult {
RefPtr<Element> element;
String identifier;
};
static TargetElementResult targetElementFromIRIString(const String&, const TreeScope&, RefPtr<Document> externalDocument = nullptr);
static bool isExternalURIReference(const String& uri, const Document& document)
{
if (uri.startsWith('#'))
return false;
URL url = document.completeURL(uri);
ASSERT(!url.protocolIsData());
return !equalIgnoringFragmentIdentifier(url, document.url());
}
using AttributeOwnerProxy = SVGAttributeOwnerProxyImpl<SVGURIReference>;
using AttributeRegistry = SVGAttributeRegistry<SVGURIReference>;
static AttributeRegistry& attributeRegistry();
const String& href() const;
RefPtr<SVGAnimatedString> hrefAnimated();
protected:
SVGURIReference(SVGElement* contextElement);
static bool isKnownAttribute(const QualifiedName& attributeName);
private:
static void registerAttributes();
std::unique_ptr<AttributeOwnerProxy> m_attributeOwnerProxy;
SVGAnimatedStringAttribute m_href;
};
}