Diff
Modified: trunk/LayoutTests/ChangeLog (173658 => 173659)
--- trunk/LayoutTests/ChangeLog 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/LayoutTests/ChangeLog 2014-09-16 15:58:12 UTC (rev 173659)
@@ -1,3 +1,25 @@
+2014-09-14 Darin Adler <[email protected]>
+
+ Scroll snap properties do not handle inherit and initial properly.
+ https://bugs.webkit.org/show_bug.cgi?id=136643
+
+ Reviewed by Beth Dakin.
+
+ * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Added
+ expected passing results from new tests.
+ * css3/scroll-snap/scroll-snap-property-computed-style.js: Added new test
+ cases that cover inherit and initial. Before, these would crash or fail.
+
+ * css3/scroll-snap/scroll-snap-property-parsing-expected.txt: Added expected
+ passing results from new tests, and also updated to expect pass rather than
+ fail for the tests that had incorrect expected results.
+
+ * css3/scroll-snap/scroll-snap-property-parsing.js: Added new test cases that
+ cover inherit and initial. Also updated expected results for certain pixel
+ repeat cases that were incorrect.
+
+ * platform/mac/TestExpectations: Fixed an unrelated syntax error in this file.
+
2014-09-16 Youenn Fablet <[email protected]>
[GStreamer] http/tests/media/video-auth.html is failing
Modified: trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style-expected.txt (173658 => 173659)
--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style-expected.txt 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style-expected.txt 2014-09-16 15:58:12 UTC (rev 173659)
@@ -34,12 +34,27 @@
mismatched x coordinate : 50% 100px 75%
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-coordinate') is 'none'
+inherited type : inherit
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-type') is 'none'
+
+initial type : initial
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-type') is 'none'
+
+none type : none
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-type') is 'none'
+
mandatory type : mandatory
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-type') is 'mandatory'
proximity type : proximity
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-type') is 'proximity'
+inherited points along x axis : inherit
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'repeat(100%)'
+
+initial points along x axis : initial
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'repeat(100%)'
+
element points along x axis : elements
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'elements'
@@ -67,6 +82,12 @@
pixel points along x axis with pixel repeat : 100px repeat(42px)
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is '100px repeat(42px)'
+inherited points along y axis : inherit
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is 'repeat(100%)'
+
+initial points along y axis : initial
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is 'repeat(100%)'
+
element points along y axis : elements
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is 'elements'
@@ -94,6 +115,12 @@
pixel points along y axis with pixel repeat : 100px repeat(42px)
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is '100px repeat(42px)'
+inherited destination : inherit
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-destination') is '0px 0px'
+
+initial destination : initial
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-destination') is '0px 0px'
+
pixel/pixel destination : 10px 50px
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-destination') is '10px 50px'
@@ -106,6 +133,15 @@
percentage/percentage destination : 5% 100%
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-destination') is '5% 100%'
+inherited coordinate : inherit
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-coordinate') is 'none'
+
+initial coordinate : initial
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-coordinate') is 'none'
+
+no coordinate : none
+PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-coordinate') is 'none'
+
single pixel coordinate : 50px 100px
PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-coordinate') is '50px 100px'
Modified: trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style.js (173658 => 173659)
--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style.js 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style.js 2014-09-16 15:58:12 UTC (rev 173659)
@@ -27,9 +27,14 @@
testComputedScrollSnapRule("invalid coordinates", "coordinate", "ben bitdiddle", "none")
testComputedScrollSnapRule("mismatched x coordinate", "coordinate", "50% 100px 75%", "none");
+testComputedScrollSnapRule("inherited type", "type", "inherit", "none");
+testComputedScrollSnapRule("initial type", "type", "initial", "none");
+testComputedScrollSnapRule("none type", "type", "none", "none");
testComputedScrollSnapRule("mandatory type", "type", "mandatory", "mandatory");
testComputedScrollSnapRule("proximity type", "type", "proximity", "proximity");
+testComputedScrollSnapRule("inherited points along x axis", "points-x", "inherit", "repeat(100%)");
+testComputedScrollSnapRule("initial points along x axis", "points-x", "initial", "repeat(100%)");
testComputedScrollSnapRule("element points along x axis", "points-x", "elements", "elements");
testComputedScrollSnapRule("percentage points along x axis", "points-x", "100% 50%", "100% 50%");
testComputedScrollSnapRule("pixel points along x axis", "points-x", "100px 50px", "100px 50px");
@@ -40,6 +45,8 @@
testComputedScrollSnapRule("percentage points along x axis with pixel repeat", "points-x", "100% 50% repeat(40px)", "100% 50% repeat(40px)");
testComputedScrollSnapRule("pixel points along x axis with pixel repeat", "points-x", "100px repeat(42px)", "100px repeat(42px)");
+testComputedScrollSnapRule("inherited points along y axis", "points-y", "inherit", "repeat(100%)");
+testComputedScrollSnapRule("initial points along y axis", "points-y", "initial", "repeat(100%)");
testComputedScrollSnapRule("element points along y axis", "points-y", "elements", "elements");
testComputedScrollSnapRule("percentage points along y axis", "points-y", "100% 50%", "100% 50%");
testComputedScrollSnapRule("pixel points along y axis", "points-y", "100px 50px", "100px 50px");
@@ -50,11 +57,16 @@
testComputedScrollSnapRule("percentage points along y axis with pixel repeat", "points-y", "100% 50% repeat(40px)", "100% 50% repeat(40px)");
testComputedScrollSnapRule("pixel points along y axis with pixel repeat", "points-y", "100px repeat(42px)", "100px repeat(42px)");
+testComputedScrollSnapRule("inherited destination", "destination", "inherit", "0px 0px");
+testComputedScrollSnapRule("initial destination", "destination", "initial", "0px 0px");
testComputedScrollSnapRule("pixel/pixel destination", "destination", "10px 50px", "10px 50px");
testComputedScrollSnapRule("pixel/percentage destination", "destination", "20px 40%", "20px 40%");
testComputedScrollSnapRule("percentage/pixel destination", "destination", "0% 0px", "0% 0px");
testComputedScrollSnapRule("percentage/percentage destination", "destination", "5% 100%", "5% 100%");
+testComputedScrollSnapRule("inherited coordinate", "coordinate", "inherit", "none");
+testComputedScrollSnapRule("initial coordinate", "coordinate", "initial", "none");
+testComputedScrollSnapRule("no coordinate", "coordinate", "none", "none");
testComputedScrollSnapRule("single pixel coordinate", "coordinate", "50px 100px", "50px 100px");
testComputedScrollSnapRule("single percentage coordinate", "coordinate", "50% 100%", "50% 100%");
testComputedScrollSnapRule("multiple pixel coordinates", "coordinate", "50px 100px 150px 100px 200px 100px", "50px 100px, 150px 100px, 200px 100px");
Modified: trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-parsing-expected.txt (173658 => 173659)
--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-parsing-expected.txt 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-parsing-expected.txt 2014-09-16 15:58:12 UTC (rev 173659)
@@ -4,6 +4,56 @@
+inherited type : inherit
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-type') is 'inherit'
+
+initial type : initial
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-type') is 'initial'
+
+inherited points-x : inherit
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-points-x') is 'inherit'
+
+initial points-x : initial
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-points-x') is 'initial'
+
+inherited points-y : inherit
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-points-y') is 'inherit'
+
+initial points-y : initial
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-points-y') is 'initial'
+
+inherited destination : inherit
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-destination') is 'inherit'
+
+initial destination : initial
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-destination') is 'initial'
+
+inherited coordinate : inherit
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-coordinate') is 'inherit'
+
+initial coordinate : initial
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('-webkit-scroll-snap-coordinate') is 'initial'
+
mandatory type : mandatory
PASS cssRule.type is 1
PASS declaration.length is 1
@@ -107,22 +157,22 @@
em points along x axis with pixel repeat : 100em repeat(42em)
PASS cssRule.type is 1
PASS declaration.length is 1
-FAIL declaration.getPropertyValue('-webkit-scroll-snap-points-x') should be 100em repeat 42em. Was 100em repeat(42em).
+PASS declaration.getPropertyValue('-webkit-scroll-snap-points-x') is '100em repeat(42em)'
mm along x axis with pixel repeat : 100mm repeat(42mm)
PASS cssRule.type is 1
PASS declaration.length is 1
-FAIL declaration.getPropertyValue('-webkit-scroll-snap-points-x') should be 100mm repeat 42mm. Was 100mm repeat(42mm).
+PASS declaration.getPropertyValue('-webkit-scroll-snap-points-x') is '100mm repeat(42mm)'
in along x axis with pixel repeat : 100in repeat(42in)
PASS cssRule.type is 1
PASS declaration.length is 1
-FAIL declaration.getPropertyValue('-webkit-scroll-snap-points-x') should be 100in repeat 42in. Was 100in repeat(42in).
+PASS declaration.getPropertyValue('-webkit-scroll-snap-points-x') is '100in repeat(42in)'
pt along x axis with pixel repeat : 100pt repeat(42pt)
PASS cssRule.type is 1
PASS declaration.length is 1
-FAIL declaration.getPropertyValue('-webkit-scroll-snap-points-x') should be 100pt repeat 42pt. Was 100pt repeat(42pt).
+PASS declaration.getPropertyValue('-webkit-scroll-snap-points-x') is '100pt repeat(42pt)'
pixel/pixel destination : 10px 50px
PASS cssRule.type is 1
Modified: trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-parsing.js (173658 => 173659)
--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-parsing.js 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-parsing.js 2014-09-16 15:58:12 UTC (rev 173659)
@@ -20,6 +20,21 @@
shouldBe("declaration.getPropertyValue('-webkit-scroll-snap-" + snapProperty + "')", "'" + expectedValue + "'");
}
+testScrollSnapRule("inherited type", "type", "inherit", "inherit");
+testScrollSnapRule("initial type", "type", "initial", "initial");
+
+testScrollSnapRule("inherited points-x", "points-x", "inherit", "inherit");
+testScrollSnapRule("initial points-x", "points-x", "initial", "initial");
+
+testScrollSnapRule("inherited points-y", "points-y", "inherit", "inherit");
+testScrollSnapRule("initial points-y", "points-y", "initial", "initial");
+
+testScrollSnapRule("inherited destination", "destination", "inherit", "inherit");
+testScrollSnapRule("initial destination", "destination", "initial", "initial");
+
+testScrollSnapRule("inherited coordinate", "coordinate", "inherit", "inherit");
+testScrollSnapRule("initial coordinate", "coordinate", "initial", "initial");
+
testScrollSnapRule("mandatory type", "type", "mandatory", "mandatory");
testScrollSnapRule("proximity type", "type", "proximity", "proximity");
@@ -43,10 +58,10 @@
testScrollSnapRule("percentage points along y axis with pixel repeat", "points-y", "100% 50% repeat(40px)", "100% 50% repeat(40px)");
testScrollSnapRule("pixel points along y axis with pixel repeat", "points-y", "100px repeat(42px)", "100px repeat(42px)");
-testScrollSnapRule("em points along x axis with pixel repeat", "points-x", "100em repeat(42em)", "100em repeat 42em");
-testScrollSnapRule("mm along x axis with pixel repeat", "points-x", "100mm repeat(42mm)", "100mm repeat 42mm");
-testScrollSnapRule("in along x axis with pixel repeat", "points-x", "100in repeat(42in)", "100in repeat 42in");
-testScrollSnapRule("pt along x axis with pixel repeat", "points-x", "100pt repeat(42pt)", "100pt repeat 42pt");
+testScrollSnapRule("em points along x axis with pixel repeat", "points-x", "100em repeat(42em)", "100em repeat(42em)");
+testScrollSnapRule("mm along x axis with pixel repeat", "points-x", "100mm repeat(42mm)", "100mm repeat(42mm)");
+testScrollSnapRule("in along x axis with pixel repeat", "points-x", "100in repeat(42in)", "100in repeat(42in)");
+testScrollSnapRule("pt along x axis with pixel repeat", "points-x", "100pt repeat(42pt)", "100pt repeat(42pt)");
testScrollSnapRule("pixel/pixel destination", "destination", "10px 50px", "10px 50px");
testScrollSnapRule("pixel/percentage destination", "destination", "20px 40%", "20px 40%");
Modified: trunk/Source/WebCore/ChangeLog (173658 => 173659)
--- trunk/Source/WebCore/ChangeLog 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/ChangeLog 2014-09-16 15:58:12 UTC (rev 173659)
@@ -1,3 +1,119 @@
+2014-09-14 Darin Adler <[email protected]>
+
+ Scroll snap properties don't handle inherit and initial propertly.
+ https://bugs.webkit.org/show_bug.cgi?id=136643
+
+ Reviewed by Beth Dakin.
+
+ Restructured scroll snap code both to handle inherit and initial, and to reduce the
+ total code size a bit, fixing a few minor bugs along the way. Updated the regression
+ tests to cover the new parts.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::addValuesForNamedGridLinesAtIndex): Use a modern for loop.
+ (WebCore::scrollSnapDestination): Changed to take a LengthSize. Also streamlined.
+ (WebCore::scrollSnapPoints): Changed to to take a ScrollSnapPoints. Also streamlined and
+ added code to handle the "uses elements" case; serialize that as an identifier, not the
+ string "elements", fixing a minor bug.
+ (WebCore::scrollSnapCoordinates): Changed to take a Vector<LengthSize>. Also streamlined
+ and added code to handle the empty vector case; serialize that as an identifier, not the
+ string "none", fixing a minor bug.
+ (WebCore::ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword): Use nullptr.
+ (WebCore::counterToCSSValue): Use nullptr.
+ (WebCore::ComputedStyleExtractor::styledNode): Use nullptr.
+ (WebCore::ComputedStyleExtractor::propertyValue): Use nullptr. Moved CSS_SCROLL_SNAP
+ to a more appropriate section of the switch statement. Made it just call through to
+ the functions above in a more straightforward way.
+ (WebCore::CSSComputedStyleDeclaration::getPropertyValue): Reversed logic to use early
+ return and to call emptyString.
+ (WebCore::CSSComputedStyleDeclaration::item): Use emptyString.
+ (WebCore::ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand): Use nullptr.
+ (WebCore::CSSComputedStyleDeclaration::parentRule): Use nullptr.
+ (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Use nullptr.
+ (WebCore::CSSComputedStyleDeclaration::getPropertyPriority): Use emptyString.
+ (WebCore::CSSComputedStyleDeclaration::getPropertyShorthand): Use emptyString.
+
+ * css/DeprecatedStyleBuilder.cpp:
+ (WebCore::ApplyPropertyMarqueeIncrement::applyValue): Use the switch statement for the
+ invalid value as well as for the valid values, rather than a separate if statement.
+ Call convertToLength directly rather than through a StyleResolver static member function.
+
+ * css/PropertySetCSSStyleDeclaration.cpp:
+ (WebCore::PropertySetCSSStyleDeclaration::getPropertyValue): Fixed a formatting mistake.
+
+ * css/StyleResolver.cpp:
+ (WebCore::convertToIntLength): Made this function local to this file instead of a
+ static member function.
+ (WebCore::convertToFloatLength): Ditto.
+ (WebCore::StyleResolver::parseSnapCoordinate): Added. Used to keep snap point parsing
+ code small.
+ (WebCore::StyleResolver::parseSnapCoordinatePair): Ditto.
+ (WebCore::StyleResolver::parseSnapPoints): Added. Parses an entire snap points property.
+ (WebCore::StyleResolver::applyProperty): Removed various bits of redundant code that
+ were not using the primitiveValue value already in a local variable. Added the
+ HANDLE_INHERIT_AND_INITIAL to all the scroll snap properties and updated since the
+ RenderStyle structure now more closely matches the CSS properties.
+
+ * css/StyleResolver.h: Updated for above changes, and removed a redundant "private:".
+
+ * page/scrolling/AxisScrollSnapOffsets.cpp:
+ (WebCore::appendChildSnapOffsets): Use auto& instead of SnapCoordinate since that type
+ is now gone. Updated since coordinates are now LengthSize.
+ (WebCore::updateFromStyle): Changed to take a reference instead of a pointer and
+ also to fetch the data from RenderStyle in a new way that more closely matches the
+ CSS properties.
+ (WebCore::updateSnapOffsetsForScrollableArea): Ditto. Also moved some memory allocation
+ inside if statements so we don't wastefully allocate and destroy.
+
+ * rendering/style/RenderStyle.cpp: Added an include of StyleScrollSnapPoints.h now
+ that the header doesn't include them. Moved the conditional includes out of the main
+ include paragraph (even though I don't think conditional includes are usually a good
+ idea).
+ (WebCore::RenderStyle::initialScrollSnapPointsX): Added.
+ (WebCore::RenderStyle::initialScrollSnapPointsY): Added.
+ (WebCore::RenderStyle::initialScrollSnapDestination): Added.
+ (WebCore::RenderStyle::initialScrollSnapCoordinates): Added.
+ (WebCore::RenderStyle::scrollSnapPointsX): Added.
+ (WebCore::RenderStyle::scrollSnapPointsY): Added.
+ (WebCore::RenderStyle::scrollSnapDestination): Added.
+ (WebCore::RenderStyle::scrollSnapCoordinates): Added.
+ (WebCore::RenderStyle::setScrollSnapPointsX): Added.
+ (WebCore::RenderStyle::setScrollSnapPointsY): Added.
+ (WebCore::RenderStyle::setScrollSnapDestination): Added.
+ (WebCore::RenderStyle::setScrollSnapCoordinates): Added.
+
+ * rendering/style/RenderStyle.h: Replaced the include of StyleScrollSnapPoints.h with
+ a forward declaration of ScrollSnapPoints. Removed getters and setters for the old
+ style properties and replaced them with new ones that match the CSS properties more
+ closely. Tweaked formatting a bit. Added initial value functions for the the scroll snap
+ properties.
+
+ * rendering/style/StyleRareNonInheritedData.cpp: Added include of StyleScrollSnapPoints.h
+ now that RenderStyle.h doesn't include it.
+ (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): Updated since
+ m_scrollSnapType is now unsigned instead of ScrollSnapType.
+
+ * rendering/style/StyleRareNonInheritedData.h: Fixed type of m_scrollSnapType to be
+ unsigned instead of ScrollSnapType. This should have been causing problems on Windows,
+ but I think we got lucky and had no detectable problems.
+
+ * rendering/style/StyleScrollSnapPoints.cpp:
+ (WebCore::ScrollSnapPoints::ScrollSnapPoints): Added.
+ (WebCore::operator==): Added overloads for both ScrollSnapPoints and also for
+ StyleScrollSnapPoints; using a free function for both since both have public data.
+ (WebCore::defaultScrollSnapDestination): Added, replaces a static member function.
+ (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): Updated both the default
+ constructor and the copy constructor for the new design.
+
+ * rendering/style/StyleScrollSnapPoints.h: Added a ScrollSnapPoints struct for the
+ type of the snap-points-x and snap-points-y CSS properties. Changed the data members
+ of StyleScrollSnapPoints to match the various CSS properties rather than breaking
+ out all the data into separate data members.
+ (WebCore::StyleScrollSnapPoints::defaultRepeatOffset): Deleted. Replaced by the
+ default constructor for ScrollSnapPoints.
+ (WebCore::StyleScrollSnapPoints::defaultDestinationOffset): Deleted. Replaced by
+ a function inside the .cpp file.
+
2014-09-16 Youenn Fablet <[email protected]>
[GStreamer] http/tests/media/video-auth.html is failing
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (173658 => 173659)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2014-09-16 15:58:12 UTC (rev 173659)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2004 Zack Rusin <[email protected]>
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2014 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alexey Proskuryakov <[email protected]>
* Copyright (C) 2007 Nicholas Shanks <[email protected]>
* Copyright (C) 2011 Sencha, Inc. All rights reserved.
@@ -998,8 +998,8 @@
return;
RefPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue::create();
- for (size_t i = 0; i < namedGridLines.size(); ++i)
- lineNames->append(cssValuePool().createValue(namedGridLines[i], CSSPrimitiveValue::CSS_STRING));
+ for (auto& name : namedGridLines)
+ lineNames->append(cssValuePool().createValue(name, CSSPrimitiveValue::CSS_STRING));
list.append(lineNames.releaseNonNull());
}
@@ -1088,38 +1088,44 @@
}
#if ENABLE(CSS_SCROLL_SNAP)
-static PassRef<CSSValueList> scrollSnapDestination(RenderStyle* style, Length x, Length y)
+
+static PassRef<CSSValueList> scrollSnapDestination(RenderStyle& style, const LengthSize& destination)
{
- RefPtr<CSSValueList> snapDestinationValue = CSSValueList::createSpaceSeparated();
- snapDestinationValue->append(percentageOrZoomAdjustedValue(x, style));
- snapDestinationValue->append(percentageOrZoomAdjustedValue(y, style));
- return snapDestinationValue.releaseNonNull();
+ auto list = CSSValueList::createSpaceSeparated();
+ list.get().append(percentageOrZoomAdjustedValue(destination.width(), &style));
+ list.get().append(percentageOrZoomAdjustedValue(destination.height(), &style));
+ return list;
}
-static PassRef<CSSValueList> scrollSnapPoints(RenderStyle* style, const Vector<Length>& points, Length repeatPoint, bool hasRepeat)
+static PassRef<CSSValue> scrollSnapPoints(RenderStyle& style, const ScrollSnapPoints& points)
{
- RefPtr<CSSValueList> snapPointsValue = CSSValueList::createSpaceSeparated();
- for (auto& point : points)
- snapPointsValue->append(percentageOrZoomAdjustedValue(point, style));
-
- if (hasRepeat)
- snapPointsValue->append(cssValuePool().createValue(LengthRepeat::create(percentageOrZoomAdjustedValue(repeatPoint, style))));
-
- return snapPointsValue.releaseNonNull();
+ if (points.usesElements)
+ return cssValuePool().createIdentifierValue(CSSValueElements);
+ auto list = CSSValueList::createSpaceSeparated();
+ for (auto& point : points.offsets)
+ list.get().append(percentageOrZoomAdjustedValue(point, &style));
+ if (points.hasRepeat)
+ list.get().append(cssValuePool().createValue(LengthRepeat::create(percentageOrZoomAdjustedValue(points.repeatOffset, &style))));
+ return WTF::move(list);
}
-static PassRef<CSSValueList> scrollSnapCoordinates(RenderStyle* style, const Vector<SnapCoordinate>& coordinates)
+static PassRef<CSSValue> scrollSnapCoordinates(RenderStyle& style, const Vector<LengthSize>& coordinates)
{
- RefPtr<CSSValueList> snapCoordinatesValue = CSSValueList::createCommaSeparated();
- for (const auto& coordinate : coordinates) {
- RefPtr<CSSValueList> currentCoordinate = CSSValueList::createSpaceSeparated();
- currentCoordinate->append(percentageOrZoomAdjustedValue(coordinate.first, style));
- currentCoordinate->append(percentageOrZoomAdjustedValue(coordinate.second, style));
+ if (coordinates.isEmpty())
+ return cssValuePool().createIdentifierValue(CSSValueNone);
- snapCoordinatesValue->append(currentCoordinate.releaseNonNull());
+ auto list = CSSValueList::createCommaSeparated();
+
+ for (auto& coordinate : coordinates) {
+ auto pair = CSSValueList::createSpaceSeparated();
+ pair.get().append(percentageOrZoomAdjustedValue(coordinate.width(), &style));
+ pair.get().append(percentageOrZoomAdjustedValue(coordinate.height(), &style));
+ list.get().append(WTF::move(pair));
}
- return snapCoordinatesValue.releaseNonNull();
+
+ return WTF::move(list);
}
+
#endif
static PassRef<CSSValueList> getDelayValue(const AnimationList* animList)
@@ -1268,13 +1274,13 @@
PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() const
{
if (!m_node)
- return 0;
+ return nullptr;
m_node->document().updateLayoutIgnorePendingStylesheets();
RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
if (!style)
- return 0;
+ return nullptr;
if (int keywordSize = style->fontDescription().keywordSize())
return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
@@ -1464,7 +1470,7 @@
{
const CounterDirectiveMap* map = style->counterDirectives();
if (!map)
- return 0;
+ return nullptr;
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
@@ -1622,7 +1628,7 @@
Node* ComputedStyleExtractor::styledNode() const
{
if (!m_node)
- return 0;
+ return nullptr;
if (!m_node->isElementNode())
return m_node.get();
Element* element = toElement(m_node.get());
@@ -1690,10 +1696,10 @@
{
Node* styledNode = this->styledNode();
if (!styledNode)
- return 0;
+ return nullptr;
RefPtr<RenderStyle> style;
- RenderObject* renderer = 0;
+ RenderObject* renderer = nullptr;
bool forceFullLayout = false;
if (updateLayout) {
Document& document = styledNode->document();
@@ -1728,7 +1734,7 @@
}
if (!style)
- return 0;
+ return nullptr;
propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
@@ -2324,7 +2330,7 @@
EPageBreak pageBreak = style->pageBreakInside();
ASSERT(pageBreak != PBALWAYS);
if (pageBreak == PBALWAYS)
- return 0;
+ return nullptr;
return cssValuePool().createValue(style->pageBreakInside());
}
case CSSPropertyPosition:
@@ -2458,7 +2464,7 @@
return cssValuePool().createValue(style->verticalAlignLength());
}
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
case CSSPropertyVisibility:
return cssValuePool().createValue(style->visibility());
case CSSPropertyWhiteSpace:
@@ -2528,7 +2534,7 @@
return cssValuePool().createIdentifierValue(CSSValueNone);
RefPtr<DashboardRegion> firstRegion;
- DashboardRegion* previousRegion = 0;
+ DashboardRegion* previousRegion = nullptr;
for (unsigned i = 0; i < count; i++) {
RefPtr<DashboardRegion> region = DashboardRegion::create();
StyleDashboardRegion styleRegion = regions[i];
@@ -2898,11 +2904,10 @@
return getBackgroundShorthandValue();
case CSSPropertyBorder: {
RefPtr<CSSValue> value = propertyValue(CSSPropertyBorderTop, DoNotUpdateLayout);
- const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
- CSSPropertyBorderLeft };
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
- if (!compareCSSValuePtr<CSSValue>(value, propertyValue(properties[i], DoNotUpdateLayout)))
- return 0;
+ const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft };
+ for (auto& property : properties) {
+ if (!compareCSSValuePtr<CSSValue>(value, propertyValue(property, DoNotUpdateLayout)))
+ return nullptr;
}
return value.release();
}
@@ -2936,6 +2941,20 @@
return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
case CSSPropertyPadding:
return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
+
+#if ENABLE(CSS_SCROLL_SNAP)
+ case CSSPropertyWebkitScrollSnapType:
+ return cssValuePool().createValue(style->scrollSnapType());
+ case CSSPropertyWebkitScrollSnapDestination:
+ return scrollSnapDestination(*style, style->scrollSnapDestination());
+ case CSSPropertyWebkitScrollSnapPointsX:
+ return scrollSnapPoints(*style, style->scrollSnapPointsX());
+ case CSSPropertyWebkitScrollSnapPointsY:
+ return scrollSnapPoints(*style, style->scrollSnapPointsY());
+ case CSSPropertyWebkitScrollSnapCoordinate:
+ return scrollSnapCoordinates(*style, style->scrollSnapCoordinates());
+#endif
+
/* Individual properties not part of the spec */
case CSSPropertyBackgroundRepeatX:
case CSSPropertyBackgroundRepeatY:
@@ -3093,38 +3112,18 @@
case CSSPropertyWritingMode:
case CSSPropertyWebkitSvgShadow:
return svgPropertyValue(propertyID, DoNotUpdateLayout);
-
-#if ENABLE(CSS_SCROLL_SNAP)
- case CSSPropertyWebkitScrollSnapType:
- return cssValuePool().createValue(style->scrollSnapType());
- case CSSPropertyWebkitScrollSnapDestination:
- return scrollSnapDestination(style.get(), style->scrollSnapDestinationX(), style->scrollSnapDestinationY());
- case CSSPropertyWebkitScrollSnapPointsX:
- if (style->scrollSnapUsesElementsX())
- return cssValuePool().createValue("elements", CSSPrimitiveValue::CSS_STRING);
- return scrollSnapPoints(style.get(), style->scrollSnapOffsetsX(), style->scrollSnapRepeatOffsetX(), style->scrollSnapHasRepeatX());
- case CSSPropertyWebkitScrollSnapPointsY:
- if (style->scrollSnapUsesElementsY())
- return cssValuePool().createValue("elements", CSSPrimitiveValue::CSS_STRING);
- return scrollSnapPoints(style.get(), style->scrollSnapOffsetsY(), style->scrollSnapRepeatOffsetY(), style->scrollSnapHasRepeatY());
- case CSSPropertyWebkitScrollSnapCoordinate:
- Vector<SnapCoordinate> coords = style->scrollSnapCoordinates();
- if (!coords.size())
- return cssValuePool().createValue("none", CSSPrimitiveValue::CSS_STRING);
- return scrollSnapCoordinates(style.get(), coords);
-#endif
}
logUnimplementedPropertyID(propertyID);
- return 0;
+ return nullptr;
}
String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
{
RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
- if (value)
- return value->cssText();
- return "";
+ if (!value)
+ return emptyString(); // FIXME: Should this be null instead, as it is in StyleProperties::getPropertyValue?
+ return value->cssText();
}
unsigned CSSComputedStyleDeclaration::length() const
@@ -3143,7 +3142,7 @@
String CSSComputedStyleDeclaration::item(unsigned i) const
{
if (i >= length())
- return "";
+ return emptyString();
return getPropertyNameString(computedProperties[i]);
}
@@ -3190,7 +3189,7 @@
// All 4 properties must be specified.
if (!topValue || !rightValue || !bottomValue || !leftValue)
- return 0;
+ return nullptr;
bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
@@ -3231,16 +3230,16 @@
CSSRule* CSSComputedStyleDeclaration::parentRule() const
{
- return 0;
+ return nullptr;
}
PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
{
CSSPropertyID propertyID = cssPropertyID(propertyName);
if (!propertyID)
- return 0;
+ return nullptr;
RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
- return value ? value->cloneForCSSOM() : 0;
+ return value ? value->cloneForCSSOM() : nullptr;
}
String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
@@ -3254,12 +3253,12 @@
String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
{
// All computed styles have a priority of not "important".
- return "";
+ return emptyString(); // FIXME: Should this sometimes be null instead of empty, to match a normal style declaration?
}
String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
{
- return "";
+ return emptyString(); // FIXME: Should this sometimes be null instead of empty, to match a normal style declaration?
}
bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (173658 => 173659)
--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp 2014-09-16 15:58:12 UTC (rev 173659)
@@ -1348,26 +1348,26 @@
if (!value->isPrimitiveValue())
return;
- CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
- if (primitiveValue->getValueID()) {
- switch (primitiveValue->getValueID()) {
- case CSSValueSmall:
- styleResolver->style()->setMarqueeIncrement(Length(1, Fixed)); // 1px.
- break;
- case CSSValueNormal:
- styleResolver->style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default.
- break;
- case CSSValueLarge:
- styleResolver->style()->setMarqueeIncrement(Length(36, Fixed)); // 36px.
- break;
- default:
- break;
- }
- } else {
- Length marqueeLength = styleResolver->convertToIntLength(primitiveValue, styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
- if (!marqueeLength.isUndefined())
- styleResolver->style()->setMarqueeIncrement(marqueeLength);
+ CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*value);
+ Length marqueeLength(Undefined);
+ switch (primitiveValue.getValueID()) {
+ case CSSValueSmall:
+ marqueeLength = Length(1, Fixed); // 1px.
+ break;
+ case CSSValueNormal:
+ marqueeLength = Length(6, Fixed); // 6px. The WinIE default.
+ break;
+ case CSSValueLarge:
+ marqueeLength = Length(36, Fixed); // 36px.
+ break;
+ case CSSValueInvalid:
+ marqueeLength = primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
+ break;
+ default:
+ break;
}
+ if (!marqueeLength.isUndefined())
+ styleResolver->style()->setMarqueeIncrement(marqueeLength);
}
static PropertyHandler createHandler()
{
Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp (173658 => 173659)
--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2014-09-16 15:58:12 UTC (rev 173659)
@@ -168,7 +168,7 @@
return cloneAndCacheForCSSOM(m_propertySet->getPropertyCSSValue(propertyID).get());
}
-String PropertySetCSSStyleDeclaration::getPropertyValue(const String &propertyName)
+String PropertySetCSSStyleDeclaration::getPropertyValue(const String& propertyName)
{
CSSPropertyID propertyID = cssPropertyID(propertyName);
if (!propertyID)
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (173658 => 173659)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2014-09-16 15:58:12 UTC (rev 173659)
@@ -1,8 +1,8 @@
/*
* Copyright (C) 1999 Lars Knoll ([email protected])
- * (C) 2004-2005 Allan Sandfeld Jensen ([email protected])
+ * Copyright (C) 2004-2005 Allan Sandfeld Jensen ([email protected])
* Copyright (C) 2006, 2007 Nicholas Shanks ([email protected])
- * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2014 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alexey Proskuryakov <[email protected]>
* Copyright (C) 2007, 2008 Eric Seidel <[email protected]>
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
@@ -121,6 +121,7 @@
#include "StylePropertyShorthand.h"
#include "StyleRule.h"
#include "StyleRuleImport.h"
+#include "StyleScrollSnapPoints.h"
#include "StyleSheetContents.h"
#include "StyleSheetList.h"
#include "Text.h"
@@ -1466,14 +1467,13 @@
}
// -------------------------------------------------------------------------------------
-// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
-Length StyleResolver::convertToIntLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData)
+static Length convertToIntLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData)
{
return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(conversionData) : Length(Undefined);
}
-Length StyleResolver::convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData)
+static Length convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData)
{
return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion>(conversionData) : Length(Undefined);
}
@@ -2047,6 +2047,50 @@
}
#endif /* ENABLE(CSS_GRID_LAYOUT) */
+#if ENABLE(CSS_SCROLL_SNAP)
+
+Length StyleResolver::parseSnapCoordinate(CSSPrimitiveValue& value)
+{
+ return value.convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(m_state.cssToLengthConversionData());
+}
+
+Length StyleResolver::parseSnapCoordinate(CSSValueList& valueList, unsigned offset)
+{
+ return parseSnapCoordinate(toCSSPrimitiveValue(*valueList.item(offset)));
+}
+
+LengthSize StyleResolver::parseSnapCoordinatePair(CSSValueList& valueList, unsigned offset)
+{
+ return LengthSize(parseSnapCoordinate(valueList, offset), parseSnapCoordinate(valueList, offset + 1));
+}
+
+ScrollSnapPoints StyleResolver::parseSnapPoints(CSSValue& value)
+{
+ ScrollSnapPoints points;
+
+ if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == CSSValueElements) {
+ points.usesElements = true;
+ return points;
+ }
+
+ points.hasRepeat = false;
+ for (CSSValueListIterator it(&value); it.hasMore(); it.advance()) {
+ auto& itemValue = toCSSPrimitiveValue(*it.value());
+ if (auto* lengthRepeat = itemValue.getLengthRepeatValue()) {
+ if (auto* interval = lengthRepeat->interval()) {
+ points.repeatOffset = parseSnapCoordinate(*interval);
+ points.hasRepeat = true;
+ break;
+ }
+ }
+ points.offsets.append(parseSnapCoordinate(itemValue));
+ }
+
+ return points;
+}
+
+#endif
+
void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
{
ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wasn't expanded at parsing time", id);
@@ -2782,8 +2826,8 @@
return;
}
- if (value->isPrimitiveValue()) {
- ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
+ if (primitiveValue) {
+ ASSERT(primitiveValue->getValueID() == CSSValueNone);
return;
}
@@ -2839,97 +2883,48 @@
return;
}
#endif /* ENABLE(CSS_GRID_LAYOUT) */
- case CSSPropertyWebkitJustifySelf: {
+
+ case CSSPropertyWebkitJustifySelf:
HANDLE_INHERIT_AND_INITIAL(justifySelf, JustifySelf);
- CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (Pair* pairValue = primitiveValue->getPairValue()) {
state.style()->setJustifySelf(*pairValue->first());
state.style()->setJustifySelfOverflowAlignment(*pairValue->second());
} else
state.style()->setJustifySelf(*primitiveValue);
return;
- }
#if ENABLE(CSS_SCROLL_SNAP)
- case CSSPropertyWebkitScrollSnapType: {
+ case CSSPropertyWebkitScrollSnapType:
+ HANDLE_INHERIT_AND_INITIAL(scrollSnapType, ScrollSnapType);
state.style()->setScrollSnapType(*primitiveValue);
return;
- }
case CSSPropertyWebkitScrollSnapPointsX:
- case CSSPropertyWebkitScrollSnapPointsY: {
- RenderStyle* renderStyle = state.style();
- if (id == CSSPropertyWebkitScrollSnapPointsX)
- renderStyle->setScrollSnapHasRepeatX(false);
- else
- renderStyle->setScrollSnapHasRepeatY(false);
-
- if (primitiveValue && primitiveValue->getValueID() == CSSValueElements) {
- if (id == CSSPropertyWebkitScrollSnapPointsX)
- renderStyle->setScrollSnapUsesElementsX(true);
- else
- renderStyle->setScrollSnapUsesElementsY(true);
- return;
- }
- if (id == CSSPropertyWebkitScrollSnapPointsX)
- renderStyle->setScrollSnapUsesElementsX(false);
- else
- renderStyle->setScrollSnapUsesElementsY(false);
-
- Vector<Length> offsets;
- for (CSSValueListIterator it(value); it.hasMore(); it.advance()) {
- RefPtr<CSSValue> rawItemValue = it.value();
- CSSPrimitiveValue* primitiveItemValue = toCSSPrimitiveValue(rawItemValue.get());
- if (primitiveItemValue->isLengthRepeat()) {
- LengthRepeat* lengthRepeat = primitiveItemValue->getLengthRepeatValue();
- if (lengthRepeat && lengthRepeat->interval()) {
- if (id == CSSPropertyWebkitScrollSnapPointsX) {
- renderStyle->setScrollSnapRepeatOffsetX(lengthRepeat->interval()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData()));
- renderStyle->setScrollSnapHasRepeatX(true);
- } else {
- renderStyle->setScrollSnapRepeatOffsetY(lengthRepeat->interval()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData()));
- renderStyle->setScrollSnapHasRepeatY(true);
- }
- break;
- }
- } else
- offsets.append(primitiveItemValue->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData()));
- }
- if (id == CSSPropertyWebkitScrollSnapPointsX)
- renderStyle->setScrollSnapOffsetsX(offsets);
- else
- renderStyle->setScrollSnapOffsetsY(offsets);
+ HANDLE_INHERIT_AND_INITIAL(scrollSnapPointsX, ScrollSnapPointsX);
+ state.style()->setScrollSnapPointsX(parseSnapPoints(*value));
return;
- }
+ case CSSPropertyWebkitScrollSnapPointsY:
+ HANDLE_INHERIT_AND_INITIAL(scrollSnapPointsY, ScrollSnapPointsY);
+ state.style()->setScrollSnapPointsY(parseSnapPoints(*value));
+ break;
case CSSPropertyWebkitScrollSnapDestination: {
- CSSValueList& position = toCSSValueList(*value);
- RefPtr<CSSValue> xCoordinate = position.item(0);
- RefPtr<CSSPrimitiveValue> xCoordinateValue = toCSSPrimitiveValue(xCoordinate.get());
- state.style()->setScrollSnapDestinationX(xCoordinateValue->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData()));
-
- RefPtr<CSSValue> yCoordinate = position.item(1);
- RefPtr<CSSPrimitiveValue> yCoordinateValue = toCSSPrimitiveValue(yCoordinate.get());
- state.style()->setScrollSnapDestinationY(yCoordinateValue->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData()));
+ HANDLE_INHERIT_AND_INITIAL(scrollSnapDestination, ScrollSnapDestination)
+ state.style()->setScrollSnapDestination(parseSnapCoordinatePair(toCSSValueList(*value), 0));
return;
}
case CSSPropertyWebkitScrollSnapCoordinate: {
- Vector<SnapCoordinate> coordinates;
+ HANDLE_INHERIT_AND_INITIAL(scrollSnapCoordinates, ScrollSnapCoordinates)
CSSValueList& valueList = toCSSValueList(*value);
- size_t pointCount = valueList.length();
- // Every x must be followed by a y.
- if (pointCount % 2)
- return;
- pointCount /= 2;
- coordinates.reserveCapacity(pointCount);
- for (size_t i = 0; i < pointCount; i++) {
- RefPtr<CSSValue> xCoordinate = valueList.item(i * 2);
- RefPtr<CSSValue> yCoordinate = valueList.item((i * 2) + 1);
- RefPtr<CSSPrimitiveValue> xCoordinateValue = toCSSPrimitiveValue(xCoordinate.get());
- RefPtr<CSSPrimitiveValue> yCoordinateValue = toCSSPrimitiveValue(yCoordinate.get());
- coordinates.append(SnapCoordinate(xCoordinateValue->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData()), yCoordinateValue->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData())));
- }
- state.style()->setScrollSnapCoordinates(coordinates);
+ ASSERT(!(valueList.length() % 2));
+ size_t pointCount = valueList.length() / 2;
+ Vector<LengthSize> coordinates;
+ coordinates.reserveInitialCapacity(pointCount);
+ for (size_t i = 0; i < pointCount; i++)
+ coordinates.append(parseSnapCoordinatePair(valueList, i * 2));
+ state.style()->setScrollSnapCoordinates(WTF::move(coordinates));
return;
}
+#endif
+
case CSSPropertyWebkitInitialLetter: {
HANDLE_INHERIT_AND_INITIAL(initialLetter, InitialLetter)
if (!value->isPrimitiveValue())
@@ -2940,7 +2935,6 @@
return;
}
- CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
if (!pair || !pair->first() || !pair->second())
return;
@@ -2949,7 +2943,6 @@
return;
}
-#endif
// These properties are aliased and DeprecatedStyleBuilder already applied the property on the prefixed version.
case CSSPropertyTransitionDelay:
case CSSPropertyTransitionDuration:
Modified: trunk/Source/WebCore/css/StyleResolver.h (173658 => 173659)
--- trunk/Source/WebCore/css/StyleResolver.h 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/css/StyleResolver.h 2014-09-16 15:58:12 UTC (rev 173659)
@@ -458,9 +458,6 @@
bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToRegularStyle(); }
bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle(); }
- static Length convertToIntLength(const CSSPrimitiveValue*, const CSSToLengthConversionData&);
- static Length convertToFloatLength(const CSSPrimitiveValue*, const CSSToLengthConversionData&);
-
CSSToStyleMap* styleMap() { return &m_styleMap; }
InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWrappers; }
const FontDescription& fontDescription() { return m_state.fontDescription(); }
@@ -476,7 +473,6 @@
void cacheBorderAndBackground();
-private:
bool canShareStyleWithControl(StyledElement*) const;
void applyProperty(CSSPropertyID, CSSValue*);
@@ -507,6 +503,10 @@
bool classNamesAffectedByRules(const SpaceSplitString&) const;
bool sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement*) const;
+ Length parseSnapCoordinate(CSSPrimitiveValue&);
+ Length parseSnapCoordinate(CSSValueList&, unsigned offset);
+ LengthSize parseSnapCoordinatePair(CSSValueList&, unsigned offset);
+ ScrollSnapPoints parseSnapPoints(CSSValue&);
unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep;
Modified: trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp (173658 => 173659)
--- trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp 2014-09-16 15:58:12 UTC (rev 173659)
@@ -30,6 +30,7 @@
#include "HTMLElement.h"
#include "RenderBox.h"
#include "ScrollableArea.h"
+#include "StyleScrollSnapPoints.h"
#if ENABLE(CSS_SCROLL_SNAP)
@@ -53,12 +54,12 @@
float left = position.x();
float top = position.y();
#endif
- for (SnapCoordinate coordinate : box->style().scrollSnapCoordinates()) {
- LayoutUnit lastPotentialSnapPositionX = LayoutUnit(left) + valueForLength(coordinate.first, viewWidth);
+ for (auto& coordinate : box->style().scrollSnapCoordinates()) {
+ LayoutUnit lastPotentialSnapPositionX = LayoutUnit(left) + valueForLength(coordinate.width(), viewWidth);
if (shouldAddHorizontalChildOffsets && lastPotentialSnapPositionX > 0)
horizontalSnapOffsetSubsequence.append(lastPotentialSnapPositionX);
- LayoutUnit lastPotentialSnapPositionY = LayoutUnit(top) + valueForLength(coordinate.second, viewHeight);
+ LayoutUnit lastPotentialSnapPositionY = LayoutUnit(top) + valueForLength(coordinate.height(), viewHeight);
if (shouldAddVerticalChildOffsets && lastPotentialSnapPositionY > 0)
verticalSnapOffsetSubsequence.append(lastPotentialSnapPositionY);
}
@@ -67,22 +68,24 @@
}
}
-static void updateFromStyle(Vector<LayoutUnit>* snapOffsets, const RenderStyle& style, ScrollEventAxis axis, LayoutUnit viewSize, LayoutUnit scrollSize, Vector<LayoutUnit>& snapOffsetSubsequence)
+static void updateFromStyle(Vector<LayoutUnit>& snapOffsets, const RenderStyle& style, ScrollEventAxis axis, LayoutUnit viewSize, LayoutUnit scrollSize, Vector<LayoutUnit>& snapOffsetSubsequence)
{
std::sort(snapOffsetSubsequence.begin(), snapOffsetSubsequence.end());
if (!snapOffsetSubsequence.size())
snapOffsetSubsequence.append(0);
bool isHorizontalAxis = axis == ScrollEventAxis::Horizontal;
- bool hasRepeat = isHorizontalAxis ? style.scrollSnapHasRepeatX() : style.scrollSnapHasRepeatY();
- LayoutUnit repeatOffset = valueForLength(isHorizontalAxis ? style.scrollSnapRepeatOffsetX() : style.scrollSnapRepeatOffsetY(), viewSize);
- LayoutUnit destinationOffset = valueForLength(isHorizontalAxis ? style.scrollSnapDestinationX() : style.scrollSnapDestinationY(), viewSize);
+ auto& points = isHorizontalAxis ? style.scrollSnapPointsX() : style.scrollSnapPointsY();
+ auto& destination = style.scrollSnapDestination();
+ bool hasRepeat = points.hasRepeat;
+ LayoutUnit repeatOffset = valueForLength(points.repeatOffset, viewSize);
+ LayoutUnit destinationOffset = valueForLength(isHorizontalAxis ? destination.width() : destination.height(), viewSize);
LayoutUnit curSnapPositionShift = 0;
LayoutUnit maxScrollOffset = scrollSize - viewSize;
LayoutUnit lastSnapPosition = curSnapPositionShift;
- snapOffsets->append(0);
+ snapOffsets.append(0);
do {
- for (LayoutUnit snapPosition : snapOffsetSubsequence) {
+ for (auto& snapPosition : snapOffsetSubsequence) {
LayoutUnit potentialSnapPosition = curSnapPositionShift + snapPosition - destinationOffset;
if (potentialSnapPosition <= 0)
continue;
@@ -90,15 +93,15 @@
if (potentialSnapPosition >= maxScrollOffset)
break;
- snapOffsets->append(potentialSnapPosition);
+ snapOffsets.append(potentialSnapPosition);
lastSnapPosition = potentialSnapPosition + destinationOffset;
}
curSnapPositionShift = lastSnapPosition + repeatOffset;
} while (hasRepeat && curSnapPositionShift < maxScrollOffset);
// Always put a snap point on the maximum scroll offset.
// Not a part of the spec, but necessary to prevent unreachable content when snapping.
- if (snapOffsets->last() != maxScrollOffset)
- snapOffsets->append(maxScrollOffset);
+ if (snapOffsets.last() != maxScrollOffset)
+ snapOffsets.append(maxScrollOffset);
}
void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, HTMLElement& scrollingElement, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle)
@@ -108,15 +111,16 @@
scrollableArea.clearVerticalSnapOffsets();
return;
}
+
LayoutUnit viewWidth = scrollingElementBox.width();
LayoutUnit viewHeight = scrollingElementBox.height();
LayoutUnit scrollWidth = scrollingElementBox.scrollWidth();
LayoutUnit scrollHeight = scrollingElementBox.scrollHeight();
bool canComputeHorizontalOffsets = scrollWidth > 0 && viewWidth > 0 && viewWidth < scrollWidth;
bool canComputeVerticalOffsets = scrollHeight > 0 && viewHeight > 0 && viewHeight < scrollHeight;
+
if (!canComputeHorizontalOffsets)
scrollableArea.clearHorizontalSnapOffsets();
-
if (!canComputeVerticalOffsets)
scrollableArea.clearVerticalSnapOffsets();
@@ -125,30 +129,31 @@
Vector<LayoutUnit> horizontalSnapOffsetSubsequence;
Vector<LayoutUnit> verticalSnapOffsetSubsequence;
- if (scrollingElementStyle.scrollSnapUsesElementsX() || scrollingElementStyle.scrollSnapUsesElementsY()) {
- bool shouldAddHorizontalChildOffsets = scrollingElementStyle.scrollSnapUsesElementsX() && canComputeHorizontalOffsets;
- bool shouldAddVerticalChildOffsets = scrollingElementStyle.scrollSnapUsesElementsY() && canComputeVerticalOffsets;
+
+ if (scrollingElementStyle.scrollSnapPointsX().usesElements || scrollingElementStyle.scrollSnapPointsY().usesElements) {
+ bool shouldAddHorizontalChildOffsets = scrollingElementStyle.scrollSnapPointsX().usesElements && canComputeHorizontalOffsets;
+ bool shouldAddVerticalChildOffsets = scrollingElementStyle.scrollSnapPointsY().usesElements && canComputeVerticalOffsets;
appendChildSnapOffsets(scrollingElement, shouldAddHorizontalChildOffsets, horizontalSnapOffsetSubsequence, shouldAddVerticalChildOffsets, verticalSnapOffsetSubsequence);
}
- if (!scrollingElementStyle.scrollSnapUsesElementsX() && canComputeHorizontalOffsets) {
- for (Length snapLength : scrollingElementStyle.scrollSnapOffsetsX())
+ if (!scrollingElementStyle.scrollSnapPointsX().usesElements && canComputeHorizontalOffsets) {
+ for (auto& snapLength : scrollingElementStyle.scrollSnapPointsX().offsets)
horizontalSnapOffsetSubsequence.append(valueForLength(snapLength, viewWidth));
}
- if (!scrollingElementStyle.scrollSnapUsesElementsY() && canComputeVerticalOffsets) {
- for (Length snapLength : scrollingElementStyle.scrollSnapOffsetsY())
+ if (!scrollingElementStyle.scrollSnapPointsY().usesElements && canComputeVerticalOffsets) {
+ for (auto& snapLength : scrollingElementStyle.scrollSnapPointsY().offsets)
verticalSnapOffsetSubsequence.append(valueForLength(snapLength, viewHeight));
}
- std::unique_ptr<Vector<LayoutUnit>> horizontalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
- std::unique_ptr<Vector<LayoutUnit>> verticalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
if (canComputeHorizontalOffsets) {
- updateFromStyle(horizontalSnapOffsets.get(), scrollingElementStyle, ScrollEventAxis::Horizontal, viewWidth, scrollWidth, horizontalSnapOffsetSubsequence);
+ auto horizontalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
+ updateFromStyle(*horizontalSnapOffsets, scrollingElementStyle, ScrollEventAxis::Horizontal, viewWidth, scrollWidth, horizontalSnapOffsetSubsequence);
scrollableArea.setHorizontalSnapOffsets(WTF::move(horizontalSnapOffsets));
}
if (canComputeVerticalOffsets) {
- updateFromStyle(verticalSnapOffsets.get(), scrollingElementStyle, ScrollEventAxis::Vertical, viewHeight, scrollHeight, verticalSnapOffsetSubsequence);
+ auto verticalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
+ updateFromStyle(*verticalSnapOffsets, scrollingElementStyle, ScrollEventAxis::Vertical, viewHeight, scrollHeight, verticalSnapOffsetSubsequence);
scrollableArea.setVerticalSnapOffsets(WTF::move(verticalSnapOffsets));
}
}
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (173658 => 173659)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2014-09-16 15:58:12 UTC (rev 173659)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999 Antti Koivisto ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2014 Apple Inc. All rights reserved.
* Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -38,9 +38,7 @@
#include "StyleImage.h"
#include "StyleInheritedData.h"
#include "StyleResolver.h"
-#if ENABLE(TOUCH_EVENTS)
-#include "RenderTheme.h"
-#endif
+#include "StyleScrollSnapPoints.h"
#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
#include <algorithm>
@@ -53,6 +51,10 @@
#include "TextAutosizer.h"
#endif
+#if ENABLE(TOUCH_EVENTS)
+#include "RenderTheme.h"
+#endif
+
namespace WebCore {
struct SameSizeAsBorderValue {
@@ -1826,4 +1828,76 @@
}
}
+#if ENABLE(CSS_SCROLL_SNAP)
+
+ScrollSnapPoints RenderStyle::initialScrollSnapPointsX()
+{
+ return ScrollSnapPoints();
+}
+
+ScrollSnapPoints RenderStyle::initialScrollSnapPointsY()
+{
+ return ScrollSnapPoints();
+}
+
+LengthSize RenderStyle::initialScrollSnapDestination()
+{
+ return defaultScrollSnapDestination();
+}
+
+Vector<LengthSize> RenderStyle::initialScrollSnapCoordinates()
+{
+ return Vector<LengthSize>();
+}
+
+const ScrollSnapPoints& RenderStyle::scrollSnapPointsX() const
+{
+ return rareNonInheritedData->m_scrollSnapPoints->xPoints;
+}
+
+const ScrollSnapPoints& RenderStyle::scrollSnapPointsY() const
+{
+ return rareNonInheritedData->m_scrollSnapPoints->yPoints;
+}
+
+const LengthSize& RenderStyle::scrollSnapDestination() const
+{
+ return rareNonInheritedData->m_scrollSnapPoints->destination;
+}
+
+const Vector<LengthSize>& RenderStyle::scrollSnapCoordinates() const
+{
+ return rareNonInheritedData->m_scrollSnapPoints->coordinates;
+}
+
+void RenderStyle::setScrollSnapPointsX(ScrollSnapPoints points)
+{
+ if (rareNonInheritedData->m_scrollSnapPoints->xPoints == points)
+ return;
+ rareNonInheritedData.access()->m_scrollSnapPoints.access()->xPoints = WTF::move(points);
+}
+
+void RenderStyle::setScrollSnapPointsY(ScrollSnapPoints points)
+{
+ if (rareNonInheritedData->m_scrollSnapPoints->yPoints == points)
+ return;
+ rareNonInheritedData.access()->m_scrollSnapPoints.access()->yPoints = WTF::move(points);
+}
+
+void RenderStyle::setScrollSnapDestination(LengthSize destination)
+{
+ if (rareNonInheritedData->m_scrollSnapPoints->destination == destination)
+ return;
+ rareNonInheritedData.access()->m_scrollSnapPoints.access()->destination = WTF::move(destination);
+}
+
+void RenderStyle::setScrollSnapCoordinates(Vector<LengthSize> coordinates)
+{
+ if (rareNonInheritedData->m_scrollSnapPoints->coordinates == coordinates)
+ return;
+ rareNonInheritedData.access()->m_scrollSnapPoints.access()->coordinates = WTF::move(coordinates);
+}
+
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (173658 => 173659)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2014-09-16 15:58:12 UTC (rev 173659)
@@ -2,7 +2,7 @@
* Copyright (C) 2000 Lars Knoll ([email protected])
* (C) 2000 Antti Koivisto ([email protected])
* (C) 2000 Dirk Mueller ([email protected])
- * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2014 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis ([email protected])
*
* This library is free software; you can redistribute it and/or
@@ -84,10 +84,6 @@
#include "StyleDashboardRegion.h"
#endif
-#if ENABLE(CSS_SCROLL_SNAP)
-#include "StyleScrollSnapPoints.h"
-#endif
-
#if ENABLE(IOS_TEXT_AUTOSIZING)
#include "TextSizeAdjustment.h"
#endif
@@ -104,10 +100,11 @@
namespace WebCore {
-class FilterOperations;
class BorderData;
+class ContentData;
class CounterContent;
class CursorList;
+class FilterOperations;
class Font;
class FontMetrics;
class IntRect;
@@ -118,7 +115,7 @@
class StyleResolver;
class TransformationMatrix;
-class ContentData;
+struct ScrollSnapPoints;
typedef Vector<RefPtr<RenderStyle>, 4> PseudoStyleCache;
@@ -1080,30 +1077,28 @@
#if ENABLE(CSS_SCROLL_SNAP)
ScrollSnapType scrollSnapType() const { return static_cast<ScrollSnapType>(rareNonInheritedData->m_scrollSnapType); }
- Vector<Length> scrollSnapOffsetsX() const { return rareNonInheritedData->m_scrollSnapPoints->offsetsX; }
- Vector<Length> scrollSnapOffsetsY() const { return rareNonInheritedData->m_scrollSnapPoints->offsetsY; }
- Length scrollSnapRepeatOffsetX() const { return rareNonInheritedData->m_scrollSnapPoints->repeatOffsetX; }
- Length scrollSnapRepeatOffsetY() const { return rareNonInheritedData->m_scrollSnapPoints->repeatOffsetY; }
- bool scrollSnapHasRepeatX() const { return rareNonInheritedData->m_scrollSnapPoints->hasRepeatX; }
- bool scrollSnapHasRepeatY() const { return rareNonInheritedData->m_scrollSnapPoints->hasRepeatY; }
- Length scrollSnapDestinationX() const { return rareNonInheritedData->m_scrollSnapPoints->destinationX; }
- Length scrollSnapDestinationY() const { return rareNonInheritedData->m_scrollSnapPoints->destinationY; }
- Vector<SnapCoordinate> scrollSnapCoordinates() const { return rareNonInheritedData->m_scrollSnapPoints->coordinates; }
- bool scrollSnapUsesElementsX() const { return rareNonInheritedData->m_scrollSnapPoints->usesElementsX; }
- bool scrollSnapUsesElementsY() const { return rareNonInheritedData->m_scrollSnapPoints->usesElementsY; }
+ const ScrollSnapPoints& scrollSnapPointsX() const;
+ const ScrollSnapPoints& scrollSnapPointsY() const;
+ const LengthSize& scrollSnapDestination() const;
+ const Vector<LengthSize>& scrollSnapCoordinates() const;
#endif
+
#if ENABLE(TOUCH_EVENTS)
Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
#endif
+
#if PLATFORM(IOS)
bool touchCalloutEnabled() const { return rareInheritedData->touchCalloutEnabled; }
#endif
+
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
bool useTouchOverflowScrolling() const { return rareInheritedData->useTouchOverflowScrolling; }
#endif
+
#if ENABLE(IOS_TEXT_AUTOSIZING)
TextSizeAdjustment textSizeAdjust() const { return rareInheritedData->textSizeAdjust; }
#endif
+
ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
WritingMode writingMode() const { return static_cast<WritingMode>(inherited_flags.m_writingMode); }
@@ -1319,7 +1314,7 @@
#if ENABLE(CSS3_TEXT)
void setTextAlignLast(TextAlignLast v) { SET_VAR(rareInheritedData, m_textAlignLast, v); }
void setTextJustify(TextJustify v) { SET_VAR(rareInheritedData, m_textJustify, v); }
-#endif // CSS3_TEXT
+#endif
void setTextDecorationStyle(TextDecorationStyle v) { SET_VAR(rareNonInheritedData, m_textDecorationStyle, v); }
void setTextDecorationSkip(TextDecorationSkip skip) { SET_VAR(rareInheritedData, m_textDecorationSkip, skip); }
void setTextUnderlinePosition(TextUnderlinePosition v) { SET_VAR(rareInheritedData, m_textUnderlinePosition, v); }
@@ -1605,32 +1600,29 @@
void setInitialLetter(const IntSize& size) { SET_VAR(rareNonInheritedData, m_initialLetter, size); }
#if ENABLE(CSS_SCROLL_SNAP)
- void setScrollSnapType(ScrollSnapType type) { SET_VAR(rareNonInheritedData, m_scrollSnapType, type); }
- void setScrollSnapOffsetsX(Vector<Length>& offsets) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, offsetsX, offsets); }
- void setScrollSnapOffsetsY(Vector<Length>& offsets) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, offsetsY, offsets); }
- void setScrollSnapRepeatOffsetX(Length repeatOffset) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, repeatOffsetX, repeatOffset); }
- void setScrollSnapRepeatOffsetY(Length repeatOffset) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, repeatOffsetY, repeatOffset); }
- void setScrollSnapHasRepeatX(bool hasRepeat) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, hasRepeatX, hasRepeat); }
- void setScrollSnapHasRepeatY(bool hasRepeat) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, hasRepeatY, hasRepeat); }
- void setScrollSnapDestinationX(Length destination) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, destinationX, destination); }
- void setScrollSnapDestinationY(Length destination) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, destinationY, destination); }
- void setScrollSnapCoordinates(Vector<SnapCoordinate>& coordinates) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, coordinates, coordinates); }
- void setScrollSnapUsesElementsX(bool usesElements) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, usesElementsX, usesElements); }
- void setScrollSnapUsesElementsY(bool usesElements) { SET_VAR(rareNonInheritedData.access()->m_scrollSnapPoints, usesElementsY, usesElements); }
+ void setScrollSnapType(ScrollSnapType type) { SET_VAR(rareNonInheritedData, m_scrollSnapType, static_cast<unsigned>(type)); }
+ void setScrollSnapPointsX(ScrollSnapPoints);
+ void setScrollSnapPointsY(ScrollSnapPoints);
+ void setScrollSnapDestination(LengthSize);
+ void setScrollSnapCoordinates(Vector<LengthSize>);
#endif
#if ENABLE(TOUCH_EVENTS)
void setTapHighlightColor(const Color& c) { SET_VAR(rareInheritedData, tapHighlightColor, c); }
#endif
+
#if PLATFORM(IOS)
void setTouchCalloutEnabled(bool v) { SET_VAR(rareInheritedData, touchCalloutEnabled, v); }
#endif
+
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
void setUseTouchOverflowScrolling(bool v) { SET_VAR(rareInheritedData, useTouchOverflowScrolling, v); }
#endif
+
#if ENABLE(IOS_TEXT_AUTOSIZING)
void setTextSizeAdjust(TextSizeAdjustment anAdjustment) { SET_VAR(rareInheritedData, textSizeAdjust, anAdjustment); }
#endif
+
void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
const SVGRenderStyle& svgStyle() const { return *m_svgStyle; }
@@ -1932,8 +1924,13 @@
static StyleImage* initialBorderImageSource() { return 0; }
static StyleImage* initialMaskBoxImageSource() { return 0; }
static PrintColorAdjust initialPrintColorAdjust() { return PrintColorAdjustEconomy; }
+
#if ENABLE(CSS_SCROLL_SNAP)
static ScrollSnapType initialScrollSnapType() { return ScrollSnapType::None; }
+ static ScrollSnapPoints initialScrollSnapPointsX();
+ static ScrollSnapPoints initialScrollSnapPointsY();
+ static LengthSize initialScrollSnapDestination();
+ static Vector<LengthSize> initialScrollSnapCoordinates();
#endif
#if ENABLE(CSS_GRID_LAYOUT)
Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (173658 => 173659)
--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp 2014-09-16 15:58:12 UTC (rev 173659)
@@ -30,6 +30,7 @@
#include "StyleTransformData.h"
#include "StyleImage.h"
#include "StyleResolver.h"
+#include "StyleScrollSnapPoints.h"
namespace WebCore {
@@ -68,7 +69,7 @@
, m_flowThread(RenderStyle::initialFlowThread())
, m_regionThread(RenderStyle::initialRegionThread())
#if ENABLE(CSS_SCROLL_SNAP)
- , m_scrollSnapType(RenderStyle::initialScrollSnapType())
+ , m_scrollSnapType(static_cast<unsigned>(RenderStyle::initialScrollSnapType()))
#endif
, m_regionFragment(RenderStyle::initialRegionFragment())
, m_regionBreakAfter(RenderStyle::NonInheritedFlags::initialPageBreak())
Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (173658 => 173659)
--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h 2014-09-16 15:58:12 UTC (rev 173659)
@@ -168,7 +168,7 @@
AtomicString m_regionThread;
#if ENABLE(CSS_SCROLL_SNAP)
- ScrollSnapType m_scrollSnapType; // ScrollSnapType
+ unsigned m_scrollSnapType : 2; // ScrollSnapType
#endif
unsigned m_regionFragment : 1; // RegionFragment
Modified: trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp (173658 => 173659)
--- trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp 2014-09-16 15:58:12 UTC (rev 173659)
@@ -30,30 +30,36 @@
namespace WebCore {
+ScrollSnapPoints::ScrollSnapPoints()
+ : repeatOffset(100, Percent)
+ , hasRepeat(true)
+ , usesElements(false)
+{
+}
+
+bool operator==(const ScrollSnapPoints& a, const ScrollSnapPoints& b)
+{
+ return a.repeatOffset == b.repeatOffset
+ && a.hasRepeat == b.hasRepeat
+ && a.usesElements == b.usesElements
+ && a.offsets == b.offsets;
+}
+
+LengthSize defaultScrollSnapDestination()
+{
+ return LengthSize(Length(0, Fixed), Length(0, Fixed));
+}
+
StyleScrollSnapPoints::StyleScrollSnapPoints()
- : repeatOffsetX(StyleScrollSnapPoints::defaultRepeatOffset())
- , repeatOffsetY(StyleScrollSnapPoints::defaultRepeatOffset())
- , destinationX(StyleScrollSnapPoints::defaultDestinationOffset())
- , destinationY(StyleScrollSnapPoints::defaultDestinationOffset())
- , hasRepeatX(true)
- , hasRepeatY(true)
- , usesElementsX(false)
- , usesElementsY(false)
+ : destination(defaultScrollSnapDestination())
{
}
-inline StyleScrollSnapPoints::StyleScrollSnapPoints(const StyleScrollSnapPoints& o)
- : repeatOffsetX(o.repeatOffsetX)
- , repeatOffsetY(o.repeatOffsetY)
- , destinationX(o.destinationX)
- , destinationY(o.destinationY)
- , hasRepeatX(o.hasRepeatX)
- , hasRepeatY(o.hasRepeatY)
- , usesElementsX(o.usesElementsX)
- , usesElementsY(o.usesElementsY)
- , offsetsX(o.offsetsX)
- , offsetsY(o.offsetsY)
- , coordinates(o.coordinates)
+inline StyleScrollSnapPoints::StyleScrollSnapPoints(const StyleScrollSnapPoints& other)
+ : xPoints(other.xPoints)
+ , yPoints(other.yPoints)
+ , destination(other.destination)
+ , coordinates(other.coordinates)
{
}
@@ -62,20 +68,14 @@
return adoptRef(*new StyleScrollSnapPoints(*this));
}
-bool StyleScrollSnapPoints::operator==(const StyleScrollSnapPoints& o) const
+bool operator==(const StyleScrollSnapPoints& a, const StyleScrollSnapPoints& b)
{
- return (offsetsX == o.offsetsX
- && offsetsY == o.offsetsY
- && repeatOffsetX == o.repeatOffsetX
- && hasRepeatX == o.hasRepeatX
- && hasRepeatY == o.hasRepeatY
- && destinationX == o.destinationX
- && destinationY == o.destinationY
- && coordinates == o.coordinates
- && usesElementsX == o.usesElementsX
- && usesElementsY == o.usesElementsY);
+ return a.xPoints == b.xPoints
+ && a.yPoints == b.yPoints
+ && a.destination == b.destination
+ && a.coordinates == b.coordinates;
}
-
+
} // namespace WebCore
#endif /* ENABLE(CSS_SCROLL_SNAP) */
Modified: trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h (173658 => 173659)
--- trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h 2014-09-16 12:36:41 UTC (rev 173658)
+++ trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h 2014-09-16 15:58:12 UTC (rev 173659)
@@ -28,57 +28,46 @@
#if ENABLE(CSS_SCROLL_SNAP)
-#include "Length.h"
-
-#include <wtf/PassRefPtr.h>
+#include "LengthSize.h"
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace WebCore {
-typedef std::pair<Length, Length> SnapCoordinate;
+struct ScrollSnapPoints {
+ Length repeatOffset;
+ bool hasRepeat;
+ bool usesElements;
+ Vector<Length> offsets;
+ ScrollSnapPoints();
+};
+
+bool operator==(const ScrollSnapPoints&, const ScrollSnapPoints&);
+inline bool operator!=(const ScrollSnapPoints& a, const ScrollSnapPoints& b) { return !(a == b); }
+
+LengthSize defaultScrollSnapDestination();
+
class StyleScrollSnapPoints : public RefCounted<StyleScrollSnapPoints> {
public:
static PassRef<StyleScrollSnapPoints> create() { return adoptRef(*new StyleScrollSnapPoints); }
-
- static Length defaultRepeatOffset()
- {
- return Length(100, Percent);
- }
-
- static Length defaultDestinationOffset()
- {
- return Length(0, Fixed);
- }
-
PassRef<StyleScrollSnapPoints> copy() const;
-
- bool operator==(const StyleScrollSnapPoints&) const;
- bool operator!=(const StyleScrollSnapPoints& o) const
- {
- return !(*this == o);
- }
-
- Length repeatOffsetX;
- Length repeatOffsetY;
- Length destinationX;
- Length destinationY;
- bool hasRepeatX;
- bool hasRepeatY;
- bool usesElementsX;
- bool usesElementsY;
- Vector<Length> offsetsX;
- Vector<Length> offsetsY;
- Vector<SnapCoordinate> coordinates;
-
+
+ ScrollSnapPoints xPoints;
+ ScrollSnapPoints yPoints;
+ LengthSize destination;
+ Vector<LengthSize> coordinates;
+
private:
StyleScrollSnapPoints();
StyleScrollSnapPoints(const StyleScrollSnapPoints&);
};
+bool operator==(const StyleScrollSnapPoints&, const StyleScrollSnapPoints&);
+inline bool operator!=(const StyleScrollSnapPoints& a, const StyleScrollSnapPoints& b) { return !(a == b); }
+
} // namespace WebCore
-#endif /* ENABLE(CSS_SCROLL_SNAP) */
+#endif // ENABLE(CSS_SCROLL_SNAP)
#endif // StyleScrollSnapPoints_h