[iOS] Page scale update messages for media controls should only fire at the end of...
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2014 00:09:28 +0000 (00:09 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2014 00:09:28 +0000 (00:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132857
<rdar://problem/16631009>

Reviewed by Simon Fraser.

As the user was zooming, the media controls that responded
to the page scale (and resized themselves) would do so
slightly out of sync with the screen refreshes, and it looked

Source/WebCore:
terrible. They really only need to get told at the end
of the zoom that they need to relayout.

Allow setPageScaleFactor to accept another parameter
that indicates if the change is stable. That way, changes
during a user triggers zoom gesture can be ignored for
media controls.

* WebCore.exp.in: Page::setPageScaleFactor takes a new parameter.
* dom/Document.cpp:
(WebCore::Document::pageScaleFactorChangedAndStable): Renamed from pageScaleFactorChanged.
(WebCore::Document::pageScaleFactorChanged): Deleted.
* dom/Document.h:
* page/Page.cpp:
(WebCore::Page::setPageScaleFactor): Accepts a new inStableState parameter,
and tells the main frame that the scale factor has changed if it's stable.
* page/Page.h:

Source/WebKit2:
terrible.

We already know if a pageScale change is happening inside
a gesture using the inStableState property of the visibleContentRectUpdateInfo.
Simply pass this along to WebCore::Page.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::updateVisibleContentRects): Pass inStableState onto the
WebCore::Page. Note that we have to send this message even if the
scale has not changed, since the last changing update might not have
been stable.

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index 0af0448..cb63ab0 100644 (file)
@@ -1,3 +1,32 @@
+2014-05-13  Dean Jackson  <dino@apple.com>
+
+        [iOS] Page scale update messages for media controls should only fire at the end of zooming
+        https://bugs.webkit.org/show_bug.cgi?id=132857
+        <rdar://problem/16631009>
+
+        Reviewed by Simon Fraser.
+
+        As the user was zooming, the media controls that responded
+        to the page scale (and resized themselves) would do so
+        slightly out of sync with the screen refreshes, and it looked
+        terrible. They really only need to get told at the end
+        of the zoom that they need to relayout.
+
+        Allow setPageScaleFactor to accept another parameter
+        that indicates if the change is stable. That way, changes
+        during a user triggers zoom gesture can be ignored for
+        media controls.
+
+        * WebCore.exp.in: Page::setPageScaleFactor takes a new parameter.
+        * dom/Document.cpp:
+        (WebCore::Document::pageScaleFactorChangedAndStable): Renamed from pageScaleFactorChanged.
+        (WebCore::Document::pageScaleFactorChanged): Deleted.
+        * dom/Document.h:
+        * page/Page.cpp:
+        (WebCore::Page::setPageScaleFactor): Accepts a new inStableState parameter,
+        and tells the main frame that the scale factor has changed if it's stable.
+        * page/Page.h:
+
 2014-05-13  Eric Carlson  <eric.carlson@apple.com>
 
         Unreviewed build fix after r168755.
index 4b4726d..3b81536 100644 (file)
@@ -1065,7 +1065,7 @@ __ZN7WebCore4Page16countFindMatchesERKN3WTF6StringEhj
 __ZN7WebCore4Page16setCanStartMediaEb
 __ZN7WebCore4Page16setDefersLoadingEb
 __ZN7WebCore4Page18removeSchedulePairEN3WTF10PassRefPtrINS1_12SchedulePairEEE
-__ZN7WebCore4Page18setPageScaleFactorEfRKNS_8IntPointE
+__ZN7WebCore4Page18setPageScaleFactorEfRKNS_8IntPointEb
 __ZN7WebCore4Page18setTopContentInsetEf
 __ZN7WebCore4Page19addLayoutMilestonesEj
 __ZN7WebCore4Page19createPageThrottlerEv
index d71b6f3..465b069 100644 (file)
@@ -4204,7 +4204,7 @@ void Document::unregisterForPageScaleFactorChangedCallbacks(HTMLMediaElement* el
     m_pageScaleFactorChangedElements.remove(element);
 }
 
-void Document::pageScaleFactorChanged()
+void Document::pageScaleFactorChangedAndStable()
 {
     for (HTMLMediaElement* mediaElement : m_pageScaleFactorChangedElements)
         mediaElement->pageScaleFactorChanged();
index 54ef9c0..7c09697 100644 (file)
@@ -1046,7 +1046,7 @@ public:
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     void registerForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
     void unregisterForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
-    void pageScaleFactorChanged();
+    void pageScaleFactorChangedAndStable();
 #endif
 
 #if ENABLE(PAGE_VISIBILITY_API)
index f5fbfb5..1fa7407 100644 (file)
@@ -707,7 +707,7 @@ void Page::setZoomedOutPageScaleFactor(float scale)
     mainFrame().deviceOrPageScaleFactorChanged();
 }
 
-void Page::setPageScaleFactor(float scale, const IntPoint& origin)
+void Page::setPageScaleFactor(float scale, const IntPoint& origin, bool inStableState)
 {
     Document* document = mainFrame().document();
     FrameView* view = document->view();
@@ -724,6 +724,12 @@ void Page::setPageScaleFactor(float scale, const IntPoint& origin)
                 view->hostWindow()->delegatedScrollRequested(origin);
 #endif
         }
+#if ENABLE(MEDIA_CONTROLS_SCRIPT)
+        if (inStableState) {
+            for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
+                frame->document()->pageScaleFactorChangedAndStable();
+        }
+#endif
         return;
     }
 
@@ -757,8 +763,10 @@ void Page::setPageScaleFactor(float scale, const IntPoint& origin)
     }
 
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
-    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
-        frame->document()->pageScaleFactorChanged();
+    if (inStableState) {
+        for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
+            frame->document()->pageScaleFactorChangedAndStable();
+    }
 #endif
 }
 
@@ -783,7 +791,7 @@ void Page::setDeviceScaleFactor(float scaleFactor)
     pageCache()->markPagesForFullStyleRecalc(this);
     GraphicsContext::updateDocumentMarkerResources();
 }
-    
+
 void Page::setTopContentInset(float contentInset)
 {
     if (m_topContentInset == contentInset)
index 59f8ae6..9d3686c 100644 (file)
@@ -271,7 +271,7 @@ public:
     float mediaVolume() const { return m_mediaVolume; }
     void setMediaVolume(float);
 
-    void setPageScaleFactor(float scale, const IntPoint& origin);
+    void setPageScaleFactor(float scale, const IntPoint& origin, bool inStableState = true);
     float pageScaleFactor() const { return m_pageScaleFactor; }
 
     void setZoomedOutPageScaleFactor(float);
index c23d18e..9200ff6 100644 (file)
@@ -1,3 +1,26 @@
+2014-05-13  Dean Jackson  <dino@apple.com>
+
+        [iOS] Page scale update messages for media controls should only fire at the end of zooming
+        https://bugs.webkit.org/show_bug.cgi?id=132857
+        <rdar://problem/16631009>
+
+        Reviewed by Simon Fraser.
+
+        As the user was zooming, the media controls that responded
+        to the page scale (and resized themselves) would do so
+        slightly out of sync with the screen refreshes, and it looked
+        terrible.
+
+        We already know if a pageScale change is happening inside
+        a gesture using the inStableState property of the visibleContentRectUpdateInfo.
+        Simply pass this along to WebCore::Page.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::updateVisibleContentRects): Pass inStableState onto the
+        WebCore::Page. Note that we have to send this message even if the
+        scale has not changed, since the last changing update might not have
+        been stable.
+
 2014-05-13  Benjamin Poulain  <bpoulain@apple.com>
 
         [iOS][WK2] When the secondary UIScrollView delegates respond to callbacks, delay the state change until both delegates have finished
index 8e4d2b1..fcb792b 100644 (file)
@@ -2164,17 +2164,25 @@ void WebPage::updateVisibleContentRects(const VisibleContentRectUpdateInfo& visi
     IntPoint scrollPosition = roundedUnobscuredRect.location();
 
     float floatBoundedScale = boundedScale;
+    bool hasSetPageScale = false;
     if (floatBoundedScale != m_page->pageScaleFactor()) {
         m_scaleWasSetByUIProcess = true;
 
         m_dynamicSizeUpdateHistory.clear();
 
-        m_page->setPageScaleFactor(floatBoundedScale, scrollPosition);
+        m_page->setPageScaleFactor(floatBoundedScale, scrollPosition, visibleContentRectUpdateInfo.inStableState());
+        hasSetPageScale = true;
+
         if (LayerTreeHost* layerTreeHost = m_drawingArea->layerTreeHost())
             layerTreeHost->deviceOrPageScaleFactorChanged();
         send(Messages::WebPageProxy::PageScaleFactorDidChange(floatBoundedScale));
     }
 
+    if (!hasSetPageScale && visibleContentRectUpdateInfo.inStableState()) {
+        m_page->setPageScaleFactor(floatBoundedScale, scrollPosition, true);
+        hasSetPageScale = true;
+    }
+
     FrameView& frameView = *m_page->mainFrame().view();
     if (scrollPosition != IntPoint(frameView.scrollOffset()))
         m_dynamicSizeUpdateHistory.clear();