Changeset 107551 in webkit


Ignore:
Timestamp:
Feb 13, 2012 2:09:49 AM (12 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.)
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 as they already have the same tagQName().

Altogether this knocks off ~8ms 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

    r107548 r107551  
     12012-02-13  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        Moved comparison of "type" and "readonly" attributes into the more specific
     11        canShareStyleWithControl() since they are only relevant for input elements. Don't bother
     12        calling isFormControlElement() on both elements as they already have the same tagQName().
     13
     14        Altogether this knocks off ~8ms worth of samples per cycle of the "Moz" page cycler test.
     15
     16        * css/CSSStyleSelector.cpp:
     17        (WebCore::CSSStyleSelector::canShareStyleWithControl):
     18        (WebCore::CSSStyleSelector::canShareStyleWithElement):
     19        (WebCore::isCommonAttributeSelectorAttribute):
     20
    1212012-02-13  Arko Saha  <arko@motorola.com>
    222
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r107526 r107551  
    11901190    }
    11911191
     1192    if (element->fastGetAttribute(typeAttr) != m_element->fastGetAttribute(typeAttr))
     1193        return false;
     1194
     1195    if (element->fastGetAttribute(readonlyAttr) != m_element->fastGetAttribute(readonlyAttr))
     1196        return false;
     1197
     1198
    11921199    return true;
    11931200}
     
    12351242    if (!!element->attributeStyle() != !!m_styledElement->attributeStyle())
    12361243        return false;
    1237     StylePropertySet* additionalAttributeStyleA = element->additionalAttributeStyle();
    1238     StylePropertySet* additionalAttributeStyleB = m_styledElement->additionalAttributeStyle();
    1239     if (!additionalAttributeStyleA != !additionalAttributeStyleB)
    1240         return false;
    12411244    if (element->isLink() != m_element->isLink())
    12421245        return false;
     
    12491252    if (element->focused() != m_element->focused())
    12501253        return false;
    1251     if (element->shadowPseudoId() != m_element->shadowPseudoId())
    1252         return false;
    12531254    if (element == element->document()->cssTarget())
    12541255        return false;
    12551256    if (m_element == m_element->document()->cssTarget())
    12561257        return false;
    1257     if (element->getAttribute(typeAttr) != m_element->getAttribute(typeAttr))
     1258    if (style->transitions() || style->animations())
    12581259        return false;
    1259     if (element->fastGetAttribute(XMLNames::langAttr) != m_element->fastGetAttribute(XMLNames::langAttr))
     1260    if (element->isLink() && m_elementLinkState != style->insideLink())
    12601261        return false;
    1261     if (element->fastGetAttribute(langAttr) != m_element->fastGetAttribute(langAttr))
     1262    if (element->shadowPseudoId() != m_element->shadowPseudoId())
    12621263        return false;
    1263     if (element->fastGetAttribute(readonlyAttr) != m_element->fastGetAttribute(readonlyAttr))
    1264         return false;
    1265     if (element->fastGetAttribute(cellpaddingAttr) != m_element->fastGetAttribute(cellpaddingAttr))
    1266         return false;
    1267 
    12681264    if (element->hasID() && m_features.idsInRules.contains(element->idForStyleResolution().impl()))
    12691265        return false;
    1270 
    1271 #if ENABLE(STYLE_SCOPED)
    1272     if (element->hasScopedHTMLStyleChild())
    1273         return false;
    1274 #endif
    1275 
    1276     bool isControl = element->isFormControlElement();
    1277 
    1278     if (isControl != m_element->isFormControlElement())
    1279         return false;
    1280 
    1281     if (isControl && !canShareStyleWithControl(element))
    1282         return false;
    1283 
    1284     if (style->transitions() || style->animations())
     1266    if (m_element->isFormControlElement() && !canShareStyleWithControl(element))
    12851267        return false;
    12861268
     
    13031285        return false;
    13041286
     1287    StylePropertySet* additionalAttributeStyleA = element->additionalAttributeStyle();
     1288    StylePropertySet* additionalAttributeStyleB = m_styledElement->additionalAttributeStyle();
     1289    if (!additionalAttributeStyleA != !additionalAttributeStyleB)
     1290        return false;
     1291
     1292    if (element->fastGetAttribute(XMLNames::langAttr) != m_element->fastGetAttribute(XMLNames::langAttr))
     1293        return false;
     1294    if (element->fastGetAttribute(langAttr) != m_element->fastGetAttribute(langAttr))
     1295        return false;
     1296
    13051297    if (element->attributeStyle() && !attributeStylesEqual(element->attributeStyle(), m_styledElement->attributeStyle()))
    13061298        return false;
     
    13091301        return false;
    13101302
    1311     if (element->isLink() && m_elementLinkState != style->insideLink())
     1303#if ENABLE(STYLE_SCOPED)
     1304    if (element->hasScopedHTMLStyleChild())
    13121305        return false;
     1306#endif
    13131307
    13141308    return true;
     
    21732167static inline bool isCommonAttributeSelectorAttribute(const QualifiedName& attribute)
    21742168{
    2175     // These are explicitly tested for equality in canShareStyleWithElement.
     2169    // These are explicitly tested for equality in canShareStyleWithControl.
    21762170    return attribute == typeAttr || attribute == readonlyAttr;
    21772171}
Note: See TracChangeset for help on using the changeset viewer.