Title: [222678] trunk/Source/WebInspectorUI
Revision
222678
Author
nvasil...@apple.com
Date
2017-09-29 22:07:01 -0700 (Fri, 29 Sep 2017)

Log Message

Web Inspector: Styles Redesign: support undo/redo of manual edits
https://bugs.webkit.org/show_bug.cgi?id=177314

Reviewed by Joseph Pecoraro.

Make sure Command-Z and Command-Shift-Z undo changes in the styles sidebar
when not focused on a contentEditable field.

* UserInterface/Views/EditingSupport.js:
(WI.isEventTargetAnEditableField):
Make sure WI._undoKeyboardShortcut doesn't call WI.undo() when editing inside of a contentEditable element.

* UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js:
(WI.SpreadsheetCSSStyleDeclarationEditor):
Call style setter to setup event listeners during instantiation.

(WI.SpreadsheetCSSStyleDeclarationEditor.prototype.set style):
(WI.SpreadsheetCSSStyleDeclarationEditor.prototype._propertiesChanged):
Update style declaration section when it isn't focused.
This is the same logic as in the old styles sidebar (CSSStyleDeclarationTextEditor style setter).

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (222677 => 222678)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-09-30 04:31:29 UTC (rev 222677)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-09-30 05:07:01 UTC (rev 222678)
@@ -1,3 +1,26 @@
+2017-09-29  Nikita Vasilyev  <nvasil...@apple.com>
+
+        Web Inspector: Styles Redesign: support undo/redo of manual edits
+        https://bugs.webkit.org/show_bug.cgi?id=177314
+
+        Reviewed by Joseph Pecoraro.
+
+        Make sure Command-Z and Command-Shift-Z undo changes in the styles sidebar
+        when not focused on a contentEditable field.
+
+        * UserInterface/Views/EditingSupport.js:
+        (WI.isEventTargetAnEditableField):
+        Make sure WI._undoKeyboardShortcut doesn't call WI.undo() when editing inside of a contentEditable element.
+
+        * UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js:
+        (WI.SpreadsheetCSSStyleDeclarationEditor):
+        Call style setter to setup event listeners during instantiation.
+
+        (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.set style):
+        (WI.SpreadsheetCSSStyleDeclarationEditor.prototype._propertiesChanged):
+        Update style declaration section when it isn't focused.
+        This is the same logic as in the old styles sidebar (CSSStyleDeclarationTextEditor style setter).
+
 2017-09-29  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Open Resource Dialog icons are blurry (24x24 instead of 32x32)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/EditingSupport.js (222677 => 222678)


--- trunk/Source/WebInspectorUI/UserInterface/Views/EditingSupport.js	2017-09-30 04:31:29 UTC (rev 222677)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/EditingSupport.js	2017-09-30 05:07:01 UTC (rev 222678)
@@ -68,6 +68,9 @@
     if (event.target instanceof HTMLTextAreaElement)
         return true;
 
+    if (event.target.isContentEditable)
+        return true;
+
     if (event.target.enclosingNodeOrSelfWithClass("text-prompt"))
         return true;
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js (222677 => 222678)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js	2017-09-30 04:31:29 UTC (rev 222677)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js	2017-09-30 05:07:01 UTC (rev 222678)
@@ -31,7 +31,7 @@
 
         this.element.classList.add(WI.SpreadsheetCSSStyleDeclarationEditor.StyleClassName);
 
-        this._style = style;
+        this.style = style;
     }
 
     // Public
@@ -59,8 +59,14 @@
         if (this._style === style)
             return;
 
+        if (this._style)
+            this._style.removeEventListener(WI.CSSStyleDeclaration.Event.PropertiesChanged, this._propertiesChanged, this);
+
         this._style = style || null;
 
+        if (this._style)
+            this._style.addEventListener(WI.CSSStyleDeclaration.Event.PropertiesChanged, this._propertiesChanged, this);
+
         this.needsLayout();
     }
 
@@ -73,6 +79,14 @@
 
         return this._style.allProperties;
     }
+
+    _propertiesChanged(event)
+    {
+        let focusedElement = document.activeElement;
+        let isFocused = focusedElement && focusedElement.isSelfOrDescendant(this.element);
+        if (!isFocused)
+            this.needsLayout();
+    }
 };
 
 WI.SpreadsheetCSSStyleDeclarationEditor.StyleClassName = "spreadsheet-style-declaration-editor";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to