Title: [226082] trunk/Source/WebInspectorUI
- Revision
- 226082
- Author
- nvasil...@apple.com
- Date
- 2017-12-18 15:02:40 -0800 (Mon, 18 Dec 2017)
Log Message
Web Inspector: Styles Redesign: Command-S should save changes in matching CSS resource
https://bugs.webkit.org/show_bug.cgi?id=180900
Reviewed by Timothy Hatcher.
When focused on a CSS selector, property name or value, pressing Command-S should save
the CSS resource to the file system.
* UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
(WI.SpreadsheetCSSStyleDeclarationSection.prototype.initialLayout):
(WI.SpreadsheetCSSStyleDeclarationSection.prototype._save):
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (226081 => 226082)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-12-18 22:20:22 UTC (rev 226081)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-12-18 23:02:40 UTC (rev 226082)
@@ -1,3 +1,17 @@
+2017-12-18 Nikita Vasilyev <nvasil...@apple.com>
+
+ Web Inspector: Styles Redesign: Command-S should save changes in matching CSS resource
+ https://bugs.webkit.org/show_bug.cgi?id=180900
+
+ Reviewed by Timothy Hatcher.
+
+ When focused on a CSS selector, property name or value, pressing Command-S should save
+ the CSS resource to the file system.
+
+ * UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
+ (WI.SpreadsheetCSSStyleDeclarationSection.prototype.initialLayout):
+ (WI.SpreadsheetCSSStyleDeclarationSection.prototype._save):
+
2017-12-18 Devin Rousso <web...@devinrousso.com>
Web Inspector: Styles Redesign: add inline swatch for CSS variables
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js (226081 => 226082)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js 2017-12-18 22:20:22 UTC (rev 226081)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js 2017-12-18 23:02:40 UTC (rev 226082)
@@ -104,6 +104,9 @@
if (this._style.editable) {
this.element.addEventListener("click", this._handleClick.bind(this));
this.element.addEventListener("mousedown", this._handleMouseDown.bind(this));
+
+ new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl, "S", this._save.bind(this), this._element);
+ new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl | WI.KeyboardShortcut.Modifier.Shift, "S", this._save.bind(this), this._element);
}
}
@@ -377,6 +380,42 @@
return mediaElement;
}
+ _save(event)
+ {
+ event.stop();
+
+ if (this._style.type !== WI.CSSStyleDeclaration.Type.Rule) {
+ // FIXME: Can't save CSS inside <style></style> <https://webkit.org/b/150357>
+ InspectorFrontendHost.beep();
+ return;
+ }
+
+ console.assert(this._style.ownerRule instanceof WI.CSSRule);
+ console.assert(this._style.ownerRule.sourceCodeLocation instanceof WI.SourceCodeLocation);
+
+ let sourceCode = this._style.ownerRule.sourceCodeLocation.sourceCode;
+ if (sourceCode.type !== WI.Resource.Type.Stylesheet) {
+ // FIXME: Can't save CSS inside style="" <https://webkit.org/b/150357>
+ InspectorFrontendHost.beep();
+ return;
+ }
+
+ let url;
+ if (sourceCode.urlComponents.scheme === "data") {
+ let mainResource = WI.frameResourceManager.mainFrame.mainResource;
+ if (mainResource.urlComponents.lastPathComponent.endsWith(".html"))
+ url = "" "-data.css");
+ else {
+ let pathDirectory = mainResource.url.slice(0, -mainResource.urlComponents.lastPathComponent.length);
+ url = "" + "data.css";
+ }
+ } else
+ url = ""
+
+ const saveAs = event.shiftKey;
+ WI.saveDataToFile({url: url, content: sourceCode.content}, saveAs);
+ }
+
_handleMouseDown(event)
{
this._wasFocused = this._propertiesEditor.isFocused();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes