<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[191634] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/191634">191634</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-10-27 13:09:29 -0700 (Tue, 27 Oct 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>WKView being inside WKWebView leads to weird API issues
https://bugs.webkit.org/show_bug.cgi?id=150174
Reviewed by Anders Carlsson.
* UIProcess/API/mac/WKView.mm:
(-[WKView scrollWheel:]):
(-[WKView swipeWithEvent:]):
(-[WKView _superSwipeWithEvent:]):
(-[WKView _superMagnifyWithEvent:]):
(-[WKView _superSmartMagnifyWithEvent:]):
(-[WKView _processDidExit]):
(-[WKView setAllowsBackForwardNavigationGestures:]):
(-[WKView allowsBackForwardNavigationGestures]):
(-[WKView setAllowsMagnification:]):
(-[WKView allowsMagnification]):
(-[WKView magnifyWithEvent:]):
(-[WKView rotateWithEvent:]):
(-[WKView _gestureEventWasNotHandledByWebCore:]):
(-[WKView smartMagnifyWithEvent:]):
(-[WKView setMagnification:centeredAtPoint:]):
(-[WKView setMagnification:]):
(-[WKView magnification]):
(-[WKView _setCustomSwipeViews:]):
(-[WKView _setCustomSwipeViewsTopContentInset:]):
(-[WKView _tryToSwipeWithEvent:ignoringPinnedState:]):
(-[WKView _setDidMoveSwipeSnapshotCallback:]):
(-[WKView _ensureGestureController]): Deleted.
(takeWindowSnapshot): Deleted.
(-[WKView _takeViewSnapshot]): Deleted.
(-[WKView _wheelEventWasNotHandledByWebCore:]): Deleted.
(-[WKView _didFirstVisuallyNonEmptyLayoutForMainFrame]): Deleted.
(-[WKView _didFinishLoadForMainFrame]): Deleted.
(-[WKView _didFailLoadForMainFrame]): Deleted.
(-[WKView _didSameDocumentNavigationForMainFrame:]): Deleted.
(-[WKView _removeNavigationGestureSnapshot]): Deleted.
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/Cocoa/WebViewImpl.h:
(WebKit::WebViewImpl::gestureController):
(WebKit::WebViewImpl::allowsBackForwardNavigationGestures):
(WebKit::WebViewImpl::allowsMagnification):
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::takeWindowSnapshot):
(WebKit::WebViewImpl::takeViewSnapshot):
(WebKit::WebViewImpl::ensureGestureController):
(WebKit::WebViewImpl::resetGestureController):
(WebKit::WebViewImpl::setAllowsBackForwardNavigationGestures):
(WebKit::WebViewImpl::setAllowsMagnification):
(WebKit::WebViewImpl::setMagnification):
(WebKit::WebViewImpl::magnification):
(WebKit::WebViewImpl::setCustomSwipeViews):
(WebKit::WebViewImpl::setCustomSwipeViewsTopContentInset):
(WebKit::WebViewImpl::tryToSwipeWithEvent):
(WebKit::WebViewImpl::setDidMoveSwipeSnapshotCallback):
(WebKit::WebViewImpl::scrollWheel):
(WebKit::WebViewImpl::swipeWithEvent):
(WebKit::WebViewImpl::magnifyWithEvent):
(WebKit::WebViewImpl::smartMagnifyWithEvent):
(WebKit::WebViewImpl::rotateWithEvent):
(WebKit::WebViewImpl::gestureEventWasNotHandledByWebCore):
(WebKit::WebViewImpl::gestureEventWasNotHandledByWebCoreFromViewOnly):
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::takeViewSnapshot):
(WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
(WebKit::PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame):
(WebKit::PageClientImpl::didFinishLoadForMainFrame):
(WebKit::PageClientImpl::didFailLoadForMainFrame):
(WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
(WebKit::PageClientImpl::removeNavigationGestureSnapshot):
Move swipe, zoom, rotate, and snapshotting code.
* platform/spi/cg/CoreGraphicsSPI.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformspicgCoreGraphicsSPIh">trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewInternalh">trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplh">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplmm">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebCore/ChangeLog        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2015-10-27 Tim Horton <timothy_horton@apple.com>
+
+ WKView being inside WKWebView leads to weird API issues
+ https://bugs.webkit.org/show_bug.cgi?id=150174
+
+ Reviewed by Anders Carlsson.
+
+ * platform/spi/cg/CoreGraphicsSPI.h:
+
</ins><span class="cx"> 2015-10-27 Zhuo Li <zachli@apple.com>
</span><span class="cx">
</span><span class="cx"> Add WebKit API to clear data type Search Field Recent Searches.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspicgCoreGraphicsSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -182,6 +182,7 @@
</span><span class="cx"> CFArrayRef CGSHWCaptureWindowList(CGSConnectionID cid, CGSWindowIDList windowList, CGSWindowCount windowCount, CGSWindowCaptureOptions options);
</span><span class="cx"> CGError CGSSetConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef value);
</span><span class="cx"> CGError CGSCopyConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef *value);
</span><ins>+CGError CGSGetScreenRectForWindow(CGSConnectionID, CGSWindowID, CGRect *);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> WTF_EXTERN_C_END
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/ChangeLog        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -1,3 +1,76 @@
</span><ins>+2015-10-27 Tim Horton <timothy_horton@apple.com>
+
+ WKView being inside WKWebView leads to weird API issues
+ https://bugs.webkit.org/show_bug.cgi?id=150174
+
+ Reviewed by Anders Carlsson.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView scrollWheel:]):
+ (-[WKView swipeWithEvent:]):
+ (-[WKView _superSwipeWithEvent:]):
+ (-[WKView _superMagnifyWithEvent:]):
+ (-[WKView _superSmartMagnifyWithEvent:]):
+ (-[WKView _processDidExit]):
+ (-[WKView setAllowsBackForwardNavigationGestures:]):
+ (-[WKView allowsBackForwardNavigationGestures]):
+ (-[WKView setAllowsMagnification:]):
+ (-[WKView allowsMagnification]):
+ (-[WKView magnifyWithEvent:]):
+ (-[WKView rotateWithEvent:]):
+ (-[WKView _gestureEventWasNotHandledByWebCore:]):
+ (-[WKView smartMagnifyWithEvent:]):
+ (-[WKView setMagnification:centeredAtPoint:]):
+ (-[WKView setMagnification:]):
+ (-[WKView magnification]):
+ (-[WKView _setCustomSwipeViews:]):
+ (-[WKView _setCustomSwipeViewsTopContentInset:]):
+ (-[WKView _tryToSwipeWithEvent:ignoringPinnedState:]):
+ (-[WKView _setDidMoveSwipeSnapshotCallback:]):
+ (-[WKView _ensureGestureController]): Deleted.
+ (takeWindowSnapshot): Deleted.
+ (-[WKView _takeViewSnapshot]): Deleted.
+ (-[WKView _wheelEventWasNotHandledByWebCore:]): Deleted.
+ (-[WKView _didFirstVisuallyNonEmptyLayoutForMainFrame]): Deleted.
+ (-[WKView _didFinishLoadForMainFrame]): Deleted.
+ (-[WKView _didFailLoadForMainFrame]): Deleted.
+ (-[WKView _didSameDocumentNavigationForMainFrame:]): Deleted.
+ (-[WKView _removeNavigationGestureSnapshot]): Deleted.
+ * UIProcess/API/mac/WKViewInternal.h:
+ * UIProcess/Cocoa/WebViewImpl.h:
+ (WebKit::WebViewImpl::gestureController):
+ (WebKit::WebViewImpl::allowsBackForwardNavigationGestures):
+ (WebKit::WebViewImpl::allowsMagnification):
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::takeWindowSnapshot):
+ (WebKit::WebViewImpl::takeViewSnapshot):
+ (WebKit::WebViewImpl::ensureGestureController):
+ (WebKit::WebViewImpl::resetGestureController):
+ (WebKit::WebViewImpl::setAllowsBackForwardNavigationGestures):
+ (WebKit::WebViewImpl::setAllowsMagnification):
+ (WebKit::WebViewImpl::setMagnification):
+ (WebKit::WebViewImpl::magnification):
+ (WebKit::WebViewImpl::setCustomSwipeViews):
+ (WebKit::WebViewImpl::setCustomSwipeViewsTopContentInset):
+ (WebKit::WebViewImpl::tryToSwipeWithEvent):
+ (WebKit::WebViewImpl::setDidMoveSwipeSnapshotCallback):
+ (WebKit::WebViewImpl::scrollWheel):
+ (WebKit::WebViewImpl::swipeWithEvent):
+ (WebKit::WebViewImpl::magnifyWithEvent):
+ (WebKit::WebViewImpl::smartMagnifyWithEvent):
+ (WebKit::WebViewImpl::rotateWithEvent):
+ (WebKit::WebViewImpl::gestureEventWasNotHandledByWebCore):
+ (WebKit::WebViewImpl::gestureEventWasNotHandledByWebCoreFromViewOnly):
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::takeViewSnapshot):
+ (WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
+ (WebKit::PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame):
+ (WebKit::PageClientImpl::didFinishLoadForMainFrame):
+ (WebKit::PageClientImpl::didFailLoadForMainFrame):
+ (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
+ (WebKit::PageClientImpl::removeNavigationGestureSnapshot):
+ Move swipe, zoom, rotate, and snapshotting code.
+
</ins><span class="cx"> 2015-10-27 Zhuo Li <zachli@apple.com>
</span><span class="cx">
</span><span class="cx"> Add WebKit API to clear data type Search Field Recent Searches.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -41,7 +41,6 @@
</span><span class="cx"> #import "EditorState.h"
</span><span class="cx"> #import "LayerTreeContext.h"
</span><span class="cx"> #import "Logging.h"
</span><del>-#import "NativeWebGestureEvent.h"
</del><span class="cx"> #import "NativeWebKeyboardEvent.h"
</span><span class="cx"> #import "NativeWebMouseEvent.h"
</span><span class="cx"> #import "NativeWebWheelEvent.h"
</span><span class="lines">@@ -54,8 +53,6 @@
</span><span class="cx"> #import "TextChecker.h"
</span><span class="cx"> #import "TextCheckerState.h"
</span><span class="cx"> #import "TiledCoreAnimationDrawingAreaProxy.h"
</span><del>-#import "ViewGestureController.h"
-#import "ViewSnapshotStore.h"
</del><span class="cx"> #import "WKAPICast.h"
</span><span class="cx"> #import "WKFullScreenWindowController.h"
</span><span class="cx"> #import "WKLayoutMode.h"
</span><span class="lines">@@ -83,6 +80,7 @@
</span><span class="cx"> #import <QuartzCore/QuartzCore.h>
</span><span class="cx"> #import <WebCore/AXObjectCache.h>
</span><span class="cx"> #import <WebCore/ColorMac.h>
</span><ins>+#import <WebCore/CoreGraphicsSPI.h>
</ins><span class="cx"> #import <WebCore/DataDetectorsSPI.h>
</span><span class="cx"> #import <WebCore/DictionaryLookup.h>
</span><span class="cx"> #import <WebCore/DragController.h>
</span><span class="lines">@@ -131,17 +129,6 @@
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if defined(__has_include) && __has_include(<CoreGraphics/CoreGraphicsPrivate.h>)
-#import <CoreGraphics/CoreGraphicsPrivate.h>
-#endif
-
-extern "C" {
-typedef uint32_t CGSConnectionID;
-typedef uint32_t CGSWindowID;
-CGSConnectionID CGSMainConnectionID(void);
-CGError CGSGetScreenRectForWindow(CGSConnectionID cid, CGSWindowID wid, CGRect *rect);
-};
-
</del><span class="cx"> using namespace WebKit;
</span><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="lines">@@ -204,10 +191,6 @@
</span><span class="cx">
</span><span class="cx"> BOOL _windowOcclusionDetectionEnabled;
</span><span class="cx">
</span><del>- std::unique_ptr<ViewGestureController> _gestureController;
- BOOL _allowsMagnification;
- BOOL _allowsBackForwardNavigationGestures;
-
</del><span class="cx"> CGFloat _totalHeightOfBanners;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1010,48 +993,14 @@
</span><span class="cx">
</span><span class="cx"> #undef NATIVE_MOUSE_EVENT_HANDLER
</span><span class="cx">
</span><del>-- (void)_ensureGestureController
-{
- if (_data->_gestureController)
- return;
-
- _data->_gestureController = std::make_unique<ViewGestureController>(*_data->_page);
-}
-
</del><span class="cx"> - (void)scrollWheel:(NSEvent *)event
</span><span class="cx"> {
</span><del>- if (_data->_impl->ignoresAllEvents())
- return;
-
- if (event.phase == NSEventPhaseBegan)
- [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
- if (_data->_allowsBackForwardNavigationGestures) {
- [self _ensureGestureController];
- if (_data->_gestureController->handleScrollWheelEvent(event))
- return;
- }
-
- NativeWebWheelEvent webEvent = NativeWebWheelEvent(event, self);
- _data->_page->handleWheelEvent(webEvent);
</del><ins>+ _data->_impl->scrollWheel(event);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)swipeWithEvent:(NSEvent *)event
</span><span class="cx"> {
</span><del>- if (_data->_impl->ignoresNonWheelEvents())
- return;
-
- if (!_data->_allowsBackForwardNavigationGestures) {
- [super swipeWithEvent:event];
- return;
- }
-
- if (event.deltaX > 0.0)
- _data->_page->goBack();
- else if (event.deltaX < 0.0)
- _data->_page->goForward();
- else
- [super swipeWithEvent:event];
</del><ins>+ _data->_impl->swipeWithEvent(event);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)mouseMoved:(NSEvent *)event
</span><span class="lines">@@ -2078,6 +2027,21 @@
</span><span class="cx"> [super quickLookWithEvent:event];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)_superSwipeWithEvent:(NSEvent *)event
+{
+ [super swipeWithEvent:event];
+}
+
+- (void)_superMagnifyWithEvent:(NSEvent *)event
+{
+ [super magnifyWithEvent:event];
+}
+
+- (void)_superSmartMagnifyWithEvent:(NSEvent *)event
+{
+ [super smartMagnifyWithEvent:event];
+}
+
</ins><span class="cx"> - (void)_superRemoveTrackingRect:(NSTrackingRectTag)tag
</span><span class="cx"> {
</span><span class="cx"> [super removeTrackingRect:tag];
</span><span class="lines">@@ -2316,7 +2280,7 @@
</span><span class="cx">
</span><span class="cx"> [self _updateRemoteAccessibilityRegistration:NO];
</span><span class="cx">
</span><del>- _data->_gestureController = nullptr;
</del><ins>+ _data->_impl->resetGestureController();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_pageClosed
</span><span class="lines">@@ -2419,81 +2383,6 @@
</span><span class="cx"> _data->_impl->toolTipChanged(oldToolTip, newToolTip);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static RetainPtr<CGImageRef> takeWindowSnapshot(CGSWindowID windowID, bool captureAtNominalResolution)
-{
- CGSWindowCaptureOptions options = kCGSCaptureIgnoreGlobalClipShape;
- if (captureAtNominalResolution)
- options |= kCGSWindowCaptureNominalResolution;
- RetainPtr<CFArrayRef> windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &windowID, 1, options));
-
- if (windowSnapshotImages && CFArrayGetCount(windowSnapshotImages.get()))
- return (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
-
- // Fall back to the non-hardware capture path if we didn't get a snapshot
- // (which usually happens if the window is fully off-screen).
- CGWindowImageOption imageOptions = kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque;
- if (captureAtNominalResolution)
- imageOptions |= kCGWindowImageNominalResolution;
- return adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, imageOptions));
-}
-
-- (PassRefPtr<ViewSnapshot>)_takeViewSnapshot
-{
- NSWindow *window = self.window;
-
- CGSWindowID windowID = (CGSWindowID)[window windowNumber];
- if (!windowID || ![window isVisible])
- return nullptr;
-
- RetainPtr<CGImageRef> windowSnapshotImage = takeWindowSnapshot(windowID, false);
- if (!windowSnapshotImage)
- return nullptr;
-
- // Work around <rdar://problem/17084993>; re-request the snapshot at kCGWindowImageNominalResolution if it was captured at the wrong scale.
- CGFloat desiredSnapshotWidth = window.frame.size.width * window.screen.backingScaleFactor;
- if (CGImageGetWidth(windowSnapshotImage.get()) != desiredSnapshotWidth)
- windowSnapshotImage = takeWindowSnapshot(windowID, true);
-
- if (!windowSnapshotImage)
- return nullptr;
-
- [self _ensureGestureController];
-
- NSRect windowCaptureRect;
- FloatRect boundsForCustomSwipeViews = _data->_gestureController->windowRelativeBoundsForCustomSwipeViews();
- if (!boundsForCustomSwipeViews.isEmpty())
- windowCaptureRect = boundsForCustomSwipeViews;
- else {
- NSRect unobscuredBounds = self.bounds;
- float topContentInset = _data->_page->topContentInset();
- unobscuredBounds.origin.y += topContentInset;
- unobscuredBounds.size.height -= topContentInset;
- windowCaptureRect = [self convertRect:unobscuredBounds toView:nil];
- }
-
- NSRect windowCaptureScreenRect = [window convertRectToScreen:windowCaptureRect];
- CGRect windowScreenRect;
- CGSGetScreenRectForWindow(CGSMainConnectionID(), (CGSWindowID)[window windowNumber], &windowScreenRect);
-
- NSRect croppedImageRect = windowCaptureRect;
- croppedImageRect.origin.y = windowScreenRect.size.height - windowCaptureScreenRect.size.height - NSMinY(windowCaptureRect);
-
- auto croppedSnapshotImage = adoptCF(CGImageCreateWithImageInRect(windowSnapshotImage.get(), NSRectToCGRect([window convertRectToBacking:croppedImageRect])));
-
- auto surface = IOSurface::createFromImage(croppedSnapshotImage.get());
- if (!surface)
- return nullptr;
- surface->setIsVolatile(true);
-
- return ViewSnapshot::create(WTF::move(surface));
-}
-
-- (void)_wheelEventWasNotHandledByWebCore:(NSEvent *)event
-{
- if (_data->_gestureController)
- _data->_gestureController->wheelEventWasNotHandledByWebCore(event);
-}
-
</del><span class="cx"> - (void)_setAccessibilityWebProcessToken:(NSData *)data
</span><span class="cx"> {
</span><span class="cx"> _data->_remoteAccessibilityChild = WKAXRemoteElementForToken(data);
</span><span class="lines">@@ -2784,12 +2673,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // WK_API_ENABLED
</span><span class="cx">
</span><del>-- (void)_didFirstVisuallyNonEmptyLayoutForMainFrame
-{
- if (_data->_gestureController)
- _data->_gestureController->didFirstVisuallyNonEmptyLayoutForMainFrame();
-}
-
</del><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> - (_WKRemoteObjectRegistry *)_remoteObjectRegistry
</span><span class="cx"> {
</span><span class="lines">@@ -2802,30 +2685,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-- (void)_didFinishLoadForMainFrame
-{
- if (_data->_gestureController)
- _data->_gestureController->didFinishLoadForMainFrame();
-}
-
-- (void)_didFailLoadForMainFrame
-{
- if (_data->_gestureController)
- _data->_gestureController->didFailLoadForMainFrame();
-}
-
-- (void)_didSameDocumentNavigationForMainFrame:(SameDocumentNavigationType)type
-{
- if (_data->_gestureController)
- _data->_gestureController->didSameDocumentNavigationForMainFrame(type);
-}
-
-- (void)_removeNavigationGestureSnapshot
-{
- if (_data->_gestureController)
- _data->_gestureController->removeSwipeSnapshot();
-}
-
</del><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
</span><span class="cx"> - (void)_startWindowDrag
</span><span class="cx"> {
</span><span class="lines">@@ -3064,14 +2923,12 @@
</span><span class="cx">
</span><span class="cx"> - (void)setAllowsBackForwardNavigationGestures:(BOOL)allowsBackForwardNavigationGestures
</span><span class="cx"> {
</span><del>- _data->_allowsBackForwardNavigationGestures = allowsBackForwardNavigationGestures;
- _data->_page->setShouldRecordNavigationSnapshots(allowsBackForwardNavigationGestures);
- _data->_page->setShouldUseImplicitRubberBandControl(allowsBackForwardNavigationGestures);
</del><ins>+ _data->_impl->setAllowsBackForwardNavigationGestures(allowsBackForwardNavigationGestures);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)allowsBackForwardNavigationGestures
</span><span class="cx"> {
</span><del>- return _data->_allowsBackForwardNavigationGestures;
</del><ins>+ return _data->_impl->allowsBackForwardNavigationGestures();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)allowsLinkPreview
</span><span class="lines">@@ -3271,145 +3128,69 @@
</span><span class="cx">
</span><span class="cx"> - (void)setAllowsMagnification:(BOOL)allowsMagnification
</span><span class="cx"> {
</span><del>- _data->_allowsMagnification = allowsMagnification;
</del><ins>+ _data->_impl->setAllowsMagnification(allowsMagnification);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)allowsMagnification
</span><span class="cx"> {
</span><del>- return _data->_allowsMagnification;
</del><ins>+ return _data->_impl->allowsMagnification();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)magnifyWithEvent:(NSEvent *)event
</span><span class="cx"> {
</span><del>- if (!_data->_allowsMagnification) {
-#if ENABLE(MAC_GESTURE_EVENTS)
- NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
- _data->_page->handleGestureEvent(webEvent);
-#endif
- [super magnifyWithEvent:event];
- return;
- }
-
- [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
- [self _ensureGestureController];
-
-#if ENABLE(MAC_GESTURE_EVENTS)
- if (_data->_gestureController->hasActiveMagnificationGesture()) {
- _data->_gestureController->handleMagnificationGestureEvent(event, [self convertPoint:event.locationInWindow fromView:nil]);
- return;
- }
-
- NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
- _data->_page->handleGestureEvent(webEvent);
-#else
- _data->_gestureController->handleMagnificationGestureEvent(event, [self convertPoint:event.locationInWindow fromView:nil]);
-#endif
</del><ins>+ _data->_impl->magnifyWithEvent(event);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MAC_GESTURE_EVENTS)
</span><span class="cx"> - (void)rotateWithEvent:(NSEvent *)event
</span><span class="cx"> {
</span><del>- NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
- _data->_page->handleGestureEvent(webEvent);
</del><ins>+ _data->_impl->rotateWithEvent(event);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> - (void)_gestureEventWasNotHandledByWebCore:(NSEvent *)event
</span><span class="cx"> {
</span><del>-#if ENABLE(MAC_GESTURE_EVENTS)
- if (_data->_gestureController)
- _data->_gestureController->gestureEventWasNotHandledByWebCore(event, [self convertPoint:event.locationInWindow fromView:nil]);
-#endif
</del><ins>+ _data->_impl->gestureEventWasNotHandledByWebCoreFromViewOnly(event);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)smartMagnifyWithEvent:(NSEvent *)event
</span><span class="cx"> {
</span><del>- if (!_data->_allowsMagnification) {
- [super smartMagnifyWithEvent:event];
- return;
- }
-
- [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
- [self _ensureGestureController];
-
- _data->_gestureController->handleSmartMagnificationGesture([self convertPoint:event.locationInWindow fromView:nil]);
</del><ins>+ _data->_impl->smartMagnifyWithEvent(event);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)setMagnification:(double)magnification centeredAtPoint:(NSPoint)point
</span><span class="cx"> {
</span><del>- if (magnification <= 0 || isnan(magnification) || isinf(magnification))
- [NSException raise:NSInvalidArgumentException format:@"Magnification should be a positive number"];
-
- [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
- _data->_page->scalePageInViewCoordinates(magnification, roundedIntPoint(point));
</del><ins>+ _data->_impl->setMagnification(magnification, NSPointToCGPoint(point));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)setMagnification:(double)magnification
</span><span class="cx"> {
</span><del>- if (magnification <= 0 || isnan(magnification) || isinf(magnification))
- [NSException raise:NSInvalidArgumentException format:@"Magnification should be a positive number"];
-
- [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
- FloatPoint viewCenter(NSMidX([self bounds]), NSMidY([self bounds]));
- _data->_page->scalePageInViewCoordinates(magnification, roundedIntPoint(viewCenter));
</del><ins>+ _data->_impl->setMagnification(magnification);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (double)magnification
</span><span class="cx"> {
</span><del>- if (_data->_gestureController)
- return _data->_gestureController->magnification();
-
- return _data->_page->pageScaleFactor();
</del><ins>+ return _data->_impl->magnification();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_setCustomSwipeViews:(NSArray *)customSwipeViews
</span><span class="cx"> {
</span><del>- if (!customSwipeViews.count && !_data->_gestureController)
- return;
-
- [self _ensureGestureController];
-
- Vector<RetainPtr<NSView>> views;
- for (NSView *view in customSwipeViews)
- views.append(view);
-
- _data->_gestureController->setCustomSwipeViews(views);
</del><ins>+ _data->_impl->setCustomSwipeViews(customSwipeViews);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_setCustomSwipeViewsTopContentInset:(float)topContentInset
</span><span class="cx"> {
</span><del>- [self _ensureGestureController];
- _data->_gestureController->setCustomSwipeViewsTopContentInset(topContentInset);
</del><ins>+ _data->_impl->setCustomSwipeViewsTopContentInset(topContentInset);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)_tryToSwipeWithEvent:(NSEvent *)event ignoringPinnedState:(BOOL)ignoringPinnedState
</span><span class="cx"> {
</span><del>- if (!_data->_allowsBackForwardNavigationGestures)
- return NO;
-
- [self _ensureGestureController];
-
- BOOL wasIgnoringPinnedState = _data->_gestureController->shouldIgnorePinnedState();
- _data->_gestureController->setShouldIgnorePinnedState(ignoringPinnedState);
-
- BOOL handledEvent = _data->_gestureController->handleScrollWheelEvent(event);
-
- _data->_gestureController->setShouldIgnorePinnedState(wasIgnoringPinnedState);
-
- return handledEvent;
</del><ins>+ return _data->_impl->tryToSwipeWithEvent(event, ignoringPinnedState);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_setDidMoveSwipeSnapshotCallback:(void(^)(CGRect))callback
</span><span class="cx"> {
</span><del>- if (!_data->_allowsBackForwardNavigationGestures)
- return;
-
- [self _ensureGestureController];
- _data->_gestureController->setDidMoveSwipeSnapshotCallback(callback);
</del><ins>+ _data->_impl->setDidMoveSwipeSnapshotCallback(callback);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (id)_immediateActionAnimationControllerForHitTestResult:(WKHitTestResultRef)hitTestResult withType:(uint32_t)type userData:(WKTypeRef)userData
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -87,9 +87,6 @@
</span><span class="cx"> - (NSRect)_convertToDeviceSpace:(NSRect)rect;
</span><span class="cx"> - (NSRect)_convertToUserSpace:(NSRect)rect;
</span><span class="cx">
</span><del>-- (PassRefPtr<WebKit::ViewSnapshot>)_takeViewSnapshot;
-- (void)_wheelEventWasNotHandledByWebCore:(NSEvent *)event;
-
</del><span class="cx"> - (void)_setAccessibilityWebProcessToken:(NSData *)data;
</span><span class="cx">
</span><span class="cx"> - (void)_dragImageForView:(NSView *)view withImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
</span><span class="lines">@@ -106,12 +103,6 @@
</span><span class="cx"> - (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates;
</span><span class="cx"> - (BOOL)_suppressVisibilityUpdates;
</span><span class="cx">
</span><del>-- (void)_didFirstVisuallyNonEmptyLayoutForMainFrame;
-- (void)_didFinishLoadForMainFrame;
-- (void)_didFailLoadForMainFrame;
-- (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)type;
-- (void)_removeNavigationGestureSnapshot;
-
</del><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> @property (nonatomic, setter=_setThumbnailView:) _WKThumbnailView *_thumbnailView;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -52,6 +52,9 @@
</span><span class="cx"> - (NSTextInputContext *)_superInputContext;
</span><span class="cx"> - (void)_superQuickLookWithEvent:(NSEvent *)event;
</span><span class="cx"> - (void)_superRemoveTrackingRect:(NSTrackingRectTag)tag;
</span><ins>+- (void)_superSwipeWithEvent:(NSEvent *)event;
+- (void)_superMagnifyWithEvent:(NSEvent *)event;
+- (void)_superSmartMagnifyWithEvent:(NSEvent *)event;
</ins><span class="cx">
</span><span class="cx"> // This is a hack; these things live can live on a category (e.g. WKView (Private)) but WKView itself conforms to this protocol.
</span><span class="cx"> // They're not actually optional.
</span><span class="lines">@@ -63,11 +66,13 @@
</span><span class="cx"> - (void)_completeImmediateActionAnimation;
</span><span class="cx"> - (void)_dismissContentRelativeChildWindows;
</span><span class="cx"> - (void)_dismissContentRelativeChildWindowsWithAnimation:(BOOL)animate;
</span><ins>+- (void)_gestureEventWasNotHandledByWebCore:(NSEvent *)event;
</ins><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><ins>+class ViewGestureController;
</ins><span class="cx"> class WebEditCommandProxy;
</span><span class="cx"> class WebPageProxy;
</span><span class="cx"> struct ColorSpaceData;
</span><span class="lines">@@ -250,6 +255,33 @@
</span><span class="cx"> void registerDraggedTypes();
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+ RefPtr<ViewSnapshot> takeViewSnapshot();
+
+ ViewGestureController* gestureController() { return m_gestureController.get(); }
+ ViewGestureController& ensureGestureController();
+ void resetGestureController();
+ void setAllowsBackForwardNavigationGestures(bool);
+ bool allowsBackForwardNavigationGestures() const { return m_allowsBackForwardNavigationGestures; }
+ void setAllowsMagnification(bool);
+ bool allowsMagnification() const { return m_allowsMagnification; }
+
+ void setMagnification(double, CGPoint centerPoint);
+ void setMagnification(double);
+ double magnification() const;
+ void setCustomSwipeViews(NSArray *);
+ void setCustomSwipeViewsTopContentInset(float);
+ bool tryToSwipeWithEvent(NSEvent *, bool ignoringPinnedState);
+ void setDidMoveSwipeSnapshotCallback(void(^)(CGRect));
+
+ void scrollWheel(NSEvent *);
+ void swipeWithEvent(NSEvent *);
+ void magnifyWithEvent(NSEvent *);
+ void rotateWithEvent(NSEvent *);
+ void smartMagnifyWithEvent(NSEvent *);
+
+ void gestureEventWasNotHandledByWebCore(NSEvent *);
+ void gestureEventWasNotHandledByWebCoreFromViewOnly(NSEvent *);
+
</ins><span class="cx"> private:
</span><span class="cx"> WeakPtr<WebViewImpl> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
</span><span class="cx">
</span><span class="lines">@@ -346,6 +378,10 @@
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> _WKThumbnailView *m_thumbnailView { nullptr };
</span><span class="cx"> #endif
</span><ins>+
+ std::unique_ptr<ViewGestureController> m_gestureController;
+ bool m_allowsBackForwardNavigationGestures { false };
+ bool m_allowsMagnification { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -31,11 +31,14 @@
</span><span class="cx"> #import "ColorSpaceData.h"
</span><span class="cx"> #import "GenericCallback.h"
</span><span class="cx"> #import "Logging.h"
</span><ins>+#import "NativeWebGestureEvent.h"
</ins><span class="cx"> #import "NativeWebKeyboardEvent.h"
</span><span class="cx"> #import "NativeWebMouseEvent.h"
</span><ins>+#import "NativeWebWheelEvent.h"
</ins><span class="cx"> #import "PageClient.h"
</span><span class="cx"> #import "PasteboardTypes.h"
</span><span class="cx"> #import "StringUtilities.h"
</span><ins>+#import "ViewGestureController.h"
</ins><span class="cx"> #import "WKFullScreenWindowController.h"
</span><span class="cx"> #import "WKImmediateActionController.h"
</span><span class="cx"> #import "WKTextInputWindowController.h"
</span><span class="lines">@@ -47,6 +50,7 @@
</span><span class="cx"> #import "_WKThumbnailViewInternal.h"
</span><span class="cx"> #import <HIToolbox/CarbonEventsCore.h>
</span><span class="cx"> #import <WebCore/AXObjectCache.h>
</span><ins>+#import <WebCore/CoreGraphicsSPI.h>
</ins><span class="cx"> #import <WebCore/DataDetectorsSPI.h>
</span><span class="cx"> #import <WebCore/DictionaryLookup.h>
</span><span class="cx"> #import <WebCore/DragData.h>
</span><span class="lines">@@ -1809,6 +1813,264 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(DRAG_SUPPORT)
</span><span class="cx">
</span><ins>+static RetainPtr<CGImageRef> takeWindowSnapshot(CGSWindowID windowID, bool captureAtNominalResolution)
+{
+ CGSWindowCaptureOptions options = kCGSCaptureIgnoreGlobalClipShape;
+ if (captureAtNominalResolution)
+ options |= kCGSWindowCaptureNominalResolution;
+ RetainPtr<CFArrayRef> windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &windowID, 1, options));
+
+ if (windowSnapshotImages && CFArrayGetCount(windowSnapshotImages.get()))
+ return (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
+
+ // Fall back to the non-hardware capture path if we didn't get a snapshot
+ // (which usually happens if the window is fully off-screen).
+ CGWindowImageOption imageOptions = kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque;
+ if (captureAtNominalResolution)
+ imageOptions |= kCGWindowImageNominalResolution;
+ return adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, imageOptions));
+}
+
+RefPtr<ViewSnapshot> WebViewImpl::takeViewSnapshot()
+{
+ NSWindow *window = m_view.window;
+
+ CGSWindowID windowID = (CGSWindowID)window.windowNumber;
+ if (!windowID || !window.isVisible)
+ return nullptr;
+
+ RetainPtr<CGImageRef> windowSnapshotImage = takeWindowSnapshot(windowID, false);
+ if (!windowSnapshotImage)
+ return nullptr;
+
+ // Work around <rdar://problem/17084993>; re-request the snapshot at kCGWindowImageNominalResolution if it was captured at the wrong scale.
+ CGFloat desiredSnapshotWidth = window.frame.size.width * window.screen.backingScaleFactor;
+ if (CGImageGetWidth(windowSnapshotImage.get()) != desiredSnapshotWidth)
+ windowSnapshotImage = takeWindowSnapshot(windowID, true);
+
+ if (!windowSnapshotImage)
+ return nullptr;
+
+ ViewGestureController& gestureController = ensureGestureController();
+
+ NSRect windowCaptureRect;
+ WebCore::FloatRect boundsForCustomSwipeViews = gestureController.windowRelativeBoundsForCustomSwipeViews();
+ if (!boundsForCustomSwipeViews.isEmpty())
+ windowCaptureRect = boundsForCustomSwipeViews;
+ else {
+ NSRect unobscuredBounds = m_view.bounds;
+ float topContentInset = m_page.topContentInset();
+ unobscuredBounds.origin.y += topContentInset;
+ unobscuredBounds.size.height -= topContentInset;
+ windowCaptureRect = [m_view convertRect:unobscuredBounds toView:nil];
+ }
+
+ NSRect windowCaptureScreenRect = [window convertRectToScreen:windowCaptureRect];
+ CGRect windowScreenRect;
+ CGSGetScreenRectForWindow(CGSMainConnectionID(), (CGSWindowID)[window windowNumber], &windowScreenRect);
+
+ NSRect croppedImageRect = windowCaptureRect;
+ croppedImageRect.origin.y = windowScreenRect.size.height - windowCaptureScreenRect.size.height - NSMinY(windowCaptureRect);
+
+ auto croppedSnapshotImage = adoptCF(CGImageCreateWithImageInRect(windowSnapshotImage.get(), NSRectToCGRect([window convertRectToBacking:croppedImageRect])));
+
+ auto surface = WebCore::IOSurface::createFromImage(croppedSnapshotImage.get());
+ if (!surface)
+ return nullptr;
+ surface->setIsVolatile(true);
+
+ return ViewSnapshot::create(WTF::move(surface));
+}
+
+ViewGestureController& WebViewImpl::ensureGestureController()
+{
+ if (!m_gestureController)
+ m_gestureController = std::make_unique<ViewGestureController>(m_page);
+ return *m_gestureController;
+}
+
+void WebViewImpl::resetGestureController()
+{
+ m_gestureController = nullptr;
+}
+
+void WebViewImpl::setAllowsBackForwardNavigationGestures(bool allowsBackForwardNavigationGestures)
+{
+ m_allowsBackForwardNavigationGestures = allowsBackForwardNavigationGestures;
+ m_page.setShouldRecordNavigationSnapshots(allowsBackForwardNavigationGestures);
+ m_page.setShouldUseImplicitRubberBandControl(allowsBackForwardNavigationGestures);
+}
+
+void WebViewImpl::setAllowsMagnification(bool allowsMagnification)
+{
+ m_allowsMagnification = allowsMagnification;
+}
+
+void WebViewImpl::setMagnification(double magnification, CGPoint centerPoint)
+{
+ if (magnification <= 0 || isnan(magnification) || isinf(magnification))
+ [NSException raise:NSInvalidArgumentException format:@"Magnification should be a positive number"];
+
+ dismissContentRelativeChildWindowsWithAnimation(false);
+
+ m_page.scalePageInViewCoordinates(magnification, WebCore::roundedIntPoint(centerPoint));
+}
+
+void WebViewImpl::setMagnification(double magnification)
+{
+ if (magnification <= 0 || isnan(magnification) || isinf(magnification))
+ [NSException raise:NSInvalidArgumentException format:@"Magnification should be a positive number"];
+
+ dismissContentRelativeChildWindowsWithAnimation(false);
+
+ WebCore::FloatPoint viewCenter(NSMidX([m_view bounds]), NSMidY([m_view bounds]));
+ m_page.scalePageInViewCoordinates(magnification, roundedIntPoint(viewCenter));
+}
+
+double WebViewImpl::magnification() const
+{
+ if (m_gestureController)
+ return m_gestureController->magnification();
+ return m_page.pageScaleFactor();
+}
+
+void WebViewImpl::setCustomSwipeViews(NSArray *customSwipeViews)
+{
+ if (!customSwipeViews.count && !m_gestureController)
+ return;
+
+ Vector<RetainPtr<NSView>> views;
+ views.reserveInitialCapacity(customSwipeViews.count);
+ for (NSView *view in customSwipeViews)
+ views.uncheckedAppend(view);
+
+ ensureGestureController().setCustomSwipeViews(views);
+}
+
+void WebViewImpl::setCustomSwipeViewsTopContentInset(float topContentInset)
+{
+ ensureGestureController().setCustomSwipeViewsTopContentInset(topContentInset);
+}
+
+bool WebViewImpl::tryToSwipeWithEvent(NSEvent *event, bool ignoringPinnedState)
+{
+ if (!m_allowsBackForwardNavigationGestures)
+ return false;
+
+ auto& gestureController = ensureGestureController();
+
+ bool wasIgnoringPinnedState = gestureController.shouldIgnorePinnedState();
+ gestureController.setShouldIgnorePinnedState(ignoringPinnedState);
+
+ bool handledEvent = gestureController.handleScrollWheelEvent(event);
+
+ gestureController.setShouldIgnorePinnedState(wasIgnoringPinnedState);
+
+ return handledEvent;
+}
+
+void WebViewImpl::setDidMoveSwipeSnapshotCallback(void(^callback)(CGRect))
+{
+ if (!m_allowsBackForwardNavigationGestures)
+ return;
+
+ ensureGestureController().setDidMoveSwipeSnapshotCallback(callback);
+}
+
+void WebViewImpl::scrollWheel(NSEvent *event)
+{
+ if (m_ignoresAllEvents)
+ return;
+
+ if (event.phase == NSEventPhaseBegan)
+ dismissContentRelativeChildWindowsWithAnimation(false);
+
+ if (m_allowsBackForwardNavigationGestures && ensureGestureController().handleScrollWheelEvent(event))
+ return;
+
+ NativeWebWheelEvent webEvent = NativeWebWheelEvent(event, m_view);
+ m_page.handleWheelEvent(webEvent);
+}
+
+void WebViewImpl::swipeWithEvent(NSEvent *event)
+{
+ if (m_ignoresNonWheelEvents)
+ return;
+
+ if (!m_allowsBackForwardNavigationGestures) {
+ [m_view _superSwipeWithEvent:event];
+ return;
+ }
+
+ if (event.deltaX > 0.0)
+ m_page.goBack();
+ else if (event.deltaX < 0.0)
+ m_page.goForward();
+ else
+ [m_view _superSwipeWithEvent:event];
+}
+
+void WebViewImpl::magnifyWithEvent(NSEvent *event)
+{
+ if (!m_allowsMagnification) {
+#if ENABLE(MAC_GESTURE_EVENTS)
+ NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view);
+ m_page.handleGestureEvent(webEvent);
+#endif
+ [m_view _superMagnifyWithEvent:event];
+ return;
+ }
+
+ dismissContentRelativeChildWindowsWithAnimation(false);
+
+ auto& gestureController = ensureGestureController();
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+ if (gestureController.hasActiveMagnificationGesture()) {
+ gestureController.handleMagnificationGestureEvent(event, [m_view convertPoint:event.locationInWindow fromView:nil]);
+ return;
+ }
+
+ NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view);
+ m_page.handleGestureEvent(webEvent);
+#else
+ gestureController.handleMagnificationGestureEvent(event, [m_view convertPoint:event.locationInWindow fromView:nil]);
+#endif
+}
+
+void WebViewImpl::smartMagnifyWithEvent(NSEvent *event)
+{
+ if (!m_allowsMagnification) {
+ [m_view _superSmartMagnifyWithEvent:event];
+ return;
+ }
+
+ dismissContentRelativeChildWindowsWithAnimation(false);
+
+ ensureGestureController().handleSmartMagnificationGesture([m_view convertPoint:event.locationInWindow fromView:nil]);
+}
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+void WebViewImpl::rotateWithEvent(NSEvent *event)
+{
+ NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view);
+ m_page.handleGestureEvent(webEvent);
+}
+#endif
+
+void WebViewImpl::gestureEventWasNotHandledByWebCore(NSEvent *event)
+{
+ [m_view _gestureEventWasNotHandledByWebCore:event];
+}
+
+void WebViewImpl::gestureEventWasNotHandledByWebCoreFromViewOnly(NSEvent *event)
+{
+#if ENABLE(MAC_GESTURE_EVENTS)
+ if (m_gestureController)
+ m_gestureController->gestureEventWasNotHandledByWebCore(event, [m_view convertPoint:event.locationInWindow fromView:nil]);
+#endif
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #import "NativeWebWheelEvent.h"
</span><span class="cx"> #import "NavigationState.h"
</span><span class="cx"> #import "StringUtilities.h"
</span><ins>+#import "ViewGestureController.h"
</ins><span class="cx"> #import "ViewSnapshotStore.h"
</span><span class="cx"> #import "WKAPICast.h"
</span><span class="cx"> #import "WKFullScreenWindowController.h"
</span><span class="lines">@@ -514,7 +515,7 @@
</span><span class="cx">
</span><span class="cx"> PassRefPtr<ViewSnapshot> PageClientImpl::takeViewSnapshot()
</span><span class="cx"> {
</span><del>- return [m_wkView _takeViewSnapshot];
</del><ins>+ return m_impl->takeViewSnapshot();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PageClientImpl::selectionDidChange()
</span><span class="lines">@@ -524,7 +525,8 @@
</span><span class="cx">
</span><span class="cx"> void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
</span><span class="cx"> {
</span><del>- [m_wkView _wheelEventWasNotHandledByWebCore:event.nativeEvent()];
</del><ins>+ if (auto gestureController = m_impl->gestureController())
+ gestureController->wheelEventWasNotHandledByWebCore(event.nativeEvent());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MAC_GESTURE_EVENTS)
</span><span class="lines">@@ -747,27 +749,32 @@
</span><span class="cx">
</span><span class="cx"> void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
</span><span class="cx"> {
</span><del>- [m_wkView _didFirstVisuallyNonEmptyLayoutForMainFrame];
</del><ins>+ if (auto gestureController = m_impl->gestureController())
+ gestureController->didFirstVisuallyNonEmptyLayoutForMainFrame();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PageClientImpl::didFinishLoadForMainFrame()
</span><span class="cx"> {
</span><del>- [m_wkView _didFinishLoadForMainFrame];
</del><ins>+ if (auto gestureController = m_impl->gestureController())
+ gestureController->didFinishLoadForMainFrame();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PageClientImpl::didFailLoadForMainFrame()
</span><span class="cx"> {
</span><del>- [m_wkView _didFailLoadForMainFrame];
</del><ins>+ if (auto gestureController = m_impl->gestureController())
+ gestureController->didFailLoadForMainFrame();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
</span><span class="cx"> {
</span><del>- [m_wkView _didSameDocumentNavigationForMainFrame:type];
</del><ins>+ if (auto gestureController = m_impl->gestureController())
+ gestureController->didSameDocumentNavigationForMainFrame(type);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PageClientImpl::removeNavigationGestureSnapshot()
</span><span class="cx"> {
</span><del>- [m_wkView _removeNavigationGestureSnapshot];
</del><ins>+ if (auto gestureController = m_impl->gestureController())
+ gestureController->removeSwipeSnapshot();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PageClientImpl::didChangeBackgroundColor()
</span></span></pre>
</div>
</div>
</body>
</html>