Title: [191371] trunk/Source/WebInspectorUI
- Revision
- 191371
- Author
- [email protected]
- Date
- 2015-10-20 21:25:02 -0700 (Tue, 20 Oct 2015)
Log Message
Web Inspector: Pressing Command-S while focused on the styles sidebar should save CSS file
https://bugs.webkit.org/show_bug.cgi?id=150298
Reviewed by Timothy Hatcher.
* UserInterface/Views/CSSStyleDeclarationSection.js:
(WebInspector.CSSStyleDeclarationSection):
Beep when saving didn't work. Inline CSS and CSS in style attributes aren't curently supported.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (191370 => 191371)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-10-21 02:21:02 UTC (rev 191370)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-10-21 04:25:02 UTC (rev 191371)
@@ -1,3 +1,14 @@
+2015-10-20 Nikita Vasilyev <[email protected]>
+
+ Web Inspector: Pressing Command-S while focused on the styles sidebar should save CSS file
+ https://bugs.webkit.org/show_bug.cgi?id=150298
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Views/CSSStyleDeclarationSection.js:
+ (WebInspector.CSSStyleDeclarationSection):
+ Beep when saving didn't work. Inline CSS and CSS in style attributes aren't curently supported.
+
2015-10-20 Joseph Pecoraro <[email protected]>
Web Inspector: _javascript_Core should parse sourceURL and sourceMappingURL directives
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js (191370 => 191371)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js 2015-10-21 02:21:02 UTC (rev 191370)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js 2015-10-21 04:25:02 UTC (rev 191371)
@@ -40,6 +40,8 @@
this._element = document.createElement("div");
this._element.classList.add("style-declaration-section");
+ new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "S", this._save.bind(this), this._element);
+
this._headerElement = document.createElement("div");
this._headerElement.classList.add("header");
@@ -489,6 +491,39 @@
this._hideDOMNodeHighlight();
}
+ _save(event)
+ {
+ event.preventDefault();
+ event.stopPropagation();
+
+ if (this._style.type !== WebInspector.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 WebInspector.CSSRule);
+ console.assert(this._style.ownerRule.sourceCodeLocation instanceof WebInspector.SourceCodeLocation);
+
+ let sourceCode = this._style.ownerRule.sourceCodeLocation.sourceCode;
+ if (sourceCode.type !== WebInspector.Resource.Type.Stylesheet) {
+ // FIXME: Can't save CSS inside style="" <https://webkit.org/b/150357>
+ InspectorFrontendHost.beep();
+ return;
+ }
+
+ var url;
+ if (sourceCode.urlComponents.scheme === "data") {
+ let mainResource = WebInspector.frameResourceManager.mainFrame.mainResource;
+ let pathDirectory = mainResource.url.slice(0, -mainResource.urlComponents.lastPathComponent.length);
+ url = "" + "base64.css";
+ } else
+ url = ""
+
+ const saveAs = event.shiftKey;
+ WebInspector.saveDataToFile({url: url, content: sourceCode.content}, saveAs);
+ }
+
_handleKeyDown(event)
{
if (event.keyCode !== 9) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes