- Revision
- 103615
- Author
- [email protected]
- Date
- 2011-12-23 02:06:59 -0800 (Fri, 23 Dec 2011)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (103614 => 103615)
--- trunk/Source/WebCore/ChangeLog 2011-12-23 10:05:55 UTC (rev 103614)
+++ trunk/Source/WebCore/ChangeLog 2011-12-23 10:06:59 UTC (rev 103615)
@@ -1,3 +1,30 @@
+2011-12-19 Alexander Pavlov <[email protected]>
+
+ 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):
+
2011-12-23 Ivan Briano <[email protected]>
[EFL] Fix building with Glib support disabled
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (103614 => 103615)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-12-23 10:05:55 UTC (rev 103614)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-12-23 10:06:59 UTC (rev 103615)
@@ -66,6 +66,7 @@
#include "HTMLNames.h"
#include "HTMLProgressElement.h"
#include "HTMLTextAreaElement.h"
+#include "InspectorInstrumentation.h"
#include "KeyframeList.h"
#include "LinkHash.h"
#include "LocaleToScriptMapping.h"
@@ -715,21 +716,31 @@
const RuleData& ruleData = rules->at(i);
if (canUseFastReject && m_checker.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes()))
continue;
+
+ CSSStyleRule* rule = ruleData.rule();
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule);
if (checkSelector(ruleData)) {
- if (!matchesInTreeScope(m_element->treeScope(), m_checker.hasUnknownPseudoElements()))
+ if (!matchesInTreeScope(m_element->treeScope(), m_checker.hasUnknownPseudoElements())) {
+ InspectorInstrumentation::didMatchRule(cookie, false);
continue;
+ }
// If the rule has no properties to apply, then ignore it in the non-debug mode.
- CSSStyleRule* rule = ruleData.rule();
CSSMutableStyleDeclaration* decl = rule->declaration();
- if (!decl || (!decl->length() && !includeEmptyRules))
+ if (!decl || (!decl->length() && !includeEmptyRules)) {
+ InspectorInstrumentation::didMatchRule(cookie, false);
continue;
- if (m_sameOriginOnly && !m_checker.document()->securityOrigin()->canRequest(rule->baseURL()))
+ }
+ if (m_sameOriginOnly && !m_checker.document()->securityOrigin()->canRequest(rule->baseURL())) {
+ InspectorInstrumentation::didMatchRule(cookie, false);
continue;
+ }
// If we're matching normal rules, set a pseudo bit if
// we really just matched a pseudo-element.
if (m_dynamicPseudo != NOPSEUDO && m_checker.pseudoStyle() == NOPSEUDO) {
- if (m_checker.isCollectingRulesOnly())
+ if (m_checker.isCollectingRulesOnly()) {
+ InspectorInstrumentation::didMatchRule(cookie, false);
continue;
+ }
if (m_dynamicPseudo < FIRST_INTERNAL_PSEUDOID)
m_style->setHasPseudoStyle(m_dynamicPseudo);
} else {
@@ -740,8 +751,11 @@
// Add this rule to our list of matched rules.
addMatchedRule(&ruleData);
+ InspectorInstrumentation::didMatchRule(cookie, true);
+ continue;
}
}
+ InspectorInstrumentation::didMatchRule(cookie, false);
}
}
@@ -2162,6 +2176,7 @@
template <bool applyFirst>
void CSSStyleSelector::applyDeclaration(CSSMutableStyleDeclaration* styleDeclaration, bool isImportant, bool inheritedOnly)
{
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), styleDeclaration->parentRule());
CSSMutableStyleDeclaration::const_iterator end = styleDeclaration->end();
for (CSSMutableStyleDeclaration::const_iterator it = styleDeclaration->begin(); it != end; ++it) {
const CSSProperty& current = *it;
@@ -2193,6 +2208,7 @@
if (property > CSSPropertyLineHeight)
applyProperty(current.id(), current.value());
}
+ InspectorInstrumentation::didProcessRule(cookie);
}
template <bool applyFirst>
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (103614 => 103615)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2011-12-23 10:05:55 UTC (rev 103614)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2011-12-23 10:06:59 UTC (rev 103615)
@@ -347,7 +347,6 @@
void InspectorCSSAgent::enable(ErrorString*)
{
m_state->setBoolean(CSSAgentState::cssAgentEnabled, true);
- m_instrumentingAgents->setInspectorCSSAgent(this);
}
void InspectorCSSAgent::disable(ErrorString*)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (103614 => 103615)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2011-12-23 10:05:55 UTC (rev 103614)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2011-12-23 10:06:59 UTC (rev 103615)
@@ -33,6 +33,8 @@
#if ENABLE(INSPECTOR)
+#include "CSSRule.h"
+#include "CSSStyleRule.h"
#include "DOMFileSystem.h"
#include "DOMWindow.h"
#include "Database.h"
@@ -438,6 +440,45 @@
resourceAgent->didScheduleStyleRecalculation(document);
}
+InspectorInstrumentationCookie InspectorInstrumentation::willMatchRuleImpl(InstrumentingAgents* instrumentingAgents, const CSSStyleRule* rule)
+{
+ InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent();
+ if (cssAgent) {
+ cssAgent->willMatchRule(rule);
+ return InspectorInstrumentationCookie(instrumentingAgents, 1);
+ }
+
+ return InspectorInstrumentationCookie();
+}
+
+void InspectorInstrumentation::didMatchRuleImpl(const InspectorInstrumentationCookie& cookie, bool matched)
+{
+ InspectorCSSAgent* cssAgent = cookie.first->inspectorCSSAgent();
+ if (cssAgent)
+ cssAgent->didMatchRule(matched);
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willProcessRuleImpl(InstrumentingAgents* instrumentingAgents, const CSSRule* rule)
+{
+ if (!rule->isStyleRule())
+ return InspectorInstrumentationCookie();
+
+ InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent();
+ if (cssAgent) {
+ cssAgent->willProcessRule(static_cast<const CSSStyleRule*>(rule));
+ return InspectorInstrumentationCookie(instrumentingAgents, 1);
+ }
+
+ return InspectorInstrumentationCookie();
+}
+
+void InspectorInstrumentation::didProcessRuleImpl(const InspectorInstrumentationCookie& cookie)
+{
+ InspectorCSSAgent* cssAgent = cookie.first->inspectorCSSAgent();
+ if (cssAgent)
+ cssAgent->didProcessRule();
+}
+
void InspectorInstrumentation::applyUserAgentOverrideImpl(InstrumentingAgents* instrumentingAgents, String* userAgent)
{
if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (103614 => 103615)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2011-12-23 10:05:55 UTC (rev 103614)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2011-12-23 10:06:59 UTC (rev 103615)
@@ -41,6 +41,8 @@
namespace WebCore {
+class CSSRule;
+class CSSStyleRule;
class CharacterData;
class DOMFileSystem;
class DOMWindow;
@@ -50,6 +52,7 @@
class EventContext;
class DocumentLoader;
class HitTestResult;
+class InspectorCSSAgent;
class InspectorTimelineAgent;
class InstrumentingAgents;
class KURL;
@@ -119,6 +122,10 @@
static InspectorInstrumentationCookie willRecalculateStyle(Document*);
static void didRecalculateStyle(const InspectorInstrumentationCookie&);
static void didScheduleStyleRecalculation(Document*);
+ static InspectorInstrumentationCookie willMatchRule(Document*, const CSSStyleRule*);
+ static void didMatchRule(const InspectorInstrumentationCookie&, bool matched);
+ static InspectorInstrumentationCookie willProcessRule(Document*, const CSSRule*);
+ static void didProcessRule(const InspectorInstrumentationCookie&);
static void applyUserAgentOverride(Frame*, String*);
static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
@@ -260,6 +267,10 @@
static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents*);
static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
static void didScheduleStyleRecalculationImpl(InstrumentingAgents*, Document*);
+ static InspectorInstrumentationCookie willMatchRuleImpl(InstrumentingAgents*, const CSSStyleRule*);
+ static void didMatchRuleImpl(const InspectorInstrumentationCookie&, bool matched);
+ static InspectorInstrumentationCookie willProcessRuleImpl(InstrumentingAgents*, const CSSRule*);
+ static void didProcessRuleImpl(const InspectorInstrumentationCookie&);
static void applyUserAgentOverrideImpl(InstrumentingAgents*, String*);
static void willSendRequestImpl(InstrumentingAgents*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
@@ -719,6 +730,46 @@
#endif
}
+inline InspectorInstrumentationCookie InspectorInstrumentation::willMatchRule(Document* document, const CSSStyleRule* rule)
+{
+#if ENABLE(INSPECTOR)
+ FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
+ return willMatchRuleImpl(instrumentingAgents, rule);
+#endif
+ return InspectorInstrumentationCookie();
+}
+
+inline void InspectorInstrumentation::didMatchRule(const InspectorInstrumentationCookie& cookie, bool matched)
+{
+#if ENABLE(INSPECTOR)
+ FAST_RETURN_IF_NO_FRONTENDS(void());
+ if (cookie.first)
+ didMatchRuleImpl(cookie, matched);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willProcessRule(Document* document, const CSSRule* rule)
+{
+#if ENABLE(INSPECTOR)
+ FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
+ if (!rule)
+ return InspectorInstrumentationCookie();
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
+ return willProcessRuleImpl(instrumentingAgents, rule);
+#endif
+ return InspectorInstrumentationCookie();
+}
+
+inline void InspectorInstrumentation::didProcessRule(const InspectorInstrumentationCookie& cookie)
+{
+#if ENABLE(INSPECTOR)
+ FAST_RETURN_IF_NO_FRONTENDS(void());
+ if (cookie.first)
+ didProcessRuleImpl(cookie);
+#endif
+}
+
inline void InspectorInstrumentation::applyUserAgentOverride(Frame* frame, String* userAgent)
{
#if ENABLE(INSPECTOR)