[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

apavlov at chromium.org apavlov at chromium.org
Wed Dec 22 13:24:28 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 838a107f1be1a7728b348140268ae74660e27694
Author: apavlov at chromium.org <apavlov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 14 14:59:20 2010 +0000

    2010-09-10  Alexander Pavlov  <apavlov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: Implement on-demand reporting of empty CSS rules matched for a node by WebCore
            https://bugs.webkit.org/show_bug.cgi?id=45530
    
            WebCore:
            * css/CSSStyleSelector.cpp:
            (WebCore::CSSStyleSelector::matchRules):
            (WebCore::CSSStyleSelector::matchRulesForList):
            (WebCore::CSSStyleSelector::matchUARules):
            (WebCore::CSSStyleSelector::styleForElement):
            (WebCore::CSSStyleSelector::pseudoStyleForElement):
            (WebCore::CSSStyleSelector::styleRulesForElement):
            (WebCore::CSSStyleSelector::pseudoStyleRulesForElement):
            * css/CSSStyleSelector.h:
            * inspector/InspectorDOMAgent.cpp:
            (WebCore::InspectorDOMAgent::getStyles):
            (WebCore::InspectorDOMAgent::buildArrayForPseudoElements):
    
            LayoutTests:
            * inspector/elements-panel-styles-expected.txt:
            * inspector/resources/elements-panel-styles.css:
            (.foo):
            (.foo::before):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67469 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 70f00c2..09d97f8 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-09-10  Alexander Pavlov  <apavlov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Implement on-demand reporting of empty CSS rules matched for a node by WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=45530
+
+        * inspector/elements-panel-styles-expected.txt:
+        * inspector/resources/elements-panel-styles.css:
+        (.foo):
+        (.foo::before):
+
 2010-09-14  Mihai Parparita  <mihaip at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/LayoutTests/inspector/elements-panel-styles-expected.txt b/LayoutTests/inspector/elements-panel-styles-expected.txt
index 866ed4b..ef2e9e4 100644
--- a/LayoutTests/inspector/elements-panel-styles-expected.txt
+++ b/LayoutTests/inspector/elements-panel-styles-expected.txt
@@ -25,6 +25,8 @@ margin-top: 10px;
 display: none;
 
 ======== Matched CSS Rules ========
+[expanded] .foo { (resources/elements-panel-styles.css:33)
+
 [expanded] .foo, .foo::before { (resources/elements-panel-styles.css:15)
 color: blue;
 content: '[before Foo]';
@@ -51,6 +53,8 @@ font-size: 14px;
 
 
 ======== Pseudo ::before element ========
+[expanded] .foo::before { (resources/elements-panel-styles.css:37)
+
 [expanded] .foo::before { (resources/elements-panel-styles.css:20)
 color: red;
 
diff --git a/LayoutTests/inspector/resources/elements-panel-styles.css b/LayoutTests/inspector/resources/elements-panel-styles.css
index fc231d6..1b30663 100644
--- a/LayoutTests/inspector/resources/elements-panel-styles.css
+++ b/LayoutTests/inspector/resources/elements-panel-styles.css
@@ -29,3 +29,11 @@ body {
 	font-family: courier;
 	content: "[after Foo 2]";
 }
+
+.foo {
+    /* Empty rule that should be reported in the Styles pane */
+}
+
+.foo::before {
+    /* Empty rule that should be reported in the Styles pane */
+}
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9d7b641..f5efc70 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-10  Alexander Pavlov  <apavlov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Implement on-demand reporting of empty CSS rules matched for a node by WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=45530
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::matchRules):
+        (WebCore::CSSStyleSelector::matchRulesForList):
+        (WebCore::CSSStyleSelector::matchUARules):
+        (WebCore::CSSStyleSelector::styleForElement):
+        (WebCore::CSSStyleSelector::pseudoStyleForElement):
+        (WebCore::CSSStyleSelector::styleRulesForElement):
+        (WebCore::CSSStyleSelector::pseudoStyleRulesForElement):
+        * css/CSSStyleSelector.h:
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::getStyles):
+        (WebCore::InspectorDOMAgent::buildArrayForPseudoElements):
+
 2010-09-14  Hyung Song  <beergun at company100.net>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp
index 8319620..89e16fa 100644
--- a/WebCore/css/CSSStyleSelector.cpp
+++ b/WebCore/css/CSSStyleSelector.cpp
@@ -654,7 +654,7 @@ void CSSStyleSelector::resolveVariablesForDeclaration(CSSMutableStyleDeclaration
     }
 }
 
-void CSSStyleSelector::matchRules(CSSRuleSet* rules, int& firstRuleIndex, int& lastRuleIndex)
+void CSSStyleSelector::matchRules(CSSRuleSet* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)
 {
     m_matchedRules.clear();
 
@@ -664,16 +664,16 @@ void CSSStyleSelector::matchRules(CSSRuleSet* rules, int& firstRuleIndex, int& l
     // We need to collect the rules for id, class, tag, and everything else into a buffer and
     // then sort the buffer.
     if (m_element->hasID())
-        matchRulesForList(rules->getIDRules(m_element->idForStyleResolution().impl()), firstRuleIndex, lastRuleIndex);
+        matchRulesForList(rules->getIDRules(m_element->idForStyleResolution().impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     if (m_element->hasClass()) {
         ASSERT(m_styledElement);
         const SpaceSplitString& classNames = m_styledElement->classNames();
         size_t size = classNames.size();
         for (size_t i = 0; i < size; ++i)
-            matchRulesForList(rules->getClassRules(classNames[i].impl()), firstRuleIndex, lastRuleIndex);
+            matchRulesForList(rules->getClassRules(classNames[i].impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     }
-    matchRulesForList(rules->getTagRules(m_element->localName().impl()), firstRuleIndex, lastRuleIndex);
-    matchRulesForList(rules->getUniversalRules(), firstRuleIndex, lastRuleIndex);
+    matchRulesForList(rules->getTagRules(m_element->localName().impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
+    matchRulesForList(rules->getUniversalRules(), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     
     // If we didn't match any rules, we're done.
     if (m_matchedRules.isEmpty())
@@ -695,7 +695,7 @@ void CSSStyleSelector::matchRules(CSSRuleSet* rules, int& firstRuleIndex, int& l
     }
 }
 
-void CSSStyleSelector::matchRulesForList(CSSRuleDataList* rules, int& firstRuleIndex, int& lastRuleIndex)
+void CSSStyleSelector::matchRulesForList(CSSRuleDataList* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)
 {
     if (!rules)
         return;
@@ -703,9 +703,9 @@ void CSSStyleSelector::matchRulesForList(CSSRuleDataList* rules, int& firstRuleI
     for (CSSRuleData* d = rules->first(); d; d = d->next()) {
         CSSStyleRule* rule = d->rule();
         if (checkSelector(d->selector())) {
-            // If the rule has no properties to apply, then ignore it.
+            // If the rule has no properties to apply, then ignore it in the non-debug mode.
             CSSMutableStyleDeclaration* decl = rule->declaration();
-            if (!decl || !decl->length())
+            if (!decl || (!decl->length() && !includeEmptyRules))
                 continue;
             
             // If we're matching normal rules, set a pseudo bit if 
@@ -1083,17 +1083,17 @@ void CSSStyleSelector::matchUARules(int& firstUARule, int& lastUARule)
     // First we match rules from the user agent sheet.
     CSSRuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print")
         ? defaultPrintStyle : defaultStyle;
-    matchRules(userAgentStyleSheet, firstUARule, lastUARule);
+    matchRules(userAgentStyleSheet, firstUARule, lastUARule, false);
 
     // In quirks mode, we match rules from the quirks user agent sheet.
     if (!m_checker.m_strictParsing)
-        matchRules(defaultQuirksStyle, firstUARule, lastUARule);
+        matchRules(defaultQuirksStyle, firstUARule, lastUARule, false);
         
     // If we're in view source mode, then we match rules from the view source style sheet.
     if (m_checker.m_document->frame() && m_checker.m_document->frame()->inViewSourceMode()) {
         if (!defaultViewSourceStyle)
             loadViewSourceStyle();
-        matchRules(defaultViewSourceStyle, firstUARule, lastUARule);
+        matchRules(defaultViewSourceStyle, firstUARule, lastUARule, false);
     }
 }
 
@@ -1247,7 +1247,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl
     if (!resolveForRootDefault) {
         // 4. Now we check user sheet rules.
         if (m_matchAuthorAndUserStyles)
-            matchRules(m_userStyle.get(), firstUserRule, lastUserRule);
+            matchRules(m_userStyle.get(), firstUserRule, lastUserRule, false);
 
         // 5. Now check author rules, beginning first with presentational attributes
         // mapped from HTML.
@@ -1286,7 +1286,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl
     
         // 6. Check the rules in author sheets next.
         if (m_matchAuthorAndUserStyles)
-            matchRules(m_authorStyle.get(), firstAuthorRule, lastAuthorRule);
+            matchRules(m_authorStyle.get(), firstAuthorRule, lastAuthorRule, false);
 
         // 7. Now check our inline style attribute.
         if (m_matchAuthorAndUserStyles && m_styledElement) {
@@ -1517,8 +1517,8 @@ PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(PseudoId pseudo,
     matchUARules(firstUARule, lastUARule);
 
     if (m_matchAuthorAndUserStyles) {
-        matchRules(m_userStyle.get(), firstUserRule, lastUserRule);
-        matchRules(m_authorStyle.get(), firstAuthorRule, lastAuthorRule);
+        matchRules(m_userStyle.get(), firstUserRule, lastUserRule, false);
+        matchRules(m_authorStyle.get(), firstAuthorRule, lastAuthorRule, false);
     }
 
     if (m_matchedDecls.isEmpty() && !visitedStyle)
@@ -1843,12 +1843,12 @@ void CSSStyleSelector::cacheBorderAndBackground()
     }
 }
 
-PassRefPtr<CSSRuleList> CSSStyleSelector::styleRulesForElement(Element* e, bool authorOnly)
+PassRefPtr<CSSRuleList> CSSStyleSelector::styleRulesForElement(Element* e, bool authorOnly, bool includeEmptyRules)
 {
-    return pseudoStyleRulesForElement(e, NOPSEUDO, authorOnly);
+    return pseudoStyleRulesForElement(e, NOPSEUDO, authorOnly, includeEmptyRules);
 }
 
-PassRefPtr<CSSRuleList> CSSStyleSelector::pseudoStyleRulesForElement(Element* e, PseudoId pseudoId, bool authorOnly)
+PassRefPtr<CSSRuleList> CSSStyleSelector::pseudoStyleRulesForElement(Element* e, PseudoId pseudoId, bool authorOnly, bool includeEmptyRules)
 {
     if (!e || !e->document()->haveStylesheetsLoaded())
         return 0;
@@ -1866,14 +1866,14 @@ PassRefPtr<CSSRuleList> CSSStyleSelector::pseudoStyleRulesForElement(Element* e,
         // Now we check user sheet rules.
         if (m_matchAuthorAndUserStyles) {
             int firstUserRule = -1, lastUserRule = -1;
-            matchRules(m_userStyle.get(), firstUserRule, lastUserRule);
+            matchRules(m_userStyle.get(), firstUserRule, lastUserRule, includeEmptyRules);
         }
     }
 
     if (m_matchAuthorAndUserStyles) {
         // Check the rules in author sheets.
         int firstAuthorRule = -1, lastAuthorRule = -1;
-        matchRules(m_authorStyle.get(), firstAuthorRule, lastAuthorRule);
+        matchRules(m_authorStyle.get(), firstAuthorRule, lastAuthorRule, includeEmptyRules);
     }
 
     m_checker.m_collectRulesOnly = false;
diff --git a/WebCore/css/CSSStyleSelector.h b/WebCore/css/CSSStyleSelector.h
index 4a4565d..b77f23c 100644
--- a/WebCore/css/CSSStyleSelector.h
+++ b/WebCore/css/CSSStyleSelector.h
@@ -119,8 +119,8 @@ public:
 
     public:
         // These methods will give back the set of rules that matched for a given element (or a pseudo-element).
-        PassRefPtr<CSSRuleList> styleRulesForElement(Element*, bool authorOnly);
-        PassRefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, PseudoId, bool authorOnly);
+        PassRefPtr<CSSRuleList> styleRulesForElement(Element*, bool authorOnly, bool includeEmptyRules = false);
+        PassRefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, PseudoId, bool authorOnly, bool includeEmptyRules = false);
 
         // Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this function will return
         // the correct font size scaled relative to the user's default (medium).
@@ -186,8 +186,8 @@ public:
         void addMatchedRule(CSSRuleData* rule) { m_matchedRules.append(rule); }
         void addMatchedDeclaration(CSSMutableStyleDeclaration* decl);
 
-        void matchRules(CSSRuleSet*, int& firstRuleIndex, int& lastRuleIndex);
-        void matchRulesForList(CSSRuleDataList*, int& firstRuleIndex, int& lastRuleIndex);
+        void matchRules(CSSRuleSet*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules);
+        void matchRulesForList(CSSRuleDataList*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules);
         void sortMatchedRules(unsigned start, unsigned end);
 
         template <bool firstPass>
diff --git a/WebCore/inspector/InspectorDOMAgent.cpp b/WebCore/inspector/InspectorDOMAgent.cpp
index 23c22aa..ddd71f9 100644
--- a/WebCore/inspector/InspectorDOMAgent.cpp
+++ b/WebCore/inspector/InspectorDOMAgent.cpp
@@ -1148,7 +1148,7 @@ void InspectorDOMAgent::getStyles(long nodeId, bool authorOnly, RefPtr<Inspector
     result->setObject("computedStyle", buildObjectForStyle(computedStyleInfo.get(), false));
 
     CSSStyleSelector* selector = element->ownerDocument()->styleSelector();
-    RefPtr<CSSRuleList> matchedRules = selector->styleRulesForElement(element, authorOnly);
+    RefPtr<CSSRuleList> matchedRules = selector->styleRulesForElement(element, authorOnly, true);
     result->setArray("matchedCSSRules", buildArrayForCSSRules(node->ownerDocument(), matchedRules.get()));
 
     result->setObject("styleAttributes", buildObjectForAttributeStyles(element));
@@ -1163,7 +1163,7 @@ void InspectorDOMAgent::getStyles(long nodeId, bool authorOnly, RefPtr<Inspector
             parentStyle->setObject("inlineStyle", buildObjectForStyle(parentElement->style(), true));
 
         CSSStyleSelector* parentSelector = parentElement->ownerDocument()->styleSelector();
-        RefPtr<CSSRuleList> parentMatchedRules = parentSelector->styleRulesForElement(parentElement, authorOnly);
+        RefPtr<CSSRuleList> parentMatchedRules = parentSelector->styleRulesForElement(parentElement, authorOnly, true);
         parentStyle->setArray("matchedCSSRules", buildArrayForCSSRules(parentElement->ownerDocument(), parentMatchedRules.get()));
 
         parentElement = parentElement->parentElement();
@@ -1267,7 +1267,7 @@ PassRefPtr<InspectorArray> InspectorDOMAgent::buildArrayForPseudoElements(Elemen
     RefPtr<RenderStyle> renderStyle = element->styleForRenderer();
 
     for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_INTERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) {
-        RefPtr<CSSRuleList> matchedRules = selector->pseudoStyleRulesForElement(element, pseudoId, authorOnly);
+        RefPtr<CSSRuleList> matchedRules = selector->pseudoStyleRulesForElement(element, pseudoId, authorOnly, true);
         if (matchedRules && matchedRules->length()) {
             RefPtr<InspectorObject> pseudoStyles = InspectorObject::create();
             pseudoStyles->setNumber("pseudoId", static_cast<int>(pseudoId));

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list