Title: [137792] trunk/Source
Revision
137792
Author
[email protected]
Date
2012-12-14 17:21:25 -0800 (Fri, 14 Dec 2012)

Log Message

WebViewImpl::resetScrollAndScaleState() causes the page to render incorrectly
https://bugs.webkit.org/show_bug.cgi?id=104767

Patch by Dan Alcantara <[email protected]> on 2012-12-14
Reviewed by Darin Fisher.

Change WebViewImpl::resetScrollAndScaleState() so that it directly
alters values in the HistoryItem instead of indirectly changing the
values.

Adds a method in HistoryController to clear the scroll and scale state of
its current HistoryItem.

* public/WebView.h:
(WebView):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::resetScrollAndScaleState):
* tests/WebViewTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/loader/HistoryController.cpp (137791 => 137792)


--- trunk/Source/WebCore/loader/HistoryController.cpp	2012-12-15 00:52:24 UTC (rev 137791)
+++ trunk/Source/WebCore/loader/HistoryController.cpp	2012-12-15 01:21:25 UTC (rev 137792)
@@ -93,6 +93,15 @@
     m_frame->loader()->client()->saveViewStateToItem(item);
 }
 
+void HistoryController::clearScrollPositionAndViewState()
+{
+    if (!m_currentItem)
+        return;
+
+    m_currentItem->clearScrollPoint();
+    m_currentItem->setPageScaleFactor(0);
+}
+
 /*
  There is a race condition between the layout and load completion that affects restoring the scroll position.
  We try to restore the scroll position at both the first layout and upon load completion.

Modified: trunk/Source/WebCore/loader/HistoryController.h (137791 => 137792)


--- trunk/Source/WebCore/loader/HistoryController.h	2012-12-15 00:52:24 UTC (rev 137791)
+++ trunk/Source/WebCore/loader/HistoryController.h	2012-12-15 01:21:25 UTC (rev 137792)
@@ -52,6 +52,7 @@
     ~HistoryController();
 
     void saveScrollPositionAndViewStateToItem(HistoryItem*);
+    void clearScrollPositionAndViewState();
     void restoreScrollPositionAndViewState();
 
     void updateBackForwardListForFragmentScroll();

Modified: trunk/Source/WebKit/chromium/ChangeLog (137791 => 137792)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-12-15 00:52:24 UTC (rev 137791)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-12-15 01:21:25 UTC (rev 137792)
@@ -1,3 +1,23 @@
+2012-12-14  Dan Alcantara  <[email protected]>
+
+        WebViewImpl::resetScrollAndScaleState() causes the page to render incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=104767
+
+        Reviewed by Darin Fisher.
+
+        Change WebViewImpl::resetScrollAndScaleState() so that it directly
+        alters values in the HistoryItem instead of indirectly changing the
+        values.
+
+        Adds a method in HistoryController to clear the scroll and scale state of
+        its current HistoryItem.
+
+        * public/WebView.h:
+        (WebView):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::resetScrollAndScaleState):
+        * tests/WebViewTest.cpp:
+
 2012-12-14  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r137765.

Modified: trunk/Source/WebKit/chromium/public/WebView.h (137791 => 137792)


--- trunk/Source/WebKit/chromium/public/WebView.h	2012-12-15 00:52:24 UTC (rev 137791)
+++ trunk/Source/WebKit/chromium/public/WebView.h	2012-12-15 01:21:25 UTC (rev 137792)
@@ -262,8 +262,7 @@
     // state, this function deletes any saved scroll and scale state.
     virtual void restoreScrollAndScaleState() = 0;
 
-    // Reset the scroll and scale state and clobber any previously saved values for
-    // these parameters.
+    // Reset any saved values for the scroll and scale state.
     virtual void resetScrollAndScaleState() = 0;
 
     // Prevent the web page from setting a maximum scale via the viewport meta

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (137791 => 137792)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-12-15 00:52:24 UTC (rev 137791)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-12-15 01:21:25 UTC (rev 137792)
@@ -3095,14 +3095,18 @@
 
 void WebViewImpl::resetScrollAndScaleState()
 {
-    page()->setPageScaleFactor(0, IntPoint());
+    page()->setPageScaleFactor(1, IntPoint());
+
+    // Clear out the values for the current history item. This will prevent the history item from clobbering the
+    // value determined during page scale initialization, which may be less than 1.
+    page()->mainFrame()->loader()->history()->saveDocumentAndScrollState();
+    page()->mainFrame()->loader()->history()->clearScrollPositionAndViewState();
     m_pageScaleFactorIsSet = false;
 
     // Clobber saved scales and scroll offsets.
     if (FrameView* view = page()->mainFrame()->document()->view())
         view->cacheCurrentScrollPosition();
     resetSavedScrollAndScaleState();
-    page()->mainFrame()->loader()->history()->saveDocumentAndScrollState();
 }
 
 WebSize WebViewImpl::fixedLayoutSize() const

Modified: trunk/Source/WebKit/chromium/tests/WebViewTest.cpp (137791 => 137792)


--- trunk/Source/WebKit/chromium/tests/WebViewTest.cpp	2012-12-15 00:52:24 UTC (rev 137791)
+++ trunk/Source/WebKit/chromium/tests/WebViewTest.cpp	2012-12-15 01:21:25 UTC (rev 137792)
@@ -482,14 +482,15 @@
     EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height);
     webViewImpl->page()->mainFrame()->loader()->history()->saveDocumentAndScrollState();
 
-    // Confirm that resetting the page state resets both the scale and scroll position, as well
-    // as overwrites the original parameters that were saved to the HistoryController.
+    // Confirm that resetting the page state resets the saved scroll position.
+    // The HistoryController treats a page scale factor of 0.0f as special and avoids
+    // restoring it to the WebView.
     webViewImpl->resetScrollAndScaleState();
-    EXPECT_EQ(0.0f, webViewImpl->pageScaleFactor());
+    EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor());
     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
     webViewImpl->page()->mainFrame()->loader()->history()->restoreScrollPositionAndViewState();
-    EXPECT_EQ(0.0f, webViewImpl->pageScaleFactor());
+    EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor());
     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
     webViewImpl->close();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to