Diff
Modified: branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog (285320 => 285321)
--- branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog 2021-11-04 23:46:28 UTC (rev 285320)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog 2021-11-04 23:48:11 UTC (rev 285321)
@@ -1,5 +1,51 @@
2021-11-04 Russell Epstein <[email protected]>
+ Cherry-pick r282379. rdar://problem/85039227
+
+ Fix computed style for transform-origin on SVG boxes
+ https://bugs.webkit.org/show_bug.cgi?id=230172
+
+ Reviewed by Alan Bujtas.
+
+ LayoutTests/imported/w3c:
+
+ * web-platform-tests/css/css-transforms/transform-origin-014-expected.txt:
+
+ Source/WebCore:
+
+ When getting the computed value for transform-origin on SVG boxes, we need to get
+ the appropriate "reference box" from the renderer. Do minor refactoring to share
+ code between rendering and computed style for SVG and non-SVG boxes.
+
+ Tested by imported/w3c/web-platform-tests/css/css-transforms/transform-origin-014.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::transformReferenceBox):
+ (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+ * rendering/RenderLayer.cpp:
+ (WebCore::transformBoxToCSSBoxType): Deleted.
+ * rendering/style/RenderStyleConstants.cpp:
+ (WebCore::transformBoxToCSSBoxType):
+ * rendering/style/RenderStyleConstants.h:
+ * rendering/svg/SVGRenderSupport.cpp:
+ (WebCore::SVGRenderSupport::transformReferenceBox):
+ * rendering/svg/SVGRenderSupport.h:
+ * svg/SVGGraphicsElement.cpp:
+ (WebCore::SVGGraphicsElement::animatedLocalTransform const):
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-13 Simon Fraser <[email protected]>
+
+ Fix computed style for transform-origin on SVG boxes
+ https://bugs.webkit.org/show_bug.cgi?id=230172
+
+ Reviewed by Alan Bujtas.
+
+ * web-platform-tests/css/css-transforms/transform-origin-014-expected.txt:
+
+2021-11-04 Russell Epstein <[email protected]>
+
Cherry-pick r284853. rdar://problem/84516016
Fix issue for transform-origin in SVG
Added: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/transform-origin-014-expected.txt (0 => 285321)
--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/transform-origin-014-expected.txt (rev 0)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/transform-origin-014-expected.txt 2021-11-04 23:48:11 UTC (rev 285321)
@@ -0,0 +1,6 @@
+
+PASS Percentage 'transform-origin' with 'fill-box' transform-box
+PASS Percentage 'transform-origin' with 'view-box' transform-box
+PASS Percentage 'transform-origin' with 'view-box' transform-box in nested <svg> with 'viewBox'
+PASS Percentage 'transform-origin' with 'view-box' transform-box in nested <svg> without 'viewBox'
+
Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (285320 => 285321)
--- branches/safari-612-branch/Source/WebCore/ChangeLog 2021-11-04 23:46:28 UTC (rev 285320)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog 2021-11-04 23:48:11 UTC (rev 285321)
@@ -1,5 +1,69 @@
2021-11-04 Russell Epstein <[email protected]>
+ Cherry-pick r282379. rdar://problem/85039227
+
+ Fix computed style for transform-origin on SVG boxes
+ https://bugs.webkit.org/show_bug.cgi?id=230172
+
+ Reviewed by Alan Bujtas.
+
+ LayoutTests/imported/w3c:
+
+ * web-platform-tests/css/css-transforms/transform-origin-014-expected.txt:
+
+ Source/WebCore:
+
+ When getting the computed value for transform-origin on SVG boxes, we need to get
+ the appropriate "reference box" from the renderer. Do minor refactoring to share
+ code between rendering and computed style for SVG and non-SVG boxes.
+
+ Tested by imported/w3c/web-platform-tests/css/css-transforms/transform-origin-014.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::transformReferenceBox):
+ (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+ * rendering/RenderLayer.cpp:
+ (WebCore::transformBoxToCSSBoxType): Deleted.
+ * rendering/style/RenderStyleConstants.cpp:
+ (WebCore::transformBoxToCSSBoxType):
+ * rendering/style/RenderStyleConstants.h:
+ * rendering/svg/SVGRenderSupport.cpp:
+ (WebCore::SVGRenderSupport::transformReferenceBox):
+ * rendering/svg/SVGRenderSupport.h:
+ * svg/SVGGraphicsElement.cpp:
+ (WebCore::SVGGraphicsElement::animatedLocalTransform const):
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-13 Simon Fraser <[email protected]>
+
+ Fix computed style for transform-origin on SVG boxes
+ https://bugs.webkit.org/show_bug.cgi?id=230172
+
+ Reviewed by Alan Bujtas.
+
+ When getting the computed value for transform-origin on SVG boxes, we need to get
+ the appropriate "reference box" from the renderer. Do minor refactoring to share
+ code between rendering and computed style for SVG and non-SVG boxes.
+
+ Tested by imported/w3c/web-platform-tests/css/css-transforms/transform-origin-014.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::transformReferenceBox):
+ (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+ * rendering/RenderLayer.cpp:
+ (WebCore::transformBoxToCSSBoxType): Deleted.
+ * rendering/style/RenderStyleConstants.cpp:
+ (WebCore::transformBoxToCSSBoxType):
+ * rendering/style/RenderStyleConstants.h:
+ * rendering/svg/SVGRenderSupport.cpp:
+ (WebCore::SVGRenderSupport::transformReferenceBox):
+ * rendering/svg/SVGRenderSupport.h:
+ * svg/SVGGraphicsElement.cpp:
+ (WebCore::SVGGraphicsElement::animatedLocalTransform const):
+
+2021-11-04 Russell Epstein <[email protected]>
+
Apply patch. rdar://problem/80991209
2021-11-04 Kate Cheney <[email protected]>
Modified: branches/safari-612-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (285320 => 285321)
--- branches/safari-612-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2021-11-04 23:46:28 UTC (rev 285320)
+++ branches/safari-612-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2021-11-04 23:48:11 UTC (rev 285321)
@@ -65,6 +65,7 @@
#include "RenderInline.h"
#include "RenderStyle.h"
#include "SVGElement.h"
+#include "SVGRenderSupport.h"
#include "Settings.h"
#include "ShapeValue.h"
#include "StyleProperties.h"
@@ -537,6 +538,17 @@
return box.style().boxSizing() == BoxSizing::BorderBox ? box.borderBoxRect() : box.computedCSSContentBoxRect();
}
+static FloatRect transformReferenceBox(const RenderStyle& style, const RenderElement& renderer)
+{
+ if (is<RenderBox>(renderer))
+ return downcast<RenderBox>(renderer).referenceBox(transformBoxToCSSBoxType(style.transformBox()));
+
+ if (is<SVGElement>(renderer.element()))
+ return SVGRenderSupport::transformReferenceBox(renderer, downcast<SVGElement>(*renderer.element()), style);
+
+ return { };
+}
+
static Ref<CSSFunctionValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle& style)
{
RefPtr<CSSFunctionValue> transformValue;
@@ -3540,10 +3552,7 @@
case CSSPropertyPerspectiveOrigin: {
auto list = CSSValueList::createSpaceSeparated();
if (renderer) {
- LayoutRect box;
- if (is<RenderBox>(*renderer))
- box = downcast<RenderBox>(*renderer).borderBoxRect();
-
+ auto box = transformReferenceBox(style, *renderer);
list->append(zoomAdjustedPixelValue(minimumValueForLength(style.perspectiveOriginX(), box.width()), style));
list->append(zoomAdjustedPixelValue(minimumValueForLength(style.perspectiveOriginY(), box.height()), style));
} else {
@@ -3599,10 +3608,7 @@
case CSSPropertyTransformOrigin: {
auto list = CSSValueList::createSpaceSeparated();
if (renderer) {
- LayoutRect box;
- if (is<RenderBox>(*renderer))
- box = downcast<RenderBox>(*renderer).borderBoxRect();
-
+ auto box = transformReferenceBox(style, *renderer);
list->append(zoomAdjustedPixelValue(minimumValueForLength(style.transformOriginX(), box.width()), style));
list->append(zoomAdjustedPixelValue(minimumValueForLength(style.transformOriginY(), box.height()), style));
if (style.transformOriginZ())
Modified: branches/safari-612-branch/Source/WebCore/rendering/RenderLayer.cpp (285320 => 285321)
--- branches/safari-612-branch/Source/WebCore/rendering/RenderLayer.cpp 2021-11-04 23:46:28 UTC (rev 285320)
+++ branches/safari-612-branch/Source/WebCore/rendering/RenderLayer.cpp 2021-11-04 23:48:11 UTC (rev 285321)
@@ -1230,25 +1230,6 @@
return computeReferenceRectFromBox(downcast<RenderBox>(renderer), boxType, offsetFromRoot);
}
-static inline CSSBoxType transformBoxToCSSBoxType(TransformBox transformBox)
-{
- switch (transformBox) {
- case TransformBox::StrokeBox:
- return CSSBoxType::StrokeBox;
- case TransformBox::ContentBox:
- return CSSBoxType::ContentBox;
- case TransformBox::BorderBox:
- return CSSBoxType::BorderBox;
- case TransformBox::FillBox:
- return CSSBoxType::FillBox;
- case TransformBox::ViewBox:
- return CSSBoxType::ViewBox;
- default:
- ASSERT_NOT_REACHED();
- return CSSBoxType::BorderBox;
- }
-}
-
void RenderLayer::updateTransform()
{
bool hasTransform = renderer().hasTransform();
Modified: branches/safari-612-branch/Source/WebCore/rendering/style/RenderStyleConstants.cpp (285320 => 285321)
--- branches/safari-612-branch/Source/WebCore/rendering/style/RenderStyleConstants.cpp 2021-11-04 23:46:28 UTC (rev 285320)
+++ branches/safari-612-branch/Source/WebCore/rendering/style/RenderStyleConstants.cpp 2021-11-04 23:48:11 UTC (rev 285321)
@@ -1305,6 +1305,25 @@
return between >= BreakBetween::Page;
}
+CSSBoxType transformBoxToCSSBoxType(TransformBox transformBox)
+{
+ switch (transformBox) {
+ case TransformBox::StrokeBox:
+ return CSSBoxType::StrokeBox;
+ case TransformBox::ContentBox:
+ return CSSBoxType::ContentBox;
+ case TransformBox::BorderBox:
+ return CSSBoxType::BorderBox;
+ case TransformBox::FillBox:
+ return CSSBoxType::FillBox;
+ case TransformBox::ViewBox:
+ return CSSBoxType::ViewBox;
+ default:
+ ASSERT_NOT_REACHED();
+ return CSSBoxType::BorderBox;
+ }
+}
+
const float defaultMiterLimit = 4;
} // namespace WebCore
Modified: branches/safari-612-branch/Source/WebCore/rendering/style/RenderStyleConstants.h (285320 => 285321)
--- branches/safari-612-branch/Source/WebCore/rendering/style/RenderStyleConstants.h 2021-11-04 23:46:28 UTC (rev 285320)
+++ branches/safari-612-branch/Source/WebCore/rendering/style/RenderStyleConstants.h 2021-11-04 23:48:11 UTC (rev 285321)
@@ -1238,6 +1238,8 @@
Size = 1 << 2,
};
+CSSBoxType transformBoxToCSSBoxType(TransformBox);
+
extern const float defaultMiterLimit;
WTF::TextStream& operator<<(WTF::TextStream&, AnimationFillMode);
Modified: branches/safari-612-branch/Source/WebCore/rendering/svg/SVGRenderSupport.cpp (285320 => 285321)
--- branches/safari-612-branch/Source/WebCore/rendering/svg/SVGRenderSupport.cpp 2021-11-04 23:46:28 UTC (rev 285320)
+++ branches/safari-612-branch/Source/WebCore/rendering/svg/SVGRenderSupport.cpp 2021-11-04 23:48:11 UTC (rev 285321)
@@ -335,6 +335,26 @@
return true;
}
+FloatRect SVGRenderSupport::transformReferenceBox(const RenderElement& renderer, const SVGElement& element, const RenderStyle& style)
+{
+ switch (style.transformBox()) {
+ case TransformBox::BorderBox:
+ // For SVG elements without an associated CSS layout box, the used value for border-box is stroke-box.
+ case TransformBox::StrokeBox:
+ return renderer.strokeBoundingBox();
+ case TransformBox::ContentBox:
+ // For SVG elements without an associated CSS layout box, the used value for content-box is fill-box.
+ case TransformBox::FillBox:
+ return renderer.objectBoundingBox();
+ case TransformBox::ViewBox: {
+ FloatSize viewportSize;
+ SVGLengthContext(&element).determineViewport(viewportSize);
+ return FloatRect { { }, viewportSize };
+ }
+ }
+ return { };
+}
+
inline FloatRect clipPathReferenceBox(const RenderElement& renderer, CSSBoxType boxType)
{
FloatRect referenceBox;
Modified: branches/safari-612-branch/Source/WebCore/rendering/svg/SVGRenderSupport.h (285320 => 285321)
--- branches/safari-612-branch/Source/WebCore/rendering/svg/SVGRenderSupport.h 2021-11-04 23:46:28 UTC (rev 285320)
+++ branches/safari-612-branch/Source/WebCore/rendering/svg/SVGRenderSupport.h 2021-11-04 23:48:11 UTC (rev 285321)
@@ -38,6 +38,7 @@
class RenderLayerModelObject;
class RenderStyle;
class RenderSVGRoot;
+class SVGElement;
class TransformState;
// SVGRendererSupport is a helper class sharing code between all SVG renderers.
@@ -80,6 +81,8 @@
static void clipContextToCSSClippingArea(GraphicsContext&, const RenderElement& renderer);
static void styleChanged(RenderElement&, const RenderStyle*);
+
+ static FloatRect transformReferenceBox(const RenderElement&, const SVGElement&, const RenderStyle&);
#if ENABLE(CSS_COMPOSITING)
static bool isolatesBlending(const RenderStyle&);
Modified: branches/safari-612-branch/Source/WebCore/svg/SVGGraphicsElement.cpp (285320 => 285321)
--- branches/safari-612-branch/Source/WebCore/svg/SVGGraphicsElement.cpp 2021-11-04 23:46:28 UTC (rev 285320)
+++ branches/safari-612-branch/Source/WebCore/svg/SVGGraphicsElement.cpp 2021-11-04 23:48:11 UTC (rev 285321)
@@ -28,6 +28,7 @@
#include "SVGNames.h"
#include "SVGPathData.h"
#include "SVGRect.h"
+#include "SVGRenderSupport.h"
#include "SVGSVGElement.h"
#include "SVGStringList.h"
#include <wtf/IsoMallocInlines.h>
@@ -79,26 +80,7 @@
// Honor any of the transform-related CSS properties if set.
if (hasSpecifiedTransform || (style && (style->translate() || style->scale() || style->rotate()))) {
-
- FloatRect boundingBox;
- switch (style->transformBox()) {
- case TransformBox::BorderBox:
- // For SVG elements without an associated CSS layout box, the used value for border-box is stroke-box.
- case TransformBox::StrokeBox:
- boundingBox = renderer()->strokeBoundingBox();
- break;
- case TransformBox::ContentBox:
- // For SVG elements without an associated CSS layout box, the used value for content-box is fill-box.
- case TransformBox::FillBox:
- boundingBox = renderer()->objectBoundingBox();
- break;
- case TransformBox::ViewBox: {
- FloatSize viewportSize;
- SVGLengthContext(this).determineViewport(viewportSize);
- boundingBox.setSize(viewportSize);
- break;
- }
- }
+ auto boundingBox = SVGRenderSupport::transformReferenceBox(*renderer(), *this, *style);
// Note: objectBoundingBox is an emptyRect for elements like pattern or clipPath.
// See the "Object bounding box units" section of http://dev.w3.org/csswg/css3-transforms/
@@ -114,7 +96,6 @@
matrix.setE(matrix.e() / zoom);
matrix.setF(matrix.f() / zoom);
}
-
}
// If we didn't have the CSS "transform" property set, we must account for the "transform" attribute.