Diff
Modified: branches/safari-600.1-branch/Source/WebKit2/ChangeLog (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/ChangeLog 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/ChangeLog 2014-08-29 00:09:46 UTC (rev 173094)
@@ -1,5 +1,47 @@
2014-08-28 Lucas Forschler <lforsch...@apple.com>
+ Merge r173040
+
+ 2014-08-27 Tim Horton <timothy_hor...@apple.com>
+
+ WebKit2 swipe gesture should report the position of the snapshot to the client
+ https://bugs.webkit.org/show_bug.cgi?id=136308
+ rdar://problem/18105827
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/API/Cocoa/WKViewPrivate.h:
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _setDidMoveSwipeSnapshotCallback:]):
+ Add _setDidMoveSwipeSnapshotCallback, and plumb it to ViewGestureController.
+ Callers provide a block which is called whenever ViewGestureController moves the
+ swipe *snapshot* layer around.
+
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::boundsOfLayerInLayerBackedWindowCoordinates):
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::boundsOfLayerInLayerBackedWindowCoordinates):
+ Expose a Mac-only way to get the bounds of a given CALayer in window coordinates,
+ respecting transforms. This only works for layer-backed windows because
+ it uses CA in order to do the mapping respecting transforms.
+
+ * UIProcess/mac/ViewGestureController.h:
+ * UIProcess/mac/ViewGestureControllerMac.mm:
+ (WebKit::ViewGestureController::ViewGestureController):
+ (WebKit::ViewGestureController::~ViewGestureController):
+ (WebKit::ViewGestureController::setDidMoveSwipeSnapshotCallback):
+ Do the Block_copy and Block_release dance to keep our copy of the callback block.
+
+ (WebKit::ViewGestureController::beginSwipeGesture):
+ (WebKit::ViewGestureController::handleSwipeGesture):
+ (WebKit::ViewGestureController::didMoveSwipeSnapshotLayer):
+ When the swipe snapshot layer moves around, call the block.
+
+2014-08-28 Lucas Forschler <lforsch...@apple.com>
+
Merge r173029
2014-08-27 Tim Horton <timothy_hor...@apple.com>
Modified: branches/safari-600.1-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h 2014-08-29 00:09:46 UTC (rev 173094)
@@ -113,6 +113,8 @@
// The top content inset is applied in the window's coordinate space, to the union of the custom swipe view's frames.
- (void)_setCustomSwipeViewsTopContentInset:(float)topContentInset;
- (BOOL)_tryToSwipeWithEvent:(NSEvent *)event ignoringPinnedState:(BOOL)ignoringPinnedState;
+// The rect returned is always that of the snapshot, not necessarily the swiping layer. This only works for layer-backed windows.
+- (void)_setDidMoveSwipeSnapshotCallback:(void(^)(CGRect swipeSnapshotRectInWindowCoordinates))callback;
#endif
Modified: branches/safari-600.1-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm 2014-08-29 00:09:46 UTC (rev 173094)
@@ -4080,6 +4080,15 @@
return handledEvent;
}
+- (void)_setDidMoveSwipeSnapshotCallback:(void(^)(CGRect))callback
+{
+ if (!_data->_allowsBackForwardNavigationGestures)
+ return;
+
+ [self _ensureGestureController];
+ _data->_gestureController->setDidMoveSwipeSnapshotCallback(callback);
+}
+
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
- (void)_setAutomaticallyAdjustsContentInsets:(BOOL)automaticallyAdjustsContentInsets
Modified: branches/safari-600.1-branch/Source/WebKit2/UIProcess/PageClient.h (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/UIProcess/PageClient.h 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/UIProcess/PageClient.h 2014-08-29 00:09:46 UTC (rev 173094)
@@ -231,6 +231,8 @@
virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) = 0;
virtual void removeNavigationGestureSnapshot() = 0;
+ virtual CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const = 0;
+
virtual ColorSpaceData colorSpace() = 0;
#if USE(APPKIT)
Modified: branches/safari-600.1-branch/Source/WebKit2/UIProcess/WebPageProxy.h (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/UIProcess/WebPageProxy.h 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/UIProcess/WebPageProxy.h 2014-08-29 00:09:46 UTC (rev 173094)
@@ -509,6 +509,7 @@
WKView* wkView() const;
void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize);
+ CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const;
#endif
#endif // PLATFORM(COCOA)
#if PLATFORM(EFL)
Modified: branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h 2014-08-29 00:09:46 UTC (rev 173094)
@@ -108,7 +108,9 @@
virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) = 0;
virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) = 0;
#endif
-
+
+ CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *layer) const;
+
virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled);
virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
Modified: branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2014-08-29 00:09:46 UTC (rev 173094)
@@ -742,6 +742,14 @@
[m_wkView _removeNavigationGestureSnapshot];
}
+CGRect PageClientImpl::boundsOfLayerInLayerBackedWindowCoordinates(CALayer *layer) const
+{
+ CALayer *windowContentLayer = static_cast<NSView *>(m_wkView.window.contentView).layer;
+ ASSERT(windowContentLayer);
+
+ return [windowContentLayer convertRect:layer.bounds fromLayer:layer];
+}
+
} // namespace WebKit
#endif // PLATFORM(MAC)
Modified: branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/ViewGestureController.h (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/ViewGestureController.h 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/ViewGestureController.h 2014-08-29 00:09:46 UTC (rev 173094)
@@ -100,6 +100,7 @@
void setCustomSwipeViews(Vector<RetainPtr<NSView>> views) { m_customSwipeViews = WTF::move(views); }
void setCustomSwipeViewsTopContentInset(float topContentInset) { m_customSwipeViewsTopContentInset = topContentInset; }
WebCore::FloatRect windowRelativeBoundsForCustomSwipeViews() const;
+ void setDidMoveSwipeSnapshotCallback(void(^)(CGRect));
void endActiveGesture();
@@ -148,6 +149,7 @@
CALayer *determineSnapshotLayerParent() const;
CALayer *determineLayerAdjacentToSnapshotForParent(SwipeDirection, CALayer *snapshotLayerParent) const;
void applyDebuggingPropertiesToSwipeViews();
+ void didMoveSwipeSnapshotLayer();
#endif
WebPageProxy& m_webPageProxy;
@@ -189,6 +191,8 @@
SwipeDirection m_pendingSwipeDirection;
WebCore::FloatSize m_cumulativeDeltaForPendingSwipe;
+ void (^m_didMoveSwipeSnapshotCallback)(CGRect);
+
bool m_shouldIgnorePinnedState;
bool m_swipeWaitingForVisuallyNonEmptyLayout;
Modified: branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm 2014-08-29 00:09:46 UTC (rev 173094)
@@ -106,6 +106,7 @@
, m_swipeTransitionStyle(SwipeTransitionStyle::Overlap)
, m_customSwipeViewsTopContentInset(0)
, m_pendingSwipeReason(PendingSwipeReason::None)
+ , m_didMoveSwipeSnapshotCallback(nullptr)
, m_shouldIgnorePinnedState(false)
, m_swipeWaitingForVisuallyNonEmptyLayout(false)
, m_swipeWaitingForRenderTreeSizeThreshold(false)
@@ -123,6 +124,11 @@
if (m_activeGestureType == ViewGestureType::Swipe)
removeSwipeSnapshot();
+ if (m_didMoveSwipeSnapshotCallback) {
+ Block_release(m_didMoveSwipeSnapshotCallback);
+ m_didMoveSwipeSnapshotCallback = nullptr;
+ }
+
m_webPageProxy.process().removeMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID());
}
@@ -315,6 +321,13 @@
return true;
}
+void ViewGestureController::setDidMoveSwipeSnapshotCallback(void(^callback)(CGRect))
+{
+ if (m_didMoveSwipeSnapshotCallback)
+ Block_release(m_didMoveSwipeSnapshotCallback);
+ m_didMoveSwipeSnapshotCallback = Block_copy(callback);
+}
+
bool ViewGestureController::handleScrollWheelEvent(NSEvent *event)
{
if (event.phase == NSEventPhaseEnded) {
@@ -595,6 +608,8 @@
[snapshotLayerParent insertSublayer:m_swipeLayer.get() below:layerAdjacentToSnapshot];
else
[snapshotLayerParent insertSublayer:m_swipeLayer.get() above:layerAdjacentToSnapshot];
+
+ didMoveSwipeSnapshotLayer();
}
void ViewGestureController::handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, SwipeDirection direction)
@@ -613,8 +628,10 @@
double swipingLayerOffset = floor(width * progress);
if (m_swipeTransitionStyle == SwipeTransitionStyle::Overlap) {
- if (direction == SwipeDirection::Right)
+ if (direction == SwipeDirection::Right) {
[m_swipeLayer setTransform:CATransform3DMakeTranslation(width + swipingLayerOffset, 0, 0)];
+ didMoveSwipeSnapshotLayer();
+ }
} else if (m_swipeTransitionStyle == SwipeTransitionStyle::Push)
[m_swipeLayer setTransform:CATransform3DMakeTranslation((direction == SwipeDirection::Left ? -width : width) + swipingLayerOffset, 0, 0)];
@@ -627,6 +644,14 @@
}
}
+void ViewGestureController::didMoveSwipeSnapshotLayer()
+{
+ if (!m_didMoveSwipeSnapshotCallback)
+ return;
+
+ m_didMoveSwipeSnapshotCallback(m_webPageProxy.boundsOfLayerInLayerBackedWindowCoordinates(m_swipeLayer.get()));
+}
+
void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem, bool cancelled)
{
ASSERT(m_activeGestureType == ViewGestureType::Swipe);
Modified: branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (173093 => 173094)
--- branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm 2014-08-29 00:01:39 UTC (rev 173093)
+++ branches/safari-600.1-branch/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm 2014-08-29 00:09:46 UTC (rev 173094)
@@ -663,6 +663,11 @@
}
#endif
+CGRect WebPageProxy::boundsOfLayerInLayerBackedWindowCoordinates(CALayer *layer) const
+{
+ return m_pageClient.boundsOfLayerInLayerBackedWindowCoordinates(layer);
+}
+
} // namespace WebKit
#endif // PLATFORM(MAC)