Changeset 100196 in webkit
- Timestamp:
- Nov 14, 2011, 2:47:05 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
- 1 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png (modified) ( previous)
-
LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.txt (added)
-
LayoutTests/platform/chromium/fast/repaint/background-scaling-expected.png (copied) (copied from trunk/LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png )
-
LayoutTests/platform/chromium/fast/repaint/background-scaling-expected.txt (added)
-
Source/WebKit/chromium/ChangeLog (modified) (1 diff)
-
Source/WebKit/chromium/public/WebView.h (modified) (2 diffs)
-
Source/WebKit/chromium/src/WebViewImpl.cpp (modified) (6 diffs)
-
Source/WebKit/chromium/src/WebViewImpl.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r100193 r100196 1 2011-11-14 Fady Samuel <fsamuel@chromium.org> 2 3 [Chromium] setPageScaleFactor and associated methods should take scaling limits into account 4 https://bugs.webkit.org/show_bug.cgi?id=72176 5 6 Reviewed by Darin Fisher. 7 8 Rebaselined some tests that broke because we now clamp pageScaleFactor to 0.25 (these test at 0.2). 9 10 Since this is a Chromium only change, the new baselines are only for Chromium. 11 12 * platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png: 13 * platform/chromium-linux/fast/repaint/scale-page-shrink-expected.txt: Added. 14 * platform/chromium/fast/repaint/background-scaling-expected.png: Copied from LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png. 15 * platform/chromium/fast/repaint/background-scaling-expected.txt: Added. 16 1 17 2011-11-14 Robert Hogan <robert@webkit.org> 2 18 -
trunk/Source/WebKit/chromium/ChangeLog
r100194 r100196 1 2011-11-14 Fady Samuel <fsamuel@chromium.org> 2 3 [Chromium] setPageScaleFactor and associated methods should take scaling limits into account 4 https://bugs.webkit.org/show_bug.cgi?id=72176 5 6 Reviewed by Darin Fisher. 7 8 A couple of changes: 9 10 1. setPageScaleFactorLimits now affects the behavior of other scaling methods 11 including setPageScaleFactor. 12 2. setPageScaleFactorPreservingScrollOffset introduced that scales the scroll offset 13 along with the page, preserving the scroll position within the page bounds. 14 15 16 * public/WebView.h: 17 * src/WebViewImpl.cpp: 18 (WebKit::WebViewImpl::WebViewImpl): 19 (WebKit::WebViewImpl::computePageScaleFactorWithinLimits): 20 (WebKit::WebViewImpl::clampOffsetAtScale): 21 (WebKit::WebViewImpl::setPageScaleFactorPreservingScrollOffset): 22 (WebKit::WebViewImpl::setPageScaleFactor): 23 (WebKit::WebViewImpl::setPageScaleFactorLimits): 24 (WebKit::WebViewImpl::applyScrollAndScale): 25 * src/WebViewImpl.h: 26 1 27 2011-11-14 Vincent Scheib <scheib@chromium.org> 2 28 -
trunk/Source/WebKit/chromium/public/WebView.h
r99774 r100196 62 62 WEBKIT_EXPORT static const double minTextSizeMultiplier; 63 63 WEBKIT_EXPORT static const double maxTextSizeMultiplier; 64 WEBKIT_EXPORT static const float minPageScaleFactor; 65 WEBKIT_EXPORT static const float maxPageScaleFactor; 64 66 65 67 // Controls the time that user scripts injected into the document run. … … 208 210 WEBKIT_EXPORT static double zoomFactorToZoomLevel(double factor); 209 211 212 // Gets the scale factor of the page, where 1.0 is the normal size, > 1.0 213 // is scaled up, < 1.0 is scaled down. 214 virtual float pageScaleFactor() const = 0; 215 216 // Scales the page and the scroll offset by a given factor, while ensuring 217 // that the new scroll position does not go beyond the edge of the page. 218 virtual void setPageScaleFactorPreservingScrollOffset(float) = 0; 219 220 // Scales a page by a factor of scaleFactor and then sets a scroll position to (x, y). 221 // setPageScaleFactor() magnifies and shrinks a page without affecting layout. 222 // On the other hand, zooming affects layout of the page. 223 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin) = 0; 224 210 225 // PageScaleFactor will be force-clamped between minPageScale and maxPageScale 211 226 // (and these values will persist until setPageScaleFactorLimits is called 212 227 // again). 213 228 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale) = 0; 214 215 // Gets the scale factor of the page, where 1.0 is the normal size, > 1.0216 // is scaled up, < 1.0 is scaled down.217 virtual float pageScaleFactor() const = 0;218 219 // Scales a page by a factor of scaleFactor and then sets a scroll position to (x, y).220 // setPageScaleFactor() magnifies and shrinks a page without affecting layout.221 // On the other hand, zooming affects layout of the page.222 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin) = 0;223 229 224 230 // The ratio of the current device's screen DPI to the target device's screen DPI. -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r100099 r100196 200 200 const double WebView::minTextSizeMultiplier = 0.5; 201 201 const double WebView::maxTextSizeMultiplier = 3.0; 202 const float WebView::minPageScaleFactor = 0.25; 203 const float WebView::maxPageScaleFactor = 4.0; 202 204 203 205 … … 339 341 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) 340 342 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) 343 , m_minimumPageScaleFactor(minPageScaleFactor) 344 , m_maximumPageScaleFactor(maxPageScaleFactor) 341 345 , m_contextMenuAllowed(false) 342 346 , m_doingDragAndDrop(false) … … 1853 1857 } 1854 1858 1859 float WebViewImpl::computePageScaleFactorWithinLimits(float scaleFactor) 1860 { 1861 return min(max(scaleFactor, m_minimumPageScaleFactor), m_maximumPageScaleFactor); 1862 } 1863 1864 WebPoint WebViewImpl::clampOffsetAtScale(const WebPoint& offset, float scale) 1865 { 1866 // This is the scaled content size. We need to convert it to the new scale factor. 1867 WebSize contentSize = mainFrame()->contentsSize(); 1868 float deltaScale = scale / pageScaleFactor(); 1869 int docWidthAtNewScale = contentSize.width * deltaScale; 1870 int docHeightAtNewScale = contentSize.height * deltaScale; 1871 int viewWidth = m_size.width; 1872 int viewHeight = m_size.height; 1873 1874 // Enforce the maximum and minimum scroll positions at the new scale. 1875 IntPoint clampedOffset = offset; 1876 clampedOffset.clampNegativeToZero(); 1877 clampedOffset = clampedOffset.shrunkTo(IntPoint(docWidthAtNewScale - viewWidth, docHeightAtNewScale - viewHeight)); 1878 return clampedOffset; 1879 } 1880 1881 void WebViewImpl::setPageScaleFactorPreservingScrollOffset(float scaleFactor) 1882 { 1883 // Pick a scale factor that is within the expected limits 1884 scaleFactor = computePageScaleFactorWithinLimits(scaleFactor); 1885 if (scaleFactor == pageScaleFactor()) 1886 return; 1887 1888 IntPoint scrollOffsetAtNewScale(mainFrame()->scrollOffset().width, mainFrame()->scrollOffset().height); 1889 float deltaScale = scaleFactor / pageScaleFactor(); 1890 scrollOffsetAtNewScale.scale(deltaScale, deltaScale); 1891 1892 WebPoint clampedOffsetAtNewScale = clampOffsetAtScale(scrollOffsetAtNewScale, scaleFactor); 1893 setPageScaleFactor(scaleFactor, clampedOffsetAtNewScale); 1894 } 1895 1855 1896 void WebViewImpl::setPageScaleFactor(float scaleFactor, const WebPoint& origin) 1856 1897 { … … 1858 1899 return; 1859 1900 1901 if (!scaleFactor) 1902 scaleFactor = 1; 1903 1904 scaleFactor = computePageScaleFactorWithinLimits(scaleFactor); 1860 1905 page()->setPageScaleFactor(scaleFactor, origin); 1861 1906 } … … 1911 1956 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScale) 1912 1957 { 1958 m_minimumPageScaleFactor = min(max(minPageScale, minPageScaleFactor), maxPageScaleFactor) * deviceScaleFactor(); 1959 m_maximumPageScaleFactor = max(min(maxPageScale, maxPageScaleFactor), minPageScaleFactor) * deviceScaleFactor(); 1960 1961 // Limit page scaling down to the document width. 1962 int viewWidth = m_size.width; 1963 int unscaledContentWidth = mainFrame()->contentsSize().width / pageScaleFactor(); 1964 m_minimumPageScaleFactor = max(m_minimumPageScaleFactor, static_cast<float>(viewWidth) / unscaledContentWidth); 1965 ASSERT(minPageScale <= maxPageScale); 1913 1966 #if USE(ACCELERATED_COMPOSITING) 1914 m_layerTreeHost->setPageScaleFactorLimits(minPageScale, maxPageScale); 1967 if (m_layerTreeHost) 1968 m_layerTreeHost->setPageScaleFactorLimits(m_minimumPageScaleFactor, m_maximumPageScaleFactor); 1915 1969 #endif 1916 1970 } … … 2731 2785 float oldScale = pageScaleFactor(); 2732 2786 if (!oldScale) 2733 oldScale = 1 .0f;2787 oldScale = 1; 2734 2788 2735 2789 if (!scaleFactor || oldScale == scaleFactor) -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r99774 r100196 159 159 double maximumZoomLevel); 160 160 virtual float pageScaleFactor() const; 161 virtual void setPageScaleFactorPreservingScrollOffset(float); 161 162 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin); 162 163 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale); … … 418 419 419 420 private: 421 float computePageScaleFactorWithinLimits(float scale); 422 WebPoint clampOffsetAtScale(const WebPoint& offset, float scale); 423 420 424 friend class WebView; // So WebView::Create can call our constructor 421 425 friend class WTF::RefCounted<WebViewImpl>; … … 513 517 514 518 double m_maximumZoomLevel; 519 520 float m_minimumPageScaleFactor; 521 522 float m_maximumPageScaleFactor; 515 523 516 524 bool m_contextMenuAllowed;
Note:
See TracChangeset
for help on using the changeset viewer.