Diff
Modified: trunk/Source/WebCore/ChangeLog (164465 => 164466)
--- trunk/Source/WebCore/ChangeLog 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebCore/ChangeLog 2014-02-21 04:53:48 UTC (rev 164466)
@@ -1,3 +1,15 @@
+2014-02-20 Benjamin Poulain <[email protected]>
+
+ Start fixing the view states driven by the WKScrollView
+ https://bugs.webkit.org/show_bug.cgi?id=129140
+
+ Reviewed by Tim Horton and Simon Fraser.
+
+ * platform/graphics/ca/mac/TileController.mm:
+ (WebCore::TileController::scaledExposedRect):
+ That comment was more confusing than helping. FrameView-relative coordinates should not need
+ scaling.
+
2014-02-20 Gyuyoung Kim <[email protected]>
Start to use std::unique_ptr for DragImageLoader
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm (164465 => 164466)
--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm 2014-02-21 04:53:48 UTC (rev 164466)
@@ -319,7 +319,6 @@
FloatRect TileController::scaledExposedRect() const
{
- // Since the exposedRect is in FrameView-relative coordinates, we need to scale into document space.
FloatRect scaledExposedRect = m_exposedRect;
scaledExposedRect.scale(1 / m_scale);
return scaledExposedRect;
Modified: trunk/Source/WebKit2/ChangeLog (164465 => 164466)
--- trunk/Source/WebKit2/ChangeLog 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/ChangeLog 2014-02-21 04:53:48 UTC (rev 164466)
@@ -1,3 +1,60 @@
+2014-02-20 Benjamin Poulain <[email protected]>
+
+ Start fixing the view states driven by the WKScrollView
+ https://bugs.webkit.org/show_bug.cgi?id=129140
+
+ Reviewed by Tim Horton and Simon Fraser.
+
+ WKScrollView creates a "window" over WKContentView with an area that is exposed,
+ an area that is unobcured and with a certain scale.
+
+ Instead of having 3 loosely related paths for updating WKContentView
+ when the content "window" change, everything is consolidated behind the
+ single API -[WKContentView didUpdateVisibleRect:unobscuredRect:scale:].
+
+ This patch only fixes the content updates from the UI process side to keep things simple.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _didFinishScrolling]):
+ (-[WKWebView scrollViewDidEndDragging:willDecelerate:]):
+ (-[WKWebView scrollViewDidEndDecelerating:]):
+ (-[WKWebView scrollViewDidScrollToTop:]):
+ (-[WKWebView scrollViewDidScroll:]):
+ (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
+ (-[WKWebView _frameOrBoundsChanged]):
+ (-[WKWebView _updateContentWindow]):
+ (-[WKWebView _setObscuredInsets:]):
+ * UIProcess/API/ios/WKContentView.h:
+ * UIProcess/API/ios/WKContentView.mm:
+ (-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:]):
+ (-[WKContentView _updateFixedPositionRect]):
+ (-[WKContentView didFinishScrolling]):
+ (-[WKContentView didZoomToScale:]):
+ * UIProcess/API/ios/WKViewIOS.mm:
+ (-[WKView contentView:didCommitLayerTree:]):
+ (-[WKView _didFinishScrolling]):
+ (-[WKView scrollViewDidEndDragging:willDecelerate:]):
+ (-[WKView scrollViewDidEndDecelerating:]):
+ (-[WKView scrollViewDidScrollToTop:]):
+ (-[WKView scrollViewDidScroll:]):
+ (-[WKView scrollViewDidEndZooming:withView:atScale:]):
+ Scrolling is modified to take into account the view position and the obcured content.
+ Instead of driving the scrolling position from the UIScrollView delegate callbacks,
+ we use changes in unobscured rect to find changes in "content visible scroll position".
+
+ WebPageProxy::didFinishScrolling() is removed. All the scrollOffset updates now go through
+ the ScrollingCoordinator.
+
+ (-[WKView _frameOrBoundsChanged]):
+ (-[WKView _updateContentWindow]):
+ (-[WKView _setObscuredInsets:]):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::unobscuredContentRect):
+ (WebKit::WebPageProxy::setUnobscuredContentRect):
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+
2014-02-20 Tim Horton <[email protected]>
Fix a build warning by moving some WKWebView methods from the private category to WKWebView itself.
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (164465 => 164466)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2014-02-21 04:53:48 UTC (rev 164466)
@@ -356,38 +356,38 @@
[_contentView willStartZoomOrScroll];
}
-- (void)_didFinishScroll
+- (void)_didFinishScrolling
{
- CGPoint position = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
- [_contentView didFinishScrollTo:position];
+ [self _updateVisibleContentRects];
+ [_contentView didFinishScrolling];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
// If we're decelerating, scroll offset will be updated when scrollViewDidFinishDecelerating: is called.
if (!decelerate)
- [self _didFinishScroll];
+ [self _didFinishScrolling];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
- [self _didFinishScroll];
+ [self _didFinishScrolling];
}
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
{
- [self _didFinishScroll];
+ [self _didFinishScrolling];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
- CGPoint position = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
- [_contentView didScrollTo:position];
+ [self _updateVisibleContentRects];
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
{
ASSERT(scrollView == _scrollView);
+ [self _updateVisibleContentRects];
[_contentView didZoomToScale:scale];
}
@@ -399,17 +399,20 @@
[_contentView setMinimumLayoutSize:bounds.size];
[_scrollView setFrame:bounds];
[_contentView setMinimumSize:bounds.size];
+ [self _updateVisibleContentRects];
}
-- (void)_setDocumentScale:(CGFloat)newScale
+- (void)_updateVisibleContentRects
{
- CGPoint contentOffsetInDocumentCoordinates = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
+ CGRect fullViewRect = self.bounds;
+ CGRect visibleRectInContentCoordinates = [self convertRect:fullViewRect toView:_contentView.get()];
- [_scrollView setZoomScale:newScale];
- [_contentView didZoomToScale:newScale];
+ CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, _obscuredInsets);
+ CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()];
- CGPoint contentOffset = [_scrollView convertPoint:contentOffsetInDocumentCoordinates fromView:_contentView.get()];
- [_scrollView setContentOffset:contentOffset];
+ CGFloat scaleFactor = [_scrollView zoomScale];
+
+ [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates scale:scaleFactor];
}
- (void)_keyboardChangedWithInfo:(NSDictionary *)keyboardInfo adjustScrollView:(BOOL)adjustScrollView
@@ -672,6 +675,7 @@
ASSERT(obscuredInsets.bottom >= 0);
ASSERT(obscuredInsets.right >= 0);
_obscuredInsets = obscuredInsets;
+ [self _updateVisibleContentRects];
}
- (UIColor *)_pageExtendedBackgroundColor
Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h (164465 => 164466)
--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h 2014-02-21 04:53:48 UTC (rev 164466)
@@ -62,9 +62,9 @@
- (void)setMinimumSize:(CGSize)size;
- (void)setMinimumLayoutSize:(CGSize)size;
+- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale;
-- (void)didFinishScrollTo:(CGPoint)contentOffset;
-- (void)didScrollTo:(CGPoint)contentOffset;
+- (void)didFinishScrolling;
- (void)didZoomToScale:(CGFloat)scale;
- (void)willStartZoomOrScroll;
- (void)willStartUserTriggeredZoom;
Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm (164465 => 164466)
--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm 2014-02-21 04:53:48 UTC (rev 164466)
@@ -68,8 +68,6 @@
RetainPtr<UIView> _rootContentView;
RetainPtr<WKInteractionView> _interactionView;
-
- WebCore::FloatPoint _currentExposedRectPosition;
}
- (instancetype)initWithFrame:(CGRect)frame context:(WebKit::WebContext&)context configuration:(WebKit::WebPageConfiguration)webPageConfiguration
@@ -150,6 +148,20 @@
return [_interactionView isEditable];
}
+- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale
+{
+ _page->setUnobscuredContentRect(unobscuredRect);
+ _page->scrollingCoordinatorProxy()->scrollPositionChangedViaDelegatedScrolling(_page->scrollingCoordinatorProxy()->rootScrollingNodeID(), roundedIntPoint(unobscuredRect.origin));
+
+ if (auto drawingArea = _page->drawingArea()) {
+ FloatRect exposedRect = visibleRect;
+ exposedRect.scale(scale);
+ drawingArea->setExposedRect(exposedRect);
+ }
+
+ [self _updateFixedPositionRect];
+}
+
- (void)setMinimumSize:(CGSize)size
{
_page->drawingArea()->setSize(IntSize(size), IntSize(), IntSize());
@@ -162,22 +174,12 @@
return exposedRect;
}
-- (void)_updateViewExposedRect
-{
- FloatPoint exposedRectPosition = _currentExposedRectPosition;
- exposedRectPosition.scale(_page->pageScaleFactor(), _page->pageScaleFactor());
-
- if (auto drawingArea = _page->drawingArea())
- drawingArea->setExposedRect(FloatRect(exposedRectPosition, _page->drawingArea()->size()));
-}
-
- (void)_updateFixedPositionRect
{
auto drawingArea = _page->drawingArea();
if (!drawingArea)
return;
- FloatRect exposedRect(_currentExposedRectPosition, drawingArea->size());
- FloatRect fixedPosRect = [self fixedPositionRectFromExposedRect:exposedRect scale:_page->pageScaleFactor()];
+ FloatRect fixedPosRect = [self fixedPositionRectFromExposedRect:_page->unobscuredContentRect() scale:_page->pageScaleFactor()];
drawingArea->setCustomFixedPositionRect(fixedPosRect);
}
@@ -186,23 +188,12 @@
_page->setViewportConfigurationMinimumLayoutSize(IntSize(CGCeiling(size.width), CGCeiling(size.height)));
}
-- (void)didFinishScrollTo:(CGPoint)contentOffset
+- (void)didFinishScrolling
{
- _currentExposedRectPosition = contentOffset;
- _page->didFinishScrolling(contentOffset);
- [self _updateViewExposedRect];
[self _updateFixedPositionRect];
[_interactionView _didEndScrollingOrZooming];
}
-- (void)didScrollTo:(CGPoint)contentOffset
-{
- _currentExposedRectPosition = contentOffset;
- [self _updateViewExposedRect];
-
- _page->scrollingCoordinatorProxy()->scrollPositionChangedViaDelegatedScrolling(_page->scrollingCoordinatorProxy()->rootScrollingNodeID(), roundedIntPoint(contentOffset));
-}
-
- (void)willStartZoomOrScroll
{
[_interactionView _willStartScrollingOrZooming];
@@ -216,8 +207,6 @@
- (void)didZoomToScale:(CGFloat)scale
{
_page->didFinishZooming(scale);
- [self _updateViewExposedRect];
- [self _updateFixedPositionRect];
[_interactionView _didEndScrollingOrZooming];
}
Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm (164465 => 164466)
--- trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm 2014-02-21 04:53:48 UTC (rev 164466)
@@ -44,7 +44,6 @@
using namespace WebKit;
@interface WKView () <UIScrollViewDelegate, WKContentViewDelegate>
-- (void)_setDocumentScale:(CGFloat)newScale;
@end
@interface UIScrollView (UIScrollViewInternal)
@@ -171,7 +170,7 @@
[_scrollView setContentOffset:CGPointMake(-inset.left, -inset.top)];
_isWaitingForNewLayerTreeAfterDidCommitLoad = NO;
}
-
+ [self _updateVisibleContentRects];
}
#pragma mark - UIScrollViewDelegate
@@ -194,38 +193,38 @@
[_contentView willStartZoomOrScroll];
}
-- (void)_didFinishScroll
+- (void)_didFinishScrolling
{
- CGPoint position = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
- [_contentView didFinishScrollTo:position];
+ [self _updateVisibleContentRects];
+ [_contentView didFinishScrolling];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
// If we're decelerating, scroll offset will be updated when scrollViewDidFinishDecelerating: is called.
if (!decelerate)
- [self _didFinishScroll];
+ [self _didFinishScrolling];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
- [self _didFinishScroll];
+ [self _didFinishScrolling];
}
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
{
- [self _didFinishScroll];
+ [self _didFinishScrolling];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
- CGPoint position = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
- [_contentView didScrollTo:position];
+ [self _updateVisibleContentRects];
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
{
ASSERT(scrollView == _scrollView);
+ [self _updateVisibleContentRects];
[_contentView didZoomToScale:scale];
}
@@ -271,20 +270,22 @@
[_contentView setMinimumLayoutSize:bounds.size];
[_scrollView setFrame:bounds];
[_contentView setMinimumSize:bounds.size];
+ [self _updateVisibleContentRects];
}
-- (void)_setDocumentScale:(CGFloat)newScale
+- (void)_updateVisibleContentRects
{
- CGPoint contentOffsetInDocumentCoordinates = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
+ CGRect fullViewRect = self.bounds;
+ CGRect visibleRectInContentCoordinates = [self convertRect:fullViewRect toView:_contentView.get()];
- [_scrollView setZoomScale:newScale];
- [_contentView didZoomToScale:newScale];
+ CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, _obscuredInsets);
+ CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()];
- CGPoint contentOffset = [_scrollView convertPoint:contentOffsetInDocumentCoordinates fromView:_contentView.get()];
- [_scrollView setContentOffset:contentOffset];
+ CGFloat scaleFactor = [_scrollView zoomScale];
+
+ [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates scale:scaleFactor];
}
-
- (RetainPtr<CGImageRef>)takeViewSnapshotForContentView:(WKContentView *)contentView
{
// FIXME: We should be able to use acquire an IOSurface directly, instead of going to CGImage here and back in ViewSnapshotStore.
@@ -378,6 +379,7 @@
ASSERT(obscuredInsets.bottom >= 0);
ASSERT(obscuredInsets.right >= 0);
_obscuredInsets = obscuredInsets;
+ [self _updateVisibleContentRects];
}
- (void)_beginInteractiveObscuredInsetsChange
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (164465 => 164466)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-02-21 04:53:48 UTC (rev 164466)
@@ -450,8 +450,11 @@
void executeEditCommand(const String& commandName);
void validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback>);
#if PLATFORM(IOS)
+ const WebCore::FloatRect& unobscuredContentRect() const;
+ void setUnobscuredContentRect(const WebCore::FloatRect& unobscuredRect);
void setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize&);
void didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction&);
+
void selectWithGesture(const WebCore::IntPoint, WebCore::TextGranularity, uint32_t gestureType, uint32_t gestureState, PassRefPtr<GestureCallback>);
void updateSelectionWithTouches(const WebCore::IntPoint, uint32_t touches, bool baseIsStart, PassRefPtr<TouchesCallback>);
void selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, PassRefPtr<GestureCallback>);
@@ -841,7 +844,6 @@
#if PLATFORM(IOS)
void willStartUserTriggeredZooming();
- void didFinishScrolling(const WebCore::FloatPoint& contentOffset);
void didFinishZooming(float newScale);
void tapHighlightAtPosition(const WebCore::FloatPoint&, uint64_t& requestID);
@@ -1235,6 +1237,7 @@
#endif
#if PLATFORM(IOS)
RefPtr<WebVideoFullscreenManagerProxy> m_videoFullscreenManager;
+ WebCore::FloatRect m_unobscuredRect;
#endif
#if ENABLE(VIBRATION)
Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (164465 => 164466)
--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2014-02-21 04:53:48 UTC (rev 164466)
@@ -229,6 +229,16 @@
callback->performCallbackWithReturnValue(beforeText, markedText, selectedText, afterText, location, length);
}
+const FloatRect& WebPageProxy::unobscuredContentRect() const
+{
+ return m_unobscuredRect;
+}
+
+void WebPageProxy::setUnobscuredContentRect(const FloatRect& unobscuredRect)
+{
+ m_unobscuredRect = unobscuredRect;
+}
+
void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize& size)
{
m_process->send(Messages::WebPage::SetViewportConfigurationMinimumLayoutSize(size), m_pageID);
@@ -432,11 +442,6 @@
process().send(Messages::WebPage::WillStartUserTriggeredZooming(), m_pageID);
}
-void WebPageProxy::didFinishScrolling(const WebCore::FloatPoint& contentOffset)
-{
- process().send(Messages::WebPage::DidFinishScrolling(contentOffset), m_pageID);
-}
-
void WebPageProxy::didFinishZooming(float newScale)
{
m_pageScaleFactor = newScale;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (164465 => 164466)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-02-21 04:53:48 UTC (rev 164466)
@@ -314,7 +314,6 @@
#if PLATFORM(IOS)
WillStartUserTriggeredZooming();
- DidFinishScrolling(WebCore::FloatPoint contentOffset);
DidFinishZooming(float scale);
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (164465 => 164466)
--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2014-02-21 04:53:48 UTC (rev 164466)
@@ -1080,11 +1080,6 @@
m_userHasChangedPageScaleFactor = true;
}
-void WebPage::didFinishScrolling(const WebCore::FloatPoint& contentOffset)
-{
- m_page->mainFrame().view()->setScrollOffset(WebCore::IntPoint(contentOffset));
-}
-
void WebPage::didFinishZooming(float newScale)
{
m_page->setPageScaleFactor(newScale, m_page->mainFrame().view()->scrollPosition());