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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173040
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-08-27 Tim Horton <timothy_horton@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-27 Tim Horton <timothy_horton@apple.com>
Occasional crashes in commitTransientZoom's transaction completion block
// 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
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
virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) = 0;
virtual void removeNavigationGestureSnapshot() = 0;
+ virtual CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const = 0;
+
virtual ColorSpaceData colorSpace() = 0;
#if USE(APPKIT)
WKView* wkView() const;
void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize);
+ CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const;
#endif
#endif // PLATFORM(COCOA)
#if PLATFORM(EFL)
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*);
[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)
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();
CALayer *determineSnapshotLayerParent() const;
CALayer *determineLayerAdjacentToSnapshotForParent(SwipeDirection, CALayer *snapshotLayerParent) const;
void applyDebuggingPropertiesToSwipeViews();
+ void didMoveSwipeSnapshotLayer();
#endif
WebPageProxy& m_webPageProxy;
SwipeDirection m_pendingSwipeDirection;
WebCore::FloatSize m_cumulativeDeltaForPendingSwipe;
+ void (^m_didMoveSwipeSnapshotCallback)(CGRect);
+
bool m_shouldIgnorePinnedState;
bool m_swipeWaitingForVisuallyNonEmptyLayout;
, m_swipeTransitionStyle(SwipeTransitionStyle::Overlap)
, m_customSwipeViewsTopContentInset(0)
, m_pendingSwipeReason(PendingSwipeReason::None)
+ , m_didMoveSwipeSnapshotCallback(nullptr)
, m_shouldIgnorePinnedState(false)
, m_swipeWaitingForVisuallyNonEmptyLayout(false)
, m_swipeWaitingForRenderTreeSizeThreshold(false)
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());
}
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) {
[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)
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)];
}
}
+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);
}
#endif
+CGRect WebPageProxy::boundsOfLayerInLayerBackedWindowCoordinates(CALayer *layer) const
+{
+ return m_pageClient.boundsOfLayerInLayerBackedWindowCoordinates(layer);
+}
+
} // namespace WebKit
#endif // PLATFORM(MAC)