Title: [186635] trunk/Source/WebInspectorUI
- Revision
- 186635
- Author
- drou...@apple.com
- Date
- 2015-07-09 14:57:32 -0700 (Thu, 09 Jul 2015)
Log Message
Web Inspector: Pseudo-element style ordering is wrong for pseudo-styles on unique selectors
https://bugs.webkit.org/show_bug.cgi?id=146804
Reviewed by Timothy Hatcher.
* UserInterface/Models/CSSRule.js:
(WebInspector.CSSRule.prototype.selectorIsGreater):
Loops through the selectors in a rule to check if their specificity is greater than a given selector's specificity.
* UserInterface/Models/CSSSelector.js:
(WebInspector.CSSSelector.prototype.isGreaterThan):
Determines if the given selector's specificity is greater than this selector's specificity.
(WebInspector.CSSSelector):
* UserInterface/Views/RulesStyleDetailsPanel.js:
(WebInspector.RulesStyleDetailsPanel.prototype.refresh):
If the pseudo-element selector's specificity is greater than the current selector's
specificity, create the pseudo-element's section and add it before the current style.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (186634 => 186635)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-07-09 21:54:11 UTC (rev 186634)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-07-09 21:57:32 UTC (rev 186635)
@@ -1,5 +1,24 @@
2015-07-09 Devin Rousso <drou...@apple.com>
+ Web Inspector: Pseudo-element style ordering is wrong for pseudo-styles on unique selectors
+ https://bugs.webkit.org/show_bug.cgi?id=146804
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Models/CSSRule.js:
+ (WebInspector.CSSRule.prototype.selectorIsGreater):
+ Loops through the selectors in a rule to check if their specificity is greater than a given selector's specificity.
+ * UserInterface/Models/CSSSelector.js:
+ (WebInspector.CSSSelector.prototype.isGreaterThan):
+ Determines if the given selector's specificity is greater than this selector's specificity.
+ (WebInspector.CSSSelector):
+ * UserInterface/Views/RulesStyleDetailsPanel.js:
+ (WebInspector.RulesStyleDetailsPanel.prototype.refresh):
+ If the pseudo-element selector's specificity is greater than the current selector's
+ specificity, create the pseudo-element's section and add it before the current style.
+
+2015-07-09 Devin Rousso <drou...@apple.com>
+
Web Inspector: Special Logs to Console that do not have an _expression_ should be styled differently, looks like code
https://bugs.webkit.org/show_bug.cgi?id=143840
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js (186634 => 186635)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js 2015-07-09 21:54:11 UTC (rev 186634)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js 2015-07-09 21:57:32 UTC (rev 186635)
@@ -182,6 +182,32 @@
return Object.shallowEqual(this._id, rule.id);
}
+ selectorIsGreater(otherSelectors)
+ {
+ if (!otherSelectors || !otherSelectors.length)
+ return true;
+
+ var selectorIsGreater = true;
+
+ var selectors = this.matchedSelectors;
+ if (!selectors.length)
+ selectors = this._selectors;
+
+ for (var selector of selectors) {
+ for (var otherSelector of otherSelectors) {
+ if (selector.isGreaterThan(otherSelector))
+ continue;
+
+ selectorIsGreater = false;
+ }
+
+ if (selectorIsGreater)
+ return true;
+ }
+
+ return false;
+ }
+
// Protected
get nodeStyles()
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSSelector.js (186634 => 186635)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSSelector.js 2015-07-09 21:54:11 UTC (rev 186634)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSSelector.js 2015-07-09 21:57:32 UTC (rev 186635)
@@ -52,4 +52,19 @@
{
return this._dynamic;
}
+
+ isGreaterThan(selector)
+ {
+ if (!selector || !selector.specificity)
+ return true;
+
+ for (var i = 0; i < this._specificity.length; ++i) {
+ if (this._specificity[i] === selector.specificity[i])
+ continue;
+
+ return this._specificity[i] > selector.specificity[i];
+ }
+
+ return false;
+ }
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js (186634 => 186635)
--- trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js 2015-07-09 21:54:11 UTC (rev 186634)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js 2015-07-09 21:57:32 UTC (rev 186635)
@@ -179,7 +179,7 @@
var pseudoElementSelectors = [];
for (var style of orderedPseudoStyles)
- pseudoElementSelectors.push({ style, selectorText: style.ownerRule.selectorText.replace(/:{1,2}[\w-]+\s*/, " ").trimRight() });
+ 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)
@@ -263,12 +263,15 @@
this._ruleMediaAndInherticanceList.push(hasMediaOrInherited);
- if (pseudoElementSelectors.length && style.ownerRule) {
+ var ownerRule = style.ownerRule;
+
+ if (pseudoElementSelectors.length && ownerRule) {
for (var j = pseudoElementSelectors.length - 1; j >= 0; --j) {
var pseudoElement = pseudoElementSelectors[j];
+ var matchedSelectorText = ownerRule.matchedSelectorText;
- if (style.ownerRule.type === WebInspector.CSSRule.Type.UserAgent || style.inerhited
- || (pseudoElement.lastMatchingSelector && pseudoElement.lastMatchingSelector !== style.ownerRule.selectorText)) {
+ 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);
@@ -276,8 +279,8 @@
continue;
}
- if (style.ownerRule.selectorText.includes(pseudoElement.selectorText))
- pseudoElement.lastMatchingSelector = style.ownerRule.selectorText;
+ if (matchedSelectorText.includes(pseudoElement.selectorText) || !ownerRule.selectorIsGreater(pseudoElement.style.ownerRule.selectors))
+ pseudoElement.lastMatchingSelector = matchedSelectorText;
}
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes