Modified: trunk/Source/WebInspectorUI/ChangeLog (250632 => 250633)
--- trunk/Source/WebInspectorUI/ChangeLog 2019-10-02 21:50:46 UTC (rev 250632)
+++ trunk/Source/WebInspectorUI/ChangeLog 2019-10-02 21:54:40 UTC (rev 250633)
@@ -1,3 +1,24 @@
+2019-10-02 Nikita Vasilyev <[email protected]>
+
+ Web Inspector: Styles: for rules that don't match selected node, property values always show as invalid
+ https://bugs.webkit.org/show_bug.cgi?id=201571
+
+ Reviewed by Matt Baker.
+
+ The gist of the bug:
+ - WI.CSSProperty is instantiated with `valid` false.
+ - CSSAgent.getMatchedStylesForNode never updates WI.CSSProperty instances because
+ the edited style does not in fact match the selected DOM node. A valid CSS property
+ is shown as invalid.
+
+ To resolve this, WI.CSSProperty instances are now updated after editing
+ in the callback of `CSSAgent.setStyleText`.
+
+ * UserInterface/Models/DOMNodeStyles.js:
+ (WI.DOMNodeStyles.prototype.changeStyleText):
+ (WI.DOMNodeStyles.prototype._parseStyleDeclarationPayload):
+ Don't store `style` in `this._stylesMap` of WI.DOMNodeStyles when the style doesn't match the selected node.
+
2019-10-02 Devin Rousso <[email protected]>
Web Inspector: REGRESSION(r250149): changing CSS via the Styles details sidebar panel doesn't update the associated resource
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js (250632 => 250633)
--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js 2019-10-02 21:50:46 UTC (rev 250632)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js 2019-10-02 21:54:40 UTC (rev 250633)
@@ -454,8 +454,13 @@
callback(error);
return;
}
+ callback();
- callback();
+ // Update validity of each property for rules that don't match the selected DOM node.
+ // These rules don't get updated by CSSAgent.getMatchedStylesForNode.
+ if (style.ownerRule && !style.ownerRule.matchedSelectorIndices.length)
+ this._parseStyleDeclarationPayload(stylePayload, this._node, false, null, style.type, style.ownerRule, false);
+
this.refresh();
};
@@ -548,7 +553,7 @@
return new WI.CSSProperty(index, text, name, value, priority, enabled, overridden, implicit, anonymous, valid, styleSheetTextRange);
}
- _parseStyleDeclarationPayload(payload, node, inherited, pseudoId, type, rule)
+ _parseStyleDeclarationPayload(payload, node, inherited, pseudoId, type, rule, matchesNode = true)
{
if (!payload)
return null;
@@ -564,24 +569,21 @@
mapKey += ":" + node.id + ":attribute";
let style = rule ? rule.style : null;
+ console.assert(matchesNode || style);
- let existingStyles = this._stylesMap.get(mapKey);
- if (existingStyles && !style) {
- for (let existingStyle of existingStyles) {
- if (existingStyle.node === node && existingStyle.inherited === inherited) {
- style = existingStyle;
- break;
+ if (matchesNode) {
+ let existingStyles = this._stylesMap.get(mapKey);
+ if (existingStyles && !style) {
+ for (let existingStyle of existingStyles) {
+ if (existingStyle.node === node && existingStyle.inherited === inherited) {
+ style = existingStyle;
+ break;
+ }
}
}
- }
- if (style)
- this._stylesMap.add(mapKey, style);
-
- var shorthands = {};
- for (var i = 0; payload.shorthandEntries && i < payload.shorthandEntries.length; ++i) {
- var shorthand = payload.shorthandEntries[i];
- shorthands[shorthand.name] = shorthand.value;
+ if (style)
+ this._stylesMap.add(mapKey, style);
}
var inheritedPropertyCount = 0;
@@ -605,6 +607,9 @@
return style;
}
+ if (!matchesNode)
+ return null;
+
var styleSheet = id ? WI.cssManager.styleSheetForIdentifier(id.styleSheetId) : null;
if (styleSheet) {
if (type === WI.CSSStyleDeclaration.Type.Inline)