Correct layering violation in DumpRenderTree Build
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Apr 2015 23:48:00 +0000 (23:48 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Apr 2015 23:48:00 +0000 (23:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143732

Reviewed by Simon Fraser.

Source/WebCore:

* testing/js/WebCoreTestSupport.cpp:
(WebCoreTestSupport::monitorWheelEvents): Added. Provides a wrapper around
the internal WebCore objects needed to implement this function.
(WebCoreTestSupport::setTestCallbackAndStartNotificationTimer): Ditto.
* testing/js/WebCoreTestSupport.h:

Tools:

Correct a layering violation in DumpRenderTree by calling functions on the
WebCoreTestSupport library, rather than attempting to work with WebCore
types directly.

* DumpRenderTree/mac/EventSendingController.mm:
(-[EventSendingController monitorWheelEvents]): Call methods on WebCoreTestSupport, rather
than WebCore itself.,
(-[EventSendingController callAfterScrollingCompletes:]): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182821 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/testing/js/WebCoreTestSupport.cpp
Source/WebCore/testing/js/WebCoreTestSupport.h
Tools/ChangeLog
Tools/DumpRenderTree/mac/EventSendingController.mm

index 0bc6fe3..3853142 100644 (file)
@@ -1,3 +1,16 @@
+2015-04-14  Brent Fulgham  <bfulgham@apple.com>
+
+        Correct layering violation in DumpRenderTree Build
+        https://bugs.webkit.org/show_bug.cgi?id=143732
+
+        Reviewed by Simon Fraser.
+
+        * testing/js/WebCoreTestSupport.cpp:
+        (WebCoreTestSupport::monitorWheelEvents): Added. Provides a wrapper around
+        the internal WebCore objects needed to implement this function.
+        (WebCoreTestSupport::setTestCallbackAndStartNotificationTimer): Ditto.
+        * testing/js/WebCoreTestSupport.h:
+
 2015-04-14  Brady Eidson  <beidson@apple.com>
 
         Make sure media element loads hit content filter extensions.
index b52d1e6..623ed99 100644 (file)
 #include "Internals.h"
 #include "JSDocument.h"
 #include "JSInternals.h"
+#include "MainFrame.h"
+#include "WheelEventTestTrigger.h"
 #include <JavaScriptCore/APICast.h>
+#include <JavaScriptCore/JSValueRef.h>
 #include <JavaScriptCore/Profile.h>
 #include <interpreter/CallFrame.h>
 #include <runtime/IdentifierInlines.h>
@@ -62,4 +65,20 @@ void resetInternalsObject(JSContextRef context)
     InternalSettings::from(page)->resetToConsistentState();
 }
 
+void monitorWheelEvents(WebCore::Frame& frame)
+{
+    frame.mainFrame().ensureTestTrigger();
+}
+
+void setTestCallbackAndStartNotificationTimer(WebCore::Frame& frame, JSContextRef context, JSObjectRef jsCallbackFunction)
+{
+    WheelEventTestTrigger* trigger = frame.mainFrame().ensureTestTrigger();
+    JSValueProtect(context, jsCallbackFunction);
+    
+    trigger->setTestCallbackAndStartNotificationTimer([=](void) {
+        JSObjectCallAsFunction(context, jsCallbackFunction, nullptr, 0, nullptr, nullptr);
+        JSValueUnprotect(context, jsCallbackFunction);
+    });
+}
+
 }
index 619f8fe..30e2bd2 100644 (file)
@@ -27,6 +27,7 @@
 #define WebCoreTestSupport_h
 
 typedef const struct OpaqueJSContext* JSContextRef;
+typedef struct OpaqueJSValue* JSObjectRef;
 
 #if PLATFORM(COCOA)
 #define TEST_SUPPORT_EXPORT WTF_EXPORT_PRIVATE
@@ -34,10 +35,16 @@ typedef const struct OpaqueJSContext* JSContextRef;
 #define TEST_SUPPORT_EXPORT
 #endif
 
+namespace WebCore {
+class Frame;
+}
+
 namespace WebCoreTestSupport {
 
 void injectInternalsObject(JSContextRef) TEST_SUPPORT_EXPORT;
 void resetInternalsObject(JSContextRef) TEST_SUPPORT_EXPORT;
+void monitorWheelEvents(WebCore::Frame&) TEST_SUPPORT_EXPORT;
+void setTestCallbackAndStartNotificationTimer(WebCore::Frame&, JSContextRef, JSObjectRef) TEST_SUPPORT_EXPORT;
 
 } // namespace WebCore
 
index d378f74..ecdbe71 100644 (file)
@@ -1,3 +1,19 @@
+2015-04-14  Brent Fulgham  <bfulgham@apple.com>
+
+        Correct layering violation in DumpRenderTree Build
+        https://bugs.webkit.org/show_bug.cgi?id=143732
+
+        Reviewed by Simon Fraser.
+
+        Correct a layering violation in DumpRenderTree by calling functions on the
+        WebCoreTestSupport library, rather than attempting to work with WebCore
+        types directly.
+
+        * DumpRenderTree/mac/EventSendingController.mm:
+        (-[EventSendingController monitorWheelEvents]): Call methods on WebCoreTestSupport, rather
+        than WebCore itself.,
+        (-[EventSendingController callAfterScrollingCompletes:]): Ditto.
+
 2015-04-14  Benjamin Poulain  <benjamin@webkit.org>
 
         Add a conservative DFA minimizer for the content extension matcher
index 8bc7a89..c435554 100644 (file)
@@ -35,6 +35,7 @@
 #import "DumpRenderTree.h"
 #import "DumpRenderTreeDraggingInfo.h"
 #import "DumpRenderTreeFileDraggingSource.h"
+#import "WebCoreTestSupport.h"
 #import <WebKit/DOMPrivate.h>
 #import <WebKit/WebKit.h>
 #import <WebKit/WebViewPrivate.h>
 
 #if !PLATFORM(IOS)
 #import <Carbon/Carbon.h> // for GetCurrentEventTime()
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <WebCore/MainFrame.h>
-#import <WebCore/Page.h>
-#import <WebCore/WheelEventTestTrigger.h>
 #endif
 
 #if PLATFORM(IOS)
@@ -1267,8 +1264,8 @@ static int buildModifierFlags(const WebScriptObject* modifiers)
     WebCore::Frame* frame = [[mainFrame webView] _mainCoreFrame];
     if (!frame)
         return;
-    
-    frame->mainFrame().ensureTestTrigger();
+
+    WebCoreTestSupport::monitorWheelEvents(*frame);
 #endif
 }
 
@@ -1283,14 +1280,8 @@ static int buildModifierFlags(const WebScriptObject* modifiers)
     if (!frame)
         return;
 
-    WebCore::WheelEventTestTrigger* trigger = frame->mainFrame().ensureTestTrigger();
     JSGlobalContextRef globalContext = [mainFrame globalContext];
-    JSValueProtect(globalContext, jsCallbackFunction);
-
-    trigger->setTestCallbackAndStartNotificationTimer([=](void) {
-        JSObjectCallAsFunction(globalContext, jsCallbackFunction, nullptr, 0, nullptr, nullptr);
-        JSValueUnprotect(globalContext, jsCallbackFunction);
-    });
+    WebCoreTestSupport::setTestCallbackAndStartNotificationTimer(*frame, globalContext, jsCallbackFunction);
 #endif
 }