Title: [185757] trunk/Source/WebInspectorUI
- Revision
- 185757
- Author
- [email protected]
- Date
- 2015-06-19 11:49:19 -0700 (Fri, 19 Jun 2015)
Log Message
Web Inspector: Make rule icon toggle all properties for that selector on and off
https://bugs.webkit.org/show_bug.cgi?id=146031
Patch by Devin Rousso <[email protected]> on 2015-06-19
Reviewed by Timothy Hatcher.
* UserInterface/Views/CSSStyleDeclarationSection.css:
(.style-declaration-section > .header > .icon.toggle-able:hover):
(.style-declaration-section.rule-disabled > .header > .icon):
* UserInterface/Views/CSSStyleDeclarationSection.js:
(WebInspector.CSSStyleDeclarationSection): Added event listener to selector icon to toggle commenting of all properties for that rule.
(WebInspector.CSSStyleDeclarationSection.prototype._toggleRuleOnOff): Adds or removes comments to all properties for that rule.
* UserInterface/Views/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties.uncommentProperties):
(WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties): Uncomments all properties.
(WebInspector.CSSStyleDeclarationTextEditor.prototype.commentAllProperties): Comments out all properties.
(WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCheckboxChanged): Moved comment logic to its own function.
(WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCommentCheckboxChanged): Moved uncomment logic to its own function.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (185756 => 185757)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-06-19 18:18:05 UTC (rev 185756)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-06-19 18:49:19 UTC (rev 185757)
@@ -1,3 +1,23 @@
+2015-06-19 Devin Rousso <[email protected]>
+
+ Web Inspector: Make rule icon toggle all properties for that selector on and off
+ https://bugs.webkit.org/show_bug.cgi?id=146031
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Views/CSSStyleDeclarationSection.css:
+ (.style-declaration-section > .header > .icon.toggle-able:hover):
+ (.style-declaration-section.rule-disabled > .header > .icon):
+ * UserInterface/Views/CSSStyleDeclarationSection.js:
+ (WebInspector.CSSStyleDeclarationSection): Added event listener to selector icon to toggle commenting of all properties for that rule.
+ (WebInspector.CSSStyleDeclarationSection.prototype._toggleRuleOnOff): Adds or removes comments to all properties for that rule.
+ * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties.uncommentProperties):
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties): Uncomments all properties.
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype.commentAllProperties): Comments out all properties.
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCheckboxChanged): Moved comment logic to its own function.
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCommentCheckboxChanged): Moved uncomment logic to its own function.
+
2015-06-19 Jon Lee <[email protected]>
Update font and font-family keyword completions
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (185756 => 185757)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2015-06-19 18:18:05 UTC (rev 185756)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2015-06-19 18:49:19 UTC (rev 185757)
@@ -107,6 +107,7 @@
localizedStrings["Code"] = "Code";
localizedStrings["Collapse columns"] = "Collapse columns";
localizedStrings["Comment"] = "Comment";
+localizedStrings["Comment All Properties"] = "Comment All Properties";
localizedStrings["Compressed"] = "Compressed";
localizedStrings["Compression"] = "Compression";
localizedStrings["Computed"] = "Computed";
@@ -493,6 +494,7 @@
localizedStrings["Type Issue"] = "Type Issue";
localizedStrings["Type information for variable: %s"] = "Type information for variable: %s";
localizedStrings["Unable to determine path to property from root"] = "Unable to determine path to property from root";
+localizedStrings["Uncomment All Properties"] = "Uncomment All Properties";
localizedStrings["Unknown node"] = "Unknown node";
localizedStrings["Untitled"] = "Untitled";
localizedStrings["User Agent Stylesheet"] = "User Agent Stylesheet";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.css (185756 => 185757)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.css 2015-06-19 18:18:05 UTC (rev 185756)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.css 2015-06-19 18:49:19 UTC (rev 185757)
@@ -68,6 +68,14 @@
height: 16px;
}
+.style-declaration-section > .header > .icon.toggle-able:hover {
+ -webkit-filter: brightness(0.9);
+}
+
+.style-declaration-section.rule-disabled > .header > .icon {
+ opacity: 0.5;
+}
+
.style-declaration-section > .header > .selector {
font-family: Menlo, monospace;
color: rgb(128, 128, 128);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js (185756 => 185757)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js 2015-06-19 18:18:05 UTC (rev 185756)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js 2015-06-19 18:49:19 UTC (rev 185757)
@@ -33,6 +33,7 @@
console.assert(style);
this._style = style || null;
this._selectorElements = [];
+ this._ruleDisabled = false;
this._element = document.createElement("div");
this._element.className = "style-declaration-section";
@@ -88,6 +89,13 @@
break;
}
+ // Matches all situations except for User Agent styles.
+ if (!(style.ownerRule && style.ownerRule.type === WebInspector.CSSRule.Type.UserAgent)) {
+ this._iconElement.classList.add("toggle-able");
+ this._iconElement.title = WebInspector.UIString("Comment All Properties");
+ this._iconElement.addEventListener("click", this._toggleRuleOnOff.bind(this));
+ }
+
console.assert(iconClassName);
this._element.classList.add(iconClassName);
@@ -376,6 +384,13 @@
return styleText;
},
+ _toggleRuleOnOff: function()
+ {
+ 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");
+ this._element.classList.toggle("rule-disabled", this._ruleDisabled);
+ },
+
_commitSelector: function(mutations)
{
console.assert(this._style.ownerRule);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js (185756 => 185757)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js 2015-06-19 18:18:05 UTC (rev 185756)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js 2015-06-19 18:49:19 UTC (rev 185757)
@@ -302,6 +302,39 @@
return matchingPropertyNames.length > 0;
}
+ uncommentAllProperties()
+ {
+ function uncommentProperties(properties)
+ {
+ if (!properties.length)
+ return false;
+
+ for (var property of properties) {
+ if (property._commentRange) {
+ this._uncommentRange(property._commentRange);
+ property._commentRange = null;
+ }
+ }
+
+ return true;
+ }
+
+ return uncommentProperties.call(this, this._style.pendingProperties) || uncommentProperties.call(this, this._style.properties);
+ }
+
+ commentAllProperties()
+ {
+ if (!this._style.properties.length)
+ return false;
+
+ for (var property of this._style.properties) {
+ if (property.__propertyTextMarker)
+ this._commentProperty(property);
+ }
+
+ return true;
+ }
+
// Protected
didDismissPopover(popover)
@@ -712,6 +745,11 @@
if (!property)
return;
+ this._commentProperty(property);
+ }
+
+ _commentProperty(property)
+ {
var textMarker = property.__propertyTextMarker;
console.assert(textMarker);
if (!textMarker)
@@ -723,6 +761,9 @@
if (!range)
return;
+ property._commentRange = range;
+ property._commentRange.to.ch += 6; // Number of characters added by comments.
+
var text = this._codeMirror.getRange(range.from, range.to);
function update()
@@ -750,6 +791,11 @@
if (!range)
return;
+ this._uncommentRange(range);
+ }
+
+ _uncommentRange(range)
+ {
var text = this._codeMirror.getRange(range.from, range.to);
// Remove the comment prefix and suffix.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes