Changeset 128133 in webkit
- Timestamp:
- Sep 10, 2012 5:22:06 PM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r128125 r128133 1 2012-09-10 Dan Alcantara <dfalcantara@chromium.org> 2 3 [chromium, android] Reloading a page with a different user agent can cause the page to be zoomed in 4 https://bugs.webkit.org/show_bug.cgi?id=90222 5 6 Reviewed by Adam Barth. 7 8 When reloading a page with an overridden URL, the page's scroll and zoom 9 state will be restored once the reload is complete. This is problematic 10 in situations when switching between mobile and desktop versions of the 11 same site because it will zoom back in on a random part of alternate page. 12 This CL just avoids that situation by resetting the zoom and scale whenever 13 this type of reload occurs. 14 15 Chromium half: https://chromiumcodereview.appspot.com/10889019 16 17 * public/WebView.h: 18 (WebView): 19 * src/WebViewImpl.cpp: 20 (WebKit::WebViewImpl::resetScrollAndScaleState): 21 (WebKit): 22 * src/WebViewImpl.h: 23 (WebViewImpl): 24 1 25 2012-09-10 Adam Barth <abarth@chromium.org> 2 26 -
trunk/Source/WebKit/chromium/public/WebView.h
r126841 r128133 258 258 virtual void saveScrollAndScaleState() = 0; 259 259 260 // Restore the previously saved scroll and scale state. After rest roing the260 // Restore the previously saved scroll and scale state. After restoring the 261 261 // state, this function deletes any saved scroll and scale state. 262 262 virtual void restoreScrollAndScaleState() = 0; 263 264 // Reset the scroll and scale state and clobber any previously saved values for 265 // these parameters. 266 virtual void resetScrollAndScaleState() = 0; 263 267 264 268 // Prevent the web page from setting a maximum scale via the viewport meta -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r128093 r128133 2929 2929 } 2930 2930 2931 void WebViewImpl::resetScrollAndScaleState() 2932 { 2933 page()->setPageScaleFactor(0, IntPoint()); 2934 m_pageScaleFactorIsSet = false; 2935 2936 // Clobber saved scales and scroll offsets. 2937 if (FrameView* view = page()->mainFrame()->document()->view()) 2938 view->cacheCurrentScrollPosition(); 2939 resetSavedScrollAndScaleState(); 2940 page()->mainFrame()->loader()->history()->saveDocumentAndScrollState(); 2941 } 2942 2931 2943 WebSize WebViewImpl::fixedLayoutSize() const 2932 2944 { -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r127948 r128133 228 228 virtual void saveScrollAndScaleState(); 229 229 virtual void restoreScrollAndScaleState(); 230 virtual void resetScrollAndScaleState(); 230 231 virtual void setIgnoreViewportTagMaximumScale(bool); 231 232 -
trunk/Source/WebKit/chromium/tests/WebViewTest.cpp
r127263 r128133 423 423 } 424 424 425 TEST_F(WebViewTest, ResetScrollAndScaleState) 426 { 427 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("hello_world.html")); 428 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "hello_world.html")); 429 webViewImpl->resize(WebSize(640, 480)); 430 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 431 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 432 433 // Make the page scale and scroll with the given paremeters. 434 webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); 435 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 436 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); 437 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); 438 webViewImpl->page()->mainFrame()->loader()->history()->saveDocumentAndScrollState(); 439 440 // Confirm that restoring the page state restores the parameters. 441 webViewImpl->setPageScaleFactor(1.5f, WebPoint(16, 24)); 442 EXPECT_EQ(1.5f, webViewImpl->pageScaleFactor()); 443 EXPECT_EQ(16, webViewImpl->mainFrame()->scrollOffset().width); 444 EXPECT_EQ(24, webViewImpl->mainFrame()->scrollOffset().height); 445 webViewImpl->page()->mainFrame()->loader()->history()->restoreScrollPositionAndViewState(); 446 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 447 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); 448 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); 449 webViewImpl->page()->mainFrame()->loader()->history()->saveDocumentAndScrollState(); 450 451 // Confirm that resetting the page state resets both the scale and scroll position, as well 452 // as overwrites the original parameters that were saved to the HistoryController. 453 webViewImpl->resetScrollAndScaleState(); 454 EXPECT_EQ(0.0f, webViewImpl->pageScaleFactor()); 455 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 456 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 457 webViewImpl->page()->mainFrame()->loader()->history()->restoreScrollPositionAndViewState(); 458 EXPECT_EQ(0.0f, webViewImpl->pageScaleFactor()); 459 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 460 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 461 webViewImpl->close(); 462 } 463 425 464 class ContentDetectorClient : public WebViewClient { 426 465 public:
Note: See TracChangeset
for help on using the changeset viewer.