⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 107261 in webkit


Ignore:
Timestamp:
Feb 9, 2012, 10:56:40 AM (15 years ago)
Author:
kling@webkit.org
Message:

Avoid unnecessary work when evaluating style sharing candidates.
<http://webkit.org/b/78220>

Reviewed by Antti Koivisto.

Do the cheap checks (bitfields, pointers) before calling virtuals and doing hash lookups.
Remove comparison of attributes that are reflected in the attribute styles (cellpadding,
lang and xml:lang.) Moved comparison of "type" and "readonly" attributes into the more
specific canShareStyleWithControl() since they are only relevant for input elements.
Don't bother calling isFormControlElement() on both elements since we already know they
have the same tagQName().

Altogether this knocks off 8-9ms worth of samples per cycle of the "Moz" page cycler test.

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::canShareStyleWithControl):
(WebCore::CSSStyleSelector::canShareStyleWithElement):
(WebCore::isCommonAttributeSelectorAttribute):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r107259 r107261  
     12012-02-09  Andreas Kling  <awesomekling@apple.com>
     2
     3        Avoid unnecessary work when evaluating style sharing candidates.
     4        <http://webkit.org/b/78220>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Do the cheap checks (bitfields, pointers) before calling virtuals and doing hash lookups.
     9        Remove comparison of attributes that are reflected in the attribute styles (cellpadding,
     10        lang and xml:lang.) Moved comparison of "type" and "readonly" attributes into the more
     11        specific canShareStyleWithControl() since they are only relevant for input elements.
     12        Don't bother calling isFormControlElement() on both elements since we already know they
     13        have the same tagQName().
     14
     15        Altogether this knocks off 8-9ms worth of samples per cycle of the "Moz" page cycler test.
     16
     17        * css/CSSStyleSelector.cpp:
     18        (WebCore::CSSStyleSelector::canShareStyleWithControl):
     19        (WebCore::CSSStyleSelector::canShareStyleWithElement):
     20        (WebCore::isCommonAttributeSelectorAttribute):
     21
    1222012-02-09  Mike Lawther  <mikelawther@chromium.org>
    223
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r107212 r107261  
    11911191    }
    11921192
     1193    if (element->fastGetAttribute(typeAttr) != m_element->fastGetAttribute(typeAttr))
     1194        return false;
     1195
     1196    if (element->fastGetAttribute(readonlyAttr) != m_element->fastGetAttribute(readonlyAttr))
     1197        return false;
     1198
     1199
    11931200    return true;
    11941201}
     
    12361243    if (!!element->attributeStyle() != !!m_styledElement->attributeStyle())
    12371244        return false;
    1238     StylePropertySet* additionalAttributeStyleA = element->additionalAttributeStyle();
    1239     StylePropertySet* additionalAttributeStyleB = m_styledElement->additionalAttributeStyle();
    1240     if (!additionalAttributeStyleA != !additionalAttributeStyleB)
    1241         return false;
    12421245    if (element->isLink() != m_element->isLink())
    12431246        return false;
     
    12501253    if (element->focused() != m_element->focused())
    12511254        return false;
    1252     if (element->shadowPseudoId() != m_element->shadowPseudoId())
    1253         return false;
    12541255    if (element == element->document()->cssTarget())
    12551256        return false;
    12561257    if (m_element == m_element->document()->cssTarget())
    12571258        return false;
    1258     if (element->getAttribute(typeAttr) != m_element->getAttribute(typeAttr))
     1259    if (style->transitions() || style->animations())
    12591260        return false;
    1260     if (element->fastGetAttribute(XMLNames::langAttr) != m_element->fastGetAttribute(XMLNames::langAttr))
     1261    if (element->isLink() && m_elementLinkState != style->insideLink())
    12611262        return false;
    1262     if (element->fastGetAttribute(langAttr) != m_element->fastGetAttribute(langAttr))
     1263    if (element->shadowPseudoId() != m_element->shadowPseudoId())
    12631264        return false;
    1264     if (element->fastGetAttribute(readonlyAttr) != m_element->fastGetAttribute(readonlyAttr))
    1265         return false;
    1266     if (element->fastGetAttribute(cellpaddingAttr) != m_element->fastGetAttribute(cellpaddingAttr))
    1267         return false;
    1268 
    12691265    if (element->hasID() && m_features.idsInRules.contains(element->idForStyleResolution().impl()))
    12701266        return false;
    1271 
    1272 #if ENABLE(STYLE_SCOPED)
    1273     if (element->hasScopedHTMLStyleChild())
    1274         return false;
    1275 #endif
    1276 
    1277     bool isControl = element->isFormControlElement();
    1278 
    1279     if (isControl != m_element->isFormControlElement())
    1280         return false;
    1281 
    1282     if (isControl && !canShareStyleWithControl(element))
    1283         return false;
    1284 
    1285     if (style->transitions() || style->animations())
     1267    if (m_element->isFormControlElement() && !canShareStyleWithControl(element))
    12861268        return false;
    12871269
     
    13041286        return false;
    13051287
     1288    StylePropertySet* additionalAttributeStyleA = element->additionalAttributeStyle();
     1289    StylePropertySet* additionalAttributeStyleB = m_styledElement->additionalAttributeStyle();
     1290    if (!additionalAttributeStyleA != !additionalAttributeStyleB)
     1291        return false;
     1292
    13061293    if (element->attributeStyle() && !attributeStylesEqual(element->attributeStyle(), m_styledElement->attributeStyle()))
    13071294        return false;
     
    13101297        return false;
    13111298
    1312     if (element->isLink() && m_elementLinkState != style->insideLink())
     1299#if ENABLE(STYLE_SCOPED)
     1300    if (element->hasScopedHTMLStyleChild())
    13131301        return false;
     1302#endif
    13141303
    13151304    return true;
     
    21742163static inline bool isCommonAttributeSelectorAttribute(const QualifiedName& attribute)
    21752164{
    2176     // These are explicitly tested for equality in canShareStyleWithElement.
     2165    // These are explicitly tested for equality in canShareStyleWithControl.
    21772166    return attribute == typeAttr || attribute == readonlyAttr;
    21782167}
Note: See TracChangeset for help on using the changeset viewer.