haikuwebkit/LayoutTests/css3/scroll-snap/scroll-snap-property-comput...

83 lines
6.7 KiB
JavaScript
Raw Permalink Normal View History

Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
description("Test the computed style of the scroll-snap-* properties.");
Implement parsing for CSS scroll snap points https://bugs.webkit.org/show_bug.cgi?id=134301 Source/JavaScriptCore: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebCore: Provided support for parsing -webkit-scroll-snap-* properties, i.e. type, points-x, points-y, destination, and coordinates. The exact syntax of the scroll snap CSS properties follow the W3C spec at http://dev.w3.org/csswg/css-snappoints/ Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests: css3/scroll-snap/scroll-snap-property-parsing.html, css3/scroll-snap/scroll-snap-property-computed-style.html * CMakeLists.txt: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP * WebCore.vcxproj/WebCore.vcxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.vcxproj/WebCore.vcxproj.filters: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.xcodeproj/project.pbxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp, LengthRepeat.h * css/CSSCalculationValue.cpp: Support for LengthRepeat (WebCore::hasDoubleValue): * css/CSSComputedStyleDeclaration.cpp: Support for showing computed style for snap point properties. (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Support for parsing snap point properties. (WebCore::isValidKeywordPropertyAndValue): handle snap point type (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Added support for parsing snap points. (WebCore::CSSParser::parseNonElementSnapPoints): Helper for parsing snap points-x/y. (WebCore::CSSParser::parseScrollSnapDestination): Helper for parsing snap point destinations. (WebCore::CSSParser::parseScrollSnapCoordinate): Helper for parsing snap point coordinates. * css/CSSParser.h: Support for parsing snap point properties. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::CSSPrimitiveValue::init): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): (WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLengthRepeat): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): * css/CSSPrimitiveValueMappings.h: Added converters for snap point type properties. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): * css/CSSPropertyNames.in: Added relevant snap point property names. * css/CSSValueKeywords.in: Added "proximity", "mandatory" and "elements". * css/LengthRepeat.h: Added to represent values of repeat(<length>) (WebCore::LengthRepeat::create): (WebCore::LengthRepeat::cloneForCSSOM): (WebCore::LengthRepeat::interval): (WebCore::LengthRepeat::setInterval): (WebCore::LengthRepeat::equals): (WebCore::LengthRepeat::cssText): (WebCore::LengthRepeat::LengthRepeat): * css/StyleResolver.cpp: Support for handling snap point properties (WebCore::StyleResolver::applyProperty):Updated switch case to build snap-point-related style data * rendering/style/RenderStyle.h: Added methods to access and modify snap point data * rendering/style/RenderStyleConstants.h: Added scroll snap type flags. * rendering/style/StyleAllInOne.cpp: Added StyleScrollSnapPoints.cpp * rendering/style/StyleRareNonInheritedData.cpp: Added initiazing for m_scrollSnapPoints, updated equality check (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Added field for StyleScrollSnapPoints * rendering/style/StyleScrollSnapPoints.cpp: Added. Wrapper for basic snap point data structures. (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): (WebCore::StyleScrollSnapPoints::copy): (WebCore::StyleScrollSnapPoints::operator==): * rendering/style/StyleScrollSnapPoints.h: Added. (WebCore::StyleScrollSnapPoints::create): (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Creates a new Length representing the default repeat value of repeat(100%) (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Creates a new Length representing a default destination value (0px) (WebCore::StyleScrollSnapPoints::operator!=): Source/WebInspectorUI: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * UserInterface/Models/CSSKeywordCompletions.js: Added snap point property keywords, such as mandatory, proximity, elements, and repeat. Source/WebKit/mac: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebKit2: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP LayoutTests: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests that parsing -webkit-scroll-snap-* properties behaves as expected. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-computed-style.html: Tests that scroll snap properties are correctly displayed via getComputedStyle. * css3/scroll-snap/scroll-snap-property-computed-style.js: Script for above test. (testComputedScrollSnapRule): * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-parsing.html: Tests that scroll snap properties are correctly parsed. * css3/scroll-snap/scroll-snap-property-parsing.js: Script for above test. (testScrollSnapRule): Canonical link: https://commits.webkit.org/153553@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-08-07 00:19:40 +00:00
var stylesheet;
var styleElement = document.createElement("style");
document.head.appendChild(styleElement);
stylesheet = styleElement.sheet;
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
function testComputedScrollSnapRule(description, snapProperty, rule, expected, expectedShorthands = {})
Implement parsing for CSS scroll snap points https://bugs.webkit.org/show_bug.cgi?id=134301 Source/JavaScriptCore: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebCore: Provided support for parsing -webkit-scroll-snap-* properties, i.e. type, points-x, points-y, destination, and coordinates. The exact syntax of the scroll snap CSS properties follow the W3C spec at http://dev.w3.org/csswg/css-snappoints/ Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests: css3/scroll-snap/scroll-snap-property-parsing.html, css3/scroll-snap/scroll-snap-property-computed-style.html * CMakeLists.txt: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP * WebCore.vcxproj/WebCore.vcxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.vcxproj/WebCore.vcxproj.filters: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.xcodeproj/project.pbxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp, LengthRepeat.h * css/CSSCalculationValue.cpp: Support for LengthRepeat (WebCore::hasDoubleValue): * css/CSSComputedStyleDeclaration.cpp: Support for showing computed style for snap point properties. (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Support for parsing snap point properties. (WebCore::isValidKeywordPropertyAndValue): handle snap point type (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Added support for parsing snap points. (WebCore::CSSParser::parseNonElementSnapPoints): Helper for parsing snap points-x/y. (WebCore::CSSParser::parseScrollSnapDestination): Helper for parsing snap point destinations. (WebCore::CSSParser::parseScrollSnapCoordinate): Helper for parsing snap point coordinates. * css/CSSParser.h: Support for parsing snap point properties. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::CSSPrimitiveValue::init): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): (WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLengthRepeat): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): * css/CSSPrimitiveValueMappings.h: Added converters for snap point type properties. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): * css/CSSPropertyNames.in: Added relevant snap point property names. * css/CSSValueKeywords.in: Added "proximity", "mandatory" and "elements". * css/LengthRepeat.h: Added to represent values of repeat(<length>) (WebCore::LengthRepeat::create): (WebCore::LengthRepeat::cloneForCSSOM): (WebCore::LengthRepeat::interval): (WebCore::LengthRepeat::setInterval): (WebCore::LengthRepeat::equals): (WebCore::LengthRepeat::cssText): (WebCore::LengthRepeat::LengthRepeat): * css/StyleResolver.cpp: Support for handling snap point properties (WebCore::StyleResolver::applyProperty):Updated switch case to build snap-point-related style data * rendering/style/RenderStyle.h: Added methods to access and modify snap point data * rendering/style/RenderStyleConstants.h: Added scroll snap type flags. * rendering/style/StyleAllInOne.cpp: Added StyleScrollSnapPoints.cpp * rendering/style/StyleRareNonInheritedData.cpp: Added initiazing for m_scrollSnapPoints, updated equality check (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Added field for StyleScrollSnapPoints * rendering/style/StyleScrollSnapPoints.cpp: Added. Wrapper for basic snap point data structures. (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): (WebCore::StyleScrollSnapPoints::copy): (WebCore::StyleScrollSnapPoints::operator==): * rendering/style/StyleScrollSnapPoints.h: Added. (WebCore::StyleScrollSnapPoints::create): (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Creates a new Length representing the default repeat value of repeat(100%) (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Creates a new Length representing a default destination value (0px) (WebCore::StyleScrollSnapPoints::operator!=): Source/WebInspectorUI: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * UserInterface/Models/CSSKeywordCompletions.js: Added snap point property keywords, such as mandatory, proximity, elements, and repeat. Source/WebKit/mac: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebKit2: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP LayoutTests: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests that parsing -webkit-scroll-snap-* properties behaves as expected. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-computed-style.html: Tests that scroll snap properties are correctly displayed via getComputedStyle. * css3/scroll-snap/scroll-snap-property-computed-style.js: Script for above test. (testComputedScrollSnapRule): * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-parsing.html: Tests that scroll snap properties are correctly parsed. * css3/scroll-snap/scroll-snap-property-parsing.js: Script for above test. (testScrollSnapRule): Canonical link: https://commits.webkit.org/153553@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-08-07 00:19:40 +00:00
{
debug("");
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
debug(`${description}: \`${rule}\``);
Implement parsing for CSS scroll snap points https://bugs.webkit.org/show_bug.cgi?id=134301 Source/JavaScriptCore: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebCore: Provided support for parsing -webkit-scroll-snap-* properties, i.e. type, points-x, points-y, destination, and coordinates. The exact syntax of the scroll snap CSS properties follow the W3C spec at http://dev.w3.org/csswg/css-snappoints/ Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests: css3/scroll-snap/scroll-snap-property-parsing.html, css3/scroll-snap/scroll-snap-property-computed-style.html * CMakeLists.txt: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP * WebCore.vcxproj/WebCore.vcxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.vcxproj/WebCore.vcxproj.filters: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.xcodeproj/project.pbxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp, LengthRepeat.h * css/CSSCalculationValue.cpp: Support for LengthRepeat (WebCore::hasDoubleValue): * css/CSSComputedStyleDeclaration.cpp: Support for showing computed style for snap point properties. (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Support for parsing snap point properties. (WebCore::isValidKeywordPropertyAndValue): handle snap point type (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Added support for parsing snap points. (WebCore::CSSParser::parseNonElementSnapPoints): Helper for parsing snap points-x/y. (WebCore::CSSParser::parseScrollSnapDestination): Helper for parsing snap point destinations. (WebCore::CSSParser::parseScrollSnapCoordinate): Helper for parsing snap point coordinates. * css/CSSParser.h: Support for parsing snap point properties. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::CSSPrimitiveValue::init): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): (WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLengthRepeat): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): * css/CSSPrimitiveValueMappings.h: Added converters for snap point type properties. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): * css/CSSPropertyNames.in: Added relevant snap point property names. * css/CSSValueKeywords.in: Added "proximity", "mandatory" and "elements". * css/LengthRepeat.h: Added to represent values of repeat(<length>) (WebCore::LengthRepeat::create): (WebCore::LengthRepeat::cloneForCSSOM): (WebCore::LengthRepeat::interval): (WebCore::LengthRepeat::setInterval): (WebCore::LengthRepeat::equals): (WebCore::LengthRepeat::cssText): (WebCore::LengthRepeat::LengthRepeat): * css/StyleResolver.cpp: Support for handling snap point properties (WebCore::StyleResolver::applyProperty):Updated switch case to build snap-point-related style data * rendering/style/RenderStyle.h: Added methods to access and modify snap point data * rendering/style/RenderStyleConstants.h: Added scroll snap type flags. * rendering/style/StyleAllInOne.cpp: Added StyleScrollSnapPoints.cpp * rendering/style/StyleRareNonInheritedData.cpp: Added initiazing for m_scrollSnapPoints, updated equality check (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Added field for StyleScrollSnapPoints * rendering/style/StyleScrollSnapPoints.cpp: Added. Wrapper for basic snap point data structures. (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): (WebCore::StyleScrollSnapPoints::copy): (WebCore::StyleScrollSnapPoints::operator==): * rendering/style/StyleScrollSnapPoints.h: Added. (WebCore::StyleScrollSnapPoints::create): (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Creates a new Length representing the default repeat value of repeat(100%) (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Creates a new Length representing a default destination value (0px) (WebCore::StyleScrollSnapPoints::operator!=): Source/WebInspectorUI: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * UserInterface/Models/CSSKeywordCompletions.js: Added snap point property keywords, such as mandatory, proximity, elements, and repeat. Source/WebKit/mac: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebKit2: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP LayoutTests: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests that parsing -webkit-scroll-snap-* properties behaves as expected. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-computed-style.html: Tests that scroll snap properties are correctly displayed via getComputedStyle. * css3/scroll-snap/scroll-snap-property-computed-style.js: Script for above test. (testComputedScrollSnapRule): * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-parsing.html: Tests that scroll snap properties are correctly parsed. * css3/scroll-snap/scroll-snap-property-parsing.js: Script for above test. (testScrollSnapRule): Canonical link: https://commits.webkit.org/153553@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-08-07 00:19:40 +00:00
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
stylesheet.insertRule(`body { ${snapProperty} : ${rule}; }`, 0);
Implement parsing for CSS scroll snap points https://bugs.webkit.org/show_bug.cgi?id=134301 Source/JavaScriptCore: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebCore: Provided support for parsing -webkit-scroll-snap-* properties, i.e. type, points-x, points-y, destination, and coordinates. The exact syntax of the scroll snap CSS properties follow the W3C spec at http://dev.w3.org/csswg/css-snappoints/ Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests: css3/scroll-snap/scroll-snap-property-parsing.html, css3/scroll-snap/scroll-snap-property-computed-style.html * CMakeLists.txt: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP * WebCore.vcxproj/WebCore.vcxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.vcxproj/WebCore.vcxproj.filters: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.xcodeproj/project.pbxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp, LengthRepeat.h * css/CSSCalculationValue.cpp: Support for LengthRepeat (WebCore::hasDoubleValue): * css/CSSComputedStyleDeclaration.cpp: Support for showing computed style for snap point properties. (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Support for parsing snap point properties. (WebCore::isValidKeywordPropertyAndValue): handle snap point type (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Added support for parsing snap points. (WebCore::CSSParser::parseNonElementSnapPoints): Helper for parsing snap points-x/y. (WebCore::CSSParser::parseScrollSnapDestination): Helper for parsing snap point destinations. (WebCore::CSSParser::parseScrollSnapCoordinate): Helper for parsing snap point coordinates. * css/CSSParser.h: Support for parsing snap point properties. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::CSSPrimitiveValue::init): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): (WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLengthRepeat): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): * css/CSSPrimitiveValueMappings.h: Added converters for snap point type properties. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): * css/CSSPropertyNames.in: Added relevant snap point property names. * css/CSSValueKeywords.in: Added "proximity", "mandatory" and "elements". * css/LengthRepeat.h: Added to represent values of repeat(<length>) (WebCore::LengthRepeat::create): (WebCore::LengthRepeat::cloneForCSSOM): (WebCore::LengthRepeat::interval): (WebCore::LengthRepeat::setInterval): (WebCore::LengthRepeat::equals): (WebCore::LengthRepeat::cssText): (WebCore::LengthRepeat::LengthRepeat): * css/StyleResolver.cpp: Support for handling snap point properties (WebCore::StyleResolver::applyProperty):Updated switch case to build snap-point-related style data * rendering/style/RenderStyle.h: Added methods to access and modify snap point data * rendering/style/RenderStyleConstants.h: Added scroll snap type flags. * rendering/style/StyleAllInOne.cpp: Added StyleScrollSnapPoints.cpp * rendering/style/StyleRareNonInheritedData.cpp: Added initiazing for m_scrollSnapPoints, updated equality check (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Added field for StyleScrollSnapPoints * rendering/style/StyleScrollSnapPoints.cpp: Added. Wrapper for basic snap point data structures. (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): (WebCore::StyleScrollSnapPoints::copy): (WebCore::StyleScrollSnapPoints::operator==): * rendering/style/StyleScrollSnapPoints.h: Added. (WebCore::StyleScrollSnapPoints::create): (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Creates a new Length representing the default repeat value of repeat(100%) (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Creates a new Length representing a default destination value (0px) (WebCore::StyleScrollSnapPoints::operator!=): Source/WebInspectorUI: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * UserInterface/Models/CSSKeywordCompletions.js: Added snap point property keywords, such as mandatory, proximity, elements, and repeat. Source/WebKit/mac: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebKit2: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP LayoutTests: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests that parsing -webkit-scroll-snap-* properties behaves as expected. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-computed-style.html: Tests that scroll snap properties are correctly displayed via getComputedStyle. * css3/scroll-snap/scroll-snap-property-computed-style.js: Script for above test. (testComputedScrollSnapRule): * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-parsing.html: Tests that scroll snap properties are correctly parsed. * css3/scroll-snap/scroll-snap-property-parsing.js: Script for above test. (testScrollSnapRule): Canonical link: https://commits.webkit.org/153553@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-08-07 00:19:40 +00:00
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
shouldBe(`window.getComputedStyle(document.body).getPropertyValue('${snapProperty}')`, `'${expected}'`);
for (let shorthand in expectedShorthands)
shouldBe(`window.getComputedStyle(document.body).getPropertyValue('${snapProperty}-${shorthand}')`, `'${expectedShorthands[shorthand]}'`);
Implement parsing for CSS scroll snap points https://bugs.webkit.org/show_bug.cgi?id=134301 Source/JavaScriptCore: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebCore: Provided support for parsing -webkit-scroll-snap-* properties, i.e. type, points-x, points-y, destination, and coordinates. The exact syntax of the scroll snap CSS properties follow the W3C spec at http://dev.w3.org/csswg/css-snappoints/ Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests: css3/scroll-snap/scroll-snap-property-parsing.html, css3/scroll-snap/scroll-snap-property-computed-style.html * CMakeLists.txt: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP * WebCore.vcxproj/WebCore.vcxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.vcxproj/WebCore.vcxproj.filters: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.xcodeproj/project.pbxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp, LengthRepeat.h * css/CSSCalculationValue.cpp: Support for LengthRepeat (WebCore::hasDoubleValue): * css/CSSComputedStyleDeclaration.cpp: Support for showing computed style for snap point properties. (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Support for parsing snap point properties. (WebCore::isValidKeywordPropertyAndValue): handle snap point type (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Added support for parsing snap points. (WebCore::CSSParser::parseNonElementSnapPoints): Helper for parsing snap points-x/y. (WebCore::CSSParser::parseScrollSnapDestination): Helper for parsing snap point destinations. (WebCore::CSSParser::parseScrollSnapCoordinate): Helper for parsing snap point coordinates. * css/CSSParser.h: Support for parsing snap point properties. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::CSSPrimitiveValue::init): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): (WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLengthRepeat): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): * css/CSSPrimitiveValueMappings.h: Added converters for snap point type properties. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): * css/CSSPropertyNames.in: Added relevant snap point property names. * css/CSSValueKeywords.in: Added "proximity", "mandatory" and "elements". * css/LengthRepeat.h: Added to represent values of repeat(<length>) (WebCore::LengthRepeat::create): (WebCore::LengthRepeat::cloneForCSSOM): (WebCore::LengthRepeat::interval): (WebCore::LengthRepeat::setInterval): (WebCore::LengthRepeat::equals): (WebCore::LengthRepeat::cssText): (WebCore::LengthRepeat::LengthRepeat): * css/StyleResolver.cpp: Support for handling snap point properties (WebCore::StyleResolver::applyProperty):Updated switch case to build snap-point-related style data * rendering/style/RenderStyle.h: Added methods to access and modify snap point data * rendering/style/RenderStyleConstants.h: Added scroll snap type flags. * rendering/style/StyleAllInOne.cpp: Added StyleScrollSnapPoints.cpp * rendering/style/StyleRareNonInheritedData.cpp: Added initiazing for m_scrollSnapPoints, updated equality check (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Added field for StyleScrollSnapPoints * rendering/style/StyleScrollSnapPoints.cpp: Added. Wrapper for basic snap point data structures. (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): (WebCore::StyleScrollSnapPoints::copy): (WebCore::StyleScrollSnapPoints::operator==): * rendering/style/StyleScrollSnapPoints.h: Added. (WebCore::StyleScrollSnapPoints::create): (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Creates a new Length representing the default repeat value of repeat(100%) (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Creates a new Length representing a default destination value (0px) (WebCore::StyleScrollSnapPoints::operator!=): Source/WebInspectorUI: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * UserInterface/Models/CSSKeywordCompletions.js: Added snap point property keywords, such as mandatory, proximity, elements, and repeat. Source/WebKit/mac: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebKit2: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP LayoutTests: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests that parsing -webkit-scroll-snap-* properties behaves as expected. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-computed-style.html: Tests that scroll snap properties are correctly displayed via getComputedStyle. * css3/scroll-snap/scroll-snap-property-computed-style.js: Script for above test. (testComputedScrollSnapRule): * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-parsing.html: Tests that scroll snap properties are correctly parsed. * css3/scroll-snap/scroll-snap-property-parsing.js: Script for above test. (testScrollSnapRule): Canonical link: https://commits.webkit.org/153553@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-08-07 00:19:40 +00:00
stylesheet.deleteRule(0);
}
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
// Test the scroll-snap-type property
// Invalid declarations
testComputedScrollSnapRule("invalid snap type", "scroll-snap-type", "potato", "none");
testComputedScrollSnapRule("empty string for snap type", "scroll-snap-type", "", "none");
testComputedScrollSnapRule("too many values", "scroll-snap-type", "block mandatory proximity", "none");
testComputedScrollSnapRule("none following axis", "scroll-snap-type", "both none", "none");
testComputedScrollSnapRule("two axis values", "scroll-snap-type", "block inline", "none");
testComputedScrollSnapRule("two strictness values", "scroll-snap-type", "proximity mandatory", "none");
testComputedScrollSnapRule("axis following strictness", "scroll-snap-type", "mandatory inline", "none");
testComputedScrollSnapRule("only strictness", "scroll-snap-type", "mandatory", "none");
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
// Valid declarations
testComputedScrollSnapRule("initial value", "scroll-snap-type", "initial", "none");
2020-10-12 08:45:57 +00:00
testComputedScrollSnapRule("only axis", "scroll-snap-type", "both", "both");
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
testComputedScrollSnapRule("none", "scroll-snap-type", "none", "none");
testComputedScrollSnapRule("strictness following axis", "scroll-snap-type", "inline mandatory", "inline mandatory");
Implement parsing for CSS scroll snap points https://bugs.webkit.org/show_bug.cgi?id=134301 Source/JavaScriptCore: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebCore: Provided support for parsing -webkit-scroll-snap-* properties, i.e. type, points-x, points-y, destination, and coordinates. The exact syntax of the scroll snap CSS properties follow the W3C spec at http://dev.w3.org/csswg/css-snappoints/ Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests: css3/scroll-snap/scroll-snap-property-parsing.html, css3/scroll-snap/scroll-snap-property-computed-style.html * CMakeLists.txt: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP * WebCore.vcxproj/WebCore.vcxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.vcxproj/WebCore.vcxproj.filters: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.xcodeproj/project.pbxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp, LengthRepeat.h * css/CSSCalculationValue.cpp: Support for LengthRepeat (WebCore::hasDoubleValue): * css/CSSComputedStyleDeclaration.cpp: Support for showing computed style for snap point properties. (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Support for parsing snap point properties. (WebCore::isValidKeywordPropertyAndValue): handle snap point type (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Added support for parsing snap points. (WebCore::CSSParser::parseNonElementSnapPoints): Helper for parsing snap points-x/y. (WebCore::CSSParser::parseScrollSnapDestination): Helper for parsing snap point destinations. (WebCore::CSSParser::parseScrollSnapCoordinate): Helper for parsing snap point coordinates. * css/CSSParser.h: Support for parsing snap point properties. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::CSSPrimitiveValue::init): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): (WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLengthRepeat): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): * css/CSSPrimitiveValueMappings.h: Added converters for snap point type properties. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): * css/CSSPropertyNames.in: Added relevant snap point property names. * css/CSSValueKeywords.in: Added "proximity", "mandatory" and "elements". * css/LengthRepeat.h: Added to represent values of repeat(<length>) (WebCore::LengthRepeat::create): (WebCore::LengthRepeat::cloneForCSSOM): (WebCore::LengthRepeat::interval): (WebCore::LengthRepeat::setInterval): (WebCore::LengthRepeat::equals): (WebCore::LengthRepeat::cssText): (WebCore::LengthRepeat::LengthRepeat): * css/StyleResolver.cpp: Support for handling snap point properties (WebCore::StyleResolver::applyProperty):Updated switch case to build snap-point-related style data * rendering/style/RenderStyle.h: Added methods to access and modify snap point data * rendering/style/RenderStyleConstants.h: Added scroll snap type flags. * rendering/style/StyleAllInOne.cpp: Added StyleScrollSnapPoints.cpp * rendering/style/StyleRareNonInheritedData.cpp: Added initiazing for m_scrollSnapPoints, updated equality check (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Added field for StyleScrollSnapPoints * rendering/style/StyleScrollSnapPoints.cpp: Added. Wrapper for basic snap point data structures. (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): (WebCore::StyleScrollSnapPoints::copy): (WebCore::StyleScrollSnapPoints::operator==): * rendering/style/StyleScrollSnapPoints.h: Added. (WebCore::StyleScrollSnapPoints::create): (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Creates a new Length representing the default repeat value of repeat(100%) (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Creates a new Length representing a default destination value (0px) (WebCore::StyleScrollSnapPoints::operator!=): Source/WebInspectorUI: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * UserInterface/Models/CSSKeywordCompletions.js: Added snap point property keywords, such as mandatory, proximity, elements, and repeat. Source/WebKit/mac: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebKit2: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP LayoutTests: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests that parsing -webkit-scroll-snap-* properties behaves as expected. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-computed-style.html: Tests that scroll snap properties are correctly displayed via getComputedStyle. * css3/scroll-snap/scroll-snap-property-computed-style.js: Script for above test. (testComputedScrollSnapRule): * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-parsing.html: Tests that scroll snap properties are correctly parsed. * css3/scroll-snap/scroll-snap-property-parsing.js: Script for above test. (testScrollSnapRule): Canonical link: https://commits.webkit.org/153553@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-08-07 00:19:40 +00:00
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
// Test the scroll-snap-align property
// Invalid declarations
Improve the serialization of scroll-snap-type and scroll-snap-align https://bugs.webkit.org/show_bug.cgi?id=221324 LayoutTests/imported/w3c: Reviewed by Alex Christensen. * web-platform-tests/css/css-scroll-snap/inheritance-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-snap-align-computed-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-snap-align-valid-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-snap-type-valid-expected.txt: * web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: Source/WebCore: Reviewed by Alex Christensen. Improve serialization of scroll-snap-type and scroll-snap-align. When the values are the same for both dimensions or a default value is used, don't add it to the list of consumed tokens. The primitive conversion process will handle this default correctly and serialization will produce a canonical serialization correctly. We handle this case for both serialization of the style (eg getPropertyValue) and for serialization of computed style. No new tests. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapAlignment): For the computed style don't serialize the second value if it is the same as the first. * css/parser/CSSPropertyParser.cpp: (WebCore::consumeScrollSnapAlign): Only add the second value to the value list if it exists and if it is different than the first value. (WebCore::consumeScrollSnapType): Only add the second value if it is a non-default value. LayoutTests: Reviewed by Alex Christensen. * css3/scroll-snap/resources/iframe-content-rtl.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: Canonical link: https://commits.webkit.org/233694@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272366 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-04 12:01:29 +00:00
testComputedScrollSnapRule("invalid snap align", "scroll-snap-align", "potato", "none");
testComputedScrollSnapRule("empty string", "scroll-snap-align", "", "none");
testComputedScrollSnapRule("too many values", "scroll-snap-align", "start center end", "none");
testComputedScrollSnapRule("invalid second value", "scroll-snap-align", "start wut", "none");
testComputedScrollSnapRule("invalid first value", "scroll-snap-align", "wat center", "none");
testComputedScrollSnapRule("one length", "scroll-snap-align", "10px", "none");
testComputedScrollSnapRule("two lengths", "scroll-snap-align", "10px 50px", "none");
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
// Valid declarations
Improve the serialization of scroll-snap-type and scroll-snap-align https://bugs.webkit.org/show_bug.cgi?id=221324 LayoutTests/imported/w3c: Reviewed by Alex Christensen. * web-platform-tests/css/css-scroll-snap/inheritance-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-snap-align-computed-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-snap-align-valid-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-snap-type-valid-expected.txt: * web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: Source/WebCore: Reviewed by Alex Christensen. Improve serialization of scroll-snap-type and scroll-snap-align. When the values are the same for both dimensions or a default value is used, don't add it to the list of consumed tokens. The primitive conversion process will handle this default correctly and serialization will produce a canonical serialization correctly. We handle this case for both serialization of the style (eg getPropertyValue) and for serialization of computed style. No new tests. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapAlignment): For the computed style don't serialize the second value if it is the same as the first. * css/parser/CSSPropertyParser.cpp: (WebCore::consumeScrollSnapAlign): Only add the second value to the value list if it exists and if it is different than the first value. (WebCore::consumeScrollSnapType): Only add the second value if it is a non-default value. LayoutTests: Reviewed by Alex Christensen. * css3/scroll-snap/resources/iframe-content-rtl.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: Canonical link: https://commits.webkit.org/233694@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272366 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-04 12:01:29 +00:00
testComputedScrollSnapRule("initial value", "scroll-snap-align", "initial", "none");
testComputedScrollSnapRule("single value", "scroll-snap-align", "start", "start");
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
testComputedScrollSnapRule("two values", "scroll-snap-align", "start end", "start end");
Implement parsing for CSS scroll snap points https://bugs.webkit.org/show_bug.cgi?id=134301 Source/JavaScriptCore: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebCore: Provided support for parsing -webkit-scroll-snap-* properties, i.e. type, points-x, points-y, destination, and coordinates. The exact syntax of the scroll snap CSS properties follow the W3C spec at http://dev.w3.org/csswg/css-snappoints/ Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests: css3/scroll-snap/scroll-snap-property-parsing.html, css3/scroll-snap/scroll-snap-property-computed-style.html * CMakeLists.txt: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP * WebCore.vcxproj/WebCore.vcxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.vcxproj/WebCore.vcxproj.filters: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.xcodeproj/project.pbxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp, LengthRepeat.h * css/CSSCalculationValue.cpp: Support for LengthRepeat (WebCore::hasDoubleValue): * css/CSSComputedStyleDeclaration.cpp: Support for showing computed style for snap point properties. (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Support for parsing snap point properties. (WebCore::isValidKeywordPropertyAndValue): handle snap point type (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Added support for parsing snap points. (WebCore::CSSParser::parseNonElementSnapPoints): Helper for parsing snap points-x/y. (WebCore::CSSParser::parseScrollSnapDestination): Helper for parsing snap point destinations. (WebCore::CSSParser::parseScrollSnapCoordinate): Helper for parsing snap point coordinates. * css/CSSParser.h: Support for parsing snap point properties. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::CSSPrimitiveValue::init): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): (WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLengthRepeat): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): * css/CSSPrimitiveValueMappings.h: Added converters for snap point type properties. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): * css/CSSPropertyNames.in: Added relevant snap point property names. * css/CSSValueKeywords.in: Added "proximity", "mandatory" and "elements". * css/LengthRepeat.h: Added to represent values of repeat(<length>) (WebCore::LengthRepeat::create): (WebCore::LengthRepeat::cloneForCSSOM): (WebCore::LengthRepeat::interval): (WebCore::LengthRepeat::setInterval): (WebCore::LengthRepeat::equals): (WebCore::LengthRepeat::cssText): (WebCore::LengthRepeat::LengthRepeat): * css/StyleResolver.cpp: Support for handling snap point properties (WebCore::StyleResolver::applyProperty):Updated switch case to build snap-point-related style data * rendering/style/RenderStyle.h: Added methods to access and modify snap point data * rendering/style/RenderStyleConstants.h: Added scroll snap type flags. * rendering/style/StyleAllInOne.cpp: Added StyleScrollSnapPoints.cpp * rendering/style/StyleRareNonInheritedData.cpp: Added initiazing for m_scrollSnapPoints, updated equality check (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Added field for StyleScrollSnapPoints * rendering/style/StyleScrollSnapPoints.cpp: Added. Wrapper for basic snap point data structures. (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): (WebCore::StyleScrollSnapPoints::copy): (WebCore::StyleScrollSnapPoints::operator==): * rendering/style/StyleScrollSnapPoints.h: Added. (WebCore::StyleScrollSnapPoints::create): (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Creates a new Length representing the default repeat value of repeat(100%) (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Creates a new Length representing a default destination value (0px) (WebCore::StyleScrollSnapPoints::operator!=): Source/WebInspectorUI: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * UserInterface/Models/CSSKeywordCompletions.js: Added snap point property keywords, such as mandatory, proximity, elements, and repeat. Source/WebKit/mac: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebKit2: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP LayoutTests: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests that parsing -webkit-scroll-snap-* properties behaves as expected. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-computed-style.html: Tests that scroll snap properties are correctly displayed via getComputedStyle. * css3/scroll-snap/scroll-snap-property-computed-style.js: Script for above test. (testComputedScrollSnapRule): * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-parsing.html: Tests that scroll snap properties are correctly parsed. * css3/scroll-snap/scroll-snap-property-parsing.js: Script for above test. (testScrollSnapRule): Canonical link: https://commits.webkit.org/153553@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-08-07 00:19:40 +00:00
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
// Test the scroll-padding property
// Invalid declarations
Add support for logical variants of 'scroll-padding' and 'scroll-margin' https://bugs.webkit.org/show_bug.cgi?id=220766 <rdar://problem/73661278> Reviewed by Darin Adler. LayoutTests/imported/w3c: Update test expectations for this change. * web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt: * web-platform-tests/css/css-scroll-snap/inheritance-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-margin-block-inline-computed-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-margin-block-inline-shorthand-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-margin-block-inline-valid-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-block-inline-computed-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-block-inline-shorthand-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-block-inline-valid-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-computed-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-invalid-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-shorthand-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-valid-expected.txt: * web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: Source/WebCore: Add support for logical `scroll-margin` and `scroll-padding` properties. Also improve parsing of `scroll-padding` which should not accept negative values and should accept "auto" values. The spec gives flexibility for how to interpret "auto", but for us this should just be 0 currently. * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): Add support for logical margin and padding longhands and shortands. * css/CSSProperties.json: Ditto. Allow padding to accept "auto" as well. * css/CSSProperty.cpp: (WebCore::CSSProperty::resolveDirectionAwareProperty): Ditto. (WebCore::CSSProperty::isDirectionAwareProperty): Ditto. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue const): Ditto. (WebCore::StyleProperties::asText const): Ditto. * css/parser/CSSPropertyParser.cpp: (WebCore::consumeScrollPadding): Added this helper that accepts a length, a percentage, or auto. (WebCore::CSSPropertyParser::parseSingleValue): Added support for logical longhands. (WebCore::CSSPropertyParser::parseShorthand): Added support for logical shorthands. * page/scrolling/ScrollSnapOffsetsInfo.cpp: (WebCore::computeScrollSnapPortOrAreaRect): Use minimumValueForLength here because auto should resolve to 0px. * rendering/RenderBox.cpp: (RenderBox::scrollPaddingForViewportRect): Ditto. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollPadding): Initialize scroll-padding values to auto as specified. * rendering/style/StyleRareNonInheritedData.h: Ditto. LayoutTests: Update test expectations. * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: Canonical link: https://commits.webkit.org/233456@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272035 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-01-28 22:24:21 +00:00
testComputedScrollSnapRule("invalid scroll padding", "scroll-padding", "potato", "auto", { top: "auto", left: "auto", right: "auto", bottom: "auto" });
testComputedScrollSnapRule("empty string", "scroll-padding", "", "auto", { top: "auto", left: "auto", right: "auto", bottom: "auto" });
testComputedScrollSnapRule("too many values", "scroll-padding", "1px 2px 3px 4px 5px", "auto", { top: "auto", left: "auto", right: "auto", bottom: "auto" });
testComputedScrollSnapRule("attempt to use auto", "scroll-padding", "auto auto", "auto", { top: "auto", left: "auto", right: "auto", bottom: "auto" });
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
// Valid declarations
testComputedScrollSnapRule("single length", "scroll-padding", "10px", "10px", { top: "10px", left: "10px", right: "10px", bottom: "10px" });
testComputedScrollSnapRule("two percentages", "scroll-padding", "10% 20%", "10% 20%", { top: "10%", left: "20%", right: "20%", bottom: "10%" });
testComputedScrollSnapRule("three lengths", "scroll-padding", "1px 2px 3px", "1px 2px 3px", { top: "1px", left: "2px", right: "2px", bottom: "3px" });
testComputedScrollSnapRule("four values", "scroll-padding", "50px 10% 20% 50px", "50px 10% 20% 50px", { top: "50px", left: "50px", right: "10%", bottom: "20%" });
calc() serialization doesn't match the spec https://bugs.webkit.org/show_bug.cgi?id=203442 LayoutTests/imported/w3c: <rdar://problem/56639402> Reviewed by Dean Jackson. New results. Current WPT don't reflect the new serialization rules yet, so we expect some failing results here. * web-platform-tests/css/css-align/gaps/column-gap-parsing-001-expected.txt: * web-platform-tests/css/css-align/gaps/gap-parsing-001-expected.txt: * web-platform-tests/css/css-align/gaps/grid-column-gap-parsing-001-expected.txt: * web-platform-tests/css/css-align/gaps/grid-gap-parsing-001-expected.txt: * web-platform-tests/css/css-align/gaps/grid-row-gap-parsing-001-expected.txt: * web-platform-tests/css/css-align/gaps/row-gap-parsing-001-expected.txt: * web-platform-tests/css/css-box/parsing/padding-valid-expected.txt: * web-platform-tests/css/css-shapes/animation/shape-outside-interpolation-expected.txt: * web-platform-tests/css/css-shapes/shape-outside/values/shape-margin-003-expected.txt: * web-platform-tests/css/css-shapes/shape-outside/values/shape-outside-circle-010-expected.txt: * web-platform-tests/css/css-shapes/shape-outside/values/shape-outside-circle-011-expected.txt: * web-platform-tests/css/css-shapes/shape-outside/values/shape-outside-ellipse-010-expected.txt: * web-platform-tests/css/css-shapes/shape-outside/values/shape-outside-ellipse-011-expected.txt: * web-platform-tests/css/css-shapes/shape-outside/values/shape-outside-inset-008-expected.txt: * web-platform-tests/css/css-shapes/shape-outside/values/shape-outside-inset-009-expected.txt: * web-platform-tests/css/css-shapes/shape-outside/values/shape-outside-polygon-006-expected.txt: * web-platform-tests/css/css-values/calc-background-position-002-expected.txt: * web-platform-tests/css/css-values/calc-background-position-003-expected.txt: * web-platform-tests/css/css-values/calc-nesting-002-expected.txt: * web-platform-tests/css/css-values/calc-serialization-002-expected.txt: * web-platform-tests/css/css-values/calc-serialization-expected.txt: * web-platform-tests/css/css-values/minmax-angle-computed-expected.txt: * web-platform-tests/css/css-values/minmax-angle-serialize-expected.txt: * web-platform-tests/css/css-values/minmax-length-percent-serialize-expected.txt: * web-platform-tests/css/css-values/minmax-length-serialize-expected.txt: * web-platform-tests/css/css-values/minmax-percentage-serialize-expected.txt: * web-platform-tests/css/css-values/minmax-time-computed-expected.txt: * web-platform-tests/css/css-values/minmax-time-serialize-expected.txt: Source/WebCore: <rdar://problem/56639402> Reviewed by Dean Jackson. These changes implement the calc() simplification and serialization rules described in https://drafts.csswg.org/css-values-4/#calc-internal. They also make it easy to add the new math functions in future. The major changes are: 1. Create Negate and Invert nodes to handle subtraction and division, so that Product and Sum are the only math operators that are tracked, which makes it possible to sort child nodes for simplification. 2. After parsing, do a bottom-up simplification parse following <https://drafts.csswg.org/css-values-4/#calc-simplification>, which sorts child nodes according to <https://drafts.csswg.org/css-values-4/#sort-a-calculations-children>, combines child nodes where possible, and hoists child nodes up to their parents were possible. Simplification always preserves a calc-like function at the root. This simplification also does unit canonicalization (e.g. all absolute lengths get px units). To make unit conversion more explicit, pass a CSSUnitType into doubleValue() methods so that it's clear what units the resulting value is in. 3. Serialize according to <https://drafts.csswg.org/css-values-4/#calc-serialize> which fixes bugs with nested parentheses. This patch does not completely implement the type checking and conversion rules described in <https://drafts.csswg.org/css-values-4/#calc-type-checking> and <https://drafts.css-houdini.org/css-typed-om-1/#numeric-typing>. Tests: fast/css/calc-parsing-limits.html fast/css/calc-parsing.html * css/CSSCalculationValue.cpp: (WebCore::calculationCategoryForCombination): (WebCore::canonicalUnitTypeForCalculationCategory): (WebCore::functionFromOperator): (WebCore::CSSCalcPrimitiveValueNode::isNumericValue const): (WebCore::CSSCalcPrimitiveValueNode::isNegative const): (WebCore::CSSCalcPrimitiveValueNode::negate): (WebCore::CSSCalcPrimitiveValueNode::invert): (WebCore::CSSCalcPrimitiveValueNode::add): (WebCore::CSSCalcPrimitiveValueNode::multiply): (WebCore::CSSCalcPrimitiveValueNode::convertToUnitType): (WebCore::CSSCalcPrimitiveValueNode::canonicalizeUnit): (WebCore::CSSCalcPrimitiveValueNode::doubleValue const): (WebCore::CSSCalcNegateNode::createCalcExpression const): (WebCore::CSSCalcNegateNode::dump const): (WebCore::CSSCalcInvertNode::createCalcExpression const): (WebCore::CSSCalcInvertNode::dump const): (WebCore::categoryForInvert): (WebCore::determineCategory): (WebCore::CSSCalcOperationNode::create): (WebCore::CSSCalcOperationNode::createSum): (WebCore::CSSCalcOperationNode::createProduct): (WebCore::CSSCalcOperationNode::hoistChildrenWithOperator): (WebCore::sortingCategoryForType): (WebCore::sortingCategory): (WebCore::primitiveTypeForCombination): (WebCore::conversionToAddValuesWithTypes): (WebCore::CSSCalcOperationNode::canCombineAllChildren const): (WebCore::CSSCalcOperationNode::combineChildren): (WebCore::CSSCalcOperationNode::simplify): (WebCore::CSSCalcOperationNode::simplifyRecursive): (WebCore::CSSCalcOperationNode::simplifyNode): (WebCore::CSSCalcOperationNode::primitiveType const): (WebCore::CSSCalcOperationNode::doubleValue const): (WebCore::CSSCalcOperationNode::computeLengthPx const): (WebCore::CSSCalcOperationNode::buildCSSText): (WebCore::functionPrefixForOperator): (WebCore::CSSCalcOperationNode::buildCSSTextRecursive): (WebCore::CSSCalcOperationNode::evaluateOperator): (WebCore::CSSCalcExpressionNodeParser::parseCalc): (WebCore::checkDepthAndIndex): (WebCore::CSSCalcExpressionNodeParser::parseCalcFunction): (WebCore::CSSCalcExpressionNodeParser::parseValue): (WebCore::CSSCalcExpressionNodeParser::parseCalcValue): (WebCore::CSSCalcExpressionNodeParser::parseCalcProduct): (WebCore::CSSCalcExpressionNodeParser::parseCalcSum): (WebCore::createCSS): (WebCore::CSSCalcValue::customCSSText const): (WebCore::CSSCalcValue::doubleValue const): (WebCore::CSSCalcValue::create): (WebCore::CSSCalcOperationNode::createSimplified): Deleted. (WebCore::CSSCalcOperationNode::buildCssText): Deleted. (WebCore::CSSCalcOperationNode::customCSSText const): Deleted. (WebCore::CSSCalcExpressionNodeParser::parseValueTerm): Deleted. (WebCore::CSSCalcExpressionNodeParser::parseValueMultiplicativeExpression): Deleted. (WebCore::CSSCalcExpressionNodeParser::parseAdditiveValueExpression): Deleted. (WebCore::CSSCalcExpressionNodeParser::parseMinMaxExpression): Deleted. (WebCore::CSSCalcExpressionNodeParser::parseValueExpression): Deleted. * css/CSSCalculationValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::unitTypeString): * css/CSSPrimitiveValue.h: * platform/CalculationValue.cpp: (WebCore::CalcExpressionNegation::evaluate const): (WebCore::CalcExpressionNegation::operator== const): (WebCore::CalcExpressionNegation::dump const): (WebCore::operator==): (WebCore::CalcExpressionInversion::evaluate const): (WebCore::CalcExpressionInversion::dump const): (WebCore::CalcExpressionInversion::operator== const): (WebCore::CalcExpressionOperation::evaluate const): (WebCore::operator<<): * platform/CalculationValue.h: LayoutTests: Reviewed by Dean Jackson. New results, mainly because of new simplification rules. * css3/calc/cssom-expected.txt: * css3/calc/simplification-expected.txt: * css3/flexbox/flex-property-parsing-expected.txt: * css3/flexbox/flex-property-parsing.html: * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/shapes/shape-outside/values/support/parsing-utils.js: * fast/css-grid-layout/grid-columns-rows-get-set-expected.txt: * fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt: * fast/css-grid-layout/non-grid-columns-rows-get-set-expected.txt: * fast/css-grid-layout/non-grid-columns-rows-get-set-multiple-expected.txt: * fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js: * fast/css-grid-layout/resources/grid-columns-rows-get-set.js: * fast/css-grid-layout/resources/non-grid-columns-rows-get-set-multiple.js: * fast/css-grid-layout/resources/non-grid-columns-rows-get-set.js: * fast/css/calc-parsing-expected.txt: Added. * fast/css/calc-parsing-limits-expected.txt: Added. * fast/css/calc-parsing-limits.html: Added. * fast/css/calc-parsing.html: Added. * fast/css/calc-with-angle-time-frequency-expected.txt: * fast/css/calc-with-angle-time-frequency.html: * fast/css/column-width-calculated-value-expected.txt: * fast/css/column-width-calculated-value.html: * fast/css/turn-angle-double-expected.txt: * fast/css/turn-angle-double.html: * fast/shapes/parsing/parsing-shape-outside-expected.txt: * fast/shapes/parsing/parsing-test-utils.js: Canonical link: https://commits.webkit.org/218041@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253079 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-04 02:22:35 +00:00
testComputedScrollSnapRule("calc expression", "scroll-padding", "calc(50px + 10%) 20px", "calc(10% + 50px) 20px", { top: "calc(10% + 50px)", left: "20px", right: "20px", bottom: "calc(10% + 50px)" });
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
testComputedScrollSnapRule("various units", "scroll-padding", "1em 5mm 2in 4cm", "16px 18.89763832092285px 192px 151.1811065673828px", { top: "16px", left: "151.1811065673828px", right: "18.89763832092285px", bottom: "192px" });
testComputedScrollSnapRule("subpixel values", "scroll-padding", "10.4375px 6.5px", "10.4375px 6.5px", { top: "10.4375px", left: "6.5px", right: "6.5px", bottom: "10.4375px" });
Implement parsing for CSS scroll snap points https://bugs.webkit.org/show_bug.cgi?id=134301 Source/JavaScriptCore: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebCore: Provided support for parsing -webkit-scroll-snap-* properties, i.e. type, points-x, points-y, destination, and coordinates. The exact syntax of the scroll snap CSS properties follow the W3C spec at http://dev.w3.org/csswg/css-snappoints/ Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests: css3/scroll-snap/scroll-snap-property-parsing.html, css3/scroll-snap/scroll-snap-property-computed-style.html * CMakeLists.txt: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP * WebCore.vcxproj/WebCore.vcxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.vcxproj/WebCore.vcxproj.filters: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.xcodeproj/project.pbxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp, LengthRepeat.h * css/CSSCalculationValue.cpp: Support for LengthRepeat (WebCore::hasDoubleValue): * css/CSSComputedStyleDeclaration.cpp: Support for showing computed style for snap point properties. (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Support for parsing snap point properties. (WebCore::isValidKeywordPropertyAndValue): handle snap point type (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Added support for parsing snap points. (WebCore::CSSParser::parseNonElementSnapPoints): Helper for parsing snap points-x/y. (WebCore::CSSParser::parseScrollSnapDestination): Helper for parsing snap point destinations. (WebCore::CSSParser::parseScrollSnapCoordinate): Helper for parsing snap point coordinates. * css/CSSParser.h: Support for parsing snap point properties. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::CSSPrimitiveValue::init): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): (WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLengthRepeat): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): * css/CSSPrimitiveValueMappings.h: Added converters for snap point type properties. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): * css/CSSPropertyNames.in: Added relevant snap point property names. * css/CSSValueKeywords.in: Added "proximity", "mandatory" and "elements". * css/LengthRepeat.h: Added to represent values of repeat(<length>) (WebCore::LengthRepeat::create): (WebCore::LengthRepeat::cloneForCSSOM): (WebCore::LengthRepeat::interval): (WebCore::LengthRepeat::setInterval): (WebCore::LengthRepeat::equals): (WebCore::LengthRepeat::cssText): (WebCore::LengthRepeat::LengthRepeat): * css/StyleResolver.cpp: Support for handling snap point properties (WebCore::StyleResolver::applyProperty):Updated switch case to build snap-point-related style data * rendering/style/RenderStyle.h: Added methods to access and modify snap point data * rendering/style/RenderStyleConstants.h: Added scroll snap type flags. * rendering/style/StyleAllInOne.cpp: Added StyleScrollSnapPoints.cpp * rendering/style/StyleRareNonInheritedData.cpp: Added initiazing for m_scrollSnapPoints, updated equality check (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Added field for StyleScrollSnapPoints * rendering/style/StyleScrollSnapPoints.cpp: Added. Wrapper for basic snap point data structures. (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): (WebCore::StyleScrollSnapPoints::copy): (WebCore::StyleScrollSnapPoints::operator==): * rendering/style/StyleScrollSnapPoints.h: Added. (WebCore::StyleScrollSnapPoints::create): (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Creates a new Length representing the default repeat value of repeat(100%) (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Creates a new Length representing a default destination value (0px) (WebCore::StyleScrollSnapPoints::operator!=): Source/WebInspectorUI: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * UserInterface/Models/CSSKeywordCompletions.js: Added snap point property keywords, such as mandatory, proximity, elements, and repeat. Source/WebKit/mac: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebKit2: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP LayoutTests: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests that parsing -webkit-scroll-snap-* properties behaves as expected. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-computed-style.html: Tests that scroll snap properties are correctly displayed via getComputedStyle. * css3/scroll-snap/scroll-snap-property-computed-style.js: Script for above test. (testComputedScrollSnapRule): * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-parsing.html: Tests that scroll snap properties are correctly parsed. * css3/scroll-snap/scroll-snap-property-parsing.js: Script for above test. (testScrollSnapRule): Canonical link: https://commits.webkit.org/153553@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-08-07 00:19:40 +00:00
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
// Test the scroll-snap-margin property
// Invalid declarations
Add support for logical variants of 'scroll-padding' and 'scroll-margin' https://bugs.webkit.org/show_bug.cgi?id=220766 <rdar://problem/73661278> Reviewed by Darin Adler. LayoutTests/imported/w3c: Update test expectations for this change. * web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt: * web-platform-tests/css/css-scroll-snap/inheritance-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-margin-block-inline-computed-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-margin-block-inline-shorthand-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-margin-block-inline-valid-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-block-inline-computed-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-block-inline-shorthand-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-block-inline-valid-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-computed-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-invalid-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-shorthand-expected.txt: * web-platform-tests/css/css-scroll-snap/parsing/scroll-padding-valid-expected.txt: * web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: Source/WebCore: Add support for logical `scroll-margin` and `scroll-padding` properties. Also improve parsing of `scroll-padding` which should not accept negative values and should accept "auto" values. The spec gives flexibility for how to interpret "auto", but for us this should just be 0 currently. * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): Add support for logical margin and padding longhands and shortands. * css/CSSProperties.json: Ditto. Allow padding to accept "auto" as well. * css/CSSProperty.cpp: (WebCore::CSSProperty::resolveDirectionAwareProperty): Ditto. (WebCore::CSSProperty::isDirectionAwareProperty): Ditto. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue const): Ditto. (WebCore::StyleProperties::asText const): Ditto. * css/parser/CSSPropertyParser.cpp: (WebCore::consumeScrollPadding): Added this helper that accepts a length, a percentage, or auto. (WebCore::CSSPropertyParser::parseSingleValue): Added support for logical longhands. (WebCore::CSSPropertyParser::parseShorthand): Added support for logical shorthands. * page/scrolling/ScrollSnapOffsetsInfo.cpp: (WebCore::computeScrollSnapPortOrAreaRect): Use minimumValueForLength here because auto should resolve to 0px. * rendering/RenderBox.cpp: (RenderBox::scrollPaddingForViewportRect): Ditto. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollPadding): Initialize scroll-padding values to auto as specified. * rendering/style/StyleRareNonInheritedData.h: Ditto. LayoutTests: Update test expectations. * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: Canonical link: https://commits.webkit.org/233456@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272035 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-01-28 22:24:21 +00:00
testComputedScrollSnapRule("invalid scroll margin", "scroll-snap-margin", "potato", "0px", { top: "0px", left: "0px", right: "0px", bottom: "0px" });
Implement the updated port/area-based Scroll Snap Module Level 1 Spec https://bugs.webkit.org/show_bug.cgi?id=165317 <rdar://problem/29490956> Reviewed by Dean Jackson. Source/WebCore: Implements the changes drafted in the latest iteration of the Scroll Snap Module Level 1 spec, which uses a snap-area and snap-port-based method for determining snap positions in a scroll snapping container. Additionally, removes the now-obsolete and prefixed implementation of the scroll snap spec and refactors all affected layout tests to use the new CSS properties. Also adds new layout tests covering some behaviors detailed in the new version of the spec, such as scroll snapping with transformed child elements. See below for more detailed descriptions of the changes. Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html css3/scroll-snap/scroll-snap-children-with-transforms.html css3/scroll-snap/scroll-snap-positions-mainframe.html css3/scroll-snap/scroll-snap-positions-overflow-resize.html css3/scroll-snap/scroll-snap-positions.html css3/scroll-snap/scroll-snap-style-changed-align.html css3/scroll-snap/scroll-snap-with-scroll-padding.html * WebCore.xcodeproj/project.pbxproj: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): Removed use of length repeat. * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForScrollSnapType): (WebCore::valueForScrollSnapAlignment): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::scrollSnapDestination): Deleted. (WebCore::scrollSnapPoints): Deleted. (WebCore::scrollSnapCoordinates): Deleted. Removed helper functions used to create CSS values for scroll snap coordinates and destination, and added helpers for computed scroll snap type (a combination of axis and strictness values) as well as scroll snap align (an alignment value per axis). * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): Removed usages of the length repeat type, since repeat(*) is no longer being used anywhere. * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapStrictness): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxis): (WebCore::CSSPrimitiveValue::operator ScrollSnapAxisAlignType): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): Deleted. Added CSSPrimitiveValue mappings to ScrollSnapAxisAlignType, ScrollSnapStrictness, and ScrollSnapAxis. Removed the old ScrollSnapType mapping. * css/CSSProperties.json: Replaced the old scroll snap CSS properties with the new ones. Note that scroll-snap-margin and scroll-padding have 4 shorthands each, for the individual top/bottom/left/right values. * css/CSSValueKeywords.in: Added CSS keywords {x, y}, which are necessary to support the new scroll snapping properties. * css/LengthRepeat.h: Removed. Removed LengthRepeat entirely. This represented the `repeat(<length>)` CSS value, which was only used for the scroll-snap-points-x and scroll-snap-points-y values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::parseSnapCoordinate): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Deleted. (WebCore::StyleBuilderConverter::convertSnapCoordinatePair): Deleted. (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates): Deleted. Added helper functions to convert scroll snap type and scroll snap alignment from parsed CSS values to their primary representation in WebCore as ScrollSnapType and ScrollSnapAlign. These methods assume that the given CSS values have successfully cleared the parsing step and are represented as CSSValueLists or length 1 or 2. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Deleted. (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Deleted. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): Adds support for the scroll-snap-margin and scroll-padding. * css/parser/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::CSSParser::parseValue): (WebCore::isScrollSnapAxisAlign): (WebCore::isScrollSnapStrictness): (WebCore::CSSParser::parseScrollSnapAlign): (WebCore::CSSParser::parseScrollSnapType): (WebCore::CSSParser::parseNonElementSnapPoints): Deleted. (WebCore::CSSParser::parseScrollSnapPositions): Deleted. (WebCore::CSSParser::parseScrollSnapDestination): Deleted. (WebCore::CSSParser::parseScrollSnapCoordinate): Deleted. * css/parser/CSSParser.h: Removed references to LengthRepeat, and added support for parsing new scroll snapping properties. Scroll snap margin and scroll padding, along with their shorthands, are parsed using the same helper functions as normal margin and padding. For type and align, I added new helper functions that build up lists of 1 or 2 CSSPrimitiveValues for each of the properties. Parsing scroll-snap-align is straightforward -- we either have one or two values in the set {none, start, center, end}. For scroll-snap-type, we allow a single axis value {x, y, inline, block, both}, or a single strictness value {none, proximity, mandatory}, or an axis value followed by a non-'none' strictness (i.e. either proximity or mandatory). * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * css/parser/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Removed references to LengthRepeat. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::CSSPropertyParser::parseShorthand): (WebCore::consumeSnapPointCoordinateList): Deleted. (WebCore::consumeScrollSnapCoordinate): Deleted. (WebCore::consumeScrollSnapDestination): Deleted. (WebCore::consumeScrollSnapPoints): Deleted. (WebCore::consumeScrollSnapAlign): (WebCore::consumeScrollSnapType): (WebCore::CSSPropertyParser::parseSingleValue): Added parsing for the longhand properties of scroll-snap-margin and scroll-padding, which use the existing consumeLength and consumeLengthOrPercent helpers, respectively. Removed code for parsing scroll snap coordinates, destinations and points. Added parsing logic for align and type. * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapPortOrAreaRect): (WebCore::computeScrollSnapAlignOffset): (WebCore::snapOffsetsToString): (WebCore::snapPortOrAreaToString): (WebCore::updateSnapOffsetsForScrollableArea): (WebCore::appendChildSnapOffsets): Deleted. (WebCore::destinationOffsetForViewSize): Deleted. (WebCore::updateFromStyle): Deleted. (WebCore::styleUsesElements): Deleted. Overhauled updateSnapOffsetsForScrollableArea to work with the new scroll snapping model. In the new way of computing scroll snap offsets, we: Compute the scroll container's scroll snap port, which is the padding box inset by the scroll padding For each child with snap positions (i.e. scroll-snap-align is not none on both axes) Compute the child's scroll snap area, which is the bounding box of the transformed border box If the container snaps along the horizontal axis and the snap area contributes a horizontal snap offset: Emit the distance from the alignment offset in the horizontal of the snap port to the corresponding offset in the snap area as a snap position. If the container snaps along the vertical axis and the snap area contributes a vertical snap offset: Emit the distance from the alignment offset in the vertical of the snap port to the corresponding offset in the snap area as a snap position. For the snap offsets in each axis, if there is at least one snap offset: Clamp the offsets to the min and max scroll offsets Ensure that the offsets are sorted and do not contain duplicated offsets * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapState): Clear out the ScrollController's snap offsets and state along an axis when its ScrollableArea no longer has snap offsets in that axis. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleWillChange): (WebCore::RenderBox::willBeRemovedFromTree): * rendering/RenderLayerModelObject.cpp: (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): (WebCore::RenderLayerModelObject::styleDidChange): * rendering/RenderView.cpp: (WebCore::RenderView::registerBoxWithScrollSnapPositions): (WebCore::RenderView::unregisterBoxWithScrollSnapPositions): (WebCore::RenderView::registerBoxWithScrollSnapCoordinates): Deleted. (WebCore::RenderView::unregisterBoxWithScrollSnapCoordinates): Deleted. * rendering/RenderView.h: Tweaked the scroll snap child registration logic. registerBoxWithScrollSnapCoordinates is renamed to unregisterBoxWithScrollSnapPositions, since the notion of scroll snap coordinates no longer exists, and instead of checking if the list of scroll snap coordinates is empty for the absence of scroll positions, we instead check for a computed scroll snap align that is not none on both axes. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::initialScrollSnapType): (WebCore::RenderStyle::initialScrollSnapAlign): (WebCore::RenderStyle::scrollSnapArea): (WebCore::RenderStyle::scrollSnapPort): (WebCore::RenderStyle::scrollSnapType): (WebCore::RenderStyle::scrollPadding): (WebCore::RenderStyle::scrollPaddingTop): (WebCore::RenderStyle::scrollPaddingBottom): (WebCore::RenderStyle::scrollPaddingLeft): (WebCore::RenderStyle::scrollPaddingRight): (WebCore::RenderStyle::scrollSnapAlign): (WebCore::RenderStyle::scrollSnapMargin): (WebCore::RenderStyle::scrollSnapMarginTop): (WebCore::RenderStyle::scrollSnapMarginBottom): (WebCore::RenderStyle::scrollSnapMarginLeft): (WebCore::RenderStyle::scrollSnapMarginRight): (WebCore::RenderStyle::setScrollSnapType): (WebCore::RenderStyle::setScrollPaddingTop): (WebCore::RenderStyle::setScrollPaddingBottom): (WebCore::RenderStyle::setScrollPaddingLeft): (WebCore::RenderStyle::setScrollPaddingRight): (WebCore::RenderStyle::setScrollSnapAlign): (WebCore::RenderStyle::setScrollSnapMarginTop): (WebCore::RenderStyle::setScrollSnapMarginBottom): (WebCore::RenderStyle::setScrollSnapMarginLeft): (WebCore::RenderStyle::setScrollSnapMarginRight): (WebCore::RenderStyle::initialScrollSnapDestination): Deleted. (WebCore::RenderStyle::initialScrollSnapCoordinates): Deleted. (WebCore::RenderStyle::scrollSnapPointsX): Deleted. (WebCore::RenderStyle::scrollSnapPointsY): Deleted. (WebCore::RenderStyle::scrollSnapDestination): Deleted. (WebCore::RenderStyle::scrollSnapCoordinates): Deleted. (WebCore::RenderStyle::setScrollSnapPointsX): Deleted. (WebCore::RenderStyle::setScrollSnapPointsY): Deleted. (WebCore::RenderStyle::setScrollSnapDestination): Deleted. (WebCore::RenderStyle::setScrollSnapCoordinates): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::initialScrollSnapMargin): (WebCore::RenderStyle::initialScrollPadding): (WebCore::RenderStyle::scrollSnapType): Deleted. (WebCore::RenderStyle::setScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapType): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted. (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted. Added boilerplate code for returning various new scroll snap style properties, and removed similar code for handling the old scroll snap properties. * rendering/style/RenderStyleConstants.h: Added three new enum classes: - ScrollSnapStrictness represents the strictness of scroll snapping along one or both axes - ScrollSnapAxis designates the axes along which scroll snapping should occur - ScrollSnapAxisAlignType indicates which offsets along the x or y axes of the snap port and snap area should be used to compute the snap position emitted by a snap area. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Replaces the StyleScrollSnapPoints object (which, confusingly, was in charge of storing both the scroll container's and child elements' scroll snap styles) with StyleScrollSnapPort and StyleScrollSnapArea objects, which keep track of the style properties on the scroll container and the child element, respectively. * rendering/style/StyleScrollSnapPoints.h: (WebCore::operator==): (WebCore::StyleScrollSnapPort::copy): (WebCore::StyleScrollSnapPort::StyleScrollSnapPort): (WebCore::StyleScrollSnapArea::copy): (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): * rendering/style/StyleScrollSnapping.h: Added. (WebCore::operator!=): (WebCore::StyleScrollSnapPort::create): (WebCore::StyleScrollSnapArea::create): (WebCore::StyleScrollSnapArea::hasSnapPosition): Overhauled StyleScrollSnapPoints, breaking the logic here into two classes: StyleScrollSnapPort for the scroll container, handling the properties `scroll-snap-type` and `scroll-padding` and StyleScrollSnapArea for child elements, handling the properties `scroll-snap-align` and `scroll-snap-margin`. The ScrollSnapType itself is composed of an axis value and a strictness, while a ScrollSnapAlign keeps track of the alignment modes in each axis. By default, these are initialized to {Both, None} and {None, None}, respectively. The rest of the logic is boilerplate code for comparing these style objects to one another and copying style representations. * testing/Internals.cpp: (WebCore::Internals::scrollSnapOffsets): Perform a layout on the document if needed before returning the list of computed snap offsets. The absence of this layout pass was causing some layout tests in css3/scroll-snap/ to flake when testing that programmatic changes to the scroll snap style properties change the computed snap offsets. Source/WebKit2: Remove unused code for adopting scroll snapping in the PDF plugin. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::didCalculateSizes): LayoutTests: Refactors layout tests to use the new scroll snapping properties, removing any tests that only made sense in the context of the old version of scroll snapping and adding new ones to cover behaviors that the existing tests do not verify. See per-method descriptions for more details. In most cases, the old way of specifying scroll snapping via repeat(<container width or length>) or a coordinate at (0, 0) on each child has been replaced with `scroll-snap-type: (x|y|both) mandatory;` on the container and `scroll-snap-align: start` on each child element. If a test below does not have an accompanying description, then this is the only change applied to it, and the behavior it is testing is still relevant in the new scroll snapping model. * css3/scroll-snap/improper-snap-points-crash-expected.txt: Removed. * css3/scroll-snap/improper-snap-points-crash.html: Removed. This test is no longer valid in the new scroll snapping model, since there is no way to specify both repeating points along an axis and child elements with scroll snap coordinates. * css3/scroll-snap/nested-elements-expected.txt: * css3/scroll-snap/nested-elements.html: * css3/scroll-snap/resources/iframe-content.html: * css3/scroll-snap/scroll-snap-2d-change-axis-type-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: Added. New layout test to check that changing the scroll-snap-type from one to both axes updates the computed snap offsets in the container to have offsets from both axes. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: Added. New layout test to check that snap offsets are computed independently on each axis. In a 3x3 grid of child elements with the child elements along the diagonal having `scroll-snap-align`s of `end`, `center` and `start` in order from top left to bottom right, we should observe the same effect as having each child emit snap positions in both axes. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-scroll-snap-margin.html: Added. New layout test to check that specifying a `scroll-snap-margin` correctly insets the scroll snap area of a child element, and that changing the `scroll-snap-margin` via script also changes the computed scroll snap offsets. * css3/scroll-snap/scroll-snap-children-with-transforms-expected.txt: Added. * css3/scroll-snap/scroll-snap-children-with-transforms.html: Added. New layout test to check that when computing the scroll snap areas of child elements, we take transforms into account and use the bounding box of the transformed border box of the child element. Also verifies that we apply the scroll offset _after_ the transform, so that scrolling the container and then recomputing snap offsets when child elements are transformed does not result in different snap offsets. * css3/scroll-snap/scroll-snap-coordinate-expected.txt: Removed. * css3/scroll-snap/scroll-snap-coordinate.html: Removed. Renamed to scroll-snap-position.html, since the notion of scroll snap coordinates no longer exists. * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Removed. * css3/scroll-snap/scroll-snap-desination-lock-up.html: Removed. This test is no longer relevant in the new scroll snapping model. This is because the logic for computing scroll snap offsets in AxisScrollSnapOffsets no longer has an opportunity to loop infinitely while trying to fill a scrollable axis with snap offsets, since repeating snap points have been removed. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-inherit-expected.txt: * css3/scroll-snap/scroll-snap-inherit.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-initial-expected.txt: * css3/scroll-snap/scroll-snap-initial.html: Updated to test the new scroll snap properties. * css3/scroll-snap/scroll-snap-mismatch.html: * css3/scroll-snap/scroll-snap-negative-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-negative-repeat.html: Removed. Removed, since negative repeating scroll snap offsets are (thankfully) no longer possible in the new scroll snapping model. * css3/scroll-snap/scroll-snap-offsets-expected.txt: * css3/scroll-snap/scroll-snap-offsets.html: Augmented to mix in various alignment values among the scroll snap child elements as well as various levels of nesting. * css3/scroll-snap/scroll-snap-position-values-expected.txt: Removed. * css3/scroll-snap/scroll-snap-position-values.html: Removed. The behaviors tested here are covered by other similar tests: scroll-snap-initial and scroll-snap-inherit. * css3/scroll-snap/scroll-snap-positions-expected.txt: Added. * css3/scroll-snap/scroll-snap-positions-mainframe-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe-expected.txt. * css3/scroll-snap/scroll-snap-positions-mainframe.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-mainframe.html. * css3/scroll-snap/scroll-snap-positions-overflow-resize-expected.txt: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt. * css3/scroll-snap/scroll-snap-positions-overflow-resize.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html. * css3/scroll-snap/scroll-snap-positions.html: Added. Renamed these existing tests to not use the term `scroll-snap-coordinate`. The semantics of these tests are still the same, only using different values of `scroll-snap-align` instead of `-webkit-scroll-snap-coordinate`. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: * css3/scroll-snap/scroll-snap-property-computed-style.js: * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: * css3/scroll-snap/scroll-snap-property-parsing.js: * css3/scroll-snap/scroll-snap-style-changed-align-expected.txt: Added. * css3/scroll-snap/scroll-snap-style-changed-align.html: Renamed from LayoutTests/css3/scroll-snap/scroll-snap-style-changed-coordinates.html. * css3/scroll-snap/scroll-snap-style-changed-coordinates-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-style-changed-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-subpixel-repeat-expected.txt: Removed. * css3/scroll-snap/scroll-snap-subpixel-repeat.html: Removed. No longer relevant, since repeating scroll snap offsets are no longer in the spec. * css3/scroll-snap/scroll-snap-with-scroll-padding-expected.txt: Added. * css3/scroll-snap/scroll-snap-with-scroll-padding.html: Added. New layout test to check that specifying scroll padding on a scroll container correctly outsets the scroll snap port, and that changing scroll padding via script also changes the computed snap offsets. * platform/mac-wk2/TestExpectations: Removed tiled-drawing/scrolling/latched-div-with-scroll-snap.html from the list of failing tests. * tiled-drawing/scrolling/latched-div-with-scroll-snap-expected.txt: * tiled-drawing/scrolling/latched-div-with-scroll-snap.html: This test was failing 100% of the time due to the momentum portion of the scrolling phase being invoked after scroll snapping has ended. This has been rewritten to perform the following steps: 1. Scroll the top div with momentum and verify that the scroll 'glided' to the red box. 2. Scroll the top div without momentum and verify that the scroll snaps back to the red box. 3. Repeat (1) and (2), but for the bottom div. The same thing should occur. * tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html: * tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up-expected.txt: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-destination-lock-up.html: Removed. * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html: * tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html: All of the tests here were updated to use the new scroll-snap-* properties instead of the old versions. The semantics of these tests have not changed. Canonical link: https://commits.webkit.org/183643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-20 18:44:38 +00:00
testComputedScrollSnapRule("empty string", "scroll-snap-margin", "", "0px", { top: "0px", left: "0px", right: "0px", bottom: "0px" });
testComputedScrollSnapRule("too many values", "scroll-snap-margin", "1px 2px 3px 4px 5px", "0px", { top: "0px", left: "0px", right: "0px", bottom: "0px" });
testComputedScrollSnapRule("attempt to use auto", "scroll-snap-margin", "auto auto", "0px", { top: "0px", left: "0px", right: "0px", bottom: "0px" });
testComputedScrollSnapRule("attempt to use percentage", "scroll-snap-margin", "25% 25%", "0px", { top: "0px", left: "0px", right: "0px", bottom: "0px" });
testComputedScrollSnapRule("attempt to use calc", "scroll-snap-margin", "calc(25% + 10px)", "0px", { top: "0px", left: "0px", right: "0px", bottom: "0px" });
// Valid declarations
testComputedScrollSnapRule("single length", "scroll-snap-margin", "10px", "10px", { top: "10px", left: "10px", right: "10px", bottom: "10px" });
testComputedScrollSnapRule("two lengths", "scroll-snap-margin", "10px 20px", "10px 20px", { top: "10px", left: "20px", right: "20px", bottom: "10px" });
testComputedScrollSnapRule("three lengths", "scroll-snap-margin", "1px 2px 3px", "1px 2px 3px", { top: "1px", left: "2px", right: "2px", bottom: "3px" });
testComputedScrollSnapRule("four lengths", "scroll-snap-margin", "50px 10px 20px 50px", "50px 10px 20px 50px", { top: "50px", left: "50px", right: "10px", bottom: "20px" });
testComputedScrollSnapRule("various units", "scroll-snap-margin", "1em 5mm 2in 4cm", "16px 18.89763832092285px 192px 151.1811065673828px", { top: "16px", left: "151.1811065673828px", right: "18.89763832092285px", bottom: "192px" });
testComputedScrollSnapRule("subpixel values", "scroll-snap-margin", "10.4375px 6.5px", "10.4375px 6.5px", { top: "10.4375px", left: "6.5px", right: "6.5px", bottom: "10.4375px" });
Implement parsing for CSS scroll snap points https://bugs.webkit.org/show_bug.cgi?id=134301 Source/JavaScriptCore: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebCore: Provided support for parsing -webkit-scroll-snap-* properties, i.e. type, points-x, points-y, destination, and coordinates. The exact syntax of the scroll snap CSS properties follow the W3C spec at http://dev.w3.org/csswg/css-snappoints/ Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests: css3/scroll-snap/scroll-snap-property-parsing.html, css3/scroll-snap/scroll-snap-property-computed-style.html * CMakeLists.txt: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP * WebCore.vcxproj/WebCore.vcxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.vcxproj/WebCore.vcxproj.filters: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp * WebCore.xcodeproj/project.pbxproj: Added StyleScrollSnapPoints.h, StyleScrollSnapPoints.cpp, LengthRepeat.h * css/CSSCalculationValue.cpp: Support for LengthRepeat (WebCore::hasDoubleValue): * css/CSSComputedStyleDeclaration.cpp: Support for showing computed style for snap point properties. (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Support for parsing snap point properties. (WebCore::isValidKeywordPropertyAndValue): handle snap point type (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Added support for parsing snap points. (WebCore::CSSParser::parseNonElementSnapPoints): Helper for parsing snap points-x/y. (WebCore::CSSParser::parseScrollSnapDestination): Helper for parsing snap point destinations. (WebCore::CSSParser::parseScrollSnapCoordinate): Helper for parsing snap point coordinates. * css/CSSParser.h: Support for parsing snap point properties. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::CSSPrimitiveValue::init): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): (WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText): (WebCore::CSSPrimitiveValue::cloneForCSSOM): (WebCore::CSSPrimitiveValue::equals): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLengthRepeat): (WebCore::CSSPrimitiveValue::getLengthRepeatValue): * css/CSSPrimitiveValueMappings.h: Added converters for snap point type properties. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator ScrollSnapType): * css/CSSPropertyNames.in: Added relevant snap point property names. * css/CSSValueKeywords.in: Added "proximity", "mandatory" and "elements". * css/LengthRepeat.h: Added to represent values of repeat(<length>) (WebCore::LengthRepeat::create): (WebCore::LengthRepeat::cloneForCSSOM): (WebCore::LengthRepeat::interval): (WebCore::LengthRepeat::setInterval): (WebCore::LengthRepeat::equals): (WebCore::LengthRepeat::cssText): (WebCore::LengthRepeat::LengthRepeat): * css/StyleResolver.cpp: Support for handling snap point properties (WebCore::StyleResolver::applyProperty):Updated switch case to build snap-point-related style data * rendering/style/RenderStyle.h: Added methods to access and modify snap point data * rendering/style/RenderStyleConstants.h: Added scroll snap type flags. * rendering/style/StyleAllInOne.cpp: Added StyleScrollSnapPoints.cpp * rendering/style/StyleRareNonInheritedData.cpp: Added initiazing for m_scrollSnapPoints, updated equality check (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Added field for StyleScrollSnapPoints * rendering/style/StyleScrollSnapPoints.cpp: Added. Wrapper for basic snap point data structures. (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): (WebCore::StyleScrollSnapPoints::copy): (WebCore::StyleScrollSnapPoints::operator==): * rendering/style/StyleScrollSnapPoints.h: Added. (WebCore::StyleScrollSnapPoints::create): (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Creates a new Length representing the default repeat value of repeat(100%) (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Creates a new Length representing a default destination value (0px) (WebCore::StyleScrollSnapPoints::operator!=): Source/WebInspectorUI: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * UserInterface/Models/CSSKeywordCompletions.js: Added snap point property keywords, such as mandatory, proximity, elements, and repeat. Source/WebKit/mac: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP Source/WebKit2: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. * Configurations/FeatureDefines.xcconfig: Added ENABLE_CSS_SCROLL_SNAP LayoutTests: Patch by Wenson Hsieh <wenson_hsieh@apple.com> on 2014-08-06 Reviewed by Dean Jackson. Tests that parsing -webkit-scroll-snap-* properties behaves as expected. * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-computed-style.html: Tests that scroll snap properties are correctly displayed via getComputedStyle. * css3/scroll-snap/scroll-snap-property-computed-style.js: Script for above test. (testComputedScrollSnapRule): * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Expected text output of below test. * css3/scroll-snap/scroll-snap-property-parsing.html: Tests that scroll snap properties are correctly parsed. * css3/scroll-snap/scroll-snap-property-parsing.js: Script for above test. (testScrollSnapRule): Canonical link: https://commits.webkit.org/153553@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-08-07 00:19:40 +00:00
successfullyParsed = true;