Changeset 102555 in webkit
- Timestamp:
- Dec 11, 2011 7:43:10 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r102553 r102555 1 2011-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 1 18 2011-12-11 Shinya Kawanaka <shinyak@google.com> 2 19 -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r102552 r102555 993 993 } 994 994 995 bool CSSStyleSelector::canShareStyleWithElement(Node* node) const 996 { 997 if (!node->isStyledElement()) 998 return false; 999 1000 StyledElement* element = static_cast<StyledElement*>(node); 995 bool CSSStyleSelector::canShareStyleWithElement(StyledElement* element) const 996 { 1001 997 RenderStyle* style = element->renderStyle(); 1002 998 … … 1081 1077 } 1082 1078 1083 inline Node* CSSStyleSelector::findSiblingForStyleSharing(Node* node, unsigned& count) const1079 inline StyledElement* CSSStyleSelector::findSiblingForStyleSharing(Node* node, unsigned& count) const 1084 1080 { 1085 1081 for (; node; node = node->previousSibling()) { 1086 if (!node->is ElementNode())1082 if (!node->isStyledElement()) 1087 1083 continue; 1088 if (canShareStyleWithElement( node))1084 if (canShareStyleWithElement(static_cast<StyledElement*>(node))) 1089 1085 break; 1090 1086 if (count++ == cStyleSearchThreshold) 1091 1087 return 0; 1092 1088 } 1093 return node;1089 return static_cast<StyledElement*>(node); 1094 1090 } 1095 1091 … … 1118 1114 unsigned count = 0; 1119 1115 unsigned visitedNodeCount = 0; 1120 Node* shareNode= 0;1116 StyledElement* shareElement = 0; 1121 1117 Node* cousinList = m_styledElement->previousSibling(); 1122 1118 while (cousinList) { 1123 share Node= findSiblingForStyleSharing(cousinList, count);1124 if (share Node)1119 shareElement = findSiblingForStyleSharing(cousinList, count); 1120 if (shareElement) 1125 1121 break; 1126 1122 cousinList = locateCousinList(cousinList->parentElement(), visitedNodeCount); … … 1128 1124 1129 1125 // If we have exhausted all our budget or our cousins. 1130 if (!share Node)1126 if (!shareElement) 1131 1127 return 0; 1132 1128 … … 1140 1136 if (parentStylePreventsSharing(m_parentStyle)) 1141 1137 return 0; 1142 return share Node->renderStyle();1138 return shareElement->renderStyle(); 1143 1139 } 1144 1140 -
trunk/Source/WebCore/css/CSSStyleSelector.h
r102234 r102555 135 135 bool matchesRuleSet(RuleSet*); 136 136 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; 139 139 140 140 PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const WebKitCSSKeyframeRule*, KeyframeValue&);
Note: See TracChangeset
for help on using the changeset viewer.