Title: [239864] trunk
Revision
239864
Author
[email protected]
Date
2019-01-11 10:28:06 -0800 (Fri, 11 Jan 2019)

Log Message

Introduce IDL files for runtime-enabled UndoManager and UndoItem _javascript_ API
https://bugs.webkit.org/show_bug.cgi?id=193109
<rdar://problem/44807048>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Adds new IDL files and stubs for UndoManager and UndoItem. This is an experimental DOM API that (in the near
future) is intended only for use in internal WebKit text editing clients. This API allows the page to
participate in the processes of undoing and redoing by defining custom undo and redo handlers, to be executed
when undo or redo is triggered.

Tests: editing/undo-manager/undo-manager-interfaces.html
       editing/undo-manager/undo-manager-keeps-wrapper-alive.html

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Sources.txt:
* UnifiedSources-input.xcfilelist:
* WebCore.xcodeproj/project.pbxproj:

Add new source files.

* bindings/js/WebCoreBuiltinNames.h:

Add "UndoManager" and "UndoItem" names.

* dom/Document.cpp:
(WebCore::m_undoManager):

Have the document own a UndoManager.

* dom/Document.h:
(WebCore::Document::undoManager const):
* dom/Document.idl:
* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setUndoManagerAPIEnabled):
(WebCore::RuntimeEnabledFeatures::undoManagerAPIEnabled const):

Guard the new bindings behind a runtime-enabled feature flag.

* page/UndoItem.h: Added.
(WebCore::UndoItem::create):
(WebCore::UndoItem::label const):
(WebCore::UndoItem::undoHandler const):
(WebCore::UndoItem::redoHandler const):
(WebCore::UndoItem::UndoItem):
* page/UndoItem.idl: Added.
* page/UndoManager.cpp: Added.
(WebCore::UndoManager::addItem):
* page/UndoManager.h: Added.
(WebCore::UndoManager::create):
(WebCore::UndoManager::document):
(WebCore::UndoManager::UndoManager):
* page/UndoManager.idl: Added.
* page/mac/WheelEventDeltaFilterMac.h:

Necessary (albeit unrelated) build fix to appease unified sources.

Source/WebKit:

Add a new SPI configuration flag to enable the UndoManager API. This is off by default.

* Shared/WebPreferences.yaml:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _setUndoManagerAPIEnabled:]):
(-[WKWebViewConfiguration _undoManagerAPIEnabled]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:

Tools:

Introduce and respect a test option to enable the UndoManager API.

* WebKitTestRunner/TestController.cpp:
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView):

LayoutTests:

Add UndoManager tests to exercise new bindings, and verify that the JS wrapper for Document's UndoManager
survives garbage collection.

* TestExpectations:
* editing/undo-manager/undo-manager-interfaces-expected.txt: Added.
* editing/undo-manager/undo-manager-interfaces.html: Added.
* editing/undo-manager/undo-manager-keeps-wrapper-alive-expected.txt: Added.
* editing/undo-manager/undo-manager-keeps-wrapper-alive.html: Added.
* platform/ios-wk2/TestExpectations:
* platform/mac-wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (239863 => 239864)


--- trunk/LayoutTests/ChangeLog	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/LayoutTests/ChangeLog	2019-01-11 18:28:06 UTC (rev 239864)
@@ -1,3 +1,22 @@
+2019-01-11  Wenson Hsieh  <[email protected]>
+
+        Introduce IDL files for runtime-enabled UndoManager and UndoItem _javascript_ API
+        https://bugs.webkit.org/show_bug.cgi?id=193109
+        <rdar://problem/44807048>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add UndoManager tests to exercise new bindings, and verify that the JS wrapper for Document's UndoManager
+        survives garbage collection.
+
+        * TestExpectations:
+        * editing/undo-manager/undo-manager-interfaces-expected.txt: Added.
+        * editing/undo-manager/undo-manager-interfaces.html: Added.
+        * editing/undo-manager/undo-manager-keeps-wrapper-alive-expected.txt: Added.
+        * editing/undo-manager/undo-manager-keeps-wrapper-alive.html: Added.
+        * platform/ios-wk2/TestExpectations:
+        * platform/mac-wk2/TestExpectations:
+
 2019-01-11  Zalan Bujtas  <[email protected]>
 
         [LFC][BFC][MarginCollapsing] Adjust vertical position when box margin collapses through.

Modified: trunk/LayoutTests/TestExpectations (239863 => 239864)


--- trunk/LayoutTests/TestExpectations	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/LayoutTests/TestExpectations	2019-01-11 18:28:06 UTC (rev 239864)
@@ -19,6 +19,7 @@
 editing/find [ Skip ]
 editing/pasteboard/gtk [ Skip ]
 editing/selection/ios [ Skip ]
+editing/undo-manager [ Skip ]
 tiled-drawing [ Skip ]
 fast/css/watchos [ Skip ]
 fast/dom/Window/watchos [ Skip ]

Added: trunk/LayoutTests/editing/undo-manager/undo-manager-interfaces-expected.txt (0 => 239864)


--- trunk/LayoutTests/editing/undo-manager/undo-manager-interfaces-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/undo-manager/undo-manager-interfaces-expected.txt	2019-01-11 18:28:06 UTC (rev 239864)
@@ -0,0 +1,43 @@
+Verifies that, when the UndoManager API is enabled, UndoManager and UndoItem interfaces behave as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Testing UndoManager:
+PASS UndoManager instanceof Function is true
+PASS typeof UndoManager is "function"
+PASS document.undoManager instanceof UndoManager is true
+PASS Object.getPrototypeOf(document.undoManager) === UndoManager.prototype is true
+PASS UndoManager.prototype.addItem instanceof Function is true
+PASS UndoManager() threw exception TypeError: Illegal constructor.
+PASS new UndoManager() threw exception TypeError: function is not a constructor (evaluating 'new UndoManager()').
+PASS document.undoManager.addItem() threw exception TypeError: Not enough arguments.
+PASS document.undoManager.addItem('foo') threw exception TypeError: Argument 1 ('item') to UndoManager.addItem must be an instance of UndoItem.
+PASS UndoManager.toString() is "function UndoManager() {\n    [native code]\n}"
+PASS document.undoManager.toString() is "[object UndoManager]"
+
+Testing UndoItem:
+PASS UndoItem instanceof Function is true
+PASS typeof UndoItem is "function"
+PASS UndoItem() threw exception TypeError: Constructor requires 'new' operator.
+PASS new UndoItem() threw exception TypeError: Not enough arguments.
+PASS new UndoItem('foo') threw exception TypeError: Type error.
+PASS new UndoItem({ }) threw exception TypeError: Member UndoItemInit.label is required and must be an instance of DOMString.
+PASS new UndoItem({ label: null, undo: null }) threw exception TypeError: Member UndoItemInit.redo is required and must be an instance of VoidCallback.
+PASS new UndoItem({ redo: null }) threw exception TypeError: Member UndoItemInit.label is required and must be an instance of DOMString.
+PASS new UndoItem({ label: '', undo: emptyFunction }) threw exception TypeError: Member UndoItemInit.redo is required and must be an instance of VoidCallback.
+PASS new UndoItem({ label: 'hello', redo: emptyFunction }) threw exception TypeError: Member UndoItemInit.undo is required and must be an instance of VoidCallback.
+PASS new UndoItem({ label: 3, undo: null, redo: null }) threw exception TypeError: Type error.
+PASS new UndoItem({ label: '', undo: '', redo: emptyFunction }) threw exception TypeError: Type error.
+PASS new UndoItem({ label: '', undo: emptyFunction, redo: 10 }) threw exception TypeError: Type error.
+PASS new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction, foo: 'hi' }) instanceof UndoItem is true
+PASS Object.getPrototypeOf(new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction })) === UndoItem.prototype is true
+PASS new UndoItem({ label: 'foo', undo: emptyFunction, redo: emptyFunction }).label is "foo"
+PASS UndoItem.toString() is "function UndoItem() {\n    [native code]\n}"
+PASS new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction }).toString() is "[object UndoItem]"
+PASS document.undoManager.addItem(new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction })) did not throw exception.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/undo-manager/undo-manager-interfaces.html (0 => 239864)


--- trunk/LayoutTests/editing/undo-manager/undo-manager-interfaces.html	                        (rev 0)
+++ trunk/LayoutTests/editing/undo-manager/undo-manager-interfaces.html	2019-01-11 18:28:06 UTC (rev 239864)
@@ -0,0 +1,49 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ enableUndoManagerAPI=true ] -->
+<html>
+    <head>
+        <script src=""
+    </head>
+    <script>
+        function emptyFunction() { }
+
+        function runTest()
+        {
+            description("Verifies that, when the UndoManager API is enabled, UndoManager and UndoItem interfaces behave as expected.");
+
+            debug("\nTesting UndoManager:");
+            shouldBeTrue("UndoManager instanceof Function");
+            shouldBeEqualToString("typeof UndoManager", "function");
+            shouldBeTrue("document.undoManager instanceof UndoManager");
+            shouldBeTrue("Object.getPrototypeOf(document.undoManager) === UndoManager.prototype");
+            shouldBeTrue("UndoManager.prototype.addItem instanceof Function");
+            shouldThrow("UndoManager()");
+            shouldThrow("new UndoManager()");
+            shouldThrow("document.undoManager.addItem()");
+            shouldThrow("document.undoManager.addItem('foo')");
+            shouldBeEqualToString("UndoManager.toString()", "function UndoManager() {\n    [native code]\n}");
+            shouldBeEqualToString("document.undoManager.toString()", "[object UndoManager]");
+
+            debug("\nTesting UndoItem:");
+            shouldBeTrue("UndoItem instanceof Function");
+            shouldBeEqualToString("typeof UndoItem", "function");
+            shouldThrow("UndoItem()");
+            shouldThrow("new UndoItem()");
+            shouldThrow("new UndoItem('foo')");
+            shouldThrow("new UndoItem({ })");
+            shouldThrow("new UndoItem({ label: null, undo: null })");
+            shouldThrow("new UndoItem({ redo: null })");
+            shouldThrow("new UndoItem({ label: '', undo: emptyFunction })");
+            shouldThrow("new UndoItem({ label: 'hello', redo: emptyFunction })");
+            shouldThrow("new UndoItem({ label: 3, undo: null, redo: null })");
+            shouldThrow("new UndoItem({ label: '', undo: '', redo: emptyFunction })");
+            shouldThrow("new UndoItem({ label: '', undo: emptyFunction, redo: 10 })");
+            shouldBeTrue("new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction, foo: 'hi' }) instanceof UndoItem");
+            shouldBeTrue("Object.getPrototypeOf(new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction })) === UndoItem.prototype");
+            shouldBeEqualToString("new UndoItem({ label: 'foo', undo: emptyFunction, redo: emptyFunction }).label", "foo");
+            shouldBeEqualToString("UndoItem.toString()", "function UndoItem() {\n    [native code]\n}");
+            shouldBeEqualToString("new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction }).toString()", "[object UndoItem]");
+            shouldNotThrow("document.undoManager.addItem(new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction }))");
+        }
+    </script>
+    <body _onload_=runTest()></body>
+</html>

Added: trunk/LayoutTests/editing/undo-manager/undo-manager-keeps-wrapper-alive-expected.txt (0 => 239864)


--- trunk/LayoutTests/editing/undo-manager/undo-manager-keeps-wrapper-alive-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/undo-manager/undo-manager-keeps-wrapper-alive-expected.txt	2019-01-11 18:28:06 UTC (rev 239864)
@@ -0,0 +1,10 @@
+Verifies that the wrapper for Document's UndoManager remains consistent across GC passes. This test must be run using WebKitTestRunner.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.undoManager.foo is "bar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/undo-manager/undo-manager-keeps-wrapper-alive.html (0 => 239864)


--- trunk/LayoutTests/editing/undo-manager/undo-manager-keeps-wrapper-alive.html	                        (rev 0)
+++ trunk/LayoutTests/editing/undo-manager/undo-manager-keeps-wrapper-alive.html	2019-01-11 18:28:06 UTC (rev 239864)
@@ -0,0 +1,17 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ enableUndoManagerAPI=true ] -->
+<html>
+    <head>
+        <script src=""
+    </head>
+    <script>
+        function runTest()
+        {
+            description("Verifies that the wrapper for Document's UndoManager remains consistent across GC passes. This test must be run using WebKitTestRunner.");
+            document.undoManager.foo = "bar";
+            if (window.GCController)
+                GCController.collect();
+            shouldBeEqualToString("document.undoManager.foo", "bar");
+        }
+    </script>
+    <body _onload_=runTest()></body>
+</html>

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (239863 => 239864)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2019-01-11 18:28:06 UTC (rev 239864)
@@ -16,6 +16,7 @@
 fast/web-share [ Pass ]
 editing/find [ Pass ]
 editing/input/ios [ Pass ]
+editing/undo-manager [ Pass ]
 
 editing/selection/character-granularity-rect.html [ Failure ]
 

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (239863 => 239864)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2019-01-11 18:28:06 UTC (rev 239864)
@@ -11,6 +11,7 @@
 swipe [ Pass ]
 fast/web-share [ Pass ]
 editing/find [ Pass ]
+editing/undo-manager [ Pass ]
 
 fast/events/autoscroll-when-zoomed.html [ Pass ]
 fast/events/autoscroll-main-document.html [ Pass ]

Modified: trunk/Source/WebCore/CMakeLists.txt (239863 => 239864)


--- trunk/Source/WebCore/CMakeLists.txt	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/CMakeLists.txt	2019-01-11 18:28:06 UTC (rev 239864)
@@ -927,6 +927,8 @@
     page/ScrollLogicalPosition.idl
     page/ScrollToOptions.idl
     page/ShareData.idl
+    page/UndoItem.idl
+    page/UndoManager.idl
     page/VisualViewport.idl
     page/WebKitPoint.idl
     page/WindowEventHandlers.idl

Modified: trunk/Source/WebCore/ChangeLog (239863 => 239864)


--- trunk/Source/WebCore/ChangeLog	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/ChangeLog	2019-01-11 18:28:06 UTC (rev 239864)
@@ -1,3 +1,65 @@
+2019-01-11  Wenson Hsieh  <[email protected]>
+
+        Introduce IDL files for runtime-enabled UndoManager and UndoItem _javascript_ API
+        https://bugs.webkit.org/show_bug.cgi?id=193109
+        <rdar://problem/44807048>
+
+        Reviewed by Ryosuke Niwa.
+
+        Adds new IDL files and stubs for UndoManager and UndoItem. This is an experimental DOM API that (in the near
+        future) is intended only for use in internal WebKit text editing clients. This API allows the page to
+        participate in the processes of undoing and redoing by defining custom undo and redo handlers, to be executed
+        when undo or redo is triggered.
+
+        Tests: editing/undo-manager/undo-manager-interfaces.html
+               editing/undo-manager/undo-manager-keeps-wrapper-alive.html
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Sources.txt:
+        * UnifiedSources-input.xcfilelist:
+        * WebCore.xcodeproj/project.pbxproj:
+
+        Add new source files.
+
+        * bindings/js/WebCoreBuiltinNames.h:
+
+        Add "UndoManager" and "UndoItem" names.
+
+        * dom/Document.cpp:
+        (WebCore::m_undoManager):
+
+        Have the document own a UndoManager.
+
+        * dom/Document.h:
+        (WebCore::Document::undoManager const):
+        * dom/Document.idl:
+        * page/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setUndoManagerAPIEnabled):
+        (WebCore::RuntimeEnabledFeatures::undoManagerAPIEnabled const):
+
+        Guard the new bindings behind a runtime-enabled feature flag.
+
+        * page/UndoItem.h: Added.
+        (WebCore::UndoItem::create):
+        (WebCore::UndoItem::label const):
+        (WebCore::UndoItem::undoHandler const):
+        (WebCore::UndoItem::redoHandler const):
+        (WebCore::UndoItem::UndoItem):
+        * page/UndoItem.idl: Added.
+        * page/UndoManager.cpp: Added.
+        (WebCore::UndoManager::addItem):
+        * page/UndoManager.h: Added.
+        (WebCore::UndoManager::create):
+        (WebCore::UndoManager::document):
+        (WebCore::UndoManager::UndoManager):
+        * page/UndoManager.idl: Added.
+        * page/mac/WheelEventDeltaFilterMac.h:
+
+        Necessary (albeit unrelated) build fix to appease unified sources.
+
 2019-01-11  Zalan Bujtas  <[email protected]>
 
         [LFC][BFC][MarginCollapsing] Adjust vertical position when box margin collapses through.

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (239863 => 239864)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2019-01-11 18:28:06 UTC (rev 239864)
@@ -852,6 +852,8 @@
 $(PROJECT_DIR)/page/ScrollToOptions.idl
 $(PROJECT_DIR)/page/Settings.yaml
 $(PROJECT_DIR)/page/ShareData.idl
+$(PROJECT_DIR)/page/UndoItem.idl
+$(PROJECT_DIR)/page/UndoManager.idl
 $(PROJECT_DIR)/page/UserMessageHandler.idl
 $(PROJECT_DIR)/page/UserMessageHandlersNamespace.idl
 $(PROJECT_DIR)/page/VisualViewport.idl

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (239863 => 239864)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2019-01-11 18:28:06 UTC (rev 239864)
@@ -1702,6 +1702,10 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUIEventInit.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSURLSearchParams.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSURLSearchParams.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUndoItem.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUndoItem.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUndoManager.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUndoManager.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUserMessageHandler.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUserMessageHandler.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUserMessageHandlersNamespace.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (239863 => 239864)


--- trunk/Source/WebCore/DerivedSources.make	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/DerivedSources.make	2019-01-11 18:28:06 UTC (rev 239864)
@@ -876,6 +876,8 @@
     $(WebCore)/page/ScrollLogicalPosition.idl \
     $(WebCore)/page/ScrollToOptions.idl \
     $(WebCore)/page/ShareData.idl \
+    $(WebCore)/page/UndoItem.idl \
+    $(WebCore)/page/UndoManager.idl \
     $(WebCore)/page/UserMessageHandler.idl \
     $(WebCore)/page/UserMessageHandlersNamespace.idl \
     $(WebCore)/page/VisualViewport.idl \

Modified: trunk/Source/WebCore/Sources.txt (239863 => 239864)


--- trunk/Source/WebCore/Sources.txt	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/Sources.txt	2019-01-11 18:28:06 UTC (rev 239864)
@@ -1507,6 +1507,7 @@
 page/SpatialNavigation.cpp
 page/SuspendableTimer.cpp
 page/TextIndicator.cpp
+page/UndoManager.cpp
 page/UserContentProvider.cpp
 page/UserContentController.cpp
 page/UserContentURLPattern.cpp
@@ -3224,6 +3225,8 @@
 JSTimeRanges.cpp
 JSTransitionEvent.cpp
 JSTreeWalker.cpp
+JSUndoItem.cpp
+JSUndoManager.cpp
 JSUIEvent.cpp
 JSUIEventInit.cpp
 JSURLSearchParams.cpp

Modified: trunk/Source/WebCore/UnifiedSources-input.xcfilelist (239863 => 239864)


--- trunk/Source/WebCore/UnifiedSources-input.xcfilelist	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/UnifiedSources-input.xcfilelist	2019-01-11 18:28:06 UTC (rev 239864)
@@ -818,6 +818,8 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUIEvent.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUIEventInit.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSURLSearchParams.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUndoItem.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUndoManager.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUserMessageHandler.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUserMessageHandlersNamespace.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSUserVerificationRequirement.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (239863 => 239864)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-01-11 18:28:06 UTC (rev 239864)
@@ -868,6 +868,8 @@
 		2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */; };
 		2EB767571DA19BDF003E23B5 /* InputEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EB767541DA19B67003E23B5 /* InputEvent.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2EBBC3D81B65988300F5253D /* WheelEventDeltaFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EBBC3D71B65988300F5253D /* WheelEventDeltaFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		2ECDBAD121D8903400F00ECD /* UndoManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ECDBACE21D8903400F00ECD /* UndoManager.h */; };
+		2ECDBAD821D8906300F00ECD /* UndoItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ECDBAD521D8906300F00ECD /* UndoItem.h */; };
 		2ECF7ADD10162B3800427DE7 /* JSErrorEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ECF7ADB10162B3800427DE7 /* JSErrorEvent.h */; };
 		2ECF7AE210162B5800427DE7 /* ErrorEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ECF7ADF10162B5800427DE7 /* ErrorEvent.h */; };
 		2ED609BD1145B07100C8684E /* DOMFormData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ED609BB1145B07100C8684E /* DOMFormData.h */; };
@@ -6833,6 +6835,11 @@
 		2EB767551DA19B99003E23B5 /* InputEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InputEvent.cpp; sourceTree = "<group>"; };
 		2EBBC3D71B65988300F5253D /* WheelEventDeltaFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelEventDeltaFilter.h; sourceTree = "<group>"; };
 		2EC41DE21C0410A300D294FE /* RealtimeMediaSourceSupportedConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeMediaSourceSupportedConstraints.cpp; sourceTree = "<group>"; };
+		2ECDBACE21D8903400F00ECD /* UndoManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UndoManager.h; sourceTree = "<group>"; };
+		2ECDBACF21D8903400F00ECD /* UndoManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UndoManager.cpp; sourceTree = "<group>"; };
+		2ECDBAD021D8903400F00ECD /* UndoManager.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = UndoManager.idl; sourceTree = "<group>"; };
+		2ECDBAD521D8906300F00ECD /* UndoItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UndoItem.h; sourceTree = "<group>"; };
+		2ECDBAD721D8906300F00ECD /* UndoItem.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = UndoItem.idl; sourceTree = "<group>"; };
 		2ECF7ADA10162B3800427DE7 /* JSErrorEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorEvent.cpp; sourceTree = "<group>"; };
 		2ECF7ADB10162B3800427DE7 /* JSErrorEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorEvent.h; sourceTree = "<group>"; };
 		2ECF7ADE10162B5800427DE7 /* ErrorEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorEvent.cpp; sourceTree = "<group>"; };
@@ -19669,7 +19676,6 @@
 		656580EC09D12B20000E61D7 /* Derived Sources */ = {
 			isa = PBXGroup;
 			children = (
-				C21BF74221CD963B00227979 /* WHLSLStandardLibrary.h */,
 				538EC7EA1F96A95B004D22A8 /* unified-sources */,
 				9908B0F31BCACFFE00ED0F65 /* ByteLengthQueuingStrategyBuiltins.cpp */,
 				9908B0F51BCAD07D00ED0F65 /* ByteLengthQueuingStrategyBuiltins.h */,
@@ -19759,6 +19765,7 @@
 				656581AF09D14EE6000E61D7 /* UserAgentStyleSheetsData.cpp */,
 				1A1414B313A0F0500019996C /* WebKitFontFamilyNames.cpp */,
 				1A1414B413A0F0500019996C /* WebKitFontFamilyNames.h */,
+				C21BF74221CD963B00227979 /* WHLSLStandardLibrary.h */,
 				51748FA21CC6EEEB00728D84 /* WorkerGlobalScopeConstructors.idl */,
 				9908B0F91BCAD07D00ED0F75 /* WritableStreamBuiltins.cpp */,
 				9B03D8061BB3110D00B764E8 /* WritableStreamBuiltins.h */,
@@ -20232,6 +20239,11 @@
 				62C1217B11AB9E77003C462C /* SuspendableTimer.h */,
 				2D4F96F11A1ECC240098BF88 /* TextIndicator.cpp */,
 				2D4F96F21A1ECC240098BF88 /* TextIndicator.h */,
+				2ECDBAD521D8906300F00ECD /* UndoItem.h */,
+				2ECDBAD721D8906300F00ECD /* UndoItem.idl */,
+				2ECDBACF21D8903400F00ECD /* UndoManager.cpp */,
+				2ECDBACE21D8903400F00ECD /* UndoManager.h */,
+				2ECDBAD021D8903400F00ECD /* UndoManager.idl */,
 				1AE79D40188DB61F002239C2 /* UserContentController.cpp */,
 				1AE79D41188DB61F002239C2 /* UserContentController.h */,
 				7C3F01BF1C8E5AB100ADD962 /* UserContentProvider.cpp */,
@@ -25375,7 +25387,6 @@
 		C210E90D21B4BCA400B7F83D /* WHLSL */ = {
 			isa = PBXGroup;
 			children = (
-				C21BF74521CD969800227979 /* WHLSLStandardLibrary.txt */,
 				C21BF6F121CD898D00227979 /* AST */,
 				C210E91121B4BD1000B7F83D /* WHLSLLexer.cpp */,
 				C210E91221B4BD1000B7F83D /* WHLSLLexer.h */,
@@ -25382,6 +25393,7 @@
 				C21BF73721CD8A0200227979 /* WHLSLParser.cpp */,
 				C21BF73821CD8A0300227979 /* WHLSLParser.h */,
 				C21BF73A21CD8D7000227979 /* WHLSLProgram.h */,
+				C21BF74521CD969800227979 /* WHLSLStandardLibrary.txt */,
 			);
 			path = WHLSL;
 			sourceTree = "<group>";
@@ -31873,6 +31885,8 @@
 				85031B4E0A44EFC700F992E0 /* UIEvent.h in Headers */,
 				83FE7CA71DA9F1A70037237C /* UIEventInit.h in Headers */,
 				85031B4F0A44EFC700F992E0 /* UIEventWithKeyState.h in Headers */,
+				2ECDBAD821D8906300F00ECD /* UndoItem.h in Headers */,
+				2ECDBAD121D8903400F00ECD /* UndoManager.h in Headers */,
 				9B2D8A7914997CCF00ECEF3E /* UndoStep.h in Headers */,
 				A863E2011343412000274926 /* UnicodeBidi.h in Headers */,
 				518864E11BBAF57400E540C9 /* UniqueIDBDatabase.h in Headers */,

Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (239863 => 239864)


--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2019-01-11 18:28:06 UTC (rev 239864)
@@ -178,6 +178,8 @@
     macro(StaticRange) \
     macro(StylePropertyMapReadOnly) \
     macro(StylePropertyMap) \
+    macro(UndoItem) \
+    macro(UndoManager) \
     macro(VRDisplay) \
     macro(VRDisplayCapabilities) \
     macro(VRDisplayEvent) \

Modified: trunk/Source/WebCore/dom/Document.cpp (239863 => 239864)


--- trunk/Source/WebCore/dom/Document.cpp	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/dom/Document.cpp	2019-01-11 18:28:06 UTC (rev 239864)
@@ -210,6 +210,7 @@
 #include "TextNodeTraversal.h"
 #include "TransformSource.h"
 #include "TreeWalker.h"
+#include "UndoManager.h"
 #include "UserGestureIndicator.h"
 #include "ValidationMessageClient.h"
 #include "VisibilityChangeClient.h"
@@ -537,6 +538,7 @@
     , m_isNonRenderedPlaceholder(constructionFlags & NonRenderedPlaceholder)
     , m_orientationNotifier(currentOrientation(frame))
     , m_identifier(generateObjectIdentifier<DocumentIdentifierType>())
+    , m_undoManager(UndoManager::create(*this))
 {
     auto addResult = allDocumentsMap().add(m_identifier, this);
     ASSERT_UNUSED(addResult, addResult.isNewEntry);

Modified: trunk/Source/WebCore/dom/Document.h (239863 => 239864)


--- trunk/Source/WebCore/dom/Document.h	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/dom/Document.h	2019-01-11 18:28:06 UTC (rev 239864)
@@ -186,6 +186,7 @@
 class Text;
 class TextResourceDecoder;
 class TreeWalker;
+class UndoManager;
 class VisibilityChangeClient;
 class VisitedLinkState;
 class WebAnimation;
@@ -1004,6 +1005,8 @@
     WEBCORE_EXPORT bool queryCommandSupported(const String& command);
     WEBCORE_EXPORT String queryCommandValue(const String& command);
 
+    UndoManager& undoManager() const { return m_undoManager.get(); }
+
     // designMode support
     enum InheritedBool { off = false, on = true, inherit };    
     void setDesignMode(InheritedBool value);
@@ -2086,6 +2089,8 @@
     bool m_isRunningUserScripts { false };
 
     bool m_alwaysAllowLocalWebarchive { false };
+
+    Ref<UndoManager> m_undoManager;
 };
 
 Element* eventTargetElementForDocument(Document*);

Modified: trunk/Source/WebCore/dom/Document.idl (239863 => 239864)


--- trunk/Source/WebCore/dom/Document.idl	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/dom/Document.idl	2019-01-11 18:28:06 UTC (rev 239864)
@@ -126,6 +126,7 @@
     boolean queryCommandState(DOMString commandId);
     boolean queryCommandSupported(DOMString commandId);
     DOMString queryCommandValue(DOMString commandId);
+    [EnabledAtRuntime=UndoManagerAPI] readonly attribute UndoManager undoManager;
 
     // Special event handler IDL attributes that only apply to Document objects.
     [LenientThis] attribute EventHandler onreadystatechange;

Modified: trunk/Source/WebCore/page/RuntimeEnabledFeatures.h (239863 => 239864)


--- trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2019-01-11 18:28:06 UTC (rev 239864)
@@ -315,6 +315,9 @@
     bool intersectionObserverEnabled() const { return m_intersectionObserverEnabled; }
 #endif
 
+    void setUndoManagerAPIEnabled(bool isEnabled) { m_undoManagerAPIEnabled = isEnabled; }
+    bool undoManagerAPIEnabled() const { return m_undoManagerAPIEnabled; }
+
 #if ENABLE(ENCRYPTED_MEDIA)
     void setEncryptedMediaAPIEnabled(bool isEnabled) { m_encryptedMediaAPIEnabled = isEnabled; }
     bool encryptedMediaAPIEnabled() const { return m_encryptedMediaAPIEnabled; }
@@ -506,6 +509,8 @@
     bool m_systemPreviewEnabled { false };
 #endif
 
+    bool m_undoManagerAPIEnabled { false };
+
     friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>;
 };
 

Copied: trunk/Source/WebCore/page/UndoItem.h (from rev 239863, trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h) (0 => 239864)


--- trunk/Source/WebCore/page/UndoItem.h	                        (rev 0)
+++ trunk/Source/WebCore/page/UndoItem.h	2019-01-11 18:28:06 UTC (rev 239864)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "VoidCallback.h"
+#include <wtf/Function.h>
+#include <wtf/IsoMallocInlines.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class UndoItem : public RefCounted<UndoItem> {
+    WTF_MAKE_ISO_ALLOCATED_INLINE(UndoItem);
+public:
+    struct Init {
+        String label;
+        RefPtr<VoidCallback> undo;
+        RefPtr<VoidCallback> redo;
+    };
+
+    static Ref<UndoItem> create(Init&& init)
+    {
+        return adoptRef(*new UndoItem(WTFMove(init)));
+    }
+
+    const String& label() const { return m_label; }
+    VoidCallback& undoHandler() const { return m_undoHandler.get(); }
+    VoidCallback& redoHandler() const { return m_redoHandler.get(); }
+
+private:
+    UndoItem(Init&& init)
+        : m_label(WTFMove(init.label))
+        , m_undoHandler(init.undo.releaseNonNull())
+        , m_redoHandler(init.redo.releaseNonNull())
+    {
+    }
+
+    String m_label;
+    Ref<VoidCallback> m_undoHandler;
+    Ref<VoidCallback> m_redoHandler;
+};
+
+} // namespace WebCore

Copied: trunk/Source/WebCore/page/UndoItem.idl (from rev 239863, trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h) (0 => 239864)


--- trunk/Source/WebCore/page/UndoItem.idl	                        (rev 0)
+++ trunk/Source/WebCore/page/UndoItem.idl	2019-01-11 18:28:06 UTC (rev 239864)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    EnabledAtRuntime=UndoManagerAPI,
+] dictionary UndoItemInit {
+    required DOMString label;
+    required VoidCallback undo;
+    required VoidCallback redo;
+};
+
+[
+    EnabledAtRuntime=UndoManagerAPI,
+    ImplementationLacksVTable,
+    Constructor(UndoItemInit initDict),
+] interface UndoItem {
+    readonly attribute DOMString label;
+};

Copied: trunk/Source/WebCore/page/UndoManager.cpp (from rev 239863, trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h) (0 => 239864)


--- trunk/Source/WebCore/page/UndoManager.cpp	                        (rev 0)
+++ trunk/Source/WebCore/page/UndoManager.cpp	2019-01-11 18:28:06 UTC (rev 239864)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "UndoManager.h"
+
+#include "UndoItem.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(UndoManager);
+
+void UndoManager::addItem(Ref<UndoItem>&& item)
+{
+    UNUSED_PARAM(item);
+    UNUSED_PARAM(m_document);
+}
+
+} // namespace WebCore

Copied: trunk/Source/WebCore/page/UndoManager.h (from rev 239863, trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h) (0 => 239864)


--- trunk/Source/WebCore/page/UndoManager.h	                        (rev 0)
+++ trunk/Source/WebCore/page/UndoManager.h	2019-01-11 18:28:06 UTC (rev 239864)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/IsoMalloc.h>
+#include <wtf/Ref.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class Document;
+class UndoItem;
+
+class UndoManager : public RefCounted<UndoManager> {
+    WTF_MAKE_ISO_ALLOCATED(UndoManager);
+public:
+    static Ref<UndoManager> create(Document& document)
+    {
+        return adoptRef(*new UndoManager(document));
+    }
+
+    void addItem(Ref<UndoItem>&&);
+    Document& document() { return m_document; }
+
+private:
+    UndoManager(Document& document)
+        : m_document(document)
+    {
+    }
+
+    Document& m_document;
+};
+
+} // namespace WebCore

Copied: trunk/Source/WebCore/page/UndoManager.idl (from rev 239863, trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h) (0 => 239864)


--- trunk/Source/WebCore/page/UndoManager.idl	                        (rev 0)
+++ trunk/Source/WebCore/page/UndoManager.idl	2019-01-11 18:28:06 UTC (rev 239864)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    EnabledAtRuntime=UndoManagerAPI,
+    ImplementationLacksVTable,
+    GenerateIsReachable=ImplDocument,
+] interface UndoManager {
+    void addItem(UndoItem item);
+};

Modified: trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h (239863 => 239864)


--- trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h	2019-01-11 18:28:06 UTC (rev 239864)
@@ -28,6 +28,7 @@
 #if PLATFORM(MAC)
 
 #include "WheelEventDeltaFilter.h"
+#include <wtf/MonotonicTime.h>
 #include <wtf/RetainPtr.h>
 
 OBJC_CLASS _NSScrollingPredominantAxisFilter;

Modified: trunk/Source/WebKit/ChangeLog (239863 => 239864)


--- trunk/Source/WebKit/ChangeLog	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebKit/ChangeLog	2019-01-11 18:28:06 UTC (rev 239864)
@@ -1,3 +1,23 @@
+2019-01-11  Wenson Hsieh  <[email protected]>
+
+        Introduce IDL files for runtime-enabled UndoManager and UndoItem _javascript_ API
+        https://bugs.webkit.org/show_bug.cgi?id=193109
+        <rdar://problem/44807048>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add a new SPI configuration flag to enable the UndoManager API. This is off by default.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]):
+        (-[WKWebViewConfiguration copyWithZone:]):
+        (-[WKWebViewConfiguration _setUndoManagerAPIEnabled:]):
+        (-[WKWebViewConfiguration _undoManagerAPIEnabled]):
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+
 2019-01-10  Jiewen Tan  <[email protected]>
 
         [WebAuthN] Change the nonce in the CTAP kInit command to weak random values

Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (239863 => 239864)


--- trunk/Source/WebKit/Shared/WebPreferences.yaml	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml	2019-01-11 18:28:06 UTC (rev 239864)
@@ -1528,3 +1528,11 @@
   humanReadableDescription: "Enable HTTP Response filtering for WebProcesses"
   category: internal
   webcoreBinding: RuntimeEnabledFeatures
+
+UndoManagerAPIEnabled:
+  type: bool
+  defaultValue: false
+  humanReadableName: "UndoManager DOM API"
+  humanReadableDescription: "Enable the UndoManager DOM API"
+  category: internal
+  webcoreBinding: RuntimeEnabledFeatures

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (239863 => 239864)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-01-11 18:28:06 UTC (rev 239864)
@@ -645,6 +645,7 @@
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::colorFilterEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _colorFilterEnabled]));
 
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::editableImagesEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _editableImagesEnabled]));
+    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::undoManagerAPIEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _undoManagerAPIEnabled]));
 
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::legacyEncryptedMediaAPIEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _legacyEncryptedMediaAPIEnabled]));

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (239863 => 239864)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2019-01-11 18:28:06 UTC (rev 239864)
@@ -160,6 +160,7 @@
     BOOL _shouldDeferAsynchronousScriptsUntilAfterDocumentLoad;
     BOOL _drawsBackground;
     BOOL _editableImagesEnabled;
+    BOOL _undoManagerAPIEnabled;
 
     RetainPtr<NSString> _mediaContentTypesRequiringHardwareSupport;
     RetainPtr<NSArray<NSString *>> _additionalSupportedImageTypes;
@@ -248,6 +249,7 @@
     _drawsBackground = YES;
 
     _editableImagesEnabled = NO;
+    _undoManagerAPIEnabled = NO;
 
     return self;
 }
@@ -409,6 +411,7 @@
     configuration->_drawsBackground = self->_drawsBackground;
 
     configuration->_editableImagesEnabled = self->_editableImagesEnabled;
+    configuration->_undoManagerAPIEnabled = self->_undoManagerAPIEnabled;
 
     return configuration;
 }
@@ -1037,6 +1040,16 @@
     return _editableImagesEnabled;
 }
 
+- (void)_setUndoManagerAPIEnabled:(BOOL)enabled
+{
+    _undoManagerAPIEnabled = enabled;
+}
+
+- (BOOL)_undoManagerAPIEnabled
+{
+    return _undoManagerAPIEnabled;
+}
+
 @end
 
 @implementation WKWebViewConfiguration (WKDeprecated)

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (239863 => 239864)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2019-01-11 18:28:06 UTC (rev 239864)
@@ -106,6 +106,7 @@
 @property (nonatomic, copy, setter=_setAdditionalSupportedImageTypes:) NSArray<NSString *> *_additionalSupportedImageTypes WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @property (nonatomic, setter=_setEditableImagesEnabled:) BOOL _editableImagesEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setUndoManagerAPIEnabled:) BOOL _undoManagerAPIEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @end
 

Modified: trunk/Tools/ChangeLog (239863 => 239864)


--- trunk/Tools/ChangeLog	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Tools/ChangeLog	2019-01-11 18:28:06 UTC (rev 239864)
@@ -1,3 +1,20 @@
+2019-01-11  Wenson Hsieh  <[email protected]>
+
+        Introduce IDL files for runtime-enabled UndoManager and UndoItem _javascript_ API
+        https://bugs.webkit.org/show_bug.cgi?id=193109
+        <rdar://problem/44807048>
+
+        Reviewed by Ryosuke Niwa.
+
+        Introduce and respect a test option to enable the UndoManager API.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions const):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::platformCreateWebView):
+
 2019-01-11  Zalan Bujtas  <[email protected]>
 
         [LFC][BFC][MarginCollapsing] Adjust vertical position when box margin collapses through.

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (239863 => 239864)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2019-01-11 18:28:06 UTC (rev 239864)
@@ -1264,6 +1264,8 @@
             testOptions.enableEditableImages = parseBooleanTestHeaderValue(value);
         else if (key == "editable")
             testOptions.editable = parseBooleanTestHeaderValue(value);
+        else if (key == "enableUndoManagerAPI")
+            testOptions.enableUndoManagerAPI = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (239863 => 239864)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2019-01-11 18:28:06 UTC (rev 239864)
@@ -67,6 +67,7 @@
     bool shouldShowSpellCheckingDots { false };
     bool enableEditableImages { false };
     bool editable { false };
+    bool enableUndoManagerAPI { false };
 
     float deviceScaleFactor { 1 };
     Vector<String> overrideLanguages;
@@ -111,7 +112,8 @@
             || shouldShowSpellCheckingDots != options.shouldShowSpellCheckingDots
             || shouldIgnoreMetaViewport != options.shouldIgnoreMetaViewport
             || enableEditableImages != options.enableEditableImages
-            || editable != options.editable)
+            || editable != options.editable
+            || enableUndoManagerAPI != options.enableUndoManagerAPI)
             return false;
 
         if (experimentalFeatures != options.experimentalFeatures)

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (239863 => 239864)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2019-01-11 16:19:41 UTC (rev 239863)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2019-01-11 18:28:06 UTC (rev 239864)
@@ -161,6 +161,9 @@
     if (options.enableEditableImages)
         [copiedConfiguration _setEditableImagesEnabled:YES];
 
+    if (options.enableUndoManagerAPI)
+        [copiedConfiguration _setUndoManagerAPIEnabled:YES];
+
     if (options.applicationManifest.length()) {
         auto manifestPath = [NSString stringWithUTF8String:options.applicationManifest.c_str()];
         NSString *text = [NSString stringWithContentsOfFile:manifestPath usedEncoding:nullptr error:nullptr];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to