Changeset 103615 in webkit
- Timestamp:
- Dec 23, 2011, 2:06:59 AM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r103614 r103615 1 2011-12-19 Alexander Pavlov <[email protected]> 2 3 Web Inspector: Add CSSStyleSelector instrumentation calls towards implementing a CSS selector profiler 4 https://bugs.webkit.org/show_bug.cgi?id=74863 5 6 Performance checks run on PerformanceTest/Parser/html5-full-render.html did not result in any noticeable 7 perf regression, as the instrumentation calls are inline and bail out early if there are no 8 Web Inspector frontends open. 9 10 Reviewed by Antti Koivisto. 11 12 No new tests, as the functionality is not bound to any user-visible outputs. 13 14 * css/CSSStyleSelector.cpp: 15 (WebCore::CSSStyleSelector::matchRulesForList): 16 (WebCore::CSSStyleSelector::applyDeclaration): 17 * inspector/InspectorInstrumentation.cpp: 18 (WebCore::InspectorInstrumentation::willMatchRuleImpl): 19 (WebCore::InspectorInstrumentation::didMatchRuleImpl): 20 (WebCore::InspectorInstrumentation::willProcessRuleImpl): 21 (WebCore::InspectorInstrumentation::didProcessRuleImpl): 22 * inspector/InspectorInstrumentation.h: 23 (WebCore::InspectorInstrumentation::willMatchRule): 24 (WebCore::InspectorInstrumentation::didMatchRule): 25 (WebCore::InspectorInstrumentation::willProcessRule): 26 (WebCore::InspectorInstrumentation::didProcessRule): 27 1 28 2011-12-23 Ivan Briano <[email protected]> 2 29 -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r103535 r103615 67 67 #include "HTMLProgressElement.h" 68 68 #include "HTMLTextAreaElement.h" 69 #include "InspectorInstrumentation.h" 69 70 #include "KeyframeList.h" 70 71 #include "LinkHash.h" … … 716 717 if (canUseFastReject && m_checker.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) 717 718 continue; 719 720 CSSStyleRule* rule = ruleData.rule(); 721 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule); 718 722 if (checkSelector(ruleData)) { 719 if (!matchesInTreeScope(m_element->treeScope(), m_checker.hasUnknownPseudoElements())) 723 if (!matchesInTreeScope(m_element->treeScope(), m_checker.hasUnknownPseudoElements())) { 724 InspectorInstrumentation::didMatchRule(cookie, false); 720 725 continue; 726 } 721 727 // If the rule has no properties to apply, then ignore it in the non-debug mode. 722 CSSStyleRule* rule = ruleData.rule();723 728 CSSMutableStyleDeclaration* decl = rule->declaration(); 724 if (!decl || (!decl->length() && !includeEmptyRules)) 729 if (!decl || (!decl->length() && !includeEmptyRules)) { 730 InspectorInstrumentation::didMatchRule(cookie, false); 725 731 continue; 726 if (m_sameOriginOnly && !m_checker.document()->securityOrigin()->canRequest(rule->baseURL())) 732 } 733 if (m_sameOriginOnly && !m_checker.document()->securityOrigin()->canRequest(rule->baseURL())) { 734 InspectorInstrumentation::didMatchRule(cookie, false); 727 735 continue; 736 } 728 737 // If we're matching normal rules, set a pseudo bit if 729 738 // we really just matched a pseudo-element. 730 739 if (m_dynamicPseudo != NOPSEUDO && m_checker.pseudoStyle() == NOPSEUDO) { 731 if (m_checker.isCollectingRulesOnly()) 740 if (m_checker.isCollectingRulesOnly()) { 741 InspectorInstrumentation::didMatchRule(cookie, false); 732 742 continue; 743 } 733 744 if (m_dynamicPseudo < FIRST_INTERNAL_PSEUDOID) 734 745 m_style->setHasPseudoStyle(m_dynamicPseudo); … … 741 752 // Add this rule to our list of matched rules. 742 753 addMatchedRule(&ruleData); 743 } 744 } 754 InspectorInstrumentation::didMatchRule(cookie, true); 755 continue; 756 } 757 } 758 InspectorInstrumentation::didMatchRule(cookie, false); 745 759 } 746 760 } … … 2163 2177 void CSSStyleSelector::applyDeclaration(CSSMutableStyleDeclaration* styleDeclaration, bool isImportant, bool inheritedOnly) 2164 2178 { 2179 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), styleDeclaration->parentRule()); 2165 2180 CSSMutableStyleDeclaration::const_iterator end = styleDeclaration->end(); 2166 2181 for (CSSMutableStyleDeclaration::const_iterator it = styleDeclaration->begin(); it != end; ++it) { … … 2194 2209 applyProperty(current.id(), current.value()); 2195 2210 } 2211 InspectorInstrumentation::didProcessRule(cookie); 2196 2212 } 2197 2213 -
trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp
r103389 r103615 348 348 { 349 349 m_state->setBoolean(CSSAgentState::cssAgentEnabled, true); 350 m_instrumentingAgents->setInspectorCSSAgent(this);351 350 } 352 351 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r102961 r103615 34 34 #if ENABLE(INSPECTOR) 35 35 36 #include "CSSRule.h" 37 #include "CSSStyleRule.h" 36 38 #include "DOMFileSystem.h" 37 39 #include "DOMWindow.h" … … 439 441 } 440 442 443 InspectorInstrumentationCookie InspectorInstrumentation::willMatchRuleImpl(InstrumentingAgents* instrumentingAgents, const CSSStyleRule* rule) 444 { 445 InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent(); 446 if (cssAgent) { 447 cssAgent->willMatchRule(rule); 448 return InspectorInstrumentationCookie(instrumentingAgents, 1); 449 } 450 451 return InspectorInstrumentationCookie(); 452 } 453 454 void InspectorInstrumentation::didMatchRuleImpl(const InspectorInstrumentationCookie& cookie, bool matched) 455 { 456 InspectorCSSAgent* cssAgent = cookie.first->inspectorCSSAgent(); 457 if (cssAgent) 458 cssAgent->didMatchRule(matched); 459 } 460 461 InspectorInstrumentationCookie InspectorInstrumentation::willProcessRuleImpl(InstrumentingAgents* instrumentingAgents, const CSSRule* rule) 462 { 463 if (!rule->isStyleRule()) 464 return InspectorInstrumentationCookie(); 465 466 InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent(); 467 if (cssAgent) { 468 cssAgent->willProcessRule(static_cast<const CSSStyleRule*>(rule)); 469 return InspectorInstrumentationCookie(instrumentingAgents, 1); 470 } 471 472 return InspectorInstrumentationCookie(); 473 } 474 475 void InspectorInstrumentation::didProcessRuleImpl(const InspectorInstrumentationCookie& cookie) 476 { 477 InspectorCSSAgent* cssAgent = cookie.first->inspectorCSSAgent(); 478 if (cssAgent) 479 cssAgent->didProcessRule(); 480 } 481 441 482 void InspectorInstrumentation::applyUserAgentOverrideImpl(InstrumentingAgents* instrumentingAgents, String* userAgent) 442 483 { -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r102903 r103615 42 42 namespace WebCore { 43 43 44 class CSSRule; 45 class CSSStyleRule; 44 46 class CharacterData; 45 47 class DOMFileSystem; … … 51 53 class DocumentLoader; 52 54 class HitTestResult; 55 class InspectorCSSAgent; 53 56 class InspectorTimelineAgent; 54 57 class InstrumentingAgents; … … 120 123 static void didRecalculateStyle(const InspectorInstrumentationCookie&); 121 124 static void didScheduleStyleRecalculation(Document*); 125 static InspectorInstrumentationCookie willMatchRule(Document*, const CSSStyleRule*); 126 static void didMatchRule(const InspectorInstrumentationCookie&, bool matched); 127 static InspectorInstrumentationCookie willProcessRule(Document*, const CSSRule*); 128 static void didProcessRule(const InspectorInstrumentationCookie&); 122 129 123 130 static void applyUserAgentOverride(Frame*, String*); … … 261 268 static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&); 262 269 static void didScheduleStyleRecalculationImpl(InstrumentingAgents*, Document*); 270 static InspectorInstrumentationCookie willMatchRuleImpl(InstrumentingAgents*, const CSSStyleRule*); 271 static void didMatchRuleImpl(const InspectorInstrumentationCookie&, bool matched); 272 static InspectorInstrumentationCookie willProcessRuleImpl(InstrumentingAgents*, const CSSRule*); 273 static void didProcessRuleImpl(const InspectorInstrumentationCookie&); 263 274 264 275 static void applyUserAgentOverrideImpl(InstrumentingAgents*, String*); … … 720 731 } 721 732 733 inline InspectorInstrumentationCookie InspectorInstrumentation::willMatchRule(Document* document, const CSSStyleRule* rule) 734 { 735 #if ENABLE(INSPECTOR) 736 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie()); 737 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document)) 738 return willMatchRuleImpl(instrumentingAgents, rule); 739 #endif 740 return InspectorInstrumentationCookie(); 741 } 742 743 inline void InspectorInstrumentation::didMatchRule(const InspectorInstrumentationCookie& cookie, bool matched) 744 { 745 #if ENABLE(INSPECTOR) 746 FAST_RETURN_IF_NO_FRONTENDS(void()); 747 if (cookie.first) 748 didMatchRuleImpl(cookie, matched); 749 #endif 750 } 751 752 inline InspectorInstrumentationCookie InspectorInstrumentation::willProcessRule(Document* document, const CSSRule* rule) 753 { 754 #if ENABLE(INSPECTOR) 755 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie()); 756 if (!rule) 757 return InspectorInstrumentationCookie(); 758 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document)) 759 return willProcessRuleImpl(instrumentingAgents, rule); 760 #endif 761 return InspectorInstrumentationCookie(); 762 } 763 764 inline void InspectorInstrumentation::didProcessRule(const InspectorInstrumentationCookie& cookie) 765 { 766 #if ENABLE(INSPECTOR) 767 FAST_RETURN_IF_NO_FRONTENDS(void()); 768 if (cookie.first) 769 didProcessRuleImpl(cookie); 770 #endif 771 } 772 722 773 inline void InspectorInstrumentation::applyUserAgentOverride(Frame* frame, String* userAgent) 723 774 {
Note:
See TracChangeset
for help on using the changeset viewer.