- Revision
- 204945
- Author
- [email protected]
- Date
- 2016-08-24 16:58:45 -0700 (Wed, 24 Aug 2016)
Log Message
[iOS DRT] Hook up uiController.zoomToScale() for DRT
https://bugs.webkit.org/show_bug.cgi?id=161173
Reviewed by Tim Horton.
Tools:
Make a UIWebScrollView subclass, DumpRenderTreeWebScrollView, which has an internal delegate to get
UIScrollView delegate callbacks. Store the zoomToScaleCompletionHandler on it.
UIScriptController::zoomToScale() has to bounce the zoom to the main thread (no poking UIKit from
the WebThread!), but queue up the callback first.
* DumpRenderTree/ios/DumpRenderTreeBrowserView.h:
* DumpRenderTree/ios/DumpRenderTreeBrowserView.mm:
(-[DumpRenderTreeWebScrollView initWithFrame:]):
(-[DumpRenderTreeWebScrollView dealloc]):
(-[DumpRenderTreeWebScrollView zoomToScale:animated:completionHandler:]):
(-[DumpRenderTreeWebScrollView completedZoomToScale]):
(-[DumpRenderTreeWebScrollViewDelegate initWithScrollView:]):
(-[DumpRenderTreeWebScrollViewDelegate viewForZoomingInScrollView:]): All UIScrollView delegates need to implement this.
(-[DumpRenderTreeWebScrollViewDelegate scrollViewDidEndZooming:withView:atScale:]):
* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::zoomToScale):
* DumpRenderTree/mac/DumpRenderTree.mm:
(createWebViewAndOffscreenWindow):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::context):
LayoutTests:
The one test in fast/zooming/ios works in DRT and WTR now.
* platform/ios-simulator-wk2/TestExpectations:
* platform/ios-simulator/TestExpectations:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (204944 => 204945)
--- trunk/LayoutTests/ChangeLog 2016-08-24 23:47:01 UTC (rev 204944)
+++ trunk/LayoutTests/ChangeLog 2016-08-24 23:58:45 UTC (rev 204945)
@@ -1,3 +1,15 @@
+2016-08-24 Simon Fraser <[email protected]>
+
+ [iOS DRT] Hook up uiController.zoomToScale() for DRT
+ https://bugs.webkit.org/show_bug.cgi?id=161173
+
+ Reviewed by Tim Horton.
+
+ The one test in fast/zooming/ios works in DRT and WTR now.
+
+ * platform/ios-simulator-wk2/TestExpectations:
+ * platform/ios-simulator/TestExpectations:
+
2016-08-24 Jiewen Tan <[email protected]>
Unreviewed, rebase iOS simulator WK1 fast/table tests
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (204944 => 204945)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-08-24 23:47:01 UTC (rev 204944)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-08-24 23:58:45 UTC (rev 204945)
@@ -13,6 +13,7 @@
media/controls/ipad [ Pass ]
fast/text-autosizing/ios [ Pass ]
+fast/zooming/ios [ Pass ]
# <rdar://problem/22898927> Crashes in iWorkImport.framework
quicklook/pages.html [ Pass Crash ]
Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (204944 => 204945)
--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations 2016-08-24 23:47:01 UTC (rev 204944)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations 2016-08-24 23:58:45 UTC (rev 204945)
@@ -8,7 +8,6 @@
fast/scrolling/ios [ Pass ]
fast/viewport/ios [ Pass ]
-fast/zooming/ios [ Pass ]
#//////////////////////////////////////////////////////////////////////////////////////////
# End platform-specific directories.
Modified: trunk/Tools/ChangeLog (204944 => 204945)
--- trunk/Tools/ChangeLog 2016-08-24 23:47:01 UTC (rev 204944)
+++ trunk/Tools/ChangeLog 2016-08-24 23:58:45 UTC (rev 204945)
@@ -1,3 +1,32 @@
+2016-08-24 Simon Fraser <[email protected]>
+
+ [iOS DRT] Hook up uiController.zoomToScale() for DRT
+ https://bugs.webkit.org/show_bug.cgi?id=161173
+
+ Reviewed by Tim Horton.
+
+ Make a UIWebScrollView subclass, DumpRenderTreeWebScrollView, which has an internal delegate to get
+ UIScrollView delegate callbacks. Store the zoomToScaleCompletionHandler on it.
+
+ UIScriptController::zoomToScale() has to bounce the zoom to the main thread (no poking UIKit from
+ the WebThread!), but queue up the callback first.
+
+ * DumpRenderTree/ios/DumpRenderTreeBrowserView.h:
+ * DumpRenderTree/ios/DumpRenderTreeBrowserView.mm:
+ (-[DumpRenderTreeWebScrollView initWithFrame:]):
+ (-[DumpRenderTreeWebScrollView dealloc]):
+ (-[DumpRenderTreeWebScrollView zoomToScale:animated:completionHandler:]):
+ (-[DumpRenderTreeWebScrollView completedZoomToScale]):
+ (-[DumpRenderTreeWebScrollViewDelegate initWithScrollView:]):
+ (-[DumpRenderTreeWebScrollViewDelegate viewForZoomingInScrollView:]): All UIScrollView delegates need to implement this.
+ (-[DumpRenderTreeWebScrollViewDelegate scrollViewDidEndZooming:withView:atScale:]):
+ * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+ (WTR::UIScriptController::zoomToScale):
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (createWebViewAndOffscreenWindow):
+ * TestRunnerShared/UIScriptContext/UIScriptController.h:
+ (WTR::UIScriptController::context):
+
2016-08-24 Ryan Haddad <[email protected]>
Attempt to fix Windows build after r204918.
Modified: trunk/Tools/DumpRenderTree/ios/DumpRenderTreeBrowserView.h (204944 => 204945)
--- trunk/Tools/DumpRenderTree/ios/DumpRenderTreeBrowserView.h 2016-08-24 23:47:01 UTC (rev 204944)
+++ trunk/Tools/DumpRenderTree/ios/DumpRenderTreeBrowserView.h 2016-08-24 23:58:45 UTC (rev 204945)
@@ -39,3 +39,16 @@
- (CGRect)documentVisibleRect;
@end
+
+
+@class DumpRenderTreeWebScrollViewDelegate;
+
+@interface DumpRenderTreeWebScrollView : UIWebScrollView
+
+@property (nonatomic, retain) DumpRenderTreeWebScrollViewDelegate *scrollViewDelegate;
+
+@property (nonatomic, copy) void (^zoomToScaleCompletionHandler)(void);
+
+- (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler;
+
+@end
Modified: trunk/Tools/DumpRenderTree/ios/DumpRenderTreeBrowserView.mm (204944 => 204945)
--- trunk/Tools/DumpRenderTree/ios/DumpRenderTreeBrowserView.mm 2016-08-24 23:47:01 UTC (rev 204944)
+++ trunk/Tools/DumpRenderTree/ios/DumpRenderTreeBrowserView.mm 2016-08-24 23:58:45 UTC (rev 204945)
@@ -28,6 +28,8 @@
#if PLATFORM(IOS)
+#import <WebCore/WebCoreThreadRun.h>
+#import <WebKit/WebCoreThread.h>
#import <WebKit/WebView.h>
@interface UIWebBrowserView (WebUIKitDelegate)
@@ -87,4 +89,79 @@
@end
+@interface DumpRenderTreeWebScrollViewDelegate : NSObject <UIScrollViewDelegate> {
+ DumpRenderTreeWebScrollView *_scrollView;
+}
+- (instancetype)initWithScrollView:(DumpRenderTreeWebScrollView *)scrollView;
+@end
+
+
+@implementation DumpRenderTreeWebScrollView
+
+- (instancetype)initWithFrame:(CGRect)frame
+{
+ self = [super initWithFrame:frame];
+ if (!self)
+ return nil;
+
+ self.scrollViewDelegate = [[[DumpRenderTreeWebScrollViewDelegate alloc] initWithScrollView:self] autorelease];
+ self.delegate = self.scrollViewDelegate;
+
+ return self;
+}
+
+- (void)dealloc
+{
+ self.scrollViewDelegate = nil;
+ [super dealloc];
+}
+
+- (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler
+{
+ ASSERT(!self.zoomToScaleCompletionHandler);
+ self.zoomToScaleCompletionHandler = completionHandler;
+
+ [self setZoomScale:scale animated:animated];
+}
+
+- (void)completedZoomToScale
+{
+ if (self.zoomToScaleCompletionHandler) {
+ auto completionHandlerCopy = Block_copy(self.zoomToScaleCompletionHandler);
+
+ WebThreadRun(^{
+ completionHandlerCopy();
+ Block_release(completionHandlerCopy);
+ });
+ self.zoomToScaleCompletionHandler = nullptr;
+ }
+}
+
+@end
+
+@implementation DumpRenderTreeWebScrollViewDelegate
+
+- (instancetype)initWithScrollView:(DumpRenderTreeWebScrollView *)scrollView
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _scrollView = scrollView;
+ return self;
+}
+
+- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
+{
+ return [scrollView.subviews firstObject];
+}
+
+// UIScrollView delegate methods.
+- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
+{
+ [_scrollView completedZoomToScale];
+}
+
+@end
+
#endif // PLATFORM(IOS)
Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (204944 => 204945)
--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm 2016-08-24 23:47:01 UTC (rev 204944)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm 2016-08-24 23:58:45 UTC (rev 204945)
@@ -31,9 +31,10 @@
#import "DumpRenderTreeBrowserView.h"
#import "UIScriptContext.h"
#import <WebCore/FloatRect.h>
+#import <wtf/MainThread.h>
extern DumpRenderTreeBrowserView *gWebBrowserView;
-extern UIWebScrollView *gWebScrollView;
+extern DumpRenderTreeWebScrollView *gWebScrollView;
namespace WTR {
@@ -50,6 +51,16 @@
void UIScriptController::zoomToScale(double scale, JSValueRef callback)
{
+ RefPtr<UIScriptController> protectedThis(this);
+ unsigned callbackID = strongThis->context()->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [gWebScrollView zoomToScale:scale animated:YES completionHandler:^{
+ if (!strongThis->context())
+ return;
+ strongThis->context()->asyncTaskComplete(callbackID);
+ }];
+ });
}
double UIScriptController::zoomScale() const
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (204944 => 204945)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2016-08-24 23:47:01 UTC (rev 204944)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2016-08-24 23:58:45 UTC (rev 204945)
@@ -222,7 +222,7 @@
#if PLATFORM(IOS)
const CGRect layoutTestViewportRect = { {0, 0}, {static_cast<CGFloat>(TestRunner::viewWidth), static_cast<CGFloat>(TestRunner::viewHeight)} };
DumpRenderTreeBrowserView *gWebBrowserView = nil;
-UIWebScrollView *gWebScrollView = nil;
+DumpRenderTreeWebScrollView *gWebScrollView = nil;
DumpRenderTreeWindow *gDrtWindow = nil;
#endif
@@ -829,7 +829,7 @@
drtWindow.uiWindow = uiWindow;
drtWindow.browserView = webBrowserView;
- UIWebScrollView *scrollView = [[UIWebScrollView alloc] initWithFrame:layoutTestViewportRect];
+ DumpRenderTreeWebScrollView *scrollView = [[DumpRenderTreeWebScrollView alloc] initWithFrame:layoutTestViewportRect];
[scrollView addSubview:webBrowserView];
[viewController.view addSubview:scrollView];
Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (204944 => 204945)
--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2016-08-24 23:47:01 UTC (rev 204944)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2016-08-24 23:58:45 UTC (rev 204945)
@@ -100,6 +100,8 @@
private:
UIScriptController(UIScriptContext&);
+
+ UIScriptContext* context() { return m_context; }
void platformSetDidStartFormControlInteractionCallback();
void platformSetDidEndFormControlInteractionCallback();