Changeset 181352 in webkit
- Timestamp:
- Mar 10, 2015 4:19:38 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r181351 r181352 1 2015-03-10 Brent Fulgham <bfulgham@apple.com> 2 3 CSS scroll-snap-destination and scroll-snap-coordinate are not honoring position values 4 https://bugs.webkit.org/show_bug.cgi?id=142411 5 6 Reviewed by Simon Fraser. 7 8 Add a test for <position> types in scroll snap operations. Also update the test expectations 9 for computed styles now that double-precision math is being used for calculated values. 10 11 * css3/scroll-snap/scroll-snap-position-values-expected.txt: Added. 12 * css3/scroll-snap/scroll-snap-position-values.html: Added. 13 * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Updated 14 * css3/scroll-snap/scroll-snap-property-computed-style.js: Updated 15 16 1 17 2015-03-10 Enrica Casucci <enrica@apple.com> 2 18 -
trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style-expected.txt
r181189 r181352 156 156 157 157 mm along x axis with pixel repeat : 10mm repeat(42mm) 158 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is '37.7 8125px repeat(158.734375px)'158 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is '37.7952766418457px repeat(158.7401580810547px)' 159 159 160 160 in along x axis with pixel repeat : 10in repeat(4in) … … 162 162 163 163 pt along x axis with pixel repeat : 10pt repeat(42pt) 164 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is '13.3 28125px repeat(56px)'164 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is '13.333333015441895px repeat(56px)' 165 165 166 166 in/cm destination : 2in 5cm 167 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-destination') is '192px 188.9 6875px'167 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-destination') is '192px 188.97637939453125px' 168 168 169 169 in/cm coordinate : 2in 5cm 5in 2cm 170 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-coordinate') is '192px 188.9 6875px, 480px 75.578125px'170 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-coordinate') is '192px 188.97637939453125px, 480px 75.5905532836914px' 171 171 172 172 subpixel along x axis with pixel repeat : 100.5px repeat(50.25px) -
trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style.js
r181189 r181352 73 73 testComputedScrollSnapRule("multiple percentage coordinates", "coordinate", "50% 100% 150% 100% 200% 100%", "50% 100%, 150% 100%, 200% 100%"); 74 74 75 testComputedScrollSnapRule("mm along x axis with pixel repeat", "points-x", "10mm repeat(42mm)", "37.7 8125px repeat(158.734375px)");75 testComputedScrollSnapRule("mm along x axis with pixel repeat", "points-x", "10mm repeat(42mm)", "37.7952766418457px repeat(158.7401580810547px)"); 76 76 testComputedScrollSnapRule("in along x axis with pixel repeat", "points-x", "10in repeat(4in)", "960px repeat(384px)"); 77 testComputedScrollSnapRule("pt along x axis with pixel repeat", "points-x", "10pt repeat(42pt)", "13.3 28125px repeat(56px)");78 testComputedScrollSnapRule("in/cm destination", "destination", "2in 5cm", "192px 188.9 6875px");79 testComputedScrollSnapRule("in/cm coordinate", "coordinate", "2in 5cm 5in 2cm", "192px 188.9 6875px, 480px 75.578125px");77 testComputedScrollSnapRule("pt along x axis with pixel repeat", "points-x", "10pt repeat(42pt)", "13.333333015441895px repeat(56px)"); 78 testComputedScrollSnapRule("in/cm destination", "destination", "2in 5cm", "192px 188.97637939453125px"); 79 testComputedScrollSnapRule("in/cm coordinate", "coordinate", "2in 5cm 5in 2cm", "192px 188.97637939453125px, 480px 75.5905532836914px"); 80 80 81 81 testComputedScrollSnapRule("subpixel along x axis with pixel repeat", "points-x", "100.5px repeat(50.25px)", "100.5px repeat(50.25px)"); -
trunk/Source/WebCore/ChangeLog
r181351 r181352 1 2015-03-10 Brent Fulgham <bfulgham@apple.com> 2 3 CSS scroll-snap-destination and scroll-snap-coordinate are not honoring position values 4 https://bugs.webkit.org/show_bug.cgi?id=142411 5 6 Reviewed by Simon Fraser. 7 8 Tested by css3/scroll-snap/scroll-snap-position-values.html. 9 10 Revise the CSSParser to recognize that scroll-snap-coordinates and scroll-snap-destination 11 may be specified as positions, therefore allowing 'top', 'bottom', and 'center' for the Y axis, 12 and 'left', 'right', and 'center' for the X axis. 13 14 Correct implementation to support calculated values for Scroll Snap Point markup. This required the 15 Scroll Snap Point-specific LengthRepeat class to change its internal representation from a CSSPrimitiveValue 16 to a regular CSSValue. 17 18 Add tests that these position labels, as well as combinations with percentages and pixel offsets 19 are parsed properly. 20 21 * css/CSSComputedStyleDeclaration.cpp: 22 (WebCore::scrollSnapDestination): Switch from 'percentageOrZoomAdjustedValue' to 'zoomAdjustedPixelValueForLength' 23 when working with Length values. This is necessary to allow calculated results to be based on the proper default 24 page dimensions. 25 (WebCore::scrollSnapPoints): Ditto. 26 (WebCore::scrollSnapCoordinates): Ditto. 27 * css/CSSParser.cpp: 28 (WebCore::CSSParser::parseScrollSnapPositions): Consolidated code for dealing with snap point 29 positions. 30 (WebCore::CSSParser::parseScrollSnapDestination): Revise to call new helper function. 31 (WebCore::CSSParser::parseScrollSnapCoordinate): Ditto. 32 (WebCore::CSSParser::parseFillPositionX): Rename as parsePositionX. 33 (WebCore::CSSParser::parseFillPositionY): Rename as parsePositionY. 34 (WebCore::CSSParser::parseFillProperty): Update to call renamed parsePosition{X|Y} methods. 35 (WebCore::CSSParser::parseTransformOrigin): Ditto. 36 (WebCore::CSSParser::parsePerspectiveOrigin): Ditto. 37 * css/CSSParser.h: 38 * css/LengthRepeat.h: Revise class to use a CSSValue, rather than a CSSPrimitiveValue, so that we can represent 39 repeat values as calculations. 40 1 41 2015-03-10 Enrica Casucci <enrica@apple.com> 2 42 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r181189 r181352 1110 1110 { 1111 1111 auto list = CSSValueList::createSpaceSeparated(); 1112 list.get().append( percentageOrZoomAdjustedValue(destination.width(), &style));1113 list.get().append( percentageOrZoomAdjustedValue(destination.height(), &style));1112 list.get().append(zoomAdjustedPixelValueForLength(destination.width(), &style)); 1113 list.get().append(zoomAdjustedPixelValueForLength(destination.height(), &style)); 1114 1114 return list; 1115 1115 } … … 1124 1124 auto list = CSSValueList::createSpaceSeparated(); 1125 1125 for (auto& point : points->offsets) 1126 list.get().append( percentageOrZoomAdjustedValue(point, &style));1126 list.get().append(zoomAdjustedPixelValueForLength(point, &style)); 1127 1127 if (points->hasRepeat) 1128 list.get().append(cssValuePool().createValue(LengthRepeat::create( percentageOrZoomAdjustedValue(points->repeatOffset, &style))));1128 list.get().append(cssValuePool().createValue(LengthRepeat::create(zoomAdjustedPixelValueForLength(points->repeatOffset, &style)))); 1129 1129 return WTF::move(list); 1130 1130 } … … 1139 1139 for (auto& coordinate : coordinates) { 1140 1140 auto pair = CSSValueList::createSpaceSeparated(); 1141 pair.get().append( percentageOrZoomAdjustedValue(coordinate.width(), &style));1142 pair.get().append( percentageOrZoomAdjustedValue(coordinate.height(), &style));1141 pair.get().append(zoomAdjustedPixelValueForLength(coordinate.width(), &style)); 1142 pair.get().append(zoomAdjustedPixelValueForLength(coordinate.height(), &style)); 1143 1143 list.get().append(WTF::move(pair)); 1144 1144 } -
trunk/Source/WebCore/css/CSSParser.cpp
r181197 r181352 3320 3320 } 3321 3321 3322 bool CSSParser::parseScrollSnapPositions(RefPtr<CSSValue>& cssValueX, RefPtr<CSSValue>& cssValueY) 3323 { 3324 cssValueX = parsePositionX(*m_valueList); 3325 if (!cssValueX) 3326 return false; 3327 3328 // Don't accept odd-length lists of positions (must always have an X and a Y): 3329 if (!m_valueList->next()) 3330 return false; 3331 3332 cssValueY = parsePositionY(*m_valueList); 3333 if (!cssValueY) 3334 return false; 3335 3336 return true; 3337 } 3338 3322 3339 bool CSSParser::parseScrollSnapDestination(CSSPropertyID propId, bool important) 3323 3340 { … … 3325 3342 if (m_valueList->size() != 2) 3326 3343 return false; 3327 ValueWithCalculation valueXWithCalculation(*m_valueList->current()); 3328 if (!validateUnit(valueXWithCalculation, FPercent | FLength)) 3329 return false; 3330 RefPtr<CSSValue> cssValueX = createPrimitiveNumericValue(valueXWithCalculation); 3331 3332 ValueWithCalculation valueYWithCalculation(*m_valueList->next()); 3333 if (!validateUnit(valueYWithCalculation, FPercent | FLength)) 3334 return false; 3335 RefPtr<CSSValue> cssValueY = createPrimitiveNumericValue(valueYWithCalculation); 3344 3345 RefPtr<CSSValue> cssValueX, cssValueY; 3346 if (!parseScrollSnapPositions(cssValueX, cssValueY)) 3347 return false; 3348 3336 3349 position->append(cssValueX.releaseNonNull()); 3337 3350 position->append(cssValueY.releaseNonNull()); … … 3345 3358 RefPtr<CSSValueList> positions = CSSValueList::createSpaceSeparated(); 3346 3359 while (m_valueList->current()) { 3347 ValueWithCalculation valueXWithCalculation(*m_valueList->current()); 3348 // Don't accept odd-length lists of coordinates. 3349 if (!m_valueList->next()) 3360 RefPtr<CSSValue> cssValueX, cssValueY; 3361 if (!parseScrollSnapPositions(cssValueX, cssValueY)) 3350 3362 return false; 3351 ValueWithCalculation valueYWithCalculation(*m_valueList->current()); 3352 if (!validateUnit(valueXWithCalculation, FPercent | FLength) || !validateUnit(valueYWithCalculation, FPercent | FLength)) 3353 return false; 3354 positions->append(createPrimitiveNumericValue(valueXWithCalculation)); 3355 positions->append(createPrimitiveNumericValue(valueYWithCalculation)); 3363 3364 positions->append(cssValueX.releaseNonNull()); 3365 positions->append(cssValueY.releaseNonNull()); 3356 3366 m_valueList->next(); 3357 3367 } 3368 3358 3369 if (positions->length()) { 3359 3370 addProperty(propId, positions.release(), important); … … 4038 4049 } 4039 4050 4040 PassRefPtr<CSSValue> CSSParser::parse FillPositionX(CSSParserValueList& valueList)4051 PassRefPtr<CSSValue> CSSParser::parsePositionX(CSSParserValueList& valueList) 4041 4052 { 4042 4053 int id = valueList.current()->id; … … 4055 4066 } 4056 4067 4057 PassRefPtr<CSSValue> CSSParser::parse FillPositionY(CSSParserValueList& valueList)4068 PassRefPtr<CSSValue> CSSParser::parsePositionY(CSSParserValueList& valueList) 4058 4069 { 4059 4070 int id = valueList.current()->id; … … 4565 4576 case CSSPropertyBackgroundPositionX: 4566 4577 case CSSPropertyWebkitMaskPositionX: { 4567 currValue = parse FillPositionX(*m_valueList);4578 currValue = parsePositionX(*m_valueList); 4568 4579 if (currValue) 4569 4580 m_valueList->next(); … … 4572 4583 case CSSPropertyBackgroundPositionY: 4573 4584 case CSSPropertyWebkitMaskPositionY: { 4574 currValue = parse FillPositionY(*m_valueList);4585 currValue = parsePositionY(*m_valueList); 4575 4586 if (currValue) 4576 4587 m_valueList->next(); … … 9715 9726 break; 9716 9727 case CSSPropertyWebkitTransformOriginX: { 9717 value = parse FillPositionX(*m_valueList);9728 value = parsePositionX(*m_valueList); 9718 9729 if (value) 9719 9730 m_valueList->next(); … … 9721 9732 } 9722 9733 case CSSPropertyWebkitTransformOriginY: { 9723 value = parse FillPositionY(*m_valueList);9734 value = parsePositionY(*m_valueList); 9724 9735 if (value) 9725 9736 m_valueList->next(); … … 9758 9769 break; 9759 9770 case CSSPropertyWebkitPerspectiveOriginX: { 9760 value = parse FillPositionX(*m_valueList);9771 value = parsePositionX(*m_valueList); 9761 9772 if (value) 9762 9773 m_valueList->next(); … … 9764 9775 } 9765 9776 case CSSPropertyWebkitPerspectiveOriginY: { 9766 value = parse FillPositionY(*m_valueList);9777 value = parsePositionY(*m_valueList); 9767 9778 if (value) 9768 9779 m_valueList->next(); -
trunk/Source/WebCore/css/CSSParser.h
r181209 r181352 155 155 enum FillPositionParsingMode { ResolveValuesAsPercent = 0, ResolveValuesAsKeyword = 1 }; 156 156 PassRefPtr<CSSPrimitiveValue> parseFillPositionComponent(CSSParserValueList&, unsigned& cumulativeFlags, FillPositionFlag& individualFlag, FillPositionParsingMode = ResolveValuesAsPercent); 157 PassRefPtr<CSSValue> parse FillPositionX(CSSParserValueList&);158 PassRefPtr<CSSValue> parse FillPositionY(CSSParserValueList&);157 PassRefPtr<CSSValue> parsePositionX(CSSParserValueList&); 158 PassRefPtr<CSSValue> parsePositionY(CSSParserValueList&); 159 159 void parse2ValuesFillPosition(CSSParserValueList&, RefPtr<CSSValue>&, RefPtr<CSSValue>&); 160 160 bool isPotentialPositionValue(CSSParserValue&); … … 560 560 bool parseScrollSnapDestination(CSSPropertyID propId, bool important); 561 561 bool parseScrollSnapCoordinate(CSSPropertyID propId, bool important); 562 bool parseScrollSnapPositions(RefPtr<CSSValue>& cssValueX, RefPtr<CSSValue>& cssValueY); 562 563 #endif 563 564 -
trunk/Source/WebCore/css/LengthRepeat.h
r172192 r181352 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014-2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 class LengthRepeat : public RefCounted<LengthRepeat> { 38 38 public: 39 static PassRefPtr<LengthRepeat> create(PassRefPtr<CSS PrimitiveValue> interval) { return adoptRef(new LengthRepeat(interval)); }39 static PassRefPtr<LengthRepeat> create(PassRefPtr<CSSValue> interval) { return adoptRef(new LengthRepeat(interval)); } 40 40 41 41 PassRefPtr<LengthRepeat> cloneForCSSOM() const { return create(interval()); } 42 42 43 CSS PrimitiveValue* interval() const { return m_interval.get(); }43 CSSValue* interval() const { return m_interval.get(); } 44 44 45 void setInterval(PassRefPtr<CSS PrimitiveValue> interval) { m_interval = interval; }45 void setInterval(PassRefPtr<CSSValue> interval) { m_interval = interval; } 46 46 47 47 bool equals(const LengthRepeat& other) const … … 56 56 57 57 private: 58 LengthRepeat(PassRefPtr<CSS PrimitiveValue> interval)58 LengthRepeat(PassRefPtr<CSSValue> interval) 59 59 : m_interval(interval) 60 60 { 61 61 } 62 62 63 RefPtr<CSS PrimitiveValue> m_interval;63 RefPtr<CSSValue> m_interval; 64 64 }; 65 65 -
trunk/Source/WebCore/css/StyleBuilderConverter.h
r181189 r181352 706 706 inline Length StyleBuilderConverter::parseSnapCoordinate(StyleResolver& styleResolver, const CSSValue& value) 707 707 { 708 return downcast<CSSPrimitiveValue>(value).convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(styleResolver.state().cssToLengthConversionData());708 return downcast<CSSPrimitiveValue>(value).convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | AutoConversion>(styleResolver.state().cssToLengthConversionData()); 709 709 } 710 710
Note: See TracChangeset
for help on using the changeset viewer.