Changeset 282379 in webkit
- Timestamp:
- Sep 13, 2021, 9:42:12 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r282362 r282379 1 2021-09-13 Simon Fraser <simon.fraser@apple.com> 2 3 Fix computed style for transform-origin on SVG boxes 4 https://bugs.webkit.org/show_bug.cgi?id=230172 5 6 Reviewed by Alan Bujtas. 7 8 * web-platform-tests/css/css-transforms/transform-origin-014-expected.txt: 9 1 10 2021-09-13 Youenn Fablet <youenn@apple.com> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/transform-origin-014-expected.txt
r282287 r282379 1 1 2 FAIL Percentage 'transform-origin' with 'fill-box' transform-box assert_equals: expected "50px 50px" but got "0px 0px" 3 FAIL Percentage 'transform-origin' with 'view-box' transform-box assert_equals: expected "150px 75px" but got "0px 0px" 4 FAIL Percentage 'transform-origin' with 'view-box' transform-box in nested <svg> with 'viewBox' assert_equals: expected "25px 25px" but got "0px 0px" 5 FAIL Percentage 'transform-origin' with 'view-box' transform-box in nested <svg> without 'viewBox' assert_equals: expected "50px 50px" but got "0px 0px" 2 PASS Percentage 'transform-origin' with 'fill-box' transform-box 3 PASS Percentage 'transform-origin' with 'view-box' transform-box 4 PASS Percentage 'transform-origin' with 'view-box' transform-box in nested <svg> with 'viewBox' 5 PASS Percentage 'transform-origin' with 'view-box' transform-box in nested <svg> without 'viewBox' 6 6 -
trunk/Source/WebCore/ChangeLog
r282377 r282379 1 2021-09-13 Simon Fraser <simon.fraser@apple.com> 2 3 Fix computed style for transform-origin on SVG boxes 4 https://bugs.webkit.org/show_bug.cgi?id=230172 5 6 Reviewed by Alan Bujtas. 7 8 When getting the computed value for transform-origin on SVG boxes, we need to get 9 the appropriate "reference box" from the renderer. Do minor refactoring to share 10 code between rendering and computed style for SVG and non-SVG boxes. 11 12 Tested by imported/w3c/web-platform-tests/css/css-transforms/transform-origin-014.html 13 14 * css/CSSComputedStyleDeclaration.cpp: 15 (WebCore::transformReferenceBox): 16 (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): 17 * rendering/RenderLayer.cpp: 18 (WebCore::transformBoxToCSSBoxType): Deleted. 19 * rendering/style/RenderStyleConstants.cpp: 20 (WebCore::transformBoxToCSSBoxType): 21 * rendering/style/RenderStyleConstants.h: 22 * rendering/svg/SVGRenderSupport.cpp: 23 (WebCore::SVGRenderSupport::transformReferenceBox): 24 * rendering/svg/SVGRenderSupport.h: 25 * svg/SVGGraphicsElement.cpp: 26 (WebCore::SVGGraphicsElement::animatedLocalTransform const): 27 1 28 2021-09-13 Chris Dumez <cdumez@apple.com> 2 29 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r282315 r282379 66 66 #include "RenderStyle.h" 67 67 #include "SVGElement.h" 68 #include "SVGRenderSupport.h" 68 69 #include "Settings.h" 69 70 #include "ShapeValue.h" … … 557 558 auto& box = downcast<RenderBox>(renderer); 558 559 return box.style().boxSizing() == BoxSizing::BorderBox ? box.borderBoxRect() : box.computedCSSContentBoxRect(); 560 } 561 562 static FloatRect transformReferenceBox(const RenderStyle& style, const RenderElement& renderer) 563 { 564 if (is<RenderBox>(renderer)) 565 return downcast<RenderBox>(renderer).referenceBox(transformBoxToCSSBoxType(style.transformBox())); 566 567 if (is<SVGElement>(renderer.element())) 568 return SVGRenderSupport::transformReferenceBox(renderer, downcast<SVGElement>(*renderer.element()), style); 569 570 return { }; 559 571 } 560 572 … … 3583 3595 auto list = CSSValueList::createSpaceSeparated(); 3584 3596 if (renderer) { 3585 LayoutRect box; 3586 if (is<RenderBox>(*renderer)) 3587 box = downcast<RenderBox>(*renderer).borderBoxRect(); 3588 3597 auto box = transformReferenceBox(style, *renderer); 3589 3598 list->append(zoomAdjustedPixelValue(minimumValueForLength(style.perspectiveOriginX(), box.width()), style)); 3590 3599 list->append(zoomAdjustedPixelValue(minimumValueForLength(style.perspectiveOriginY(), box.height()), style)); … … 3642 3651 auto list = CSSValueList::createSpaceSeparated(); 3643 3652 if (renderer) { 3644 LayoutRect box; 3645 if (is<RenderBox>(*renderer)) 3646 box = downcast<RenderBox>(*renderer).borderBoxRect(); 3647 3653 auto box = transformReferenceBox(style, *renderer); 3648 3654 list->append(zoomAdjustedPixelValue(minimumValueForLength(style.transformOriginX(), box.width()), style)); 3649 3655 list->append(zoomAdjustedPixelValue(minimumValueForLength(style.transformOriginY(), box.height()), style)); -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r281967 r282379 1257 1257 } 1258 1258 1259 static inline CSSBoxType transformBoxToCSSBoxType(TransformBox transformBox)1260 {1261 switch (transformBox) {1262 case TransformBox::StrokeBox:1263 return CSSBoxType::StrokeBox;1264 case TransformBox::ContentBox:1265 return CSSBoxType::ContentBox;1266 case TransformBox::BorderBox:1267 return CSSBoxType::BorderBox;1268 case TransformBox::FillBox:1269 return CSSBoxType::FillBox;1270 case TransformBox::ViewBox:1271 return CSSBoxType::ViewBox;1272 default:1273 ASSERT_NOT_REACHED();1274 return CSSBoxType::BorderBox;1275 }1276 }1277 1278 1259 void RenderLayer::updateTransform() 1279 1260 { -
trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp
r282143 r282379 1309 1309 } 1310 1310 1311 CSSBoxType transformBoxToCSSBoxType(TransformBox transformBox) 1312 { 1313 switch (transformBox) { 1314 case TransformBox::StrokeBox: 1315 return CSSBoxType::StrokeBox; 1316 case TransformBox::ContentBox: 1317 return CSSBoxType::ContentBox; 1318 case TransformBox::BorderBox: 1319 return CSSBoxType::BorderBox; 1320 case TransformBox::FillBox: 1321 return CSSBoxType::FillBox; 1322 case TransformBox::ViewBox: 1323 return CSSBoxType::ViewBox; 1324 default: 1325 ASSERT_NOT_REACHED(); 1326 return CSSBoxType::BorderBox; 1327 } 1328 } 1329 1311 1330 const float defaultMiterLimit = 4; 1312 1331 -
trunk/Source/WebCore/rendering/style/RenderStyleConstants.h
r282143 r282379 1246 1246 Size = 1 << 2, 1247 1247 }; 1248 1249 CSSBoxType transformBoxToCSSBoxType(TransformBox); 1248 1250 1249 1251 extern const float defaultMiterLimit; -
trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp
r281239 r282379 336 336 } 337 337 338 FloatRect SVGRenderSupport::transformReferenceBox(const RenderElement& renderer, const SVGElement& element, const RenderStyle& style) 339 { 340 switch (style.transformBox()) { 341 case TransformBox::BorderBox: 342 // For SVG elements without an associated CSS layout box, the used value for border-box is stroke-box. 343 case TransformBox::StrokeBox: 344 return renderer.strokeBoundingBox(); 345 case TransformBox::ContentBox: 346 // For SVG elements without an associated CSS layout box, the used value for content-box is fill-box. 347 case TransformBox::FillBox: 348 return renderer.objectBoundingBox(); 349 case TransformBox::ViewBox: { 350 FloatSize viewportSize; 351 SVGLengthContext(&element).determineViewport(viewportSize); 352 return FloatRect { { }, viewportSize }; 353 } 354 } 355 return { }; 356 } 357 338 358 inline FloatRect clipPathReferenceBox(const RenderElement& renderer, CSSBoxType boxType) 339 359 { -
trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h
r278253 r282379 39 39 class RenderStyle; 40 40 class RenderSVGRoot; 41 class SVGElement; 41 42 class TransformState; 42 43 … … 81 82 82 83 static void styleChanged(RenderElement&, const RenderStyle*); 84 85 static FloatRect transformReferenceBox(const RenderElement&, const SVGElement&, const RenderStyle&); 83 86 84 87 #if ENABLE(CSS_COMPOSITING) -
trunk/Source/WebCore/svg/SVGGraphicsElement.cpp
r267985 r282379 29 29 #include "SVGPathData.h" 30 30 #include "SVGRect.h" 31 #include "SVGRenderSupport.h" 31 32 #include "SVGSVGElement.h" 32 33 #include "SVGStringList.h" … … 80 81 // Honor any of the transform-related CSS properties if set. 81 82 if (hasSpecifiedTransform || (style && (style->translate() || style->scale() || style->rotate()))) { 82 83 FloatRect boundingBox; 84 switch (style->transformBox()) { 85 case TransformBox::BorderBox: 86 // For SVG elements without an associated CSS layout box, the used value for border-box is stroke-box. 87 case TransformBox::StrokeBox: 88 boundingBox = renderer()->strokeBoundingBox(); 89 break; 90 case TransformBox::ContentBox: 91 // For SVG elements without an associated CSS layout box, the used value for content-box is fill-box. 92 case TransformBox::FillBox: 93 boundingBox = renderer()->objectBoundingBox(); 94 break; 95 case TransformBox::ViewBox: { 96 FloatSize viewportSize; 97 SVGLengthContext(this).determineViewport(viewportSize); 98 boundingBox.setSize(viewportSize); 99 break; 100 } 101 } 83 auto boundingBox = SVGRenderSupport::transformReferenceBox(*renderer(), *this, *style); 102 84 103 85 // Note: objectBoundingBox is an emptyRect for elements like pattern or clipPath. … … 115 97 matrix.setF(matrix.f() / zoom); 116 98 } 117 118 99 } 119 100
Note:
See TracChangeset
for help on using the changeset viewer.