Skip to content
Permalink
Browse files
StyledElement: Make handling the "style" attribute a litte faster.
<http://webkit.org/b/102623>

Reviewed by Ojan Vafai.

We know that "style" is never a presentation attribute, so avoid the virtual call to isPresentationAttribute()
by hoisting the parseAttribute() logic up into attributeChanged().
Did the same thing with Element::parseAttribute() for consistency.

Knocks ~0.6% of samples off of the DOM/CreateNodes performance test.

* dom/Element.cpp:
(WebCore::Element::attributeChanged):
* dom/Element.h:
(WebCore::Element::parseAttribute):
* dom/StyledElement.cpp:
(WebCore::StyledElement::attributeChanged):
* dom/StyledElement.h:
(StyledElement):


Canonical link: https://commits.webkit.org/120776@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135101 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Nov 19, 2012
1 parent fe90f0a commit 6754121bbf0227219d2724a072e9fd3de6325f9f
Showing 5 changed files with 29 additions and 18 deletions.
@@ -1,3 +1,25 @@
2012-11-18 Andreas Kling <akling@apple.com>

StyledElement: Make handling the "style" attribute a litte faster.
<http://webkit.org/b/102623>

Reviewed by Ojan Vafai.

We know that "style" is never a presentation attribute, so avoid the virtual call to isPresentationAttribute()
by hoisting the parseAttribute() logic up into attributeChanged().
Did the same thing with Element::parseAttribute() for consistency.

Knocks ~0.6% of samples off of the DOM/CreateNodes performance test.

* dom/Element.cpp:
(WebCore::Element::attributeChanged):
* dom/Element.h:
(WebCore::Element::parseAttribute):
* dom/StyledElement.cpp:
(WebCore::StyledElement::attributeChanged):
* dom/StyledElement.h:
(StyledElement):

2012-11-18 Laszlo Gombos <l.gombos@samsung.com>

[CMake] Consolidate common input files
@@ -773,7 +773,9 @@ void Element::attributeChanged(const QualifiedName& name, const AtomicString& ne
attributeData()->setIdForStyleResolution(newId);
shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyleInvalidationForIdChange(oldId, newId, styleResolver);
}
} else if (name == HTMLNames::nameAttr)
} else if (name == classAttr)
classAttributeChanged(newValue);
else if (name == HTMLNames::nameAttr)
setHasName(!newValue.isNull());
else if (name == HTMLNames::pseudoAttr)
shouldInvalidateStyle |= testShouldInvalidateStyle && isInShadowTree();
@@ -789,12 +791,6 @@ void Element::attributeChanged(const QualifiedName& name, const AtomicString& ne
document()->axObjectCache()->handleAttributeChanged(name, this);
}

void Element::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == classAttr)
classAttributeChanged(value);
}

template <typename CharacterType>
static inline bool classStringHasClassName(const CharacterType* characters, unsigned length)
{
@@ -246,7 +246,7 @@ class Element : public ContainerNode {

// This method is called whenever an attribute is added, changed or removed.
virtual void attributeChanged(const QualifiedName&, const AtomicString&);
virtual void parseAttribute(const QualifiedName&, const AtomicString&);
virtual void parseAttribute(const QualifiedName&, const AtomicString&) { }

// Only called by the parser immediately after element construction.
void parserSetAttributes(const Vector<Attribute>&, FragmentScriptingPermission);
@@ -158,7 +158,9 @@ StylePropertySet* StyledElement::ensureMutableInlineStyle()

void StyledElement::attributeChanged(const QualifiedName& name, const AtomicString& newValue)
{
if (isPresentationAttribute(name)) {
if (name == styleAttr)
styleAttributeChanged(newValue);
else if (isPresentationAttribute(name)) {
// Avoid dirtying the presentation attribute style if we're using shared attribute data with already generated style.
if (attributeData()->isMutable() || !attributeData()->m_presentationAttributeStyle)
attributeData()->m_presentationAttributeStyleIsDirty = true;
@@ -215,14 +217,6 @@ void StyledElement::styleAttributeChanged(const AtomicString& newStyleString)
InspectorInstrumentation::didInvalidateStyleAttr(document(), this);
}

void StyledElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == styleAttr)
styleAttributeChanged(value);
else
Element::parseAttribute(name, value);
}

void StyledElement::inlineStyleChanged()
{
setNeedsStyleRecalc(InlineStyleChange);
@@ -63,7 +63,6 @@ class StyledElement : public Element {
}

virtual void attributeChanged(const QualifiedName&, const AtomicString&) OVERRIDE;
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;

virtual bool isPresentationAttribute(const QualifiedName&) const { return false; }

0 comments on commit 6754121

Please sign in to comment.