Commit 880effa5 authored by kouhei@chromium.org's avatar kouhei@chromium.org

SVGElement::parseAttribute resolves property via property map (Step 2.4)

This is to replace the existing |SVGElement::parseAttribute| implementation,
but as there are many callers, we would like to proceed this incrementally.
a) Introduce |SVGElement::parseAttributeNew| *LANDED*
b) Convert all overrides |SVGElement::parseAttribute| to
   a |parseAttributeNew| call. <-- This patch
c) Replace existing |parseAttribute| with |parseAttributeNew|, and remove all
   overrides simply calling |parseAttributeNew|

This patch is (b).

BUG=397902

Review URL: https://codereview.chromium.org/643703006

git-svn-id: svn://svn.chromium.org/blink/trunk@183736 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b5df1b62
...@@ -44,9 +44,8 @@ SVGCursorElement::~SVGCursorElement() ...@@ -44,9 +44,8 @@ SVGCursorElement::~SVGCursorElement()
{ {
// The below teardown is all handled by weak pointer processing in oilpan. // The below teardown is all handled by weak pointer processing in oilpan.
#if !ENABLE(OILPAN) #if !ENABLE(OILPAN)
HashSet<RawPtr<SVGElement> >::iterator end = m_clients.end(); for (auto& client : m_clients)
for (HashSet<RawPtr<SVGElement> >::iterator it = m_clients.begin(); it != end; ++it) client->cursorElementRemoved();
(*it)->cursorElementRemoved();
#endif #endif
} }
...@@ -64,21 +63,7 @@ bool SVGCursorElement::isSupportedAttribute(const QualifiedName& attrName) ...@@ -64,21 +63,7 @@ bool SVGCursorElement::isSupportedAttribute(const QualifiedName& attrName)
void SVGCursorElement::parseAttribute(const QualifiedName& name, const AtomicString& value) void SVGCursorElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{ {
SVGParsingError parseError = NoError; parseAttributeNew(name, value);
if (!isSupportedAttribute(name)) {
SVGElement::parseAttribute(name, value);
} else if (name == SVGNames::xAttr) {
m_x->setBaseValueAsString(value, parseError);
} else if (name == SVGNames::yAttr) {
m_y->setBaseValueAsString(value, parseError);
} else if (SVGURIReference::parseAttribute(name, value, parseError)) {
} else if (SVGTests::parseAttribute(name, value)) {
} else {
ASSERT_NOT_REACHED();
}
reportAttributeParsingError(parseError, name, value);
} }
void SVGCursorElement::addClient(SVGElement* element) void SVGCursorElement::addClient(SVGElement* element)
...@@ -113,11 +98,8 @@ void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName) ...@@ -113,11 +98,8 @@ void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName)
SVGElement::InvalidationGuard invalidationGuard(this); SVGElement::InvalidationGuard invalidationGuard(this);
// Any change of a cursor specific attribute triggers this recalc. // Any change of a cursor specific attribute triggers this recalc.
WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator it = m_clients.begin(); for (auto& client : m_clients)
WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator end = m_clients.end(); client->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::SVGCursor));
for (; it != end; ++it)
(*it)->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::SVGCursor));
} }
void SVGCursorElement::trace(Visitor* visitor) void SVGCursorElement::trace(Visitor* visitor)
......
...@@ -55,7 +55,6 @@ void SVGGlyphRefElement::parseAttributeInternal(const QualifiedName& name, const ...@@ -55,7 +55,6 @@ void SVGGlyphRefElement::parseAttributeInternal(const QualifiedName& name, const
const CharType* end = ptr + value.length(); const CharType* end = ptr + value.length();
// FIXME: We need some error handling here. // FIXME: We need some error handling here.
SVGParsingError parseError = NoError;
if (name == SVGNames::xAttr) { if (name == SVGNames::xAttr) {
parseNumber(ptr, end, m_x); parseNumber(ptr, end, m_x);
} else if (name == SVGNames::yAttr) { } else if (name == SVGNames::yAttr) {
...@@ -64,11 +63,9 @@ void SVGGlyphRefElement::parseAttributeInternal(const QualifiedName& name, const ...@@ -64,11 +63,9 @@ void SVGGlyphRefElement::parseAttributeInternal(const QualifiedName& name, const
parseNumber(ptr, end, m_dx); parseNumber(ptr, end, m_dx);
} else if (name == SVGNames::dyAttr) { } else if (name == SVGNames::dyAttr) {
parseNumber(ptr, end, m_dy); parseNumber(ptr, end, m_dy);
} else if (SVGURIReference::parseAttribute(name, value, parseError)) {
} else { } else {
SVGElement::parseAttribute(name, value); parseAttributeNew(name, value);
} }
reportAttributeParsingError(parseError, name, value);
} }
void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value) void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
......
...@@ -91,44 +91,20 @@ void SVGMPathElement::removedFrom(ContainerNode* rootParent) ...@@ -91,44 +91,20 @@ void SVGMPathElement::removedFrom(ContainerNode* rootParent)
clearResourceReferences(); clearResourceReferences();
} }
bool SVGMPathElement::isSupportedAttribute(const QualifiedName& attrName)
{
DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
if (supportedAttributes.isEmpty()) {
SVGURIReference::addSupportedAttributes(supportedAttributes);
}
return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
}
void SVGMPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value) void SVGMPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{ {
SVGParsingError parseError = NoError; parseAttributeNew(name, value);
if (!isSupportedAttribute(name)) {
SVGElement::parseAttribute(name, value);
} else if (SVGURIReference::parseAttribute(name, value, parseError)) {
} else {
ASSERT_NOT_REACHED();
}
reportAttributeParsingError(parseError, name, value);
} }
void SVGMPathElement::svgAttributeChanged(const QualifiedName& attrName) void SVGMPathElement::svgAttributeChanged(const QualifiedName& attrName)
{ {
if (!isSupportedAttribute(attrName)) {
SVGElement::svgAttributeChanged(attrName);
return;
}
SVGElement::InvalidationGuard invalidationGuard(this);
if (SVGURIReference::isKnownAttribute(attrName)) { if (SVGURIReference::isKnownAttribute(attrName)) {
SVGElement::InvalidationGuard invalidationGuard(this);
buildPendingResource(); buildPendingResource();
return; return;
} }
ASSERT_NOT_REACHED(); SVGElement::svgAttributeChanged(attrName);
} }
SVGPathElement* SVGMPathElement::pathElement() SVGPathElement* SVGMPathElement::pathElement()
......
...@@ -50,7 +50,6 @@ private: ...@@ -50,7 +50,6 @@ private:
virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; virtual InsertionNotificationRequest insertedInto(ContainerNode*) override;
virtual void removedFrom(ContainerNode*) override; virtual void removedFrom(ContainerNode*) override;
bool isSupportedAttribute(const QualifiedName&);
virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
virtual void svgAttributeChanged(const QualifiedName&) override; virtual void svgAttributeChanged(const QualifiedName&) override;
......
...@@ -49,56 +49,23 @@ PassRefPtrWillBeRawPtr<SVGScriptElement> SVGScriptElement::create(Document& docu ...@@ -49,56 +49,23 @@ PassRefPtrWillBeRawPtr<SVGScriptElement> SVGScriptElement::create(Document& docu
return adoptRefWillBeNoop(new SVGScriptElement(document, insertedByParser, false)); return adoptRefWillBeNoop(new SVGScriptElement(document, insertedByParser, false));
} }
bool SVGScriptElement::isSupportedAttribute(const QualifiedName& attrName)
{
DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
if (supportedAttributes.isEmpty()) {
SVGURIReference::addSupportedAttributes(supportedAttributes);
supportedAttributes.add(SVGNames::typeAttr);
supportedAttributes.add(HTMLNames::onerrorAttr);
}
return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
}
void SVGScriptElement::parseAttribute(const QualifiedName& name, const AtomicString& value) void SVGScriptElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{ {
if (!isSupportedAttribute(name)) { if (name == HTMLNames::onerrorAttr)
SVGElement::parseAttribute(name, value);
return;
}
SVGParsingError parseError = NoError;
if (name == SVGNames::typeAttr)
return;
if (name == HTMLNames::onerrorAttr) {
setAttributeEventListener(EventTypeNames::error, createAttributeEventListener(this, name, value, eventParameterName())); setAttributeEventListener(EventTypeNames::error, createAttributeEventListener(this, name, value, eventParameterName()));
} else if (SVGURIReference::parseAttribute(name, value, parseError)) { else
} else { parseAttributeNew(name, value);
ASSERT_NOT_REACHED();
}
reportAttributeParsingError(parseError, name, value);
} }
void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName)
{ {
if (!isSupportedAttribute(attrName)) {
SVGElement::svgAttributeChanged(attrName);
return;
}
SVGElement::InvalidationGuard invalidationGuard(this);
if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr)
return;
if (SVGURIReference::isKnownAttribute(attrName)) { if (SVGURIReference::isKnownAttribute(attrName)) {
SVGElement::InvalidationGuard invalidationGuard(this);
m_loader->handleSourceAttribute(hrefString()); m_loader->handleSourceAttribute(hrefString());
return; return;
} }
ASSERT_NOT_REACHED(); SVGElement::svgAttributeChanged(attrName);
} }
Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode* rootParent) Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode* rootParent)
......
...@@ -50,7 +50,6 @@ private: ...@@ -50,7 +50,6 @@ private:
SVGScriptElement(Document&, bool wasInsertedByParser, bool alreadyStarted); SVGScriptElement(Document&, bool wasInsertedByParser, bool alreadyStarted);
virtual ~SVGScriptElement(); virtual ~SVGScriptElement();
bool isSupportedAttribute(const QualifiedName&);
virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; virtual InsertionNotificationRequest insertedInto(ContainerNode*) override;
virtual void didNotifySubtreeInsertionsToDocument() override; virtual void didNotifySubtreeInsertionsToDocument() override;
......
...@@ -86,25 +86,6 @@ bool SVGTextPathElement::isSupportedAttribute(const QualifiedName& attrName) ...@@ -86,25 +86,6 @@ bool SVGTextPathElement::isSupportedAttribute(const QualifiedName& attrName)
return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
} }
void SVGTextPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
SVGParsingError parseError = NoError;
if (!isSupportedAttribute(name))
SVGTextContentElement::parseAttribute(name, value);
else if (name == SVGNames::startOffsetAttr)
m_startOffset->setBaseValueAsString(value, parseError);
else if (name == SVGNames::methodAttr)
m_method->setBaseValueAsString(value, parseError);
else if (name == SVGNames::spacingAttr)
m_spacing->setBaseValueAsString(value, parseError);
else if (SVGURIReference::parseAttribute(name, value, parseError)) {
} else
ASSERT_NOT_REACHED();
reportAttributeParsingError(parseError, name, value);
}
void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName)
{ {
if (!isSupportedAttribute(attrName)) { if (!isSupportedAttribute(attrName)) {
......
...@@ -73,7 +73,6 @@ private: ...@@ -73,7 +73,6 @@ private:
virtual void removedFrom(ContainerNode*) override; virtual void removedFrom(ContainerNode*) override;
bool isSupportedAttribute(const QualifiedName&); bool isSupportedAttribute(const QualifiedName&);
virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
virtual void svgAttributeChanged(const QualifiedName&) override; virtual void svgAttributeChanged(const QualifiedName&) override;
virtual RenderObject* createRenderer(RenderStyle*) override; virtual RenderObject* createRenderer(RenderStyle*) override;
......
...@@ -105,13 +105,4 @@ void SVGURIReference::addSupportedAttributes(HashSet<QualifiedName>& supportedAt ...@@ -105,13 +105,4 @@ void SVGURIReference::addSupportedAttributes(HashSet<QualifiedName>& supportedAt
supportedAttributes.add(XLinkNames::hrefAttr); supportedAttributes.add(XLinkNames::hrefAttr);
} }
bool SVGURIReference::parseAttribute(const QualifiedName& name, const AtomicString& value, SVGParsingError& parseError)
{
if (name.matches(XLinkNames::hrefAttr)) {
m_href->setBaseValueAsString(value, parseError);
return true;
}
return false;
}
} }
...@@ -50,7 +50,6 @@ public: ...@@ -50,7 +50,6 @@ public:
} }
const String& hrefString() const { return m_href->currentValue()->value(); } const String& hrefString() const { return m_href->currentValue()->value(); }
bool parseAttribute(const QualifiedName&, const AtomicString& value, SVGParsingError&);
// JS API // JS API
SVGAnimatedString* href() const { return m_href.get(); } SVGAnimatedString* href() const { return m_href.get(); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment