Title: [196255] trunk/Source/WebInspectorUI
Revision
196255
Author
mattba...@apple.com
Date
2016-02-08 10:23:08 -0800 (Mon, 08 Feb 2016)

Log Message

Web Inspector: WebInspector.Setting should have a "reset" method
https://bugs.webkit.org/show_bug.cgi?id=153971
<rdar://problem/24544101>

Reviewed by Brian Burg.

Currently UI needing to restore a setting to its default must retain a copy
of the default value. This should be a basic operation of WebInspector.Setting.

* UserInterface/Base/Setting.js:
(WebInspector.Setting):
(WebInspector.Setting.prototype.reset):
Sets value to a copy of the default.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (196254 => 196255)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-02-08 17:06:34 UTC (rev 196254)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-02-08 18:23:08 UTC (rev 196255)
@@ -1,3 +1,19 @@
+2016-02-08  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: WebInspector.Setting should have a "reset" method
+        https://bugs.webkit.org/show_bug.cgi?id=153971
+        <rdar://problem/24544101>
+
+        Reviewed by Brian Burg.
+
+        Currently UI needing to restore a setting to its default must retain a copy
+        of the default value. This should be a basic operation of WebInspector.Setting.
+
+        * UserInterface/Base/Setting.js:
+        (WebInspector.Setting):
+        (WebInspector.Setting.prototype.reset):
+        Sets value to a copy of the default.
+
 2016-02-06  Nikita Vasilyev  <nvasil...@apple.com>
 
         REGRESSION (r195432): Web Inspector: bottom right section of the styles sidebar is 1px taller than the console prompt

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js (196254 => 196255)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js	2016-02-08 17:06:34 UTC (rev 196254)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js	2016-02-08 18:23:08 UTC (rev 196255)
@@ -90,6 +90,12 @@
 
         this.dispatchEventToListeners(WebInspector.Setting.Event.Changed, this._value, {name: this._name});
     }
+
+    reset()
+    {
+        // Make a copy of the default value so changes to object values don't modify the default value.
+        this.value = JSON.parse(JSON.stringify(this._defaultValue));
+    }
 };
 
 WebInspector.Setting.Event = {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to