Changeset 137368 in webkit


Ignore:
Timestamp:
Dec 11, 2012 3:22:05 PM (11 years ago)
Author:
wangxianzhu@chromium.org
Message:

Incorrect position of layers for fixed position elements when page is scaled smaller than viewport
https://bugs.webkit.org/show_bug.cgi?id=104294

Reviewed by James Robinson.

Source/WebCore:

Fixed issue in scrollOffsetForFixedPosition when contentRect is smaller than visibleContentRect.
This happens when a page originally bigger than viewport is scaled down to smaller than the viewport.

Test: compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport.html

  • page/scrolling/ScrollingCoordinator.cpp:

(WebCore::fixedPositionScrollOffset): Moved common code in scrollOffsetForFixedPosition here. Fixed issue when contentsSize < visibleContentSize.
(WebCore::scrollOffsetForFixedPosition):

LayoutTests:

Test the case that a page containing a composited fixed position element originally bigger than the viewport
is scaled down to be smaller than the viewport.

  • compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport.html: Added.
  • compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport-expected.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r137366 r137368  
     12012-12-11  Xianzhu Wang  <wangxianzhu@chromium.org>
     2
     3        Incorrect position of layers for fixed position elements when page is scaled smaller than viewport
     4        https://bugs.webkit.org/show_bug.cgi?id=104294
     5
     6        Reviewed by James Robinson.
     7
     8        Test the case that a page containing a composited fixed position element originally bigger than the viewport
     9        is scaled down to be smaller than the viewport.
     10
     11        * compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport.html: Added.
     12        * compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport-expected.html: Added.
     13
    1142012-12-11  Adam Klein  <adamk@chromium.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r137367 r137368  
     12012-12-11  Xianzhu Wang  <wangxianzhu@chromium.org>
     2
     3        Incorrect position of layers for fixed position elements when page is scaled smaller than viewport
     4        https://bugs.webkit.org/show_bug.cgi?id=104294
     5
     6        Reviewed by James Robinson.
     7
     8        Fixed issue in scrollOffsetForFixedPosition when contentRect is smaller than visibleContentRect.
     9        This happens when a page originally bigger than viewport is scaled down to smaller than the viewport.
     10
     11        Test: compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport.html
     12
     13        * page/scrolling/ScrollingCoordinator.cpp:
     14        (WebCore::fixedPositionScrollOffset): Moved common code in scrollOffsetForFixedPosition here. Fixed issue when contentsSize < visibleContentSize.
     15        (WebCore::scrollOffsetForFixedPosition):
     16
    1172012-12-11  Beth Dakin  <bdakin@apple.com>
    218
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

    r135360 r137368  
    6666}
    6767
    68 static int fixedPositionScrollOffset(int scrollPosition, int maxValue, int scrollOrigin, float dragFactor)
    69 {
    70     if (!maxValue)
     68static int fixedPositionScrollOffset(int visibleContentSize, int contentsSize, int scrollPosition, int scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame)
     69{
     70    int maxValue = contentsSize - visibleContentSize;
     71    if (maxValue <= 0)
    7172        return 0;
    7273
    7374    if (!scrollOrigin) {
    74         if (scrollPosition < 0)
    75             scrollPosition = 0;
    76         else if (scrollPosition > maxValue)
     75        if (scrollPosition <= 0)
     76            return 0;
     77        if (scrollPosition > maxValue)
    7778            scrollPosition = maxValue;
    7879    } else {
    79         if (scrollPosition > 0)
    80             scrollPosition = 0;
    81         else if (scrollPosition < -maxValue)
     80        if (scrollPosition >= 0)
     81            return 0;
     82        if (scrollPosition < -maxValue)
    8283            scrollPosition = -maxValue;
    8384    }
    84    
    85     return scrollPosition * dragFactor;
     85
     86    float dragFactor = fixedElementsLayoutRelativeToFrame ? 1 : (contentsSize - visibleContentSize * frameScaleFactor) / maxValue;
     87    return scrollPosition * dragFactor / frameScaleFactor;
    8688}
    8789
    8890IntSize scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& contentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame)
    8991{
    90     IntSize maxOffset(contentsSize.width() - visibleContentRect.width(), contentsSize.height() - visibleContentRect.height());
    91    
    92     FloatSize dragFactor = fixedElementsLayoutRelativeToFrame ? FloatSize(1, 1) : FloatSize(
    93         (contentsSize.width() - visibleContentRect.width() * frameScaleFactor) / maxOffset.width(),
    94         (contentsSize.height() - visibleContentRect.height() * frameScaleFactor) / maxOffset.height());
    95 
    96     int x = fixedPositionScrollOffset(scrollPosition.x(), maxOffset.width(), scrollOrigin.x(), dragFactor.width() / frameScaleFactor);
    97     int y = fixedPositionScrollOffset(scrollPosition.y(), maxOffset.height(), scrollOrigin.y(), dragFactor.height() / frameScaleFactor);
    98 
     92    int x = fixedPositionScrollOffset(visibleContentRect.width(), contentsSize.width(), scrollPosition.x(), scrollOrigin.x(), frameScaleFactor, fixedElementsLayoutRelativeToFrame);
     93    int y = fixedPositionScrollOffset(visibleContentRect.height(), contentsSize.height(), scrollPosition.y(), scrollOrigin.y(), frameScaleFactor, fixedElementsLayoutRelativeToFrame);
    9994    return IntSize(x, y);
    10095}
Note: See TracChangeset for help on using the changeset viewer.