Changeset 102292 in webkit
- Timestamp:
- Dec 7, 2011 5:53:42 PM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r102283 r102292 1 2011-12-07 Alexandre Elias <aelias@google.com> 2 3 [chromium] Preserve original pageScale limits in WebViewImpl 4 https://bugs.webkit.org/show_bug.cgi?id=72983 5 6 Reviewed by Darin Fisher. 7 8 Preserve the originally viewport-tag specified page scale limits, and 9 compute the final ones in a new private method 10 computePageScaleFactorLimits(). This is then called when contents 11 size change (which can affect the minimum). 12 13 Also clean up several minor bugs, namely clamping issues (reorder 14 clampNegativeToZero to avoid negative scroll offsets, and force max to 15 be greater than min), and incorrect behavior in the presence of 16 "solid" scrollbars. 17 18 * src/ChromeClientImpl.cpp: 19 (WebKit::ChromeClientImpl::contentsSizeChanged): 20 * src/WebViewImpl.cpp: 21 (WebKit::WebViewImpl::WebViewImpl): 22 (WebKit::WebViewImpl::clampPageScaleFactorToLimits): 23 (WebKit::WebViewImpl::clampOffsetAtScale): 24 (WebKit::WebViewImpl::setPageScaleFactorPreservingScrollOffset): 25 (WebKit::WebViewImpl::setPageScaleFactor): 26 (WebKit::WebViewImpl::setPageScaleFactorLimits): 27 (WebKit::WebViewImpl::computePageScaleFactorLimits): 28 (WebKit::WebViewImpl::didChangeContentsSize): 29 * src/WebViewImpl.h: 30 1 31 2011-12-07 Chris Sharp <csharp@chromium.org> 2 32 -
trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp
r102044 r102292 551 551 void ChromeClientImpl::contentsSizeChanged(Frame* frame, const IntSize& size) const 552 552 { 553 m_webView->didChangeContentsSize(); 554 553 555 WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame); 554 556 if (webframe->client()) -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r102181 r102292 344 344 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) 345 345 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) 346 , m_pageDefinedMinimumPageScaleFactor(-1) 347 , m_pageDefinedMaximumPageScaleFactor(-1) 346 348 , m_minimumPageScaleFactor(minPageScaleFactor) 347 349 , m_maximumPageScaleFactor(maxPageScaleFactor) … … 1954 1956 } 1955 1957 1956 float WebViewImpl::c omputePageScaleFactorWithinLimits(float scaleFactor)1958 float WebViewImpl::clampPageScaleFactorToLimits(float scaleFactor) 1957 1959 { 1958 1960 return min(max(scaleFactor, m_minimumPageScaleFactor), m_maximumPageScaleFactor); … … 1971 1973 // Enforce the maximum and minimum scroll positions at the new scale. 1972 1974 IntPoint clampedOffset = offset; 1975 clampedOffset = clampedOffset.shrunkTo(IntPoint(docWidthAtNewScale - viewWidth, docHeightAtNewScale - viewHeight)); 1973 1976 clampedOffset.clampNegativeToZero(); 1974 clampedOffset = clampedOffset.shrunkTo(IntPoint(docWidthAtNewScale - viewWidth, docHeightAtNewScale - viewHeight));1975 1977 return clampedOffset; 1976 1978 } … … 1979 1981 { 1980 1982 // Pick a scale factor that is within the expected limits 1981 scaleFactor = c omputePageScaleFactorWithinLimits(scaleFactor);1983 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); 1982 1984 if (scaleFactor == pageScaleFactor()) 1983 1985 return; … … 1999 2001 scaleFactor = 1; 2000 2002 2001 scaleFactor = c omputePageScaleFactorWithinLimits(scaleFactor);2003 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); 2002 2004 WebPoint clampedOrigin = clampOffsetAtScale(origin, scaleFactor); 2003 2005 page()->setPageScaleFactor(scaleFactor, clampedOrigin); … … 2065 2067 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScale) 2066 2068 { 2067 m_minimumPageScaleFactor = min(max(minPageScale, minPageScaleFactor), maxPageScaleFactor) * deviceScaleFactor(); 2068 m_maximumPageScaleFactor = max(min(maxPageScale, maxPageScaleFactor), minPageScaleFactor) * deviceScaleFactor(); 2069 2070 if (m_size.width && mainFrame() && mainFrame()->contentsSize().width) { 2069 m_pageDefinedMinimumPageScaleFactor = minPageScale; 2070 m_pageDefinedMaximumPageScaleFactor = maxPageScale; 2071 computePageScaleFactorLimits(); 2072 } 2073 2074 bool WebViewImpl::computePageScaleFactorLimits() 2075 { 2076 if (m_pageDefinedMinimumPageScaleFactor == -1 || m_pageDefinedMaximumPageScaleFactor == -1) 2077 return false; 2078 2079 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()->view()) 2080 return false; 2081 2082 m_minimumPageScaleFactor = min(max(m_pageDefinedMinimumPageScaleFactor, minPageScaleFactor), maxPageScaleFactor) * deviceScaleFactor(); 2083 m_maximumPageScaleFactor = max(min(m_pageDefinedMaximumPageScaleFactor, maxPageScaleFactor), minPageScaleFactor) * deviceScaleFactor(); 2084 2085 int viewWidthNotIncludingScrollbars = page()->mainFrame()->view()->visibleContentRect(false).width(); 2086 int contentsWidth = mainFrame()->contentsSize().width; 2087 if (viewWidthNotIncludingScrollbars && contentsWidth) { 2071 2088 // Limit page scaling down to the document width. 2072 int viewWidth = m_size.width;2073 int unscaledContentWidth = mainFrame()->contentsSize().width / pageScaleFactor();2074 m_m inimumPageScaleFactor = max(m_minimumPageScaleFactor, static_cast<float>(viewWidth) / unscaledContentWidth);2075 } 2076 ASSERT(m inPageScale <= maxPageScale);2089 int unscaledContentWidth = contentsWidth / pageScaleFactor(); 2090 m_minimumPageScaleFactor = max(m_minimumPageScaleFactor, static_cast<float>(viewWidthNotIncludingScrollbars) / unscaledContentWidth); 2091 m_maximumPageScaleFactor = max(m_minimumPageScaleFactor, m_maximumPageScaleFactor); 2092 } 2093 ASSERT(m_minimumPageScaleFactor <= m_maximumPageScaleFactor); 2077 2094 #if USE(ACCELERATED_COMPOSITING) 2078 2095 if (m_layerTreeHost) … … 2080 2097 #endif 2081 2098 2082 float clampedScale = c omputePageScaleFactorWithinLimits(pageScaleFactor());2083 if (clampedScale != pageScaleFactor()) 2099 float clampedScale = clampPageScaleFactorToLimits(pageScaleFactor()); 2100 if (clampedScale != pageScaleFactor()) { 2084 2101 setPageScaleFactorPreservingScrollOffset(clampedScale); 2102 return true; 2103 } 2104 2105 return false; 2085 2106 } 2086 2107 … … 2592 2613 } 2593 2614 2615 void WebViewImpl::didChangeContentsSize() 2616 { 2617 bool didClampScale = computePageScaleFactorLimits(); 2618 2619 if (!didClampScale) 2620 return; 2621 2622 if (!mainFrameImpl()) 2623 return; 2624 2625 FrameView* view = mainFrameImpl()->frameView(); 2626 if (view && view->needsLayout()) 2627 view->layout(); 2628 } 2629 2594 2630 bool WebViewImpl::useExternalPopupMenus() 2595 2631 { -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r102044 r102292 336 336 void layoutUpdated(WebFrameImpl*); 337 337 338 void didChangeContentsSize(); 339 338 340 // Returns true if popup menus should be rendered by the browser, false if 339 341 // they should be rendered by WebKit (which is the default). … … 462 464 463 465 private: 464 float computePageScaleFactorWithinLimits(float scale); 466 bool computePageScaleFactorLimits(); 467 float clampPageScaleFactorToLimits(float scale); 465 468 WebPoint clampOffsetAtScale(const WebPoint& offset, float scale); 466 469 … … 569 572 double m_maximumZoomLevel; 570 573 574 float m_pageDefinedMinimumPageScaleFactor; 575 float m_pageDefinedMaximumPageScaleFactor; 571 576 float m_minimumPageScaleFactor; 572 573 577 float m_maximumPageScaleFactor; 574 578
Note: See TracChangeset
for help on using the changeset viewer.