Diff
Modified: trunk/Source/WebCore/ChangeLog (237815 => 237816)
--- trunk/Source/WebCore/ChangeLog 2018-11-05 18:09:39 UTC (rev 237815)
+++ trunk/Source/WebCore/ChangeLog 2018-11-05 18:37:43 UTC (rev 237816)
@@ -1,3 +1,25 @@
+2018-11-05 Dean Jackson <[email protected]>
+
+ Expose a constructor for PointerEvent from PlatformTouchEvent
+ https://bugs.webkit.org/show_bug.cgi?id=191238
+ <rdar://problem/45795682>
+
+ Reviewed by Antoine Quint.
+
+ Implement a constructor that takes a PlatformTouchEvent to
+ create a PointerEvent. At the moment the code to call this
+ constructor will live in WebKitAdditions, so no new tests
+ yet.
+
+ * SourcesCocoa.txt: Add PointerEventIOS.cpp.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * dom/EventNames.h: Add macros for pointerdown, pointermove,
+ pointerup, pointercancel.
+ * dom/PointerEvent.cpp: Remove JSC namespace.
+ * dom/PointerEvent.h: Add create and constructor that takes
+ a PlatformTouchEvent.
+ * dom/ios/PointerEventIOS.cpp: Added.
+
2018-11-05 Ryan Haddad <[email protected]>
Unreviewed, rolling out r237785.
Modified: trunk/Source/WebCore/SourcesCocoa.txt (237815 => 237816)
--- trunk/Source/WebCore/SourcesCocoa.txt 2018-11-05 18:09:39 UTC (rev 237815)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2018-11-05 18:37:43 UTC (rev 237816)
@@ -73,6 +73,7 @@
dom/DataTransferMac.mm
+dom/ios/PointerEventIOS.cpp
dom/ios/TouchEvents.cpp
editing/SelectionRectGatherer.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (237815 => 237816)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-11-05 18:09:39 UTC (rev 237815)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-11-05 18:37:43 UTC (rev 237816)
@@ -6861,6 +6861,7 @@
314BE3A21B30F6D100141982 /* CSSNamedImageValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSNamedImageValue.cpp; sourceTree = "<group>"; };
314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NamedImageGeneratedImage.cpp; sourceTree = "<group>"; };
314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NamedImageGeneratedImage.h; sourceTree = "<group>"; };
+ 315574CC218F66D000D88F66 /* PointerEventIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PointerEventIOS.cpp; sourceTree = "<group>"; };
316BDB841E6E0A2100DE0D5A /* GPULegacyDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPULegacyDevice.cpp; sourceTree = "<group>"; };
316BDB851E6E0A2100DE0D5A /* GPULegacyDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPULegacyDevice.h; sourceTree = "<group>"; };
316BDB881E6E141C00DE0D5A /* GPULegacyDeviceMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPULegacyDeviceMetal.mm; sourceTree = "<group>"; };
@@ -25426,6 +25427,7 @@
CE2616A4187E65C1007955F3 /* ios */ = {
isa = PBXGroup;
children = (
+ 315574CC218F66D000D88F66 /* PointerEventIOS.cpp */,
A1DE712B18612AC100734192 /* TouchEvents.cpp */,
);
path = ios;
Modified: trunk/Source/WebCore/dom/EventNames.h (237815 => 237816)
--- trunk/Source/WebCore/dom/EventNames.h 2018-11-05 18:09:39 UTC (rev 237815)
+++ trunk/Source/WebCore/dom/EventNames.h 2018-11-05 18:37:43 UTC (rev 237816)
@@ -198,6 +198,10 @@
macro(playing) \
macro(pointerlockchange) \
macro(pointerlockerror) \
+ macro(pointercancel) \
+ macro(pointerdown) \
+ macro(pointermove) \
+ macro(pointerup) \
macro(popstate) \
macro(previoustrack) \
macro(progress) \
Modified: trunk/Source/WebCore/dom/PointerEvent.cpp (237815 => 237816)
--- trunk/Source/WebCore/dom/PointerEvent.cpp 2018-11-05 18:09:39 UTC (rev 237815)
+++ trunk/Source/WebCore/dom/PointerEvent.cpp 2018-11-05 18:37:43 UTC (rev 237816)
@@ -28,8 +28,6 @@
namespace WebCore {
-using namespace JSC;
-
PointerEvent::PointerEvent() = default;
PointerEvent::PointerEvent(const AtomicString& type, Init&& initializer)
Modified: trunk/Source/WebCore/dom/PointerEvent.h (237815 => 237816)
--- trunk/Source/WebCore/dom/PointerEvent.h 2018-11-05 18:09:39 UTC (rev 237815)
+++ trunk/Source/WebCore/dom/PointerEvent.h 2018-11-05 18:37:43 UTC (rev 237816)
@@ -28,6 +28,10 @@
#include "MouseEvent.h"
#include <wtf/text/WTFString.h>
+#if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
+#include "PlatformTouchEventIOS.h"
+#endif
+
namespace WebCore {
class PointerEvent final : public MouseEvent {
@@ -55,6 +59,10 @@
return adoptRef(*new PointerEvent);
}
+#if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
+ static Ref<PointerEvent> create(const PlatformTouchEvent&, unsigned touchIndex, Ref<WindowProxy>&&);
+#endif
+
virtual ~PointerEvent();
long pointerId() const { return m_pointerId; }
@@ -68,7 +76,7 @@
String pointerType() const { return m_pointerType; }
bool isPrimary() const { return m_isPrimary; }
- bool isPointerEvent() const override { return true; }
+ bool isPointerEvent() const final { return true; }
EventInterface eventInterface() const override;
@@ -75,6 +83,9 @@
private:
PointerEvent();
PointerEvent(const AtomicString&, Init&&);
+#if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
+ PointerEvent(const AtomicString& type, const PlatformTouchEvent&, IsCancelable isCancelable, unsigned touchIndex, Ref<WindowProxy>&&);
+#endif
long m_pointerId { 0 };
double m_width { 1 };
Added: trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp (0 => 237816)
--- trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp (rev 0)
+++ trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp 2018-11-05 18:37:43 UTC (rev 237816)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#import "config.h"
+#import "PointerEvent.h"
+
+#if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
+
+#import "EventNames.h"
+
+namespace WebCore {
+
+static AtomicString eventType(PlatformTouchPoint::TouchPhaseType phase)
+{
+ switch (phase) {
+ case PlatformTouchPoint::TouchPhaseBegan:
+ return eventNames().pointerdownEvent;
+ case PlatformTouchPoint::TouchPhaseMoved:
+ return eventNames().pointermoveEvent;
+ case PlatformTouchPoint::TouchPhaseStationary:
+ return eventNames().pointermoveEvent;
+ case PlatformTouchPoint::TouchPhaseEnded:
+ return eventNames().pointerupEvent;
+ case PlatformTouchPoint::TouchPhaseCancelled:
+ return eventNames().pointercancelEvent;
+ }
+ ASSERT_NOT_REACHED();
+ return nullAtom();
+}
+
+static PointerEvent::IsCancelable phaseIsCancelable(PlatformTouchPoint::TouchPhaseType phase)
+{
+ if (phase == PlatformTouchPoint::TouchPhaseCancelled)
+ return PointerEvent::IsCancelable::No;
+ return PointerEvent::IsCancelable::Yes;
+}
+
+Ref<PointerEvent> PointerEvent::create(const PlatformTouchEvent& event, unsigned index, Ref<WindowProxy>&& view)
+{
+ auto phase = event.touchPhaseAtIndex(index);
+ return adoptRef(*new PointerEvent(eventType(phase), event, phaseIsCancelable(phase), index, WTFMove(view)));
+}
+
+PointerEvent::PointerEvent(const AtomicString& type, const PlatformTouchEvent& event, IsCancelable isCancelable, unsigned index, Ref<WindowProxy>&& view)
+ : MouseEvent(type, CanBubble::Yes, isCancelable, IsComposed::Yes, event.timestamp().approximateMonotonicTime(), WTFMove(view), 0, event.touchLocationAtIndex(index), event.touchLocationAtIndex(index), { }, event.modifiers(), 0, 0, nullptr, 0, 0, nullptr, IsSimulated::No, IsTrusted::Yes)
+ , m_pointerId(event.touchIdentifierAtIndex(index))
+ , m_width(2 * event.radiusXAtIndex(index))
+ , m_height(2 * event.radiusYAtIndex(index))
+ , m_pointerType(event.touchTypeAtIndex(index) == PlatformTouchPoint::TouchType::Stylus ? "pen"_s : "touch"_s)
+ , m_isPrimary(!index)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
Property changes on: trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Author Id Revision HeadURL
\ No newline at end of property