Changeset 197617 in webkit
- Timestamp:
- Mar 5, 2016, 3:23:40 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r197616 r197617 1 2016-03-05 Simon Fraser <simon.fraser@apple.com> 2 3 Add parsing support for object-position 4 https://bugs.webkit.org/show_bug.cgi?id=155065 5 6 Reviewed by Sam Weinig. 7 8 object-position parsing test. 9 10 * fast/css/object-position/parsing-object-position-expected.txt: Added. 11 * fast/css/object-position/parsing-object-position.html: Added. 12 1 13 2016-03-05 Joanmarie Diggs <jdiggs@igalia.com> 2 14 -
trunk/Source/WebCore/CMakeLists.txt
r197616 r197617 2106 2106 platform/Language.cpp 2107 2107 platform/Length.cpp 2108 platform/LengthPoint.cpp 2108 2109 platform/LengthSize.cpp 2109 2110 platform/LinkHash.cpp -
trunk/Source/WebCore/ChangeLog
r197616 r197617 1 2016-03-05 Simon Fraser <simon.fraser@apple.com> 2 3 Add parsing support for object-position 4 https://bugs.webkit.org/show_bug.cgi?id=155065 5 6 Reviewed by Sam Weinig. 7 8 Add parsing support for object-position. This is the first property with 9 CSS <position> values which does not have equivalent -x and -y shorthands, 10 so we can store it as a new LengthPoint type. 11 12 Per the CSS Values spec, bottom- and right-relative values are translated 13 into calc() expressions, which are exposed via computed style. For example, 14 "right 10px bottom" becomes "calc(100% - 10px) 100%". This also allows transitions 15 between, say, "left 10px bottom" and "right 10px bottom". 16 17 Test: fast/css/object-position/parsing-object-position.html 18 19 * CMakeLists.txt: 20 * WebCore.xcodeproj/project.pbxproj: 21 * css/CSSComputedStyleDeclaration.cpp: 22 (WebCore::ComputedStyleExtractor::propertyValue): 23 * css/CSSParser.cpp: 24 (WebCore::CSSParser::parseValue): 25 * css/CSSPrimitiveValue.h: 26 (WebCore::CSSPrimitiveValue::isPair): 27 * css/CSSPropertyNames.in: 28 * css/CSSValue.h: 29 * css/StyleBuilderConverter.h: 30 (WebCore::StyleBuilderConverter::convertLength): 31 (WebCore::StyleBuilderConverter::convertTo100PercentMinusLength): 32 (WebCore::StyleBuilderConverter::convertPositionComponent): 33 (WebCore::StyleBuilderConverter::convertObjectPosition): 34 * platform/LengthPoint.cpp: Added. 35 (WebCore::operator<<): 36 * platform/LengthPoint.h: Added. 37 (WebCore::LengthPoint::LengthPoint): 38 (WebCore::LengthPoint::operator==): 39 (WebCore::LengthPoint::setX): 40 (WebCore::LengthPoint::x): 41 (WebCore::LengthPoint::setY): 42 (WebCore::LengthPoint::y): 43 (WebCore::LengthPoint::blend): 44 * rendering/style/RenderStyle.cpp: 45 (WebCore::RenderStyle::changeRequiresRepaint): 46 * rendering/style/RenderStyle.h: 47 * rendering/style/StyleRareNonInheritedData.cpp: 48 (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): 49 (WebCore::StyleRareNonInheritedData::operator==): 50 * rendering/style/StyleRareNonInheritedData.h: 51 1 52 2016-03-05 Joanmarie Diggs <jdiggs@igalia.com> 2 53 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r197616 r197617 509 509 0F6A12BE1A00923700C6DE72 /* DebugPageOverlays.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F6A12BC1A00923700C6DE72 /* DebugPageOverlays.h */; settings = {ATTRIBUTES = (Private, ); }; }; 510 510 0F7D07331884C56C00B4AF86 /* PlatformTextTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = 072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */; settings = {ATTRIBUTES = (Private, ); }; }; 511 0F87166F1C869D83004FF0DE /* LengthPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F87166D1C869D83004FF0DE /* LengthPoint.cpp */; }; 512 0F8716701C869D83004FF0DE /* LengthPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F87166E1C869D83004FF0DE /* LengthPoint.h */; settings = {ATTRIBUTES = (Private, ); }; }; 511 513 0F97A658155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F97A657155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm */; }; 512 514 0FA24D79162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */; }; … … 7902 7904 0F6A12BB1A00923700C6DE72 /* DebugPageOverlays.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DebugPageOverlays.cpp; sourceTree = "<group>"; }; 7903 7905 0F6A12BC1A00923700C6DE72 /* DebugPageOverlays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugPageOverlays.h; sourceTree = "<group>"; }; 7906 0F87166D1C869D83004FF0DE /* LengthPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthPoint.cpp; sourceTree = "<group>"; }; 7907 0F87166E1C869D83004FF0DE /* LengthPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthPoint.h; sourceTree = "<group>"; }; 7904 7908 0F97A657155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DisplayRefreshMonitorIOS.mm; sourceTree = "<group>"; }; 7905 7909 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerUpdater.cpp; sourceTree = "<group>"; }; … … 22878 22882 BCE65BE90EACDF16007E4533 /* Length.h */, 22879 22883 BCFF648F0EAD15C200C1D6F7 /* LengthBox.h */, 22884 0F87166D1C869D83004FF0DE /* LengthPoint.cpp */, 22885 0F87166E1C869D83004FF0DE /* LengthPoint.h */, 22880 22886 0FEF20CD1BD4A24100128E5D /* LengthSize.cpp */, 22881 22887 BCFF64900EAD15C200C1D6F7 /* LengthSize.h */, … … 27842 27848 FD00D7A514A3F61900734011 /* SincResampler.h in Headers */, 27843 27849 51327D6011A33A2B004F9D65 /* SinkDocument.h in Headers */, 27850 0F8716701C869D83004FF0DE /* LengthPoint.h in Headers */, 27844 27851 49E911CD0EF86D47009D0CAF /* SkewTransformOperation.h in Headers */, 27845 27852 4150F9F112B6E0E70008C860 /* SliderThumbElement.h in Headers */, … … 30451 30458 77A17AA612F28B2A004E02F6 /* JSOESVertexArrayObject.cpp in Sources */, 30452 30459 FDF6BAF8134A4C9800822920 /* JSOfflineAudioCompletionEvent.cpp in Sources */, 30460 0F87166F1C869D83004FF0DE /* LengthPoint.cpp in Sources */, 30453 30461 FDA9326616703BA9008982DC /* JSOfflineAudioContext.cpp in Sources */, 30454 30462 FDEA6242152102E200479DF0 /* JSOscillatorNode.cpp in Sources */, -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r197503 r197617 2971 2971 case CSSPropertyObjectFit: 2972 2972 return cssValuePool.createValue(style->objectFit()); 2973 case CSSPropertyObjectPosition: { 2974 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 2975 list->append(zoomAdjustedPixelValueForLength(style->objectPosition().x(), *style)); 2976 list->append(zoomAdjustedPixelValueForLength(style->objectPosition().y(), *style)); 2977 return list; 2978 } 2973 2979 case CSSPropertyOpacity: 2974 2980 return cssValuePool.createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER); -
trunk/Source/WebCore/css/CSSParser.cpp
r197503 r197617 2887 2887 parsedValue = parseColumnWidth(); 2888 2888 break; 2889 case CSSPropertyObjectPosition: { 2890 RefPtr<CSSPrimitiveValue> val1; 2891 RefPtr<CSSPrimitiveValue> val2; 2892 parseFillPosition(*m_valueList, val1, val2); 2893 if (val1) { 2894 addProperty(CSSPropertyObjectPosition, createPrimitiveValuePair(val1.release(), val2.release()), important); 2895 return true; 2896 } 2897 return false; 2898 } 2889 2899 // End of CSS3 properties 2890 2900 -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r196991 r197617 211 211 bool isLengthRepeat() const { return m_primitiveUnitType == CSS_LENGTH_REPEAT; } 212 212 #endif 213 bool isPair() const { return m_primitiveUnitType == CSS_PAIR; } 213 214 bool isPropertyID() const { return m_primitiveUnitType == CSS_PROPERTY_ID; } 214 215 bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; } -
trunk/Source/WebCore/css/CSSPropertyNames.in
r197511 r197617 275 275 min-width [Initial=initialMinSize, Converter=LengthSizing] 276 276 object-fit 277 object-position [Converter=ObjectPosition] 277 278 opacity 278 279 // Honor -webkit-opacity as a synonym for opacity. This was the only syntax that worked in Safari 1.1, -
trunk/Source/WebCore/css/StyleBuilderConverter.h
r197400 r197617 57 57 class StyleBuilderConverter { 58 58 public: 59 static Length convertLength(StyleResolver&, CSSValue&);59 static Length convertLength(StyleResolver&, const CSSValue&); 60 60 static Length convertLengthOrAuto(StyleResolver&, CSSValue&); 61 61 static Length convertLengthSizing(StyleResolver&, CSSValue&); … … 65 65 static float convertSpacing(StyleResolver&, CSSValue&); 66 66 static LengthSize convertRadius(StyleResolver&, CSSValue&); 67 static LengthPoint convertObjectPosition(StyleResolver&, CSSValue&); 67 68 static TextDecoration convertTextDecoration(StyleResolver&, CSSValue&); 68 69 template <typename T> static T convertNumber(StyleResolver&, CSSValue&); … … 148 149 static Length parseSnapCoordinate(StyleResolver&, const CSSValue&); 149 150 #endif 151 152 static Length convertTo100PercentMinusLength(const Length&); 153 static Length convertPositionComponent(StyleResolver&, const CSSPrimitiveValue&); 154 150 155 #if ENABLE(CSS_GRID_LAYOUT) 151 156 static GridLength createGridTrackBreadth(CSSPrimitiveValue&, StyleResolver&); … … 158 163 }; 159 164 160 inline Length StyleBuilderConverter::convertLength(StyleResolver& styleResolver, CSSValue& value)165 inline Length StyleBuilderConverter::convertLength(StyleResolver& styleResolver, const CSSValue& value) 161 166 { 162 167 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 296 301 297 302 return LengthSize(radiusWidth, radiusHeight); 303 } 304 305 inline Length StyleBuilderConverter::convertTo100PercentMinusLength(const Length& length) 306 { 307 if (length.isPercent()) 308 return Length(100 - length.value(), Percent); 309 310 // Turn this into a calc expression: calc(100% - length) 311 auto lhs = std::make_unique<CalcExpressionLength>(Length(100, Percent)); 312 auto rhs = std::make_unique<CalcExpressionLength>(length); 313 auto op = std::make_unique<CalcExpressionBinaryOperation>(WTFMove(lhs), WTFMove(rhs), CalcSubtract); 314 return Length(CalculationValue::create(WTFMove(op), CalculationRangeAll)); 315 } 316 317 inline Length StyleBuilderConverter::convertPositionComponent(StyleResolver& styleResolver, const CSSPrimitiveValue& value) 318 { 319 Length length; 320 321 auto* lengthValue = &value; 322 bool relativeToTrailingEdge = false; 323 324 if (value.isPair()) { 325 auto& first = *value.getPairValue()->first(); 326 if (first.getValueID() == CSSValueRight || first.getValueID() == CSSValueBottom) 327 relativeToTrailingEdge = true; 328 329 lengthValue = value.getPairValue()->second(); 330 } 331 332 length = convertLength(styleResolver, *lengthValue); 333 334 if (relativeToTrailingEdge) 335 length = convertTo100PercentMinusLength(length); 336 337 return length; 338 } 339 340 inline LengthPoint StyleBuilderConverter::convertObjectPosition(StyleResolver& styleResolver, CSSValue& value) 341 { 342 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); 343 Pair* pair = primitiveValue.getPairValue(); 344 if (!pair || !pair->first() || !pair->second()) 345 return RenderStyle::initialObjectPosition(); 346 347 Length lengthX = convertPositionComponent(styleResolver, *pair->first()); 348 Length lengthY = convertPositionComponent(styleResolver, *pair->second()); 349 350 return LengthPoint(lengthX, lengthY); 298 351 } 299 352 -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r197503 r197617 810 810 || rareNonInheritedData->m_borderFit != other.rareNonInheritedData->m_borderFit 811 811 || rareNonInheritedData->m_objectFit != other.rareNonInheritedData->m_objectFit 812 || rareNonInheritedData->m_objectPosition != other.rareNonInheritedData->m_objectPosition 812 813 || rareInheritedData->m_imageRendering != other.rareInheritedData->m_imageRendering) 813 814 return true; -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r197503 r197617 41 41 #include "LengthBox.h" 42 42 #include "LengthFunctions.h" 43 #include "LengthPoint.h" 43 44 #include "LengthSize.h" 44 45 #include "LineClampValue.h" … … 1032 1033 1033 1034 ObjectFit objectFit() const { return static_cast<ObjectFit>(rareNonInheritedData->m_objectFit); } 1034 1035 // Return true if any transform related property (currently transform, transformStyle3D or perspective) 1035 LengthPoint objectPosition() const { return rareNonInheritedData->m_objectPosition; } 1036 1037 // Return true if any transform related property (currently transform, transformStyle3D or perspective) 1036 1038 // indicates that we are transforming 1037 1039 bool hasTransformRelatedProperty() const { return hasTransform() || preserves3D() || hasPerspective(); } … … 1602 1604 1603 1605 void setObjectFit(ObjectFit fit) { SET_VAR(rareNonInheritedData, m_objectFit, fit); } 1606 void setObjectPosition(const LengthPoint& position) { SET_VAR(rareNonInheritedData, m_objectPosition, position); } 1604 1607 1605 1608 void setRubyPosition(RubyPosition position) { SET_VAR(rareInheritedData, m_rubyPosition, position); } … … 1892 1895 Mixed; } 1893 1896 static ObjectFit initialObjectFit() { return ObjectFitFill; } 1897 static LengthPoint initialObjectPosition() { return LengthPoint(Length(50.0f, Percent), Length(50.0f, Percent)); } 1894 1898 static EEmptyCell initialEmptyCells() { return SHOW; } 1895 1899 static EListStylePosition initialListStylePosition() { return OUTSIDE; } -
trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
r195892 r197617 64 64 , m_willChange(RenderStyle::initialWillChange()) 65 65 , m_mask(FillLayer(MaskFillLayer)) 66 , m_objectPosition(RenderStyle::initialObjectPosition()) 66 67 #if ENABLE(CSS_SHAPES) 67 68 , m_shapeOutside(RenderStyle::initialShapeOutside()) … … 149 150 , m_maskBoxImage(o.m_maskBoxImage) 150 151 , m_pageSize(o.m_pageSize) 152 , m_objectPosition(o.m_objectPosition) 151 153 #if ENABLE(CSS_SHAPES) 152 154 , m_shapeOutside(o.m_shapeOutside) … … 251 253 && m_maskBoxImage == o.m_maskBoxImage 252 254 && m_pageSize == o.m_pageSize 255 && m_objectPosition == o.m_objectPosition 253 256 #if ENABLE(CSS_SHAPES) 254 257 && arePointingToEqualData(m_shapeOutside, o.m_shapeOutside) -
trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h
r195892 r197617 33 33 #include "DataRef.h" 34 34 #include "FillLayer.h" 35 #include "LengthPoint.h" 35 36 #include "LineClampValue.h" 36 37 #include "NinePieceImage.h" … … 155 156 156 157 LengthSize m_pageSize; 158 LengthPoint m_objectPosition; 157 159 158 160 #if ENABLE(CSS_SHAPES)
Note:
See TracChangeset
for help on using the changeset viewer.