[iOS][WK2] Split the rects/scale updates in 3 internally consistent groups
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2014 07:43:31 +0000 (07:43 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2014 07:43:31 +0000 (07:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129354

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-02-25
Reviewed by Sam Weinig.

During scaling, the scale and rect of UIScrollView, WebPageProxy, DrawingAreaProxy,
DrawingArea and WebPage were in completely inconsistent states.

Some of those disconnect were temporary (like when setting the rect and scale in two different
messages), some were lasting the time of a tile update (like the UIProcess view of the scale).
This was causing various visual glitches.

To fix this, all the updates from the UIProcess are funneled through a single path and the values
are split into 3 different groups/types.
When updating the scale/rects, the UIProcess sends the new information to the WebProcess on a queue
through ViewUpdateDispatcher. There, the updates are accumulated until the MainThread is available.
Once the main thread is "unblocked" from the previous frame, all the data are updated at once from
the last known state in ViewUpdateDispatcher. The new tiles are created for the new converage information
and they are sent to the UIProcess.

At any point, there are 3 types of scale and rects used for different purpose:
-In the UIProcess, there is the UIScrollView scale and rects which represent the "true" state or what
 is currently on screen.
 That information is mirrored into WebPageProxy for the other classes needing it like DrawingAreaProxy.
-In the WebProcess, there is the last known state. That state is always lagging a little behind the "true"
 state.
-Back in the UIProcess, we have the tile states that is attached to RemoteLayerTreeTransaction. It is used
 to setup the rendering.

With this change, there are two paths for updating the page scale factor:
-The UI drives the change, the updates goes WKWebView->WKContentView->WebPageProxy->ViewUpdateDispatcher
 ->WebPage->RemoteLayerTreeDrawingArea->RemoteLayerTreeDrawingAreaProxy->WKContentView->WKWebView.
-If changes in the content force scaling parameters, the updates goes: WebPage->RemoteLayerTreeDrawingArea
 ->RemoteLayerTreeDrawingAreaProxy->WKContentView->WKWebView.
The two kind of updates frequently conflicts during loading. We differentiate those through the flag
scaleWasSetByUIProcess passed with the updates. In cases of conflicts, the user always wins.

* DerivedSources.make:
* Scripts/webkit2/messages.py:
(struct_or_class):
* Shared/VisibleContentRectUpdateInfo.cpp: Added.
(WebKit::VisibleContentRectUpdateInfo::encode):
(WebKit::VisibleContentRectUpdateInfo::decode):
* Shared/VisibleContentRectUpdateInfo.h: Added.
(WebKit::VisibleContentRectUpdateInfo::VisibleContentRectUpdateInfo):
(WebKit::VisibleContentRectUpdateInfo::exposedRect):
(WebKit::VisibleContentRectUpdateInfo::unobscuredRect):
(WebKit::VisibleContentRectUpdateInfo::scale):
(WebKit::operator==):
* Shared/mac/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::scaleWasSetByUIProcess):
(WebKit::RemoteLayerTreeTransaction::setScaleWasSetByUIProcess):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode):
(WebKit::RemoteLayerTreeTransaction::decode):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView contentView:didCommitLayerTree:WebKit::]):
(-[WKWebView _didFinishScrolling]):
(-[WKWebView scrollViewDidScroll:]):
(-[WKWebView scrollViewDidZoom:]):
(-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
(-[WKWebView _frameOrBoundsChanged]):
(-[WKWebView _updateVisibleContentRectsWithStableState:]):
(-[WKWebView _setObscuredInsets:]):
(-[WKWebView _endInteractiveObscuredInsetsChange]):
* UIProcess/API/ios/WKViewIOS.mm:
(-[WKView _updateVisibleContentRects]):
* UIProcess/DrawingAreaProxy.cpp:
(WebKit::DrawingAreaProxy::DrawingAreaProxy):
(WebKit::DrawingAreaProxy::setCustomFixedPositionRect):
* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::updateDebugIndicator):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::displayedContentScale):
(WebKit::WebPageProxy::exposedContentRect):
(WebKit::WebPageProxy::unobscuredContentRect):
* UIProcess/ios/WKContentView.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:inStableState:]):
(-[WKContentView didFinishScrolling]):
(-[WKContentView didZoomToScale:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::updateVisibleContentRects):
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::scaledExposedRect):
(WebKit::RemoteLayerTreeDrawingAreaProxy::indicatorLocation):
(WebKit::RemoteLayerTreeDrawingAreaProxy::indicatorScale):
(WebKit::RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebPage/ViewUpdateDispatcher.cpp: Added.
(WebKit::ViewUpdateDispatcher::create):
(WebKit::ViewUpdateDispatcher::ViewUpdateDispatcher):
(WebKit::ViewUpdateDispatcher::~ViewUpdateDispatcher):
(WebKit::ViewUpdateDispatcher::initializeConnection):
(WebKit::ViewUpdateDispatcher::visibleContentRectUpdate):
(WebKit::ViewUpdateDispatcher::dispatchVisibleContentRectUpdate):
* WebProcess/WebPage/ViewUpdateDispatcher.h: Added.
* WebProcess/WebPage/ViewUpdateDispatcher.messages.in: Added.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::scalePage):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::scaleWasSetByUIProcess):
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::tapHighlightAtPosition):
(WebKit::WebPage::updateVisibleContentRects):
(WebKit::WebPage::willStartUserTriggeredZooming):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::initializeConnection):
* WebProcess/WebProcess.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164702 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/DerivedSources.make
Source/WebKit2/Shared/VisibleContentRectUpdateInfo.cpp [new file with mode: 0644]
Source/WebKit2/Shared/VisibleContentRectUpdateInfo.h [new file with mode: 0644]
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm
Source/WebKit2/UIProcess/DrawingAreaProxy.cpp
Source/WebKit2/UIProcess/DrawingAreaProxy.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/ios/WKContentView.h
Source/WebKit2/UIProcess/ios/WKContentView.mm
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.messages.in [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h

index 77f5887..e6f7c2c 100644 (file)
@@ -1,3 +1,121 @@
+2014-02-25  Benjamin Poulain  <bpoulain@apple.com>
+
+        [iOS][WK2] Split the rects/scale updates in 3 internally consistent groups
+        https://bugs.webkit.org/show_bug.cgi?id=129354
+
+        Reviewed by Sam Weinig.
+
+        During scaling, the scale and rect of UIScrollView, WebPageProxy, DrawingAreaProxy,
+        DrawingArea and WebPage were in completely inconsistent states.
+
+        Some of those disconnect were temporary (like when setting the rect and scale in two different
+        messages), some were lasting the time of a tile update (like the UIProcess view of the scale).
+        This was causing various visual glitches.
+
+        To fix this, all the updates from the UIProcess are funneled through a single path and the values
+        are split into 3 different groups/types.
+        When updating the scale/rects, the UIProcess sends the new information to the WebProcess on a queue
+        through ViewUpdateDispatcher. There, the updates are accumulated until the MainThread is available.
+        Once the main thread is "unblocked" from the previous frame, all the data are updated at once from
+        the last known state in ViewUpdateDispatcher. The new tiles are created for the new converage information
+        and they are sent to the UIProcess.
+
+        At any point, there are 3 types of scale and rects used for different purpose:
+        -In the UIProcess, there is the UIScrollView scale and rects which represent the "true" state or what
+         is currently on screen.
+         That information is mirrored into WebPageProxy for the other classes needing it like DrawingAreaProxy.
+        -In the WebProcess, there is the last known state. That state is always lagging a little behind the "true"
+         state.
+        -Back in the UIProcess, we have the tile states that is attached to RemoteLayerTreeTransaction. It is used
+         to setup the rendering.
+
+        With this change, there are two paths for updating the page scale factor:
+        -The UI drives the change, the updates goes WKWebView->WKContentView->WebPageProxy->ViewUpdateDispatcher
+         ->WebPage->RemoteLayerTreeDrawingArea->RemoteLayerTreeDrawingAreaProxy->WKContentView->WKWebView.
+        -If changes in the content force scaling parameters, the updates goes: WebPage->RemoteLayerTreeDrawingArea
+         ->RemoteLayerTreeDrawingAreaProxy->WKContentView->WKWebView.
+        The two kind of updates frequently conflicts during loading. We differentiate those through the flag
+        scaleWasSetByUIProcess passed with the updates. In cases of conflicts, the user always wins.
+
+        * DerivedSources.make:
+        * Scripts/webkit2/messages.py:
+        (struct_or_class):
+        * Shared/VisibleContentRectUpdateInfo.cpp: Added.
+        (WebKit::VisibleContentRectUpdateInfo::encode):
+        (WebKit::VisibleContentRectUpdateInfo::decode):
+        * Shared/VisibleContentRectUpdateInfo.h: Added.
+        (WebKit::VisibleContentRectUpdateInfo::VisibleContentRectUpdateInfo):
+        (WebKit::VisibleContentRectUpdateInfo::exposedRect):
+        (WebKit::VisibleContentRectUpdateInfo::unobscuredRect):
+        (WebKit::VisibleContentRectUpdateInfo::scale):
+        (WebKit::operator==):
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        (WebKit::RemoteLayerTreeTransaction::scaleWasSetByUIProcess):
+        (WebKit::RemoteLayerTreeTransaction::setScaleWasSetByUIProcess):
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::encode):
+        (WebKit::RemoteLayerTreeTransaction::decode):
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView contentView:didCommitLayerTree:WebKit::]):
+        (-[WKWebView _didFinishScrolling]):
+        (-[WKWebView scrollViewDidScroll:]):
+        (-[WKWebView scrollViewDidZoom:]):
+        (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
+        (-[WKWebView _frameOrBoundsChanged]):
+        (-[WKWebView _updateVisibleContentRectsWithStableState:]):
+        (-[WKWebView _setObscuredInsets:]):
+        (-[WKWebView _endInteractiveObscuredInsetsChange]):
+        * UIProcess/API/ios/WKViewIOS.mm:
+        (-[WKView _updateVisibleContentRects]):
+        * UIProcess/DrawingAreaProxy.cpp:
+        (WebKit::DrawingAreaProxy::DrawingAreaProxy):
+        (WebKit::DrawingAreaProxy::setCustomFixedPositionRect):
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::updateDebugIndicator):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::displayedContentScale):
+        (WebKit::WebPageProxy::exposedContentRect):
+        (WebKit::WebPageProxy::unobscuredContentRect):
+        * UIProcess/ios/WKContentView.h:
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:inStableState:]):
+        (-[WKContentView didFinishScrolling]):
+        (-[WKContentView didZoomToScale:]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::updateVisibleContentRects):
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::scaledExposedRect):
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::indicatorLocation):
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::indicatorScale):
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/ViewUpdateDispatcher.cpp: Added.
+        (WebKit::ViewUpdateDispatcher::create):
+        (WebKit::ViewUpdateDispatcher::ViewUpdateDispatcher):
+        (WebKit::ViewUpdateDispatcher::~ViewUpdateDispatcher):
+        (WebKit::ViewUpdateDispatcher::initializeConnection):
+        (WebKit::ViewUpdateDispatcher::visibleContentRectUpdate):
+        (WebKit::ViewUpdateDispatcher::dispatchVisibleContentRectUpdate):
+        * WebProcess/WebPage/ViewUpdateDispatcher.h: Added.
+        * WebProcess/WebPage/ViewUpdateDispatcher.messages.in: Added.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::scalePage):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::scaleWasSetByUIProcess):
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::tapHighlightAtPosition):
+        (WebKit::WebPage::updateVisibleContentRects):
+        (WebKit::WebPage::willStartUserTriggeredZooming):
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+        (WebKit::WebProcess::initializeConnection):
+        * WebProcess/WebProcess.h:
+
 2014-02-25  Anders Carlsson  <andersca@apple.com>
 
         Rename WebCore::VisitedLinkProvider to WebCore::VisitedLinkStore
index 534d84f..d63d343 100644 (file)
@@ -97,6 +97,7 @@ MESSAGE_RECEIVERS = \
     StorageManager \
     ViewGestureController \
     ViewGestureGeometryCollector \
+    ViewUpdateDispatcher \
     WebApplicationCacheManager \
     WebApplicationCacheManagerProxy \
     WebConnection \
diff --git a/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.cpp b/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.cpp
new file mode 100644 (file)
index 0000000..efec5dd
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "VisibleContentRectUpdateInfo.h"
+
+#include "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+void VisibleContentRectUpdateInfo::encode(IPC::ArgumentEncoder& encoder) const
+{
+    encoder << m_exposedRect;
+    encoder << m_unobscuredRect;
+    encoder << m_scale;
+}
+
+bool VisibleContentRectUpdateInfo::decode(IPC::ArgumentDecoder& decoder, VisibleContentRectUpdateInfo& result)
+{
+    if (!decoder.decode(result.m_exposedRect))
+        return false;
+    if (!decoder.decode(result.m_unobscuredRect))
+        return false;
+    if (!decoder.decode(result.m_scale))
+        return false;
+    return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.h b/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.h
new file mode 100644 (file)
index 0000000..bc3ddfe
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef VisibleContentRectUpdateInfo_h
+#define VisibleContentRectUpdateInfo_h
+
+#include <WebCore/FloatRect.h>
+
+namespace IPC {
+class ArgumentDecoder;
+class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+class VisibleContentRectUpdateInfo {
+public:
+    VisibleContentRectUpdateInfo()
+        : m_scale(-1)
+    {
+    }
+
+    VisibleContentRectUpdateInfo(const WebCore::FloatRect& exposedRect, const WebCore::FloatRect& unobscuredRect, double scale)
+        : m_exposedRect(exposedRect)
+        , m_unobscuredRect(unobscuredRect)
+        , m_scale(scale)
+    {
+    }
+
+    const WebCore::FloatRect& exposedRect() const { return m_exposedRect; }
+    const WebCore::FloatRect& unobscuredRect() const { return m_unobscuredRect; }
+    double scale() const { return m_scale; }
+
+    void encode(IPC::ArgumentEncoder&) const;
+    static bool decode(IPC::ArgumentDecoder&, VisibleContentRectUpdateInfo&);
+
+private:
+    WebCore::FloatRect m_exposedRect;
+    WebCore::FloatRect m_unobscuredRect;
+    double m_scale;
+};
+
+inline bool operator==(const VisibleContentRectUpdateInfo& a, const VisibleContentRectUpdateInfo& b)
+{
+    return a.scale() == b.scale() && a.exposedRect() == b.exposedRect() && a.unobscuredRect() == b.unobscuredRect();
+}
+
+} // namespace WebKit
+
+#endif // VisibleContentRectUpdateInfo_h
index 9295b4b..16d5f53 100644 (file)
@@ -164,6 +164,9 @@ public:
 
     double pageScaleFactor() const { return m_pageScaleFactor; }
     void setPageScaleFactor(double pageScaleFactor) { m_pageScaleFactor = pageScaleFactor; }
+
+    bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
+    void setScaleWasSetByUIProcess(bool scaleWasSetByUIProcess) { m_scaleWasSetByUIProcess = scaleWasSetByUIProcess; }
     
     uint64_t renderTreeSize() const { return m_renderTreeSize; }
     void setRenderTreeSize(uint64_t renderTreeSize) { m_renderTreeSize = renderTreeSize; }
@@ -187,6 +190,7 @@ private:
     Vector<WebCore::GraphicsLayer::PlatformLayerID> m_destroyedLayerIDs;
     WebCore::IntSize m_contentsSize;
     double m_pageScaleFactor;
+    bool m_scaleWasSetByUIProcess;
     uint64_t m_renderTreeSize;
     double m_minimumScaleFactor;
     double m_maximumScaleFactor;
index e657b38..6d271ae 100644 (file)
@@ -410,6 +410,7 @@ void RemoteLayerTreeTransaction::encode(IPC::ArgumentEncoder& encoder) const
     encoder << m_destroyedLayerIDs;
     encoder << m_contentsSize;
     encoder << m_pageScaleFactor;
+    encoder << m_scaleWasSetByUIProcess;
     encoder << m_minimumScaleFactor;
     encoder << m_maximumScaleFactor;
     encoder << m_allowsUserScaling;
@@ -457,6 +458,9 @@ bool RemoteLayerTreeTransaction::decode(IPC::ArgumentDecoder& decoder, RemoteLay
     if (!decoder.decode(result.m_pageScaleFactor))
         return false;
 
+    if (!decoder.decode(result.m_scaleWasSetByUIProcess))
+        return false;
+
     if (!decoder.decode(result.m_minimumScaleFactor))
         return false;
 
index 9103700..b8c5107 100644 (file)
     [_scrollView setMinimumZoomScale:layerTreeTransaction.minimumScaleFactor()];
     [_scrollView setMaximumZoomScale:layerTreeTransaction.maximumScaleFactor()];
     [_scrollView setZoomEnabled:layerTreeTransaction.allowsUserScaling()];
-    if (![_scrollView isZooming] && ![_scrollView isZoomBouncing])
+    if (!layerTreeTransaction.scaleWasSetByUIProcess() && ![_scrollView isZooming] && ![_scrollView isZoomBouncing])
         [_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()];
 
     if (_gestureController)
 
 - (void)_didFinishScrolling
 {
-    [self _updateVisibleContentRects];
+    [self _updateVisibleContentRectsWithStableState:YES];
     [_contentView didFinishScrolling];
 }
 
 
 - (void)scrollViewDidScroll:(UIScrollView *)scrollView
 {
-    [self _updateVisibleContentRects];
+    [self _updateVisibleContentRectsWithStableState:NO];
 }
 
 - (void)scrollViewDidZoom:(UIScrollView *)scrollView
 {
-    [self _updateVisibleContentRects];
+    [self _updateVisibleContentRectsWithStableState:NO];
 }
 
 - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
 {
     ASSERT(scrollView == _scrollView);
-    [self _updateVisibleContentRects];
+    [self _updateVisibleContentRectsWithStableState:YES];
     [_contentView didZoomToScale:scale];
 }
 
         [_contentView setMinimumLayoutSize:bounds.size];
     [_scrollView setFrame:bounds];
     [_contentView setMinimumSize:bounds.size];
-    [self _updateVisibleContentRects];
+    [self _updateVisibleContentRectsWithStableState:YES];
 }
 
-- (void)_updateVisibleContentRects
+- (void)_updateVisibleContentRectsWithStableState:(BOOL)isStateStable
 {
     CGRect fullViewRect = self.bounds;
     CGRect visibleRectInContentCoordinates = [self convertRect:fullViewRect toView:_contentView.get()];
 
     CGFloat scaleFactor = [_scrollView zoomScale];
 
-    [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates scale:scaleFactor];
+    [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates scale:scaleFactor inStableState:isStateStable];
 }
 
 - (void)_keyboardChangedWithInfo:(NSDictionary *)keyboardInfo adjustScrollView:(BOOL)adjustScrollView
@@ -696,7 +696,7 @@ static inline WebCore::LayoutMilestones layoutMilestones(_WKRenderingProgressEve
     ASSERT(obscuredInsets.bottom >= 0);
     ASSERT(obscuredInsets.right >= 0);
     _obscuredInsets = obscuredInsets;
-    [self _updateVisibleContentRects];
+    [self _updateVisibleContentRectsWithStableState:!_isChangingObscuredInsetsInteractively];
 }
 
 - (UIColor *)_pageExtendedBackgroundColor
@@ -728,6 +728,7 @@ static inline WebCore::LayoutMilestones layoutMilestones(_WKRenderingProgressEve
 {
     ASSERT(_isChangingObscuredInsetsInteractively);
     _isChangingObscuredInsetsInteractively = NO;
+    [self _updateVisibleContentRectsWithStableState:YES];
 }
 
 #endif
index d5ecc47..54a3215 100644 (file)
@@ -263,7 +263,7 @@ using namespace WebKit;
 
     CGFloat scaleFactor = [_scrollView zoomScale];
 
-    [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates scale:scaleFactor];
+    [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates scale:scaleFactor inStableState:YES];
 }
 
 - (void)_keyboardChangedWithInfo:(NSDictionary *)keyboardInfo adjustScrollView:(BOOL)adjustScrollView
index 2d965d6..c1921c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,7 +39,7 @@ DrawingAreaProxy::DrawingAreaProxy(DrawingAreaType type, WebPageProxy* webPagePr
     : m_type(type)
     , m_webPageProxy(webPageProxy)
     , m_size(webPageProxy->viewSize())
-#if PLATFORM(COCOA)
+#if PLATFORM(MAC)
     , m_exposedRectChangedTimer(RunLoop::main(), this, &DrawingAreaProxy::exposedRectChangedTimerFired)
 #endif
 {
@@ -62,7 +62,7 @@ void DrawingAreaProxy::setSize(const IntSize& size, const IntSize& layerPosition
     sizeDidChange();
 }
 
-#if PLATFORM(COCOA)
+#if PLATFORM(MAC)
 void DrawingAreaProxy::setExposedRect(const FloatRect& exposedRect)
 {
     if (!m_webPageProxy->isValid())
@@ -85,6 +85,7 @@ void DrawingAreaProxy::exposedRectChangedTimerFired()
     m_webPageProxy->process().send(Messages::DrawingArea::SetExposedRect(m_exposedRect), m_webPageProxy->pageID());
     m_lastSentExposedRect = m_exposedRect;
 }
+#endif // PLATFORM(MAC)
 
 void DrawingAreaProxy::setCustomFixedPositionRect(const FloatRect& fixedPositionRect)
 {
@@ -93,6 +94,5 @@ void DrawingAreaProxy::setCustomFixedPositionRect(const FloatRect& fixedPosition
 
     m_webPageProxy->process().send(Messages::DrawingArea::SetCustomFixedPositionRect(fixedPositionRect), m_webPageProxy->pageID());
 }
-#endif
 
 } // namespace WebKit
index 1d72c0f..f593bd5 100644 (file)
@@ -73,14 +73,17 @@ public:
     virtual void adjustTransientZoom(double, WebCore::FloatPoint) { }
     virtual void commitTransientZoom(double, WebCore::FloatPoint) { }
 
-#if PLATFORM(COCOA)
+#if PLATFORM(MAC)
     virtual void setExposedRect(const WebCore::FloatRect&);
     WebCore::FloatRect exposedRect() const { return m_exposedRect; }
+#endif
+#if PLATFORM(COCOA)
     void exposedRectChangedTimerFired();
     
     void setCustomFixedPositionRect(const WebCore::FloatRect&);
 #endif
 
+    virtual void updateDebugIndicator() { }
     virtual void showDebugIndicator(bool) { }
     virtual bool isShowingDebugIndicator() const { return false; }
 
@@ -111,9 +114,11 @@ private:
     virtual void didUpdateGeometry() { }
     virtual void intrinsicContentSizeDidChange(const WebCore::IntSize& newIntrinsicContentSize) { }
 
+#if PLATFORM(MAC)
     RunLoop::Timer<DrawingAreaProxy> m_exposedRectChangedTimer;
     WebCore::FloatRect m_exposedRect;
     WebCore::FloatRect m_lastSentExposedRect;
+#endif // PLATFORM(MAC)
 #endif
 };
 
index ebee2a7..a0f6af8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -43,6 +43,7 @@
 #include "PlatformProcessIdentifier.h"
 #include "SandboxExtension.h"
 #include "ShareableBitmap.h"
+#include "VisibleContentRectUpdateInfo.h"
 #include "WKBase.h"
 #include "WKPagePrivate.h"
 #include "WebColorPicker.h"
@@ -451,8 +452,11 @@ public:
     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);
+    double displayedContentScale() const { return m_lastVisibleContentRectUpdate.scale(); }
+    const WebCore::FloatRect& exposedContentRect() const { return m_lastVisibleContentRectUpdate.exposedRect(); }
+    const WebCore::FloatRect& unobscuredContentRect() const { return m_lastVisibleContentRectUpdate.unobscuredRect(); }
+
+    void updateVisibleContentRects(const VisibleContentRectUpdateInfo&);
     void setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize&);
     void didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction&);
 
@@ -847,7 +851,6 @@ public:
 
 #if PLATFORM(IOS)
     void willStartUserTriggeredZooming();
-    void didFinishZooming(float newScale);
 
     void tapHighlightAtPosition(const WebCore::FloatPoint&, uint64_t& requestID);
 
@@ -1240,7 +1243,7 @@ private:
 #endif
 #if PLATFORM(IOS)
     RefPtr<WebVideoFullscreenManagerProxy> m_videoFullscreenManager;
-    WebCore::FloatRect m_unobscuredRect;
+    VisibleContentRectUpdateInfo m_lastVisibleContentRectUpdate;
 #endif
 
 #if ENABLE(VIBRATION)
index d50ed84..5e97b63 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -66,7 +66,7 @@ struct WebPageConfiguration;
 
 - (void)setMinimumSize:(CGSize)size;
 - (void)setMinimumLayoutSize:(CGSize)size;
-- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale;
+- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale inStableState:(BOOL)isStableState;
 
 - (void)didFinishScrolling;
 - (void)didZoomToScale:(CGFloat)scale;
index 4210f61..5f89ffc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -146,18 +146,21 @@ using namespace WebKit;
     return [self isEditable];
 }
 
-- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale
+- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale inStableState:(BOOL)isStableState
 {
-    _page->setUnobscuredContentRect(unobscuredRect);
-    _page->scrollingCoordinatorProxy()->scrollPositionChangedViaDelegatedScrolling(_page->scrollingCoordinatorProxy()->rootScrollingNodeID(), roundedIntPoint(unobscuredRect.origin));
+    double scaleNoiseThreshold = 0.0005;
+    if (!isStableState && abs(scale - _page->displayedContentScale()) < scaleNoiseThreshold) {
+        // Tiny changes of scale during interactive zoom cause content to jump by one pixel, creating
+        // visual noise. We filter those useless updates.
+        scale = _page->displayedContentScale();
+    }
+    _page->updateVisibleContentRects(VisibleContentRectUpdateInfo(visibleRect, unobscuredRect, scale));
 
     if (auto drawingArea = _page->drawingArea()) {
-        FloatRect exposedRect = visibleRect;
-        exposedRect.scale(scale);
-        drawingArea->setExposedRect(exposedRect);
+        FloatRect fixedPosRect = [self fixedPositionRectFromExposedRect:unobscuredRect scale:scale];
+        drawingArea->setCustomFixedPositionRect(fixedPosRect);
+        drawingArea->updateDebugIndicator();
     }
-
-    [self _updateFixedPositionRect];
 }
 
 - (void)setMinimumSize:(CGSize)size
@@ -172,15 +175,6 @@ using namespace WebKit;
     return exposedRect;
 }
 
-- (void)_updateFixedPositionRect
-{
-    auto drawingArea = _page->drawingArea();
-    if (!drawingArea)
-        return;
-    FloatRect fixedPosRect = [self fixedPositionRectFromExposedRect:_page->unobscuredContentRect() scale:_page->pageScaleFactor()];
-    drawingArea->setCustomFixedPositionRect(fixedPosRect);
-}
-
 - (void)setMinimumLayoutSize:(CGSize)size
 {
     _page->setViewportConfigurationMinimumLayoutSize(IntSize(CGCeiling(size.width), CGCeiling(size.height)));
@@ -188,7 +182,6 @@ using namespace WebKit;
 
 - (void)didFinishScrolling
 {
-    [self _updateFixedPositionRect];
     [self _didEndScrollingOrZooming];
 }
 
@@ -210,7 +203,6 @@ using namespace WebKit;
 
 - (void)didZoomToScale:(CGFloat)scale
 {
-    _page->didFinishZooming(scale);
     [self _didEndScrollingOrZooming];
 }
 
index 026a96a..a9f7228 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "NativeWebKeyboardEvent.h"
 #import "PageClient.h"
+#import "ViewUpdateDispatcherMessages.h"
 #import "WKBrowsingContextControllerInternal.h"
 #import "WebKitSystemInterfaceIOS.h"
 #import "WebPageMessages.h"
@@ -230,14 +231,12 @@ void WebPageProxy::autocorrectionContextCallback(const String& beforeText, const
     callback->performCallbackWithReturnValue(beforeText, markedText, selectedText, afterText, location, length);
 }
 
-const FloatRect& WebPageProxy::unobscuredContentRect() const
+void WebPageProxy::updateVisibleContentRects(const VisibleContentRectUpdateInfo& visibleContentRectUpdateInfo)
 {
-    return m_unobscuredRect;
-}
-
-void WebPageProxy::setUnobscuredContentRect(const FloatRect& unobscuredRect)
-{
-    m_unobscuredRect = unobscuredRect;
+    if (visibleContentRectUpdateInfo == m_lastVisibleContentRectUpdate)
+        return;
+    m_lastVisibleContentRectUpdate = visibleContentRectUpdateInfo;
+    m_process->send(Messages::ViewUpdateDispatcher::VisibleContentRectUpdate(m_pageID, visibleContentRectUpdateInfo), 0);
 }
 
 void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize& size)
@@ -455,12 +454,6 @@ void WebPageProxy::willStartUserTriggeredZooming()
     process().send(Messages::WebPage::WillStartUserTriggeredZooming(), m_pageID);
 }
 
-void WebPageProxy::didFinishZooming(float newScale)
-{
-    m_pageScaleFactor = newScale;
-    process().send(Messages::WebPage::DidFinishZooming(newScale), m_pageID);
-}
-
 void WebPageProxy::tapHighlightAtPosition(const WebCore::FloatPoint& position, uint64_t& requestID)
 {
     static uint64_t uniqueRequestID = 0;
index 7aa59dd..dcde74a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -49,11 +49,15 @@ private:
     virtual void deviceScaleFactorDidChange() override;
     virtual void didUpdateGeometry() override;
 
+    WebCore::FloatRect scaledExposedRect() const;
     void showDebugIndicator(bool);
 
+#if PLATFORM(MAC)
     virtual void setExposedRect(const WebCore::FloatRect&) override;
+#endif
 
     float indicatorScale(WebCore::IntSize contentsSize) const;
+    virtual void updateDebugIndicator() override;
     void updateDebugIndicator(WebCore::IntSize contentsSize, bool rootLayerChanged, float scale);
     void updateDebugIndicatorPosition();
     
index 9b9c37d..6d56f10 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -78,6 +78,18 @@ void RemoteLayerTreeDrawingAreaProxy::didUpdateGeometry()
         sendUpdateGeometry();
 }
 
+FloatRect RemoteLayerTreeDrawingAreaProxy::scaledExposedRect() const
+{
+#if PLATFORM(IOS)
+    return m_webPageProxy->exposedContentRect();
+#else
+    FloatRect scaledExposedRect = exposedRect();
+    float scale = 1 / m_webPageProxy->pageScaleFactor();
+    scaledExposedRect.scale(scale, scale);
+    return scaledExposedRect;
+#endif
+}
+
 void RemoteLayerTreeDrawingAreaProxy::sendUpdateGeometry()
 {
     m_lastSentSize = m_size;
@@ -109,21 +121,28 @@ void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTrans
 }
 
 static const float indicatorInset = 10;
-static const float indicatorTopInset = 100;
 
+#if PLATFORM(MAC)
 void RemoteLayerTreeDrawingAreaProxy::setExposedRect(const WebCore::FloatRect& r)
 {
     DrawingAreaProxy::setExposedRect(r);
     updateDebugIndicatorPosition();
 }
+#endif
 
 FloatPoint RemoteLayerTreeDrawingAreaProxy::indicatorLocation() const
 {
     if (m_webPageProxy->delegatesScrolling()) {
+#if PLATFORM(IOS)
+        FloatPoint tiledMapLocation = m_webPageProxy->unobscuredContentRect().location();
+        float absoluteInset = indicatorInset / m_webPageProxy->displayedContentScale();
+        tiledMapLocation += FloatSize(absoluteInset, absoluteInset);
+#else
         FloatPoint tiledMapLocation = exposedRect().location();
-        tiledMapLocation += FloatSize(indicatorInset, indicatorTopInset);
-        float scale = 1 / m_webPageProxy->pageScaleFactor();
+        tiledMapLocation += FloatSize(indicatorInset, indicatorInset);
+        float scale = 1 / m_webPageProxy->pageScaleFactor();;
         tiledMapLocation.scale(scale, scale);
+#endif
         return tiledMapLocation;
     }
     
@@ -146,12 +165,18 @@ float RemoteLayerTreeDrawingAreaProxy::indicatorScale(IntSize contentsSize) cons
     float scale = 1;
     if (!contentsSize.isEmpty()) {
         float widthScale = std::min<float>((viewSize.width() - 2 * indicatorInset) / contentsSize.width(), 0.05);
-        scale = std::min(widthScale, static_cast<float>(viewSize.height() - indicatorTopInset - indicatorInset) / contentsSize.height());
+        scale = std::min(widthScale, static_cast<float>(viewSize.height() - 2 * indicatorInset) / contentsSize.height());
     }
     
     return scale;
 }
 
+void RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator()
+{
+    // FIXME: we should also update live information during scale.
+    updateDebugIndicatorPosition();
+}
+
 void RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator(IntSize contentsSize, bool rootLayerChanged, float scale)
 {
     // Make sure we're the last sublayer.
@@ -178,10 +203,7 @@ void RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator(IntSize contentsSize,
     [m_exposedRectIndicatorLayer setBorderWidth:counterScaledBorder];
 
     if (m_webPageProxy->delegatesScrolling()) {
-        FloatRect scaledExposedRect = exposedRect();
-        float scale = 1 / m_webPageProxy->pageScaleFactor();
-        scaledExposedRect.scale(scale, scale);
-
+        FloatRect scaledExposedRect = this->scaledExposedRect();
         [m_exposedRectIndicatorLayer setPosition:scaledExposedRect.location()];
         [m_exposedRectIndicatorLayer setBounds:FloatRect(FloatPoint(), scaledExposedRect.size())];
     } else {
index 0eeedea..2e5cba4 100644 (file)
                1QQ417CB12C00CCA002BE67B /* TextCheckerCompletion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CC417C912C00CCA002BE67B /* TextCheckerCompletion.h */; };
                1ZZ417EF12C00D87002BE67B /* TextCheckerCompletion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1BB417C912C00CCA002BE67B /* TextCheckerCompletion.cpp */; };
                263172CF18B469490065B9C3 /* NativeWebTouchEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 263172CE18B469490065B9C3 /* NativeWebTouchEvent.h */; };
+               2684054418B85A630022C38B /* VisibleContentRectUpdateInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2684054218B85A630022C38B /* VisibleContentRectUpdateInfo.h */; };
+               2684054918B85FF70022C38B /* ViewUpdateDispatcher.messages.in in Resources */ = {isa = PBXBuildFile; fileRef = 2684054818B85FF70022C38B /* ViewUpdateDispatcher.messages.in */; };
+               2684054C18B86C350022C38B /* VisibleContentRectUpdateInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2684054A18B866FF0022C38B /* VisibleContentRectUpdateInfo.cpp */; };
+               2684054F18B86C8E0022C38B /* ViewUpdateDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2684054518B85E7E0022C38B /* ViewUpdateDispatcher.cpp */; };
+               2684055218B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2684055018B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp */; };
+               2684055318B86ED60022C38B /* ViewUpdateDispatcherMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 2684055118B86ED60022C38B /* ViewUpdateDispatcherMessages.h */; };
                26F9A83B18A3468100AEB88A /* WKWebViewPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 26F9A83A18A3463F00AEB88A /* WKWebViewPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                290F4272172A0C7400939FF0 /* ChildProcessSupplement.h in Headers */ = {isa = PBXBuildFile; fileRef = 290F4271172A0C7400939FF0 /* ChildProcessSupplement.h */; };
                293EBEAB1627D9C9005F89F1 /* WKDOMText.h in Headers */ = {isa = PBXBuildFile; fileRef = 293EBEA91627D9C9005F89F1 /* WKDOMText.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1FB00AC6185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInPageGroupInternal.h; sourceTree = "<group>"; };
                263172CE18B469490065B9C3 /* NativeWebTouchEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebTouchEvent.h; sourceTree = "<group>"; };
                26659AA0185FAAED004303DD /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = "<group>"; };
+               2684054218B85A630022C38B /* VisibleContentRectUpdateInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisibleContentRectUpdateInfo.h; sourceTree = "<group>"; };
+               2684054518B85E7E0022C38B /* ViewUpdateDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewUpdateDispatcher.cpp; sourceTree = "<group>"; };
+               2684054618B85E7E0022C38B /* ViewUpdateDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewUpdateDispatcher.h; sourceTree = "<group>"; };
+               2684054818B85FF70022C38B /* ViewUpdateDispatcher.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ViewUpdateDispatcher.messages.in; sourceTree = "<group>"; };
+               2684054A18B866FF0022C38B /* VisibleContentRectUpdateInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisibleContentRectUpdateInfo.cpp; sourceTree = "<group>"; };
+               2684055018B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ViewUpdateDispatcherMessageReceiver.cpp; path = "ViewUpdateDispatcherMessageReceiver.cpp"; sourceTree = "<group>"; };
+               2684055118B86ED60022C38B /* ViewUpdateDispatcherMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewUpdateDispatcherMessages.h; path = "ViewUpdateDispatcherMessages.h"; sourceTree = "<group>"; };
                26F9A83A18A3463F00AEB88A /* WKWebViewPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebViewPrivate.h; sourceTree = "<group>"; };
                290F4271172A0C7400939FF0 /* ChildProcessSupplement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChildProcessSupplement.h; sourceTree = "<group>"; };
                293EBEA91627D9C9005F89F1 /* WKDOMText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDOMText.h; sourceTree = "<group>"; };
                                1AC1336518565B5700F3EC05 /* UserData.cpp */,
                                1AC1336618565B5700F3EC05 /* UserData.h */,
                                BCB0B0DF12305AB100B1341E /* UserMessageCoders.h */,
+                               2684054A18B866FF0022C38B /* VisibleContentRectUpdateInfo.cpp */,
+                               2684054218B85A630022C38B /* VisibleContentRectUpdateInfo.h */,
                                1A0F29C9120B37160053D1B9 /* VisitedLinkTable.cpp */,
                                1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */,
                                BC329D9916ACCE9900316DE2 /* WebArchive.cpp */,
                                2D819B99186275B3001F03D1 /* ViewGestureGeometryCollector.cpp */,
                                2D819B9A186275B3001F03D1 /* ViewGestureGeometryCollector.h */,
                                2D819B9B186275B3001F03D1 /* ViewGestureGeometryCollector.messages.in */,
+                               2684054518B85E7E0022C38B /* ViewUpdateDispatcher.cpp */,
+                               2684054618B85E7E0022C38B /* ViewUpdateDispatcher.h */,
+                               2684054818B85FF70022C38B /* ViewUpdateDispatcher.messages.in */,
                                BC72B9F811E6476B001EB4EA /* WebBackForwardListProxy.cpp */,
                                BC72B9F911E6476B001EB4EA /* WebBackForwardListProxy.h */,
                                51871B59127CB89D00F76232 /* WebContextMenu.cpp */,
                                1AB31A9516BC688100F6DBC9 /* StorageManagerMessages.h */,
                                2D1B5D5B185869C8006C6596 /* ViewGestureControllerMessageReceiver.cpp */,
                                2D1B5D5C185869C8006C6596 /* ViewGestureControllerMessages.h */,
+                               2684055018B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp */,
+                               2684055118B86ED60022C38B /* ViewUpdateDispatcherMessages.h */,
                                512E3568130B57F000ABD19A /* WebApplicationCacheManagerMessageReceiver.cpp */,
                                512E3569130B57F000ABD19A /* WebApplicationCacheManagerMessages.h */,
                                512E35F6130B642E00ABD19A /* WebApplicationCacheManagerProxyMessageReceiver.cpp */,
                                51064D36189781C4004B2FEB /* SQLiteIDBCursor.h in Headers */,
                                BC032D7D10F4378D0058C15A /* WebEditorClient.h in Headers */,
                                0F5947A8187B517600437857 /* RemoteScrollingCoordinatorMessages.h in Headers */,
+                               2684055318B86ED60022C38B /* ViewUpdateDispatcherMessages.h in Headers */,
                                516A4A5D120A2CCD00C05B7F /* APIError.h in Headers */,
                                1A433F0D113C53DD00FACDE9 /* WebErrors.h in Headers */,
                                BC032DB910F4380F0058C15A /* WebEvent.h in Headers */,
                                BCE0E425168B7A280057E66A /* WebProcessSupplement.h in Headers */,
                                512F589D12A8838800629530 /* WebProtectionSpace.h in Headers */,
                                1AC1337218566C7C00F3EC05 /* APIFrameHandle.h in Headers */,
+                               2684054418B85A630022C38B /* VisibleContentRectUpdateInfo.h in Headers */,
                                37948404150C350600E52CE9 /* WebRenderLayer.h in Headers */,
                                51E351F6180F5C7500E53BE9 /* WebIDBFactoryBackend.h in Headers */,
                                3760881F150413E900FC82C7 /* WebRenderObject.h in Headers */,
                        buildActionMask = 2147483647;
                        files = (
                                E1D26A51175964D70095BFD1 /* WebContentProcess.xib in Resources */,
+                               2684054918B85FF70022C38B /* ViewUpdateDispatcher.messages.in in Resources */,
                                E133FD8A1423DD7F00FC7BFB /* WebKit.icns in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                                75E749E9180DBB9800088BA6 /* WebOriginDataManagerMessageReceiver.cpp in Sources */,
                                BC204EE611C83EA9008F3375 /* InjectedBundleMac.mm in Sources */,
                                BC8147D612F66D31007B2C32 /* InjectedBundleNavigationAction.cpp in Sources */,
+                               2684054C18B86C350022C38B /* VisibleContentRectUpdateInfo.cpp in Sources */,
                                BC4BEEAC120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.cpp in Sources */,
                                512935E31288D97800A4B695 /* InjectedBundlePageContextMenuClient.cpp in Sources */,
                                CD67D30E15C08F9A00843ADF /* InjectedBundlePageDiagnosticLoggingClient.cpp in Sources */,
                                BC82836516B354F600A278FE /* WebContentProcessMain.mm in Sources */,
                                2D125C5F1857EA05003BA3CB /* ViewGestureControllerMac.mm in Sources */,
                                BC82839916B48DC000A278FE /* WebContentServiceEntryPoint.mm in Sources */,
+                               2684054F18B86C8E0022C38B /* ViewUpdateDispatcher.cpp in Sources */,
                                BCB9E2441120DACA00A137E0 /* WebContext.cpp in Sources */,
                                31A505F91680025500A930EB /* WebContextClient.cpp in Sources */,
                                BC09B8F8147460F7005F5625 /* WebContextConnectionClient.cpp in Sources */,
                                BC0E607412D6BC200012A72A /* WebGeolocationPosition.cpp in Sources */,
                                BC1BE1F312D54DBD0004A228 /* WebGeolocationProvider.cpp in Sources */,
                                7801C099142290C400FAF9AF /* WebHitTestResult.cpp in Sources */,
+                               2684055218B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp in Sources */,
                                511B24AA132E097200065A0C /* WebIconDatabase.cpp in Sources */,
                                51834592134532E90092B696 /* WebIconDatabaseClient.cpp in Sources */,
                                51D02F64132EC5B900BEAA96 /* WebIconDatabaseMessageReceiver.cpp in Sources */,
diff --git a/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.cpp b/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.cpp
new file mode 100644 (file)
index 0000000..b028cf8
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ViewUpdateDispatcher.h"
+
+#if PLATFORM(IOS)
+
+#include "ViewUpdateDispatcherMessages.h"
+#include "WebPage.h"
+#include "WebProcess.h"
+#include <wtf/RunLoop.h>
+
+namespace WebKit {
+
+PassRef<ViewUpdateDispatcher> ViewUpdateDispatcher::create()
+{
+    return adoptRef(*new ViewUpdateDispatcher);
+}
+
+ViewUpdateDispatcher::ViewUpdateDispatcher()
+    : m_queue(WorkQueue::create("com.apple.WebKit.ViewUpdateDispatcher"))
+{
+}
+
+ViewUpdateDispatcher::~ViewUpdateDispatcher()
+{
+}
+
+void ViewUpdateDispatcher::initializeConnection(IPC::Connection* connection)
+{
+    connection->addWorkQueueMessageReceiver(Messages::ViewUpdateDispatcher::messageReceiverName(), m_queue.get(), this);
+}
+
+void ViewUpdateDispatcher::visibleContentRectUpdate(uint64_t pageID, const VisibleContentRectUpdateInfo& visibleContentRectUpdateInfo)
+{
+    {
+        MutexLocker locker(m_dataMutex);
+        m_latestUpdate.set(pageID, visibleContentRectUpdateInfo);
+    }
+    RunLoop::main()->dispatch(bind(&ViewUpdateDispatcher::dispatchVisibleContentRectUpdate, this));
+}
+
+void ViewUpdateDispatcher::dispatchVisibleContentRectUpdate()
+{
+    HashMap<uint64_t, VisibleContentRectUpdateInfo> localCopy;
+    {
+        MutexLocker locker(m_dataMutex);
+        localCopy.swap(m_latestUpdate);
+    }
+
+    for (auto& iterator : localCopy) {
+        if (WebPage* webPage = WebProcess::shared().webPage(iterator.key))
+            webPage->updateVisibleContentRects(iterator.value);
+    }
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.h b/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.h
new file mode 100644 (file)
index 0000000..44c624a
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ViewUpdateDispatcher_h
+#define ViewUpdateDispatcher_h
+
+#include "Connection.h"
+
+#include "VisibleContentRectUpdateInfo.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRef.h>
+
+namespace WebKit {
+
+class ViewUpdateDispatcher : public IPC::Connection::WorkQueueMessageReceiver {
+public:
+    static PassRef<ViewUpdateDispatcher> create();
+    ~ViewUpdateDispatcher();
+
+    void initializeConnection(IPC::Connection*);
+
+private:
+    ViewUpdateDispatcher();
+    // IPC::Connection::WorkQueueMessageReceiver.
+    virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
+
+    void visibleContentRectUpdate(uint64_t pageID, const VisibleContentRectUpdateInfo&);
+
+    void dispatchVisibleContentRectUpdate();
+
+    RefPtr<WorkQueue> m_queue;
+    Mutex m_dataMutex;
+    HashMap<uint64_t, VisibleContentRectUpdateInfo> m_latestUpdate;
+};
+
+} // namespace WebKit
+
+#endif // ViewportUpdateDispatcher_h
diff --git a/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.messages.in b/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.messages.in
new file mode 100644 (file)
index 0000000..17e2c8d
--- /dev/null
@@ -0,0 +1,25 @@
+# Copyright (C) 2014 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+messages -> ViewUpdateDispatcher {
+    VisibleContentRectUpdate(uint64_t pageID, WebKit::VisibleContentRectUpdateInfo visibleContentRectUpdateInfo)
+}
index 29ec621..3da982b 100644 (file)
@@ -284,6 +284,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 #endif
 #if PLATFORM(IOS)
     , m_shouldReturnWordAtSelection(false)
+    , m_scaleWasSetByUIProcess(false)
     , m_userHasChangedPageScaleFactor(false)
 #endif
     , m_inspectorClient(0)
@@ -1259,6 +1260,12 @@ void WebPage::windowScreenDidChange(uint64_t displayID)
 
 void WebPage::scalePage(double scale, const IntPoint& origin)
 {
+    if (scale == pageScaleFactor())
+        return;
+
+#if PLATFORM(IOS)
+    m_scaleWasSetByUIProcess = false;
+#endif
     PluginView* pluginView = pluginViewForFrame(&m_page->mainFrame());
     if (pluginView && pluginView->handlesPageScaleFactor()) {
         pluginView->setPageScaleFactor(scale, origin);
@@ -2636,6 +2643,7 @@ void WebPage::willCommitLayerTree(RemoteLayerTreeTransaction& layerTransaction)
     layerTransaction.setPageScaleFactor(corePage()->pageScaleFactor());
     layerTransaction.setRenderTreeSize(corePage()->renderTreeSize());
 #if PLATFORM(IOS)
+    layerTransaction.setScaleWasSetByUIProcess(scaleWasSetByUIProcess());
     layerTransaction.setMinimumScaleFactor(minimumPageScaleFactor());
     layerTransaction.setMaximumScaleFactor(maximumPageScaleFactor());
     layerTransaction.setAllowsUserScaling(allowsUserScaling());
index 1576b0e..cae7e96 100644 (file)
@@ -143,6 +143,7 @@ class PageBanner;
 class PageOverlay;
 class PluginView;
 class SessionState;
+class VisibleContentRectUpdateInfo;
 class WebColorChooser;
 class WebContextMenu;
 class WebContextMenuItemData;
@@ -661,9 +662,9 @@ public:
 #if PLATFORM(IOS)
     void setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize&);
     void viewportConfigurationChanged();
+    void updateVisibleContentRects(const VisibleContentRectUpdateInfo&);
+    bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
     void willStartUserTriggeredZooming();
-    void didFinishScrolling(const WebCore::FloatPoint& contentOffset);
-    void didFinishZooming(float);
 #endif
 
 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
@@ -1094,6 +1095,7 @@ private:
     bool m_shouldReturnWordAtSelection;
 
     WebCore::ViewportConfiguration m_viewportConfiguration;
+    bool m_scaleWasSetByUIProcess;
     bool m_userHasChangedPageScaleFactor;
     WebCore::IntSize m_blockSelectionDesiredSize;
 #endif
index 42fb946..d122261 100644 (file)
@@ -315,7 +315,6 @@ messages -> WebPage LegacyReceiver {
 
 #if PLATFORM(IOS)
     WillStartUserTriggeredZooming();
-    DidFinishZooming(float scale);
 #endif
 
 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
index 7159596..7d4f946 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,6 +29,8 @@
 #import "AssistedNodeInformation.h"
 #import "EditorState.h"
 #import "InteractionInformationAtPosition.h"
+#import "LayerTreeHost.h"
+#import "VisibleContentRectUpdateInfo.h"
 #import "WebChromeClient.h"
 #import "WebCoreArgumentCoders.h"
 #import "WebFrame.h"
@@ -1615,14 +1617,30 @@ void WebPage::viewportConfigurationChanged()
     scalePage(scale, m_page->mainFrame().view()->scrollPosition());
 }
 
-void WebPage::willStartUserTriggeredZooming()
+void WebPage::updateVisibleContentRects(const VisibleContentRectUpdateInfo& visibleContentRectUpdateInfo)
 {
-    m_userHasChangedPageScaleFactor = true;
+    double boundedScale = std::min(m_viewportConfiguration.maximumScale(), std::max(m_viewportConfiguration.minimumScale(), visibleContentRectUpdateInfo.scale()));
+
+    IntPoint scrollPosition = roundedIntPoint(visibleContentRectUpdateInfo.unobscuredRect().location());
+
+    FloatRect exposedRect = visibleContentRectUpdateInfo.exposedRect();
+    exposedRect.scale(boundedScale);
+    m_drawingArea->setExposedRect(exposedRect);
+
+    if (boundedScale != m_page->pageScaleFactor()) {
+        m_scaleWasSetByUIProcess = true;
+        m_page->setPageScaleFactor(boundedScale, scrollPosition);
+        if (m_drawingArea->layerTreeHost())
+            m_drawingArea->layerTreeHost()->deviceOrPageScaleFactorChanged();
+        send(Messages::WebPageProxy::PageScaleFactorDidChange(boundedScale));
+    }
+
+    // FIXME: we should also update the frame view from unobscured rect. Altenatively, we can have it pull the values from ScrollView.
 }
 
-void WebPage::didFinishZooming(float newScale)
+void WebPage::willStartUserTriggeredZooming()
 {
-    m_page->setPageScaleFactor(newScale, m_page->mainFrame().view()->scrollPosition());
+    m_userHasChangedPageScaleFactor = true;
 }
 
 } // namespace WebKit
index 857980f..157628c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
index 82dc3f1..bdd743e 100644 (file)
@@ -151,6 +151,9 @@ WebProcess& WebProcess::shared()
 
 WebProcess::WebProcess()
     : m_eventDispatcher(EventDispatcher::create())
+#if PLATFORM(IOS)
+    , m_viewUpdateDispatcher(ViewUpdateDispatcher::create())
+#endif // PLATFORM(IOS)
     , m_inDidClose(false)
     , m_shouldTrackVisitedLinks(true)
     , m_hasSetCacheModel(false)
@@ -216,6 +219,9 @@ void WebProcess::initializeConnection(IPC::Connection* connection)
     connection->setShouldExitOnSyncMessageSendFailure(true);
 
     m_eventDispatcher->initializeConnection(connection);
+#if PLATFORM(IOS)
+    m_viewUpdateDispatcher->initializeConnection(connection);
+#endif // PLATFORM(IOS)
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
     m_pluginProcessConnectionManager->initializeConnection(connection);
index 2b1caed..b48b5fe 100644 (file)
@@ -34,6 +34,7 @@
 #include "SandboxExtension.h"
 #include "SharedMemory.h"
 #include "TextCheckerState.h"
+#include "ViewUpdateDispatcher.h"
 #include "VisitedLinkTable.h"
 #include <WebCore/LinkHash.h>
 #include <WebCore/Timer.h>
@@ -279,6 +280,9 @@ private:
     RefPtr<InjectedBundle> m_injectedBundle;
 
     RefPtr<EventDispatcher> m_eventDispatcher;
+#if PLATFORM(IOS)
+    RefPtr<ViewUpdateDispatcher> m_viewUpdateDispatcher;
+#endif
 
     bool m_inDidClose;