Title: [218529] trunk/Source/WebCore
Revision
218529
Author
[email protected]
Date
2017-06-19 20:25:45 -0700 (Mon, 19 Jun 2017)

Log Message

[WebIDL] Move Touch related bindings in Document to their own IDL file
https://bugs.webkit.org/show_bug.cgi?id=173521

Reviewed by Alex Christensen.

Rather than #including in the middle of an IDL file, this moves the touch related
bindings in Document.idl to a new partial interface for Document in DocumentTouch.idl.
While here, remove the custom binding for createTouchList.

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
Add new files.

* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::createTouchList): Deleted.
Remove createTouchList. It can be generated now.

* dom/Document.cpp:
(WebCore::Document::createTouch): Deleted.
* dom/Document.h:
Move touch related bindings code to DocumentTouch.h/cpp.
Remove DocumentIOSForward as it is no longer needed.

* dom/Document.idl:
Move touch related bindings to DocumentTouch.idl
        
* dom/DocumentTouch.h: Added.
* dom/DocumentTouch.cpp: Added.
(WebCore::DocumentTouch::createTouch):
Moved from Document.

(WebCore::DocumentTouch::createTouchList):
Added to aid generated binding.

* dom/DocumentTouch.idl: Added.
Moved operations from Document.h

* dom/TouchList.h:
(WebCore::TouchList::create):
(WebCore::TouchList::TouchList):
Added create that works with the bindings.

* dom/ios/TouchEvents.cpp:
Add DocumentTouchIOS.h and sort.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (218528 => 218529)


--- trunk/Source/WebCore/CMakeLists.txt	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-06-20 03:25:45 UTC (rev 218529)
@@ -441,6 +441,7 @@
     dom/DocumentAndElementEventHandlers.idl
     dom/DocumentFragment.idl
     dom/DocumentOrShadowRoot.idl
+    dom/DocumentTouch.idl
     dom/DocumentType.idl
     dom/Element.idl
     dom/ErrorEvent.idl
@@ -1478,6 +1479,7 @@
     dom/DocumentOrderedMap.cpp
     dom/DocumentParser.cpp
     dom/DocumentSharedObjectPool.cpp
+    dom/DocumentTouch.cpp
     dom/DocumentType.cpp
     dom/Element.cpp
     dom/ElementData.cpp

Modified: trunk/Source/WebCore/ChangeLog (218528 => 218529)


--- trunk/Source/WebCore/ChangeLog	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/ChangeLog	2017-06-20 03:25:45 UTC (rev 218529)
@@ -1,3 +1,51 @@
+2017-06-19  Sam Weinig  <[email protected]>
+
+        [WebIDL] Move Touch related bindings in Document to their own IDL file
+        https://bugs.webkit.org/show_bug.cgi?id=173521
+
+        Reviewed by Alex Christensen.
+
+        Rather than #including in the middle of an IDL file, this moves the touch related
+        bindings in Document.idl to a new partial interface for Document in DocumentTouch.idl.
+        While here, remove the custom binding for createTouchList.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        Add new files.
+
+        * bindings/js/JSDocumentCustom.cpp:
+        (WebCore::JSDocument::createTouchList): Deleted.
+        Remove createTouchList. It can be generated now.
+
+        * dom/Document.cpp:
+        (WebCore::Document::createTouch): Deleted.
+        * dom/Document.h:
+        Move touch related bindings code to DocumentTouch.h/cpp.
+        Remove DocumentIOSForward as it is no longer needed.
+
+        * dom/Document.idl:
+        Move touch related bindings to DocumentTouch.idl
+        
+        * dom/DocumentTouch.h: Added.
+        * dom/DocumentTouch.cpp: Added.
+        (WebCore::DocumentTouch::createTouch):
+        Moved from Document.
+
+        (WebCore::DocumentTouch::createTouchList):
+        Added to aid generated binding.
+
+        * dom/DocumentTouch.idl: Added.
+        Moved operations from Document.h
+
+        * dom/TouchList.h:
+        (WebCore::TouchList::create):
+        (WebCore::TouchList::TouchList):
+        Added create that works with the bindings.
+
+        * dom/ios/TouchEvents.cpp:
+        Add DocumentTouchIOS.h and sort.
+
 2017-06-19  Myles C. Maxfield  <[email protected]>
 
         [Cocoa] The system Japanese font cannot be italicized

Modified: trunk/Source/WebCore/DerivedSources.make (218528 => 218529)


--- trunk/Source/WebCore/DerivedSources.make	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/DerivedSources.make	2017-06-20 03:25:45 UTC (rev 218529)
@@ -898,6 +898,7 @@
 ifeq ($(WTF_PLATFORM_IOS), 1)
 ifeq ($(findstring ENABLE_IOS_TOUCH_EVENTS,$(FEATURE_DEFINES)), ENABLE_IOS_TOUCH_EVENTS)
 ADDITIONAL_BINDING_IDLS += \
+    DocumentTouch.idl \
     Touch.idl \
     TouchEvent.idl \
     TouchList.idl
@@ -922,6 +923,7 @@
 
 ifneq ($(WTF_PLATFORM_IOS), 1)
 JS_BINDING_IDLS += \
+    $(WebCore)/dom/DocumentTouch.idl \
     $(WebCore)/dom/Touch.idl \
     $(WebCore)/dom/TouchEvent.idl \
     $(WebCore)/dom/TouchList.idl

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (218528 => 218529)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-20 03:25:45 UTC (rev 218529)
@@ -2877,6 +2877,8 @@
 		65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
 		69A6CBAC1C6BE42C00B836E9 /* AccessibilitySVGElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */; };
 		69A6CBAD1C6BE42C00B836E9 /* AccessibilitySVGElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */; };
+		6A32D7CE1A16D8C000412F0B /* InspectorCanvasAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */; };
+		6A4B6D6519D22519006F11D3 /* InspectorCanvasAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */; };
 		6B3480940EEF50D400AC1B41 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */; };
@@ -2886,8 +2888,6 @@
 		6C4C96DF1AD4483500363F64 /* JSReadableByteStreamController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500363F64 /* JSReadableByteStreamController.h */; };
 		6C4C96DF1AD4483500365672 /* JSReadableStreamBYOBRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500365672 /* JSReadableStreamBYOBRequest.h */; };
 		6C4C96DF1AD4483500365A50 /* JSReadableStreamDefaultController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500365A50 /* JSReadableStreamDefaultController.h */; };
-		6A32D7CE1A16D8C000412F0B /* InspectorCanvasAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */; };
-		6A4B6D6519D22519006F11D3 /* InspectorCanvasAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */; };
 		6C638895A96CCEE50C8C946C /* CachedResourceRequestInitiators.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6C638896A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */; };
 		6CDDE8D01770BB220016E072 /* RegionOversetState.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C70A81417707C49009A446E /* RegionOversetState.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10730,6 +10730,8 @@
 		65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
 		697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilitySVGElement.cpp; sourceTree = "<group>"; };
 		697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySVGElement.h; sourceTree = "<group>"; };
+		6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCanvasAgent.h; sourceTree = "<group>"; };
+		6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCanvasAgent.cpp; sourceTree = "<group>"; };
 		6B3480920EEF50D400AC1B41 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; };
 		6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadObserver.h; sourceTree = "<group>"; };
 		6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadObserver.cpp; sourceTree = "<group>"; };
@@ -10739,8 +10741,6 @@
 		6C4C96DB1AD4483500363F64 /* JSReadableByteStreamController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableByteStreamController.h; sourceTree = "<group>"; };
 		6C4C96DB1AD4483500365672 /* JSReadableStreamBYOBRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamBYOBRequest.h; sourceTree = "<group>"; };
 		6C4C96DB1AD4483500365A50 /* JSReadableStreamDefaultController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamDefaultController.h; sourceTree = "<group>"; };
-		6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCanvasAgent.h; sourceTree = "<group>"; };
-		6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCanvasAgent.cpp; sourceTree = "<group>"; };
 		6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequestInitiators.h; sourceTree = "<group>"; };
 		6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceRequestInitiators.cpp; sourceTree = "<group>"; };
 		6C70A81417707C49009A446E /* RegionOversetState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegionOversetState.h; sourceTree = "<group>"; };
@@ -11396,6 +11396,9 @@
 		7CE683461921821500F4D928 /* UserMessageHandlerDescriptorTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageHandlerDescriptorTypes.h; sourceTree = "<group>"; };
 		7CE6CBFA187F370700D46BF5 /* FormatConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatConverter.h; sourceTree = "<group>"; };
 		7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormatConverter.cpp; sourceTree = "<group>"; };
+		7CE7FA591EF882300060C9D6 /* DocumentTouch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DocumentTouch.h; sourceTree = "<group>"; };
+		7CE7FA5A1EF882300060C9D6 /* DocumentTouch.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DocumentTouch.idl; sourceTree = "<group>"; };
+		7CE7FA5B1EF882300060C9D6 /* DocumentTouch.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentTouch.cpp; sourceTree = "<group>"; };
 		7CEF26181D6A92E300BE905D /* JSCryptoCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoCustom.cpp; sourceTree = "<group>"; };
 		7CF158991EBBCDC700D4BFB7 /* SubresourceIntegrity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubresourceIntegrity.cpp; sourceTree = "<group>"; };
 		7CF1589A1EBBCDC700D4BFB7 /* SubresourceIntegrity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubresourceIntegrity.h; sourceTree = "<group>"; };
@@ -25736,6 +25739,9 @@
 				AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */,
 				AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */,
 				86D982F6125C154000AD9E3D /* DocumentTiming.h */,
+				7CE7FA5B1EF882300060C9D6 /* DocumentTouch.cpp */,
+				7CE7FA591EF882300060C9D6 /* DocumentTouch.h */,
+				7CE7FA5A1EF882300060C9D6 /* DocumentTouch.idl */,
 				A8185F3209765765005826D9 /* DocumentType.cpp */,
 				A8185F3109765765005826D9 /* DocumentType.h */,
 				93EEC1E809C2877700C515D1 /* DocumentType.idl */,

Modified: trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp (218528 => 218529)


--- trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp	2017-06-20 03:25:45 UTC (rev 218529)
@@ -26,14 +26,7 @@
 #include "JSXMLDocument.h"
 #include "NodeTraversal.h"
 #include "SVGDocument.h"
-#include "ScriptController.h"
-#include "XMLDocument.h"
 
-#if ENABLE(TOUCH_EVENTS)
-#include "JSTouch.h"
-#include "JSTouchList.h"
-#endif
-
 using namespace JSC;
 
 namespace WebCore {
@@ -99,24 +92,4 @@
     visitor.addOpaqueRoot(static_cast<ScriptExecutionContext*>(&wrapped()));
 }
 
-#if ENABLE(TOUCH_EVENTS)
-JSValue JSDocument::createTouchList(ExecState& state)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    auto touchList = TouchList::create();
-
-    for (size_t i = 0; i < state.argumentCount(); ++i) {
-        auto* item = JSTouch::toWrapped(vm, state.uncheckedArgument(i));
-        if (!item)
-            return JSValue::decode(throwArgumentTypeError(state, scope, i, "touches", "Document", "createTouchList", "Touch"));
-
-        touchList->append(*item);
-    }
-    return toJSNewlyCreated(&state, globalObject(), WTFMove(touchList));
-}
-#endif
-
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/Document.cpp (218528 => 218529)


--- trunk/Source/WebCore/dom/Document.cpp	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-06-20 03:25:45 UTC (rev 218529)
@@ -252,7 +252,6 @@
 
 #if ENABLE(TOUCH_EVENTS)
 #include "TouchEvent.h"
-#include "TouchList.h"
 #endif
 
 #if ENABLE(VIDEO_TRACK)
@@ -6331,20 +6330,6 @@
 #endif
 }
 
-#if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
-
-Ref<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force) const
-{
-    // FIXME: It's not clear from the documentation at
-    // http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
-    // when this method should throw and nor is it by inspection of iOS behavior. It would be nice to verify any cases where it throws under iOS
-    // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=47819
-    Frame* frame = window ? window->frame() : this->frame();
-    return Touch::create(frame, target, identifier, screenX, screenY, pageX, pageY, radiusX, radiusY, rotationAngle, force);
-}
-
-#endif
-
 void Document::wheelEventHandlersChanged()
 {
     Page* page = this->page();

Modified: trunk/Source/WebCore/dom/Document.h (218528 => 218529)


--- trunk/Source/WebCore/dom/Document.h	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/dom/Document.h	2017-06-20 03:25:45 UTC (rev 218529)
@@ -189,10 +189,6 @@
 struct AnnotatedRegionValue;
 #endif
 
-#if ENABLE(IOS_TOUCH_EVENTS)
-#include <WebKitAdditions/DocumentIOSForward.h>
-#endif
-
 #if ENABLE(TOUCH_EVENTS) || ENABLE(IOS_TOUCH_EVENTS)
 class Touch;
 class TouchList;
@@ -1147,8 +1143,6 @@
 
 #if ENABLE(IOS_TOUCH_EVENTS)
 #include <WebKitAdditions/DocumentIOS.h>
-#elif ENABLE(TOUCH_EVENTS)
-    Ref<Touch> createTouch(DOMWindow*, EventTarget*, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force) const;
 #endif
 
 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)

Modified: trunk/Source/WebCore/dom/Document.idl (218528 => 218529)


--- trunk/Source/WebCore/dom/Document.idl	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/dom/Document.idl	2017-06-20 03:25:45 UTC (rev 218529)
@@ -192,19 +192,7 @@
     // Non standard (https://developer.apple.com/reference/webkitjs/document/1633863-webkitgetnamedflows).
     [Conditional=CSS_REGIONS] DOMNamedFlowCollection webkitGetNamedFlows();
 
-    // FIXME: This has been dropped from the standard now that Touch has a constructor.
-#if defined(ENABLE_IOS_TOUCH_EVENTS) && ENABLE_IOS_TOUCH_EVENTS
-#include <WebKitAdditions/DocumentIOS.idl>
-#elif defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
-    [NewObject] Touch createTouch(optional DOMWindow? window = null, optional EventTarget? target = null,
-        optional long identifier = 0,
-        optional long pageX = 0, optional long pageY = 0, optional long screenX = 0, optional long screenY = 0,
-        optional long webkitRadiusX = 0, optional long webkitRadiusY = 0,
-        optional unrestricted float webkitRotationAngle = NaN, optional unrestricted float webkitForce = NaN);
-    [NewObject, Custom] TouchList createTouchList(Touch... touches);
-#endif
 
-
     // Obsolete features from https://html.spec.whatwg.org/multipage/obsolete.html
 
     [CEReactions] attribute [TreatNullAs=EmptyString] DOMString fgColor;

Added: trunk/Source/WebCore/dom/DocumentTouch.cpp (0 => 218529)


--- trunk/Source/WebCore/dom/DocumentTouch.cpp	                        (rev 0)
+++ trunk/Source/WebCore/dom/DocumentTouch.cpp	2017-06-20 03:25:45 UTC (rev 218529)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 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 "DocumentTouch.h"
+
+#if ENABLE(TOUCH_EVENTS)
+
+#include "DOMWindow.h"
+#include "Document.h"
+#include "Touch.h"
+#include "TouchList.h"
+
+namespace WebCore {
+
+Ref<Touch> DocumentTouch::createTouch(Document& document, DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force)
+{
+    // FIXME: It's not clear from the documentation at
+    // http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
+    // when this method should throw and nor is it by inspection of iOS behavior. It would be nice to verify any cases where it throws under iOS
+    // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=47819
+    return Touch::create(window ? window->frame() : document.frame(), target, identifier, screenX, screenY, pageX, pageY, radiusX, radiusY, rotationAngle, force);
+}
+
+Ref<TouchList> DocumentTouch::createTouchList(Document&, Vector<std::reference_wrapper<Touch>>&& touches)
+{
+    return TouchList::create(WTFMove(touches));
+}
+
+}
+
+#endif

Added: trunk/Source/WebCore/dom/DocumentTouch.h (0 => 218529)


--- trunk/Source/WebCore/dom/DocumentTouch.h	                        (rev 0)
+++ trunk/Source/WebCore/dom/DocumentTouch.h	2017-06-20 03:25:45 UTC (rev 218529)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 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
+
+#if ENABLE(IOS_TOUCH_EVENTS)
+#include <WebKitAdditions/DocumentTouchIOS.h>
+#elif ENABLE(TOUCH_EVENTS)
+
+#include <functional>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class DOMWindow;
+class Document;
+class EventTarget;
+class Touch;
+class TouchList;
+
+class DocumentTouch {
+public:
+    static Ref<Touch> createTouch(Document&, DOMWindow*, EventTarget*, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force);
+    static Ref<TouchList> createTouchList(Document&, Vector<std::reference_wrapper<Touch>>&&);
+};
+
+}
+
+#endif

Added: trunk/Source/WebCore/dom/DocumentTouch.idl (0 => 218529)


--- trunk/Source/WebCore/dom/DocumentTouch.idl	                        (rev 0)
+++ trunk/Source/WebCore/dom/DocumentTouch.idl	2017-06-20 03:25:45 UTC (rev 218529)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006, 2007, 2011, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007 Samuel Weinig <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+[
+    Conditional=TOUCH_EVENTS
+] partial interface Document {
+    // FIXME: This has been dropped from the standard now that Touch has a constructor.
+    [NewObject] Touch createTouch(optional DOMWindow? window = null, optional EventTarget? target = null,
+        optional long identifier = 0,
+        optional long pageX = 0, optional long pageY = 0, optional long screenX = 0, optional long screenY = 0,
+        optional long webkitRadiusX = 0, optional long webkitRadiusY = 0,
+        optional unrestricted float webkitRotationAngle = NaN, optional unrestricted float webkitForce = NaN);
+    [NewObject] TouchList createTouchList(Touch... touches);
+};

Modified: trunk/Source/WebCore/dom/TouchList.h (218528 => 218529)


--- trunk/Source/WebCore/dom/TouchList.h	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/dom/TouchList.h	2017-06-20 03:25:45 UTC (rev 218529)
@@ -29,6 +29,7 @@
 #elif ENABLE(TOUCH_EVENTS)
 
 #include "Touch.h"
+#include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 
@@ -40,6 +41,10 @@
     {
         return adoptRef(*new TouchList);
     }
+    static Ref<TouchList> create(Vector<std::reference_wrapper<Touch>>&& touches)
+    {
+        return adoptRef(*new TouchList(WTFMove(touches)));
+    }
 
     unsigned length() const { return m_values.size(); }
 
@@ -49,8 +54,15 @@
     void append(Ref<Touch>&& touch) { m_values.append(WTFMove(touch)); }
 
 private:
-    TouchList() {}
+    TouchList() = default;
 
+    explicit TouchList(Vector<std::reference_wrapper<Touch>>&& touches)
+    {
+        m_values.reserveInitialCapacity(touches.size());
+        for (auto& touch : touches)
+            m_values.uncheckedAppend(touch.get());
+    }
+
     Vector<Ref<Touch>> m_values;
 };
 

Modified: trunk/Source/WebCore/dom/ios/TouchEvents.cpp (218528 => 218529)


--- trunk/Source/WebCore/dom/ios/TouchEvents.cpp	2017-06-20 03:17:05 UTC (rev 218528)
+++ trunk/Source/WebCore/dom/ios/TouchEvents.cpp	2017-06-20 03:25:45 UTC (rev 218529)
@@ -28,9 +28,10 @@
 #if ENABLE(IOS_TOUCH_EVENTS)
 
 #include <WebKitAdditions/DocumentIOS.cpp>
+#include <WebKitAdditions/DocumentTouchIOS.cpp>
 #include <WebKitAdditions/GestureEvent.cpp>
+#include <WebKitAdditions/TouchEventIOS.cpp>
 #include <WebKitAdditions/TouchIOS.cpp>
-#include <WebKitAdditions/TouchEventIOS.cpp>
 #include <WebKitAdditions/TouchListIOS.cpp>
 
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to