Title: [122861] trunk
Revision
122861
Author
[email protected]
Date
2012-07-17 11:22:09 -0700 (Tue, 17 Jul 2012)

Log Message

Incorrect offset used for scrollWidth/Height calculation
https://bugs.webkit.org/show_bug.cgi?id=91461

Reviewed by Eric Seidel.

Source/WebCore:

Due to a different offset being used to calculate the scrollWidth/Height
and pixelSnappedClientWidth/Height the scroll value can be off by one in
same cases. This can causes scrollbars to appear even when there is no
overflow.

Test: fast/sub-pixel/block-with-margin-overflow.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::scrollWidth):
Change location offset passed to snapSizeToPixel to include x() to match
offset used by pixelSnappedClientWidth.

(WebCore::RenderBox::scrollHeight):
Change location offset passed to snapSizeToPixel to include y() to match
offset used by pixelSnappedClientHeight.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::clampScrollOffset):
Change calculation to use pixelSnappedClientWidth/Height as it is
subtracted from the pixel snapped scrollWidth/Height values.

(WebCore::RenderLayer::scrollWidth):
(WebCore::RenderLayer::scrollHeight):
Change RenderLayer versions of scrollWidth/Height to include x()/y() as
per the RenderBox versions.

LayoutTests:

Add new test ensuring that a block that shouldn't have overflow doesn't
have scrollbars.

* fast/sub-pixel/block-with-margin-overflow-expected.html: Added.
* fast/sub-pixel/block-with-margin-overflow.html: Added.
* platform/chromium-win/fast/block/float/026-expected.txt:
* platform/chromium-win/fast/block/float/028-expected.txt:
* platform/chromium-win/fast/block/float/overhanging-tall-block-expected.txt:
* platform/mac/fast/multicol/shrink-to-column-height-for-pagination-expected.png:
* platform/mac/fast/multicol/shrink-to-column-height-for-pagination-expected.txt:
Update test expectations that incorrectly had overflow.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (122860 => 122861)


--- trunk/LayoutTests/ChangeLog	2012-07-17 18:15:59 UTC (rev 122860)
+++ trunk/LayoutTests/ChangeLog	2012-07-17 18:22:09 UTC (rev 122861)
@@ -1,3 +1,22 @@
+2012-07-17  Emil A Eklund  <[email protected]>
+
+        Incorrect offset used for scrollWidth/Height calculation
+        https://bugs.webkit.org/show_bug.cgi?id=91461
+
+        Reviewed by Eric Seidel.
+
+        Add new test ensuring that a block that shouldn't have overflow doesn't
+        have scrollbars.
+
+        * fast/sub-pixel/block-with-margin-overflow-expected.html: Added.
+        * fast/sub-pixel/block-with-margin-overflow.html: Added.
+        * platform/chromium-win/fast/block/float/026-expected.txt:
+        * platform/chromium-win/fast/block/float/028-expected.txt:
+        * platform/chromium-win/fast/block/float/overhanging-tall-block-expected.txt:
+        * platform/mac/fast/multicol/shrink-to-column-height-for-pagination-expected.png:
+        * platform/mac/fast/multicol/shrink-to-column-height-for-pagination-expected.txt:
+        Update test expectations that incorrectly had overflow.
+
 2012-07-17  Tony Chang  <[email protected]>
 
         [chromium] Unreviewed. Remove duplicate lines added in r122857.

Added: trunk/LayoutTests/fast/sub-pixel/block-with-margin-overflow-expected.html (0 => 122861)


--- trunk/LayoutTests/fast/sub-pixel/block-with-margin-overflow-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/sub-pixel/block-with-margin-overflow-expected.html	2012-07-17 18:22:09 UTC (rev 122861)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            .block {
+                overflow: auto;
+                margin: 0 1px;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="block">
+            Should neither overflow nor display a scrollbar.
+        </div>
+    </body>
+</html>
+

Added: trunk/LayoutTests/fast/sub-pixel/block-with-margin-overflow.html (0 => 122861)


--- trunk/LayoutTests/fast/sub-pixel/block-with-margin-overflow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/sub-pixel/block-with-margin-overflow.html	2012-07-17 18:22:09 UTC (rev 122861)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            .block {
+                overflow: auto;
+                margin: 0 0.6px;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="block">
+            Should neither overflow nor display a scrollbar.
+        </div>
+    </body>
+</html>
+

Modified: trunk/LayoutTests/platform/chromium-win/fast/block/float/026-expected.txt (122860 => 122861)


--- trunk/LayoutTests/platform/chromium-win/fast/block/float/026-expected.txt	2012-07-17 18:15:59 UTC (rev 122860)
+++ trunk/LayoutTests/platform/chromium-win/fast/block/float/026-expected.txt	2012-07-17 18:22:09 UTC (rev 122861)
@@ -42,7 +42,7 @@
       text run at (39,2) width 513: "This is an overflow:scroll region. It should sit on the same line as the float and wrap as"
       text run at (290,22) width 4 RTL: "."
       text run at (294,22) width 258: "needed to fit within the remaining line width"
-layer at (189,816) size 388x79 clip at (206,818) size 369x60 scrollWidth 370
+layer at (189,816) size 388x79 clip at (206,818) size 369x60
   RenderBlock {DIV} at (180,0) size 389x79 [border: (2px solid #0000FF)]
     RenderText {#text} at (5,2) size 368x59
       text run at (5,2) width 366: "This is an overflow:scroll region. It should sit on the same line"

Modified: trunk/LayoutTests/platform/chromium-win/fast/block/float/028-expected.txt (122860 => 122861)


--- trunk/LayoutTests/platform/chromium-win/fast/block/float/028-expected.txt	2012-07-17 18:15:59 UTC (rev 122860)
+++ trunk/LayoutTests/platform/chromium-win/fast/block/float/028-expected.txt	2012-07-17 18:22:09 UTC (rev 122861)
@@ -42,7 +42,7 @@
       text run at (39,2) width 513: "This is an overflow:scroll region. It should sit on the same line as the float and wrap as"
       text run at (290,22) width 4 RTL: "."
       text run at (294,22) width 258: "needed to fit within the remaining line width"
-layer at (189,816) size 388x79 clip at (206,818) size 369x60 scrollWidth 370
+layer at (189,816) size 388x79 clip at (206,818) size 369x60
   RenderBlock {DIV} at (180,0) size 389x79 [border: (2px solid #0000FF)]
     RenderText {#text} at (5,2) size 368x59
       text run at (5,2) width 366: "This is an overflow:scroll region. It should sit on the same line"

Modified: trunk/LayoutTests/platform/chromium-win/fast/block/float/overhanging-tall-block-expected.txt (122860 => 122861)


--- trunk/LayoutTests/platform/chromium-win/fast/block/float/overhanging-tall-block-expected.txt	2012-07-17 18:15:59 UTC (rev 122860)
+++ trunk/LayoutTests/platform/chromium-win/fast/block/float/overhanging-tall-block-expected.txt	2012-07-17 18:22:09 UTC (rev 122861)
@@ -9,6 +9,6 @@
 layer at (10,10) size 179x25178662 backgroundClip at (10,10) size 179x17895687 clip at (11,11) size 177x17895686 outlineClip at (0,0) size 800x17895697
   RenderTextControl {TEXTAREA} at (2,1) size 179x25178664 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
     RenderBlock {DIV} at (3,3) size 175x16
-layer at (10,-21225448) size 179x25178662 backgroundClip at (10,0) size 179x3953214 clip at (11,0) size 162x3953213 outlineClip at (0,0) size 800x17895697 scrollHeight 25178660
+layer at (10,-21225448) size 179x25178662 backgroundClip at (10,0) size 179x3953214 clip at (11,0) size 177x3953213 outlineClip at (0,0) size 800x17895697
   RenderTextControl {TEXTAREA} at (2,25178664) size 179x-46404128 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
-    RenderBlock {DIV} at (3,3) size 160x16
+    RenderBlock {DIV} at (3,3) size 175x16

Modified: trunk/LayoutTests/platform/mac/fast/multicol/shrink-to-column-height-for-pagination-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/multicol/shrink-to-column-height-for-pagination-expected.txt (122860 => 122861)


--- trunk/LayoutTests/platform/mac/fast/multicol/shrink-to-column-height-for-pagination-expected.txt	2012-07-17 18:15:59 UTC (rev 122860)
+++ trunk/LayoutTests/platform/mac/fast/multicol/shrink-to-column-height-for-pagination-expected.txt	2012-07-17 18:22:09 UTC (rev 122861)
@@ -6,4 +6,3 @@
       RenderBlock {DIV} at (0,0) size 400x600
         RenderImage {IMG} at (392,0) size 400x600
         RenderText {#text} at (0,0) size 0x0
-scrolled to -385,0

Modified: trunk/Source/WebCore/ChangeLog (122860 => 122861)


--- trunk/Source/WebCore/ChangeLog	2012-07-17 18:15:59 UTC (rev 122860)
+++ trunk/Source/WebCore/ChangeLog	2012-07-17 18:22:09 UTC (rev 122861)
@@ -1,3 +1,36 @@
+2012-07-17  Emil A Eklund  <[email protected]>
+
+        Incorrect offset used for scrollWidth/Height calculation
+        https://bugs.webkit.org/show_bug.cgi?id=91461
+
+        Reviewed by Eric Seidel.
+
+        Due to a different offset being used to calculate the scrollWidth/Height
+        and pixelSnappedClientWidth/Height the scroll value can be off by one in
+        same cases. This can causes scrollbars to appear even when there is no
+        overflow.
+
+        Test: fast/sub-pixel/block-with-margin-overflow.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::scrollWidth):
+        Change location offset passed to snapSizeToPixel to include x() to match
+        offset used by pixelSnappedClientWidth.
+        
+        (WebCore::RenderBox::scrollHeight):
+        Change location offset passed to snapSizeToPixel to include y() to match
+        offset used by pixelSnappedClientHeight.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::clampScrollOffset):
+        Change calculation to use pixelSnappedClientWidth/Height as it is
+        subtracted from the pixel snapped scrollWidth/Height values.
+        
+        (WebCore::RenderLayer::scrollWidth):
+        (WebCore::RenderLayer::scrollHeight):
+        Change RenderLayer versions of scrollWidth/Height to include x()/y() as
+        per the RenderBox versions.
+
 2012-07-17  Hans Muller  <[email protected]>
 
         Rename CSS Exclusions CSSWrapShape class properties to match Exclusion shape function parameters

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (122860 => 122861)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-07-17 18:15:59 UTC (rev 122860)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-07-17 18:22:09 UTC (rev 122861)
@@ -385,7 +385,7 @@
     // For objects with visible overflow, this matches IE.
     // FIXME: Need to work right with writing modes.
     if (style()->isLeftToRightDirection())
-        return snapSizeToPixel(max(clientWidth(), layoutOverflowRect().maxX() - borderLeft()), clientLeft());
+        return snapSizeToPixel(max(clientWidth(), layoutOverflowRect().maxX() - borderLeft()), x() + clientLeft());
     return clientWidth() - min(ZERO_LAYOUT_UNIT, layoutOverflowRect().x() - borderLeft());
 }
 
@@ -395,7 +395,7 @@
         return layer()->scrollHeight();
     // For objects with visible overflow, this matches IE.
     // FIXME: Need to work right with writing modes.
-    return snapSizeToPixel(max(clientHeight(), layoutOverflowRect().maxY() - borderTop()), clientTop());
+    return snapSizeToPixel(max(clientHeight(), layoutOverflowRect().maxY() - borderTop()), y() + clientTop());
 }
 
 int RenderBox::scrollLeft() const

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (122860 => 122861)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-07-17 18:15:59 UTC (rev 122860)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-07-17 18:22:09 UTC (rev 122861)
@@ -1619,8 +1619,8 @@
     RenderBox* box = renderBox();
     ASSERT(box);
 
-    int maxX = scrollWidth() - box->clientWidth();
-    int maxY = scrollHeight() - box->clientHeight();
+    int maxX = scrollWidth() - box->pixelSnappedClientWidth();
+    int maxY = scrollHeight() - box->pixelSnappedClientHeight();
 
     int x = min(max(scrollOffset.width(), 0), maxX);
     int y = min(max(scrollOffset.height(), 0), maxY);
@@ -2442,7 +2442,7 @@
     ASSERT(renderBox());
     if (m_scrollDimensionsDirty)
         const_cast<RenderLayer*>(this)->computeScrollDimensions();
-    return snapSizeToPixel(m_scrollSize.width(), renderBox()->clientLeft());
+    return snapSizeToPixel(m_scrollSize.width(), renderBox()->clientLeft() + renderBox()->x());
 }
 
 int RenderLayer::scrollHeight() const
@@ -2450,7 +2450,7 @@
     ASSERT(renderBox());
     if (m_scrollDimensionsDirty)
         const_cast<RenderLayer*>(this)->computeScrollDimensions();
-    return snapSizeToPixel(m_scrollSize.height(), renderBox()->clientTop());
+    return snapSizeToPixel(m_scrollSize.height(), renderBox()->clientTop() + renderBox()->y());
 }
 
 LayoutUnit RenderLayer::overflowTop() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to