Title: [187195] trunk/Source/WebInspectorUI
Revision
187195
Author
drou...@apple.com
Date
2015-07-22 17:44:09 -0700 (Wed, 22 Jul 2015)

Log Message

Web Inspector: REGRESSION (Safari 7): Pseudo element rules are not labelled with media queries in Styles panel
https://bugs.webkit.org/show_bug.cgi?id=147207

Reviewed by Timothy Hatcher.

* UserInterface/Views/RulesStyleDetailsPanel.js:
(WebInspector.RulesStyleDetailsPanel.prototype.refresh.insertMediaOrInheritanceLabel):
(WebInspector.RulesStyleDetailsPanel.prototype.refresh.insertAllMatchingPseudoStyles):
Now inserts pseudo-styles based on whether their selector specificity is greater than
the previous style's selector specificity.
(WebInspector.RulesStyleDetailsPanel.prototype.refresh):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (187194 => 187195)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-07-23 00:04:02 UTC (rev 187194)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-07-23 00:44:09 UTC (rev 187195)
@@ -1,3 +1,17 @@
+2015-07-22  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: REGRESSION (Safari 7): Pseudo element rules are not labelled with media queries in Styles panel
+        https://bugs.webkit.org/show_bug.cgi?id=147207
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/RulesStyleDetailsPanel.js:
+        (WebInspector.RulesStyleDetailsPanel.prototype.refresh.insertMediaOrInheritanceLabel):
+        (WebInspector.RulesStyleDetailsPanel.prototype.refresh.insertAllMatchingPseudoStyles):
+        Now inserts pseudo-styles based on whether their selector specificity is greater than
+        the previous style's selector specificity.
+        (WebInspector.RulesStyleDetailsPanel.prototype.refresh):
+
 2015-07-22  Nikita Vasilyev  <nvasil...@apple.com>
 
         Web Inspector: Change syntax highlighting color for regular expressions to make them more readable

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js (187194 => 187195)


--- trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js	2015-07-23 00:04:02 UTC (rev 187194)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js	2015-07-23 00:44:09 UTC (rev 187195)
@@ -60,6 +60,16 @@
         var previousMediaList = [];
         var previousSection = null;
 
+        var pseudoElements = this.nodeStyles.pseudoElements;
+        var pseudoElementsStyle = [];
+        for (var pseudoIdentifier in pseudoElements)
+            pseudoElementsStyle = pseudoElementsStyle.concat(pseudoElements[pseudoIdentifier].orderedStyles);
+
+        var orderedPseudoStyles = uniqueOrderedStyles(pseudoElementsStyle);
+        // Reverse the array to allow ensure that splicing the array will not mess with the order.
+        if (orderedPseudoStyles.length)
+            orderedPseudoStyles.reverse();
+
         function mediaListsEqual(a, b)
         {
             a = a || [];
@@ -169,29 +179,8 @@
             addedNewRuleButton = true;
         }
 
-        var pseudoElements = this.nodeStyles.pseudoElements;
-        var pseudoElementsStyle = [];
-
-        for (var pseudoIdentifier in pseudoElements)
-            pseudoElementsStyle = pseudoElementsStyle.concat(pseudoElements[pseudoIdentifier].orderedStyles);
-
-        var orderedPseudoStyles = uniqueOrderedStyles(pseudoElementsStyle);
-        var pseudoElementSelectors = [];
-
-        for (var style of orderedPseudoStyles)
-            pseudoElementSelectors.push({ style, selectorText: style.ownerRule.selectorText.replace(/:{1,2}[\w-]+\s*/g, " ").trimRight() });
-
-        // Reverse the array to allow ensure that splicing the array will not mess with the order.
-        if (pseudoElementSelectors.length)
-            pseudoElementSelectors.reverse();
-
-        var addedNewRuleButton = false;
-        this._ruleMediaAndInherticanceList = [];
-
-        var orderedStyles = uniqueOrderedStyles(this.nodeStyles.orderedStyles);
-        for (var i = 0; i < orderedStyles.length; ++i) {
-            var style = orderedStyles[i];
-
+        function insertMediaOrInheritanceLabel(style)
+        {
             var hasMediaOrInherited = [];
 
             if (style.type === WebInspector.CSSStyleDeclaration.Type.Rule && !addedNewRuleButton)
@@ -222,9 +211,7 @@
                 if (previousSection)
                     previousSection.lastInGroup = true;
 
-                for (var j = 0; j < currentMediaList.length; ++j) {
-                    var media = currentMediaList[j];
-
+                for (var media of currentMediaList) {
                     var prefixElement = document.createElement("strong");
                     prefixElement.textContent = WebInspector.UIString("Media: ");
 
@@ -262,36 +249,55 @@
             }
 
             this._ruleMediaAndInherticanceList.push(hasMediaOrInherited);
+        }
 
-            var ownerRule = style.ownerRule;
+        function insertAllMatchingPseudoStyles(force)
+        {
+            if (!orderedPseudoStyles.length)
+                return;
 
-            if (pseudoElementSelectors.length && ownerRule) {
-                for (var j = pseudoElementSelectors.length - 1; j >= 0; --j) {
-                    var pseudoElement = pseudoElementSelectors[j];
-                    var matchedSelectorText = ownerRule.matchedSelectorText;
+            if (force) {
+                for (var j = orderedPseudoStyles.length - 1; j >= 0; --j) {
+                    var pseudoStyle = orderedPseudoStyles[j];
+                    insertMediaOrInheritanceLabel.call(this, pseudoStyle);
+                    appendStyleSection.call(this, pseudoStyle);
+                }
+                orderedPseudoStyles = [];
+            }
 
-                    if (ownerRule.type === WebInspector.CSSRule.Type.UserAgent || style.inerhited
-                    || (pseudoElement.lastMatchingSelector && pseudoElement.lastMatchingSelector !== matchedSelectorText)) {
-                        appendStyleSection.call(this, pseudoElement.style);
-                        pseudoElementSelectors.splice(j, 1);
-                        this._ruleMediaAndInherticanceList.push(hasMediaOrInherited);
+            if (!previousSection)
+                return;
 
-                        continue;
-                    }
+            var ownerRule = previousSection.style.ownerRule;
+            if (!ownerRule)
+                return;
 
-                    if (matchedSelectorText.includes(pseudoElement.selectorText) || !ownerRule.selectorIsGreater(pseudoElement.style.ownerRule.mostSpecificSelector))
-                        pseudoElement.lastMatchingSelector = matchedSelectorText;
-                }
+            for (var j = orderedPseudoStyles.length - 1; j >= 0; --j) {
+                var pseudoStyle = orderedPseudoStyles[j];
+                if (!pseudoStyle.ownerRule.selectorIsGreater(ownerRule.mostSpecificSelector))
+                    continue;
+
+                insertMediaOrInheritanceLabel.call(this, pseudoStyle);
+                appendStyleSection.call(this, pseudoStyle);
+                ownerRule = pseudoStyle.ownerRule;
+                orderedPseudoStyles.splice(j, 1);
             }
+        }
 
+        var addedNewRuleButton = false;
+        this._ruleMediaAndInherticanceList = [];
+
+        var orderedStyles = uniqueOrderedStyles(this.nodeStyles.orderedStyles);
+        for (var style of orderedStyles) {
+            var isUserAgentStyle = style.ownerRule && style.ownerRule.type === WebInspector.CSSRule.Type.UserAgent;
+            insertAllMatchingPseudoStyles.call(this, isUserAgentStyle || style.inerhited);
+
+            insertMediaOrInheritanceLabel.call(this, style);
             appendStyleSection.call(this, style);
         }
 
         // Just in case there are any pseudo-selectors left that haven't been added.
-        if (pseudoElementSelectors.length) {
-            for (var i = pseudoElementSelectors.length - 1; i >= 0; --i)
-                appendStyleSection.call(this, pseudoElementSelectors[i].style);
-        }
+        insertAllMatchingPseudoStyles.call(this, true);
 
         if (!addedNewRuleButton)
             addNewRuleButton.call(this);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to