Changeset 103615 in webkit


Ignore:
Timestamp:
Dec 23, 2011, 2:06:59 AM (14 years ago)
Author:
[email protected]
Message:

Web Inspector: Add CSSStyleSelector instrumentation calls towards implementing a CSS selector profiler
https://bugs.webkit.org/show_bug.cgi?id=74863

Performance checks run on PerformanceTest/Parser/html5-full-render.html did not result in any noticeable
perf regression, as the instrumentation calls are inline and bail out early if there are no
Web Inspector frontends open.

Reviewed by Antti Koivisto.

No new tests, as the functionality is not bound to any user-visible outputs.

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::matchRulesForList):
(WebCore::CSSStyleSelector::applyDeclaration):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::willMatchRuleImpl):
(WebCore::InspectorInstrumentation::didMatchRuleImpl):
(WebCore::InspectorInstrumentation::willProcessRuleImpl):
(WebCore::InspectorInstrumentation::didProcessRuleImpl):

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::willMatchRule):
(WebCore::InspectorInstrumentation::didMatchRule):
(WebCore::InspectorInstrumentation::willProcessRule):
(WebCore::InspectorInstrumentation::didProcessRule):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r103614 r103615  
     12011-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
    1282011-12-23  Ivan Briano  <[email protected]>
    229
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r103535 r103615  
    6767#include "HTMLProgressElement.h"
    6868#include "HTMLTextAreaElement.h"
     69#include "InspectorInstrumentation.h"
    6970#include "KeyframeList.h"
    7071#include "LinkHash.h"
     
    716717        if (canUseFastReject && m_checker.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes()))
    717718            continue;
     719
     720        CSSStyleRule* rule = ruleData.rule();
     721        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule);
    718722        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);
    720725                continue;
     726            }
    721727            // If the rule has no properties to apply, then ignore it in the non-debug mode.
    722             CSSStyleRule* rule = ruleData.rule();
    723728            CSSMutableStyleDeclaration* decl = rule->declaration();
    724             if (!decl || (!decl->length() && !includeEmptyRules))
     729            if (!decl || (!decl->length() && !includeEmptyRules)) {
     730                InspectorInstrumentation::didMatchRule(cookie, false);
    725731                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);
    727735                continue;
     736            }
    728737            // If we're matching normal rules, set a pseudo bit if
    729738            // we really just matched a pseudo-element.
    730739            if (m_dynamicPseudo != NOPSEUDO && m_checker.pseudoStyle() == NOPSEUDO) {
    731                 if (m_checker.isCollectingRulesOnly())
     740                if (m_checker.isCollectingRulesOnly()) {
     741                    InspectorInstrumentation::didMatchRule(cookie, false);
    732742                    continue;
     743                }
    733744                if (m_dynamicPseudo < FIRST_INTERNAL_PSEUDOID)
    734745                    m_style->setHasPseudoStyle(m_dynamicPseudo);
     
    741752                // Add this rule to our list of matched rules.
    742753                addMatchedRule(&ruleData);
    743             }
    744         }
     754                InspectorInstrumentation::didMatchRule(cookie, true);
     755                continue;
     756            }
     757        }
     758        InspectorInstrumentation::didMatchRule(cookie, false);
    745759    }
    746760}
     
    21632177void CSSStyleSelector::applyDeclaration(CSSMutableStyleDeclaration* styleDeclaration, bool isImportant, bool inheritedOnly)
    21642178{
     2179    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), styleDeclaration->parentRule());
    21652180    CSSMutableStyleDeclaration::const_iterator end = styleDeclaration->end();
    21662181    for (CSSMutableStyleDeclaration::const_iterator it = styleDeclaration->begin(); it != end; ++it) {
     
    21942209            applyProperty(current.id(), current.value());
    21952210    }
     2211    InspectorInstrumentation::didProcessRule(cookie);
    21962212}
    21972213
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r103389 r103615  
    348348{
    349349    m_state->setBoolean(CSSAgentState::cssAgentEnabled, true);
    350     m_instrumentingAgents->setInspectorCSSAgent(this);
    351350}
    352351
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r102961 r103615  
    3434#if ENABLE(INSPECTOR)
    3535
     36#include "CSSRule.h"
     37#include "CSSStyleRule.h"
    3638#include "DOMFileSystem.h"
    3739#include "DOMWindow.h"
     
    439441}
    440442
     443InspectorInstrumentationCookie 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
     454void InspectorInstrumentation::didMatchRuleImpl(const InspectorInstrumentationCookie& cookie, bool matched)
     455{
     456    InspectorCSSAgent* cssAgent = cookie.first->inspectorCSSAgent();
     457    if (cssAgent)
     458        cssAgent->didMatchRule(matched);
     459}
     460
     461InspectorInstrumentationCookie 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
     475void InspectorInstrumentation::didProcessRuleImpl(const InspectorInstrumentationCookie& cookie)
     476{
     477    InspectorCSSAgent* cssAgent = cookie.first->inspectorCSSAgent();
     478    if (cssAgent)
     479        cssAgent->didProcessRule();
     480}
     481
    441482void InspectorInstrumentation::applyUserAgentOverrideImpl(InstrumentingAgents* instrumentingAgents, String* userAgent)
    442483{
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r102903 r103615  
    4242namespace WebCore {
    4343
     44class CSSRule;
     45class CSSStyleRule;
    4446class CharacterData;
    4547class DOMFileSystem;
     
    5153class DocumentLoader;
    5254class HitTestResult;
     55class InspectorCSSAgent;
    5356class InspectorTimelineAgent;
    5457class InstrumentingAgents;
     
    120123    static void didRecalculateStyle(const InspectorInstrumentationCookie&);
    121124    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&);
    122129
    123130    static void applyUserAgentOverride(Frame*, String*);
     
    261268    static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
    262269    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&);
    263274
    264275    static void applyUserAgentOverrideImpl(InstrumentingAgents*, String*);
     
    720731}
    721732
     733inline 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
     743inline 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
     752inline 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
     764inline 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
    722773inline void InspectorInstrumentation::applyUserAgentOverride(Frame* frame, String* userAgent)
    723774{
Note: See TracChangeset for help on using the changeset viewer.