Scroll-snap points do not handle margins and padding propertly
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2015 02:53:00 +0000 (02:53 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2015 02:53:00 +0000 (02:53 +0000)
commit8a0df20b72fbf7cf859f8ec242dbf311ea942193
treed402c58755431b782abbf87cbf28153cd1e0a45d
parent48bf570cc0557889d5e3933dfc9150300dc025eb
Scroll-snap points do not handle margins and padding propertly
https://bugs.webkit.org/show_bug.cgi?id=144647
<rdar://problem/20829473>

Reviewed by Simon Fraser.

Source/WebCore:

The calculation of scroll snap points was incorrect because it did not account for margins or padding.
This was fixed by using the "paddingBoxRect" to represent the overall size of the view area, and
subtracting the relevant padding when computing the size of the scroll snap offsets.

Extend testing internals with accessor methods to retrieve string representations of the scroll snap
offsets and scroll snap coordinates computed during layout. These values are used in the new
'css3/scroll-snap/scroll-snap-offsets-and-coordinates.html' test.

New tests:
* css3/scroll-snap/scroll-snap-offsets-and-coordinates.html: Added.
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: Added.
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: Added.
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: Added.

* css/LengthFunctions.h: Expose the 'valueForLength' method so we can use it in WebCoreTestSupport.
* dom/Node.h: Expose the 'renderBox' method so we can use it in WebCoreTestSupport.
* page/scrolling/AxisScrollSnapOffsets.cpp:
(WebCore::appendChildSnapOffsets): Use 'contentBoxRect' for overall size, so that we don't use padding
as part of our offset calculations.
(WebCore::updateSnapOffsetsForScrollableArea): Ditto.
* rendering/RenderBox.h: Expose 'canBeScrolledAndHasScrollableArea' for use in WebCoreTestSupport.
* rendering/style/RenderStyle.h: Expose 'scrollSnapCoordinates' for use in WebCoreTestSupport.
* testing/Internals.cpp:
(WebCore::appendOffsets): Helper function.
(WebCore::Internals::scrollSnapOffsets): Added.
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Add new scroll-snap tests that cover elements with borders, padding, and rotation. Also correct the
cause of the 'scroll-snap-mandatory-overflow.html' test flakiness by making sure the mouse is always
inside the element when starting new wheel gestures.

Also add a new 'generic' test that confirms that we have expected results for scroll-snap coordinates
and calculated scroll-snap-offset values.

* css3/scroll-snap/scroll-snap-offsets.html: Added.
* platform/mac-wk2/TestExpectations: Remove flakiness annotation for scroll-snap-mandatory-overflow.
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-iframe.html:
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: Added.
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html:
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: Added.
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183906 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/scroll-snap/scroll-snap-offsets-expected.txt [new file with mode: 0644]
LayoutTests/css3/scroll-snap/scroll-snap-offsets.html [new file with mode: 0644]
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-iframe.html
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html [new file with mode: 0644]
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html [new file with mode: 0644]
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/LengthFunctions.h
Source/WebCore/dom/Node.h
Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl