#pragma once
#include "Document.h"
#include "QualifiedName.h"
#include "SVGPropertyOwnerRegistry.h"
namespace WebCore {
class SVGElement;
class SVGURIReference {
WTF_MAKE_NONCOPYABLE(SVGURIReference);
public:
virtual ~SVGURIReference() = default;
void parseAttribute(const QualifiedName&, const AtomString&);
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 PropertyRegistry = SVGPropertyOwnerRegistry<SVGURIReference>;
String href() const { return m_href->currentValue(); }
SVGAnimatedString& hrefAnimated() { return m_href; }
protected:
SVGURIReference(SVGElement* contextElement);
static bool isKnownAttribute(const QualifiedName& attributeName);
virtual bool haveFiredLoadEvent() const { return false; }
virtual void setHaveFiredLoadEvent(bool) { }
virtual bool errorOccurred() const { return false; }
virtual void setErrorOccurred(bool) { }
bool haveLoadedRequiredResources() const;
void dispatchLoadEvent();
private:
SVGElement& contextElement() const;
Ref<SVGAnimatedString> m_href;
};
}