- Revision
- 194437
- Author
- [email protected]
- Date
- 2015-12-29 10:15:45 -0800 (Tue, 29 Dec 2015)
Log Message
Web Inspector: Styling of invalid selector persists when changing the selected node
https://bugs.webkit.org/show_bug.cgi?id=152456
Patch by Devin Rousso <[email protected]> on 2015-12-29
Reviewed by Brian Burg.
If the user changes the selector of a CSS rule to be invalid (e.g. having
a { or ; character), it is expected that the invalid indicator will be removed
once the user changes nodes or reverts the selector to its previous value.
* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Views/CSSStyleDeclarationSection.css:
(.style-declaration-section > .header > .icon.toggle-able:hover):
(.style-declaration-section > .header > .icon.toggle-able:active):
(.style-declaration-section:not(.invalid-selector) > .header > .icon.toggle-able:hover): Deleted.
Added better :hover and :active styles.
* UserInterface/Views/CSSStyleDeclarationSection.js:
(WebInspector.CSSStyleDeclarationSection):
(WebInspector.CSSStyleDeclarationSection.prototype.refresh):
(WebInspector.CSSStyleDeclarationSection.prototype._handleIconElementClicked):
If the selector is invalid, simply refresh the section to regenerate the
original selector with correct content, specificity, and highlighting.
(WebInspector.CSSStyleDeclarationSection.prototype.get _hasInvalidSelector): Deleted.
Moved the state of the invalid selector to a member
variable instead of a DOM class.
(WebInspector.CSSStyleDeclarationSection.prototype._updateSelectorIcon):
Renamed from _markSelector for clarity.
* UserInterface/Views/VisualStyleSelectorTreeItem.css:
(.item.visual-style-selector-item.selector-invalid > .icon:hover):
(.item.visual-style-selector-item.selector-invalid > .icon:active):
(.item.visual-style-selector-item.selector-invalid > .icon):
Added :hover and :active styles.
* UserInterface/Views/VisualStyleSelectorTreeItem.js:
(WebInspector.VisualStyleSelectorTreeItem):
(WebInspector.VisualStyleSelectorTreeItem.prototype.onattach):
(WebInspector.VisualStyleSelectorTreeItem.prototype._commitSelector):
(WebInspector.VisualStyleSelectorTreeItem.prototype._updateSelectorIcon):
(WebInspector.VisualStyleSelectorTreeItem.prototype._handleIconElementClicked):
(WebInspector.VisualStyleSelectorTreeItem.prototype._selectorChanged): Deleted.
Changed the names of a few functions to provide better
consistency across the classes in the Style sidebar.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (194436 => 194437)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-12-29 13:57:21 UTC (rev 194436)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-12-29 18:15:45 UTC (rev 194437)
@@ -1,3 +1,51 @@
+2015-12-29 Devin Rousso <[email protected]>
+
+ Web Inspector: Styling of invalid selector persists when changing the selected node
+ https://bugs.webkit.org/show_bug.cgi?id=152456
+
+ Reviewed by Brian Burg.
+
+ If the user changes the selector of a CSS rule to be invalid (e.g. having
+ a { or ; character), it is expected that the invalid indicator will be removed
+ once the user changes nodes or reverts the selector to its previous value.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ * UserInterface/Views/CSSStyleDeclarationSection.css:
+ (.style-declaration-section > .header > .icon.toggle-able:hover):
+ (.style-declaration-section > .header > .icon.toggle-able:active):
+ (.style-declaration-section:not(.invalid-selector) > .header > .icon.toggle-able:hover): Deleted.
+ Added better :hover and :active styles.
+
+ * UserInterface/Views/CSSStyleDeclarationSection.js:
+ (WebInspector.CSSStyleDeclarationSection):
+ (WebInspector.CSSStyleDeclarationSection.prototype.refresh):
+ (WebInspector.CSSStyleDeclarationSection.prototype._handleIconElementClicked):
+ If the selector is invalid, simply refresh the section to regenerate the
+ original selector with correct content, specificity, and highlighting.
+
+ (WebInspector.CSSStyleDeclarationSection.prototype.get _hasInvalidSelector): Deleted.
+ Moved the state of the invalid selector to a member
+ variable instead of a DOM class.
+
+ (WebInspector.CSSStyleDeclarationSection.prototype._updateSelectorIcon):
+ Renamed from _markSelector for clarity.
+
+ * UserInterface/Views/VisualStyleSelectorTreeItem.css:
+ (.item.visual-style-selector-item.selector-invalid > .icon:hover):
+ (.item.visual-style-selector-item.selector-invalid > .icon:active):
+ (.item.visual-style-selector-item.selector-invalid > .icon):
+ Added :hover and :active styles.
+
+ * UserInterface/Views/VisualStyleSelectorTreeItem.js:
+ (WebInspector.VisualStyleSelectorTreeItem):
+ (WebInspector.VisualStyleSelectorTreeItem.prototype.onattach):
+ (WebInspector.VisualStyleSelectorTreeItem.prototype._commitSelector):
+ (WebInspector.VisualStyleSelectorTreeItem.prototype._updateSelectorIcon):
+ (WebInspector.VisualStyleSelectorTreeItem.prototype._handleIconElementClicked):
+ (WebInspector.VisualStyleSelectorTreeItem.prototype._selectorChanged): Deleted.
+ Changed the names of a few functions to provide better
+ consistency across the classes in the Style sidebar.
+
2015-12-27 Brian Burg <[email protected]>
Web Inspector: improve pre-filled bugzilla link on Uncaught Exception reporter sheet
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (194436 => 194437)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2015-12-29 13:57:21 UTC (rev 194436)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2015-12-29 18:15:45 UTC (rev 194437)
@@ -598,7 +598,7 @@
localizedStrings["The 'webkit' prefix is needed for this property.\nClick to insert a duplicate with the prefix."] = "The 'webkit' prefix is needed for this property.\nClick to insert a duplicate with the prefix.";
localizedStrings["The 'webkit' prefix is not necessary.\nClick to insert a duplicate without the prefix."] = "The 'webkit' prefix is not necessary.\nClick to insert a duplicate without the prefix.";
localizedStrings["The property '%s' is not supported."] = "The property '%s' is not supported.";
-localizedStrings["The selector '%s' is invalid."] = "The selector '%s' is invalid.";
+localizedStrings["The selector '%s' is invalid.\nClick to revert to the previous selector."] = "The selector '%s' is invalid.\nClick to revert to the previous selector.";
localizedStrings["The value '%s' is not supported for this property.\nClick to delete and open autocomplete."] = "The value '%s' is not supported for this property.\nClick to delete and open autocomplete.";
localizedStrings["The value '%s' needs units.\nClick to add 'px' to the value."] = "The value '%s' needs units.\nClick to add 'px' to the value.";
localizedStrings["The %s \ntable is empty."] = "The %s \ntable is empty.";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.css (194436 => 194437)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.css 2015-12-29 13:57:21 UTC (rev 194436)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.css 2015-12-29 18:15:45 UTC (rev 194437)
@@ -72,10 +72,14 @@
height: 16px;
}
-.style-declaration-section:not(.invalid-selector) > .header > .icon.toggle-able:hover {
+.style-declaration-section > .header > .icon.toggle-able:hover {
filter: brightness(0.9);
}
+.style-declaration-section > .header > .icon.toggle-able:active {
+ filter: brightness(0.8);
+}
+
.style-declaration-section:not(.invalid-selector).rule-disabled > .header > .icon {
opacity: 0.5;
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js (194436 => 194437)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js 2015-12-29 13:57:21 UTC (rev 194436)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js 2015-12-29 18:15:45 UTC (rev 194437)
@@ -36,6 +36,7 @@
this._style = style || null;
this._selectorElements = [];
this._ruleDisabled = false;
+ this._hasInvalidSelector = false;
this._element = document.createElement("div");
this._element.classList.add("style-declaration-section");
@@ -104,7 +105,7 @@
if (style.editable) {
this._iconElement.classList.add("toggle-able");
this._iconElement.title = WebInspector.UIString("Comment All Properties");
- this._iconElement.addEventListener("click", this._toggleRuleOnOff.bind(this));
+ this._iconElement.addEventListener("click", this._handleIconElementClicked.bind(this));
}
console.assert(iconClassName);
@@ -113,7 +114,7 @@
if (!style.editable)
this._element.classList.add(WebInspector.CSSStyleDeclarationSection.LockedStyleClassName);
else if (style.ownerRule) {
- this._style.ownerRule.addEventListener(WebInspector.CSSRule.Event.SelectorChanged, this._markSelector.bind(this));
+ this._style.ownerRule.addEventListener(WebInspector.CSSRule.Event.SelectorChanged, this._updateSelectorIcon.bind(this));
this._commitSelectorKeyboardShortcut = new WebInspector.KeyboardShortcut(null, WebInspector.KeyboardShortcut.Key.Enter, this._commitSelector.bind(this), this._selectorElement);
this._selectorElement.addEventListener("blur", this._commitSelector.bind(this));
} else
@@ -263,6 +264,8 @@
this._originElement.append(WebInspector.UIString("HTML Attributes"));
break;
}
+
+ this._updateSelectorIcon();
}
highlightProperty(property)
@@ -447,10 +450,13 @@
});
}
- _toggleRuleOnOff()
+ _handleIconElementClicked()
{
- if (this._hasInvalidSelector)
+ if (this._hasInvalidSelector) {
+ // This will revert the selector text to the original valid value.
+ this.refresh();
return;
+ }
this._ruleDisabled = this._ruleDisabled ? !this._propertiesTextEditor.uncommentAllProperties() : this._propertiesTextEditor.commentAllProperties();
this._iconElement.title = this._ruleDisabled ? WebInspector.UIString("Uncomment All Properties") : WebInspector.UIString("Comment All Properties");
@@ -557,27 +563,25 @@
this._style.ownerRule.selectorText = newSelectorText;
}
- _markSelector(event)
+ _updateSelectorIcon(event)
{
- var valid = event && event.data && event.data.valid;
- this._element.classList.toggle(WebInspector.CSSStyleDeclarationSection.SelectorInvalidClassName, !valid);
- if (valid) {
+ if (!this._style.ownerRule || !this._style.editable)
+ return;
+
+ this._hasInvalidSelector = event && event.data && !event.data.valid;
+ this._element.classList.toggle("invalid-selector", !!this._hasInvalidSelector);
+ if (!this._hasInvalidSelector) {
this._iconElement.title = this._ruleDisabled ? WebInspector.UIString("Uncomment All Properties") : WebInspector.UIString("Comment All Properties");
this._selectorElement.title = null;
return;
}
- this._iconElement.title = WebInspector.UIString("The selector '%s' is invalid.").format(this._selectorElement.textContent.trim());
+ this._iconElement.title = WebInspector.UIString("The selector '%s' is invalid.\nClick to revert to the previous selector.").format(this._selectorElement.textContent.trim());
this._selectorElement.title = WebInspector.UIString("Using the previous selector '%s'.").format(this._style.ownerRule.selectorText);
- for (var i = 0; i < this._selectorElement.children.length; ++i)
+ for (let i = 0; i < this._selectorElement.children.length; ++i)
this._selectorElement.children[i].title = null;
}
- get _hasInvalidSelector()
- {
- return this._element.classList.contains(WebInspector.CSSStyleDeclarationSection.SelectorInvalidClassName);
- }
-
_editorContentChanged(event)
{
this._editorActive = true;
@@ -596,7 +600,6 @@
WebInspector.CSSStyleDeclarationSection.LockedStyleClassName = "locked";
WebInspector.CSSStyleDeclarationSection.SelectorLockedStyleClassName = "selector-locked";
-WebInspector.CSSStyleDeclarationSection.SelectorInvalidClassName = "invalid-selector";
WebInspector.CSSStyleDeclarationSection.LastInGroupStyleClassName = "last-in-group";
WebInspector.CSSStyleDeclarationSection.MatchedSelectorElementStyleClassName = "matched";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.css (194436 => 194437)
--- trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.css 2015-12-29 13:57:21 UTC (rev 194436)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.css 2015-12-29 18:15:45 UTC (rev 194437)
@@ -69,11 +69,18 @@
}
.item.visual-style-selector-item.selector-invalid > .icon {
- width: 14px;
height: 14px;
content: url(../Images/Error.svg);
}
+.item.visual-style-selector-item.selector-invalid > .icon:hover {
+ filter: brightness(0.9);
+}
+
+.item.visual-style-selector-item.selector-invalid > .icon:active {
+ filter: brightness(0.8);
+}
+
.item.visual-style-selector-item.selector-invalid > .titles > .title {
position: relative;
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js (194436 => 194437)
--- trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js 2015-12-29 13:57:21 UTC (rev 194436)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js 2015-12-29 18:15:45 UTC (rev 194437)
@@ -60,6 +60,7 @@
this._iconClassName = iconClassName;
this._lastValue = title;
this._enableEditing = true;
+ this._hasInvalidSelector = false;
}
// Public
@@ -95,6 +96,8 @@
this._checkboxElement.addEventListener("change", this._handleCheckboxChanged.bind(this));
this._listItemNode.insertBefore(this._checkboxElement, this._iconElement);
+ this._iconElement.addEventListener("click", this._handleIconElementClicked.bind(this));
+
this._mainTitleElement.spellcheck = false;
this._mainTitleElement.addEventListener("mousedown", this._handleMainTitleMouseDown.bind(this));
this._mainTitleElement.addEventListener("keydown", this._handleMainTitleKeyDown.bind(this));
@@ -103,7 +106,7 @@
this.representedObject.addEventListener(WebInspector.CSSStyleDeclaration.Event.InitialTextModified, this._styleTextModified, this);
if (this.representedObject.ownerRule)
- this.representedObject.ownerRule.addEventListener(WebInspector.CSSRule.Event.SelectorChanged, this._selectorChanged, this);
+ this.representedObject.ownerRule.addEventListener(WebInspector.CSSRule.Event.SelectorChanged, this._updateSelectorIcon, this);
this._styleTextModified();
}
@@ -191,7 +194,7 @@
this._updateTitleTooltip();
let value = this.selectorText;
- if (value === this._lastValue && this._valid)
+ if (value === this._lastValue && !this._hasInvalidSelector)
return;
this.representedObject.ownerRule.selectorText = value;
@@ -202,13 +205,28 @@
this._listItemNode.classList.toggle("modified", this.representedObject.modified);
}
- _selectorChanged(event)
+ _updateSelectorIcon(event)
{
- this._valid = event && event.data && event.data.valid;
- this._listItemNode.classList.toggle("selector-invalid", !this._valid);
- let invalidTitle = WebInspector.UIString("The selector '%s' is invalid.").format(this.selectorText);
- this._iconElement.title = !this._valid ? invalidTitle : null;
+ this._hasInvalidSelector = event && event.data && !event.data.valid;
+ this._listItemNode.classList.toggle("selector-invalid", !!this._hasInvalidSelector);
+ if (this._hasInvalidSelector) {
+ this._iconElement.title = WebInspector.UIString("The selector '%s' is invalid.\nClick to revert to the previous selector.").format(this.selectorText);
+ this.mainTitleElement.title = WebInspector.UIString("Using the previous selector '%s'.").format(this.representedObject.ownerRule.selectorText);
+ return;
+ }
+
+ this._iconElement.title = null;
+ this.mainTitleElement.title = null;
}
+
+ _handleIconElementClicked(event)
+ {
+ if (this._hasInvalidSelector && this.representedObject.ownerRule) {
+ this.mainTitleElement.textContent = this._lastValue = this.representedObject.ownerRule.selectorText;
+ this._updateSelectorIcon();
+ return;
+ }
+ }
};
WebInspector.VisualStyleSelectorTreeItem.Event = {