Title: [212773] trunk/Source/WebCore
Revision
212773
Author
[email protected]
Date
2017-02-21 15:25:49 -0800 (Tue, 21 Feb 2017)

Log Message

REGRESSION (203941): iAd Producer: Clicking buttons in Preview does not work
https://bugs.webkit.org/show_bug.cgi?id=168677
<rdar://problem/30640101>

Reviewed by Ryosuke Niwa.

Add quirk to initMouseEvent to unbreak iAd Producer.

* dom/MouseEvent.cpp:
(WebCore::MouseEvent::initMouseEventQuirk):
* dom/MouseEvent.h:
* dom/MouseEvent.idl:
* platform/RuntimeApplicationChecks.h:
* platform/RuntimeApplicationChecks.mm:
(WebCore::MacApplication::isIADProducer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (212772 => 212773)


--- trunk/Source/WebCore/ChangeLog	2017-02-21 23:23:38 UTC (rev 212772)
+++ trunk/Source/WebCore/ChangeLog	2017-02-21 23:25:49 UTC (rev 212773)
@@ -1,3 +1,21 @@
+2017-02-21  Chris Dumez  <[email protected]>
+
+        REGRESSION (203941): iAd Producer: Clicking buttons in Preview does not work
+        https://bugs.webkit.org/show_bug.cgi?id=168677
+        <rdar://problem/30640101>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add quirk to initMouseEvent to unbreak iAd Producer.
+
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEvent::initMouseEventQuirk):
+        * dom/MouseEvent.h:
+        * dom/MouseEvent.idl:
+        * platform/RuntimeApplicationChecks.h:
+        * platform/RuntimeApplicationChecks.mm:
+        (WebCore::MacApplication::isIADProducer):
+
 2017-02-21  Jer Noble  <[email protected]>
 
         AudioSampleDataSource doesn't need to use the m_scratchBuffer on the pulling thread

Modified: trunk/Source/WebCore/dom/MouseEvent.cpp (212772 => 212773)


--- trunk/Source/WebCore/dom/MouseEvent.cpp	2017-02-21 23:23:38 UTC (rev 212772)
+++ trunk/Source/WebCore/dom/MouseEvent.cpp	2017-02-21 23:25:49 UTC (rev 212773)
@@ -28,11 +28,17 @@
 #include "Frame.h"
 #include "FrameView.h"
 #include "HTMLIFrameElement.h"
+#include "JSDOMConvert.h"
+#include "JSEventTarget.h"
+#include "JSEventTargetCustom.h"
 #include "PlatformMouseEvent.h"
+#include "RuntimeApplicationChecks.h"
 #include <wtf/CurrentTime.h>
 
 namespace WebCore {
 
+using namespace JSC;
+
 Ref<MouseEvent> MouseEvent::create(const AtomicString& type, const MouseEventInit& initializer, IsTrusted isTrusted)
 {
     return adoptRef(*new MouseEvent(type, initializer, isTrusted));
@@ -145,6 +151,34 @@
     // FIXME: m_dataTransfer is not set to 0 here.
 }
 
+// FIXME: We need this quirk because iAd Producer is calling this function with a relatedTarget that is not an EventTarget (rdar://problem/30640101).
+// We should remove this quirk when possible.
+void MouseEvent::initMouseEventQuirk(ExecState& state, ScriptExecutionContext& scriptExecutionContext, const AtomicString& type, bool canBubble, bool cancelable, DOMWindow* view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, JSValue relatedTargetValue)
+{
+    EventTarget* relatedTarget = nullptr;
+#if PLATFORM(MAC)
+    if (MacApplication::isIAdProducer()) {
+        // jsEventTargetCast() does not throw and will silently convert bad input to nullptr.
+        auto jsRelatedTarget = jsEventTargetCast(state.vm(), relatedTargetValue);
+        if (!jsRelatedTarget && !relatedTargetValue.isUndefinedOrNull())
+            scriptExecutionContext.addConsoleMessage(MessageSource::JS, MessageLevel::Warning, ASCIILiteral("Calling initMouseEvent() with a relatedTarget that is not an EventTarget is deprecated."));
+        relatedTarget = jsRelatedTarget ? &jsRelatedTarget->wrapped() : nullptr;
+    } else {
+#else
+    UNUSED_PARAM(scriptExecutionContext);
+#endif
+        // This is what the bindings generator would have produced.
+        auto throwScope = DECLARE_THROW_SCOPE(state.vm());
+        relatedTarget = convert<IDLNullable<IDLInterface<EventTarget>>>(state, relatedTargetValue, [](ExecState& state, ThrowScope& scope) {
+            throwArgumentTypeError(state, scope, 14, "relatedTarget", "MouseEvent", "initMouseEvent", "EventTarget");
+        });
+        RETURN_IF_EXCEPTION(throwScope, void());
+#if PLATFORM(MAC)
+    }
+#endif
+    initMouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);
+}
+
 EventInterface MouseEvent::eventInterface() const
 {
     return MouseEventInterfaceType;

Modified: trunk/Source/WebCore/dom/MouseEvent.h (212772 => 212773)


--- trunk/Source/WebCore/dom/MouseEvent.h	2017-02-21 23:23:38 UTC (rev 212772)
+++ trunk/Source/WebCore/dom/MouseEvent.h	2017-02-21 23:25:49 UTC (rev 212773)
@@ -50,7 +50,7 @@
     virtual ~MouseEvent();
 
     WEBCORE_EXPORT void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelable, DOMWindow*, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, EventTarget* relatedTarget);
-
+    void initMouseEventQuirk(JSC::ExecState&, ScriptExecutionContext&, const AtomicString& type, bool canBubble, bool cancelable, DOMWindow*, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, JSC::JSValue relatedTarget);
     // WinIE uses 1,4,2 for left/middle/right but not for click (just for mousedown/up, maybe others),
     // but we will match the standard DOM.
     unsigned short button() const { return m_button; }

Modified: trunk/Source/WebCore/dom/MouseEvent.idl (212772 => 212773)


--- trunk/Source/WebCore/dom/MouseEvent.idl	2017-02-21 23:23:38 UTC (rev 212772)
+++ trunk/Source/WebCore/dom/MouseEvent.idl	2017-02-21 23:25:49 UTC (rev 212773)
@@ -39,11 +39,12 @@
     [Conditional=MOUSE_FORCE_EVENTS, ImplementedAs=force]readonly attribute double webkitForce;
 
     // FIXME: Using "undefined" as default parameter value is wrong.
-    void initMouseEvent(optional DOMString type = "undefined", optional boolean canBubble = false,  optional boolean cancelable = false,
+    // FIXME: relatedTarget should be of type EventTarget? but we need to use any to support a quirk for iAd Producer (rdar://problem/30640101).
+    [CallWith=ScriptState&ScriptExecutionContext, ImplementedAs=initMouseEventQuirk] void initMouseEvent(optional DOMString type = "undefined", optional boolean canBubble = false,  optional boolean cancelable = false,
         optional DOMWindow? view = null, optional long detail = 0,
         optional long screenX = 0, optional long screenY = 0, optional long clientX = 0, optional long clientY = 0,
         optional boolean ctrlKey = false, optional boolean altKey = false, optional boolean shiftKey = false, optional boolean metaKey = false,
-        optional unsigned short button = 0, optional EventTarget? relatedTarget = null);
+        optional unsigned short button = 0, optional any relatedTarget = null);
 
     readonly attribute long offsetX;
     readonly attribute long offsetY;

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.h (212772 => 212773)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2017-02-21 23:23:38 UTC (rev 212772)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2017-02-21 23:25:49 UTC (rev 212773)
@@ -52,6 +52,7 @@
 bool isSolidStateNetworksDownloader();
 WEBCORE_EXPORT bool isVersions();
 WEBCORE_EXPORT bool isHRBlock();
+WEBCORE_EXPORT bool isIAdProducer();
 
 } // MacApplication
 

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.mm (212772 => 212773)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.mm	2017-02-21 23:23:38 UTC (rev 212772)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.mm	2017-02-21 23:25:49 UTC (rev 212773)
@@ -148,6 +148,12 @@
     return isHRBlock;
 }
 
+bool MacApplication::isIAdProducer()
+{
+    static bool isIAdProducer = applicationBundleIsEqualTo("com.apple.iAdProducer");
+    return isIAdProducer;
+}
+
 bool MacApplication::isSolidStateNetworksDownloader()
 {
     static bool isSolidStateNetworksDownloader = applicationBundleIsEqualTo("com.solidstatenetworks.awkhost");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to