Changeset 102555 in webkit


Ignore:
Timestamp:
Dec 11, 2011 7:43:10 PM (12 years ago)
Author:
kling@webkit.org
Message:

Micro-optimize CSSStyleSelector::findSiblingForStyleSharing().
<http://webkit.org/b/74261>

Reviewed by Antti Koivisto.

Move the isStyledElement() check from canShareStyleWithElement() into the
loop in findSiblingForStyleSharing(), and tighten up the argument/return
types to StyledElement* as appropriate.

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::canShareStyleWithElement):
(WebCore::CSSStyleSelector::findSiblingForStyleSharing):
(WebCore::CSSStyleSelector::locateSharedStyle):

  • css/CSSStyleSelector.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102553 r102555  
     12011-12-11  Andreas Kling  <kling@webkit.org>
     2
     3        Micro-optimize CSSStyleSelector::findSiblingForStyleSharing().
     4        <http://webkit.org/b/74261>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Move the isStyledElement() check from canShareStyleWithElement() into the
     9        loop in findSiblingForStyleSharing(), and tighten up the argument/return
     10        types to StyledElement* as appropriate.
     11
     12        * css/CSSStyleSelector.cpp:
     13        (WebCore::CSSStyleSelector::canShareStyleWithElement):
     14        (WebCore::CSSStyleSelector::findSiblingForStyleSharing):
     15        (WebCore::CSSStyleSelector::locateSharedStyle):
     16        * css/CSSStyleSelector.h:
     17
    1182011-12-11  Shinya Kawanaka  <shinyak@google.com>
    219
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r102552 r102555  
    993993}
    994994
    995 bool CSSStyleSelector::canShareStyleWithElement(Node* node) const
    996 {
    997     if (!node->isStyledElement())
    998         return false;
    999 
    1000     StyledElement* element = static_cast<StyledElement*>(node);
     995bool CSSStyleSelector::canShareStyleWithElement(StyledElement* element) const
     996{
    1001997    RenderStyle* style = element->renderStyle();
    1002998
     
    10811077}
    10821078
    1083 inline Node* CSSStyleSelector::findSiblingForStyleSharing(Node* node, unsigned& count) const
     1079inline StyledElement* CSSStyleSelector::findSiblingForStyleSharing(Node* node, unsigned& count) const
    10841080{
    10851081    for (; node; node = node->previousSibling()) {
    1086         if (!node->isElementNode())
     1082        if (!node->isStyledElement())
    10871083            continue;
    1088         if (canShareStyleWithElement(node))
     1084        if (canShareStyleWithElement(static_cast<StyledElement*>(node)))
    10891085            break;
    10901086        if (count++ == cStyleSearchThreshold)
    10911087            return 0;
    10921088    }
    1093     return node;
     1089    return static_cast<StyledElement*>(node);
    10941090}
    10951091
     
    11181114    unsigned count = 0;
    11191115    unsigned visitedNodeCount = 0;
    1120     Node* shareNode = 0;
     1116    StyledElement* shareElement = 0;
    11211117    Node* cousinList = m_styledElement->previousSibling();
    11221118    while (cousinList) {
    1123         shareNode = findSiblingForStyleSharing(cousinList, count);
    1124         if (shareNode)
     1119        shareElement = findSiblingForStyleSharing(cousinList, count);
     1120        if (shareElement)
    11251121            break;
    11261122        cousinList = locateCousinList(cousinList->parentElement(), visitedNodeCount);
     
    11281124
    11291125    // If we have exhausted all our budget or our cousins.
    1130     if (!shareNode)
     1126    if (!shareElement)
    11311127        return 0;
    11321128
     
    11401136    if (parentStylePreventsSharing(m_parentStyle))
    11411137        return 0;
    1142     return shareNode->renderStyle();
     1138    return shareElement->renderStyle();
    11431139}
    11441140
  • trunk/Source/WebCore/css/CSSStyleSelector.h

    r102234 r102555  
    135135    bool matchesRuleSet(RuleSet*);
    136136    Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const;
    137     Node* findSiblingForStyleSharing(Node*, unsigned& count) const;
    138     bool canShareStyleWithElement(Node*) const;
     137    StyledElement* findSiblingForStyleSharing(Node*, unsigned& count) const;
     138    bool canShareStyleWithElement(StyledElement*) const;
    139139
    140140    PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const WebKitCSSKeyframeRule*, KeyframeValue&);
Note: See TracChangeset for help on using the changeset viewer.