WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
Patch, v6
bug-237711-20220313164346.patch (text/plain), 38.49 KB, created by
Nikolas Zimmermann
on 2022-03-13 16:43:47 PDT
(
hide
)
Description:
Patch, v6
Filename:
MIME Type:
Creator:
Nikolas Zimmermann
Created:
2022-03-13 16:43:47 PDT
Size:
38.49 KB
patch
obsolete
>Subversion Revision: 291217 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 0d605ca5a3b18159df215849ada856e7f9b4b8a7..4684e92d7f81c823521a081f8a7ae281cf4b30de 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,134 @@ >+2022-03-13 Nikolas Zimmermann <nzimmermann@igalia.com> >+ >+ Unify 'transform-box' reference box computation >+ https://bugs.webkit.org/show_bug.cgi?id=237554 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Currently the code to compute the reference box, according to the CSS 'transform-box' >+ property is sprinkled over various places: CSSComputedStyleDeclaration, SVGRenderSupport, >+ RenderBox, parts in RenderLayer. >+ >+ Cleanup and unify the code in a single place: a new 'referenceBoxRect()' method implementing >+ the computation for both SVG/HTML, where the SVG code lives in RenderElement (the only shared >+ base class between legacy SVG/LBSE) and the HTML code in RenderBox. The HTML/CSS implementation >+ was already contained in RenderBox::referenceBox() and was renamed to referenceBoxRect() to follow >+ the naming convention for the other CSS box geoemtry helpers such as contentBoxRect(), >+ borderBoxRect(), etc. >+ >+ For SVGs needs referenceBoxRect() needs to return a FloatRect, whereas for CSS/HTML LayoutRect >+ is the right choice. Introduce a 'FloatOrLayoutRect' helper that can be used as return value/argument >+ in/to functions that either return/need a FloatRect or a LayoutRect, depending on the context. >+ >+ 'FloatOrLayoutRect' holds a variant<FloatRect, LayoutRect> and offers convenience functions >+ to simplify common operations, e.g. operator FloatRect() to access the stored FloatRect, or convert >+ the stored LayoutRect into a FloatRect (without applying pixel snapping). Furthermore it offers >+ a 'rectForPainting(deviceScaleFactor)' method, that either returns the stored FloatRect, or pixel-snaps >+ the stored LayoutRect and returns a new device-pixel aligned FloatRect. The name 'rectForPainting' >+ does not contain the term 'PixelSnapping' on purpose, since the intended usage is in all places that >+ currently apply pixel-snapping, to easily disable that operation in SVG subtrees. >+ >+ Covered by existing tests, no change in behaviour. >+ >+ * Headers.cmake: Add FloatOrLayoutRect.h to build. >+ * WebCore.xcodeproj/project.pbxproj: Ditto. >+ * css/CSSComputedStyleDeclaration.cpp: >+ (WebCore::computedTransform): Use the renderers transformReferenceBoxRect() instead of the static helper function transformReferenceBox(). >+ (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): Ditto. >+ (WebCore::transformReferenceBox): Deleted. RenderElement::transformReferenceBoxRect() provides the same logic in a generic way. >+ * platform/graphics/FloatOrLayoutRect.h: Added. >+ (WebCore::FloatOrLayoutRect::FloatOrLayoutRect): Add constructors for implicit construction from either LayoutRect or FloatRect. >+ (WebCore::FloatOrLayoutRect::operator FloatRect const): Returns the stored FloatRect, or converts the stored LayoutRect into a FloatRect (no pixel snapping!). >+ (WebCore::FloatOrLayoutRect::rectForPainting const): Returns the stored FloatRect as-is, or applies pixel-snapping on the stored LayoutRect, returning a device-pixel aligned FloatRect. >+ (WebCore::FloatOrLayoutRect::move): Helper method to simplify RenderLayer call-sites. Calls move() on either the stored FloatRect or LayoutRect. >+ (WebCore::FloatOrLayoutRect::isFloatRect const): Checks if the variant holds a FloatRect, if not it is guaranteed to hold a LayoutRect. >+ (WebCore::FloatOrLayoutRect::floatRect const): Read-only const acccesor. >+ (WebCore::FloatOrLayoutRect::floatRect): Mutable accessor, used by move(). >+ (WebCore::FloatOrLayoutRect::isLayoutRect const): Checks if the variant holds a LayoutRect, if not it is guaranteed to hold a FloatRect. >+ (WebCore::FloatOrLayoutRect::layoutRect const): Read-only const acccesor. >+ (WebCore::FloatOrLayoutRect::layoutRect): Mutable accessor, used by move(). >+ * rendering/RenderBox.cpp: >+ (WebCore::RenderBox::referenceBoxRect const): Rename referenceBox() to referenceBoxRect() and return FloatOrLayoutRect instead of LayoutRect. >+ LBSE wants to re-use the logic but without pixel snapping within the SVG render tree. All callers were adapted to the new return type. >+ (WebCore::RenderBox::hitTestClipPath const): Adapt to referenceBox() -> referenceBoxRect() renaming and return type change. >+ (WebCore::RenderBox::referenceBox const): Deleted. >+ * rendering/RenderBox.h: Adapt to referenceBox() -> referenceBoxRect() renaming and return type change. >+ * rendering/RenderElement.cpp: >+ (WebCore::RenderElement::referenceBoxRect const): Add referenceBoxRect() implementation for SVG renderers. The common base-class for >+ all SVG renderers is RenderElement in the legacy SVG engine and RenderLayerModelObject in LBSE. To share the code between both SVG >+ implementations it has to be placed in RenderElement -- to be moved to RenderLayerModelObject, once LBSE is the only SVG engine. >+ * rendering/RenderElement.h: >+ (WebCore::RenderElement::transformReferenceBoxRect const): Add new helper function which invokes referenceBoxRect() using >+ transformBoxToCSSBoxType(style().transformBox()). Whenever transform-box support is necessary, this method shall be used. >+ * rendering/RenderLayer.cpp: Use the new transformReferenceBoxRect() where possible, adapt to return type changes, remove manual pixel snapping. >+ (WebCore::computeReferenceBox): Adapt to referenceBox() -> referenceBoxRect() renaming and return type change. >+ (WebCore::RenderLayer::updateTransform): Simplify reference box computation, and avoid manual pixel snapping: utilize transformReferenceBoxRect() + rectForPainting(). >+ (WebCore::RenderLayer::currentTransform const): Ditto. >+ (WebCore::RenderLayer::perspectiveTransform const): Ditto. >+ (WebCore::RenderLayer::perspectiveOrigin const): Add FIXME, this always uses the border box rect as boundingBox for length resolving: it ignores transform-box. >+ (WebCore::RenderLayer::computeClipPath const): Adapt to computeReferenceBox() changes. >+ (WebCore::RenderLayer::setupClipPath): Ditto. >+ (WebCore::computeReferenceRectFromBox): Deleted. >+ * rendering/svg/SVGRenderSupport.cpp: >+ (WebCore::SVGRenderSupport::transformReferenceBox): Deleted. RenderElement::transformReferenceBoxRect() provides the same logic in a generic way. >+ * rendering/svg/SVGRenderSupport.h: Get rid of transformReferenceBox(). >+ * svg/SVGGraphicsElement.cpp: >+ (WebCore::SVGGraphicsElement::animatedLocalTransform const): Use the renderers transformReferenceBoxRect() instead of SVGRenderSupport::transformReferenceBox(). >+ >+2022-03-10 Nikolas Zimmermann <nzimmermann@igalia.com> >+ >+ Unify 'transform-box' reference box computation >+ https://bugs.webkit.org/show_bug.cgi?id=237554 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Currently the code to compute the reference box, according to the CSS 'transform-box' >+ property is sprinkled over various places: CSSComputedStyleDeclaration, SVGRenderSupport, >+ RenderBox, parts in RenderLayer. >+ >+ Cleanup and unify the code in a single place: a new 'referenceBoxRect()' method implementing >+ the computation for both SVG/HTML, where the SVG code lives in RenderElement (the only shared >+ base class between legacy SVG/LBSE) and the HTML code in RenderBox. The HTML/CSS implementation >+ was already contained in RenderBox::referenceBox() and was renamed to referenceBoxRect() to follow >+ the naming convention for the other CSS box geoemtry helpers such as contentBoxRect(), >+ borderBoxRect(), etc. >+ >+ Remove code from SVGRenderSupport/CSSComputedStyleDeclaration that can now use the shared logic. >+ >+ Covered by existing tests, no change in behaviour. >+ >+ * css/CSSComputedStyleDeclaration.cpp: >+ (WebCore::computedTransform): Use the renderers transformReferenceBoxRect() instead of the static helper function transformReferenceBox(). >+ (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): Ditto. >+ (WebCore::transformReferenceBox): Deleted. RenderElement::transformReferenceBoxRect() provides the same logic in a generic way. >+ * rendering/RenderBox.cpp: >+ (WebCore::RenderBox::referenceBoxRect const): Rename referenceBox() to referenceBoxRect() and return FloatRect instead of LayoutRect. >+ LBSE wants to re-use the logic but without pixel snapping within the SVG render tree. All callers were adapted to the new return type. >+ (WebCore::RenderBox::hitTestClipPath const): Adapt to referenceBox() -> referenceBoxRect() renaming. >+ (WebCore::RenderBox::referenceBox const): Deleted. >+ * rendering/RenderBox.h: Adapt to referenceBox() -> referenceBoxRect() renaming >+ * rendering/RenderElement.cpp: >+ (WebCore::RenderElement::referenceBoxRect const): Add referenceBoxRect() implementation for SVG renderers. The common base-class for >+ all SVG renderers is RenderElement in the legacy SVG engine and RenderLayerModelObject in LBSE. To share the code between both SVG >+ implementations it has to be placed in RenderElement -- to be moved to RenderLayerModelObject, once LBSE is the only SVG engine. >+ * rendering/RenderElement.h: >+ (WebCore::RenderElement::transformReferenceBoxRect const): Add new helper function which invokes referenceBoxRect() using >+ transformBoxToCSSBoxType(style().transformBox()). Whenever transform-box support is necessary, this method shall be used. >+ * rendering/RenderLayer.cpp: Use the new transformReferenceBoxRect() where possible. >+ (WebCore::computeReferenceBox): >+ (WebCore::RenderLayer::updateTransform): >+ (WebCore::RenderLayer::currentTransform const): >+ (WebCore::RenderLayer::perspectiveTransform const): >+ (WebCore::RenderLayer::perspectiveOrigin const): >+ (WebCore::RenderLayer::computeClipPath const): >+ (WebCore::RenderLayer::setupClipPath): >+ (WebCore::computeReferenceRectFromBox): Deleted. >+ * rendering/svg/SVGRenderSupport.cpp: >+ (WebCore::SVGRenderSupport::transformReferenceBox): Deleted. RenderElement::transformReferenceBoxRect() provides the same logic in a generic way. >+ * rendering/svg/SVGRenderSupport.h: Ditto. >+ * svg/SVGGraphicsElement.cpp: >+ (WebCore::SVGGraphicsElement::animatedLocalTransform const): Use the renderers transformReferenceBoxRect() instead of SVGRenderSupport::transformReferenceBox(). >+ > 2022-03-12 Jean-Yves Avenard <jya@apple.com> > > Safari produces scrambled output for some webm videos with vp8 codec. >diff --git a/Source/WebCore/Headers.cmake b/Source/WebCore/Headers.cmake >index 736442a08a74500a352f04c2e106d8c41e7a4fc5..e0f82185b87b44bd8323fd12b3908e1ff9d99542 100644 >--- a/Source/WebCore/Headers.cmake >+++ b/Source/WebCore/Headers.cmake >@@ -1450,6 +1450,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > platform/graphics/DisplayUpdate.h > platform/graphics/DrawGlyphsRecorder.h > platform/graphics/FloatLine.h >+ platform/graphics/FloatOrLayoutRect.h > platform/graphics/FloatPoint.h > platform/graphics/FloatPoint3D.h > platform/graphics/FloatQuad.h >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index e674bb61e985713f692147b7ae3479ee8fe19bfc..510b3adc6e73b2dbb0120cd118fe62319b7a9daa 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -3927,6 +3927,7 @@ > B27535670B053814002CE64F /* Color.h in Headers */ = {isa = PBXBuildFile; fileRef = B27535390B053814002CE64F /* Color.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B27535690B053814002CE64F /* FloatPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = B275353B0B053814002CE64F /* FloatPoint.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B275356B0B053814002CE64F /* FloatRect.h in Headers */ = {isa = PBXBuildFile; fileRef = B275353D0B053814002CE64F /* FloatRect.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ B377346B0B041916602CE64F /* FloatOrLayoutRect.h in Headers */ = {isa = PBXBuildFile; fileRef = B275353C0B053815002CE64F /* FloatOrLayoutRect.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B275356D0B053814002CE64F /* FloatSize.h in Headers */ = {isa = PBXBuildFile; fileRef = B275353F0B053814002CE64F /* FloatSize.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B275356E0B053814002CE64F /* Icon.h in Headers */ = {isa = PBXBuildFile; fileRef = B27535400B053814002CE64F /* Icon.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B27535700B053814002CE64F /* Image.h in Headers */ = {isa = PBXBuildFile; fileRef = B27535420B053814002CE64F /* Image.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -14870,6 +14871,7 @@ > B275353B0B053814002CE64F /* FloatPoint.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FloatPoint.h; sourceTree = "<group>"; }; > B275353C0B053814002CE64F /* FloatRect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FloatRect.cpp; sourceTree = "<group>"; }; > B275353D0B053814002CE64F /* FloatRect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FloatRect.h; sourceTree = "<group>"; }; >+ B275353C0B053815002CE64F /* FloatOrLayoutRect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FloatOrLayoutRect.h; sourceTree = "<group>"; }; > B275353E0B053814002CE64F /* FloatSize.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FloatSize.cpp; sourceTree = "<group>"; }; > B275353F0B053814002CE64F /* FloatSize.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FloatSize.h; sourceTree = "<group>"; }; > B27535400B053814002CE64F /* Icon.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Icon.h; sourceTree = "<group>"; }; >@@ -28982,6 +28984,7 @@ > 0FD723800EC8BD9300CA5DD7 /* FloatQuad.h */, > B275353C0B053814002CE64F /* FloatRect.cpp */, > B275353D0B053814002CE64F /* FloatRect.h */, >+ B275353C0B053815002CE64F /* FloatOrLayoutRect.h */, > 6E0E5699183BFFE600E0E8D5 /* FloatRoundedRect.cpp */, > 6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */, > B275353E0B053814002CE64F /* FloatSize.cpp */, >@@ -34665,6 +34668,7 @@ > 6EC480A216EA638A00A48DCB /* FloatPolygon.h in Headers */, > 0FD723820EC8BD9300CA5DD7 /* FloatQuad.h in Headers */, > B275356B0B053814002CE64F /* FloatRect.h in Headers */, >+ B377346B0B041916602CE64F /* FloatOrLayoutRect.h in Headers */, > 6E0E569C183BFFE600E0E8D5 /* FloatRoundedRect.h in Headers */, > B275356D0B053814002CE64F /* FloatSize.h in Headers */, > 58CD35CB18EB4C3900B9F3AC /* FloatSizeHash.h in Headers */, >diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >index acebdb3464bfe1f275de4ab08ba18df8568ebd83..c973c5a4e50b0c63e1b44351df65628f27a616ba 100644 >--- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >+++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >@@ -560,17 +560,6 @@ static LayoutRect sizingBox(RenderObject& renderer) > 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; >@@ -623,7 +612,7 @@ static Ref<CSSValue> computedTransform(RenderElement* renderer, const RenderStyl > return CSSValuePool::singleton().createIdentifierValue(CSSValueNone); > > TransformationMatrix transform; >- style.applyTransform(transform, transformReferenceBox(style, *renderer), { }); >+ style.applyTransform(transform, renderer->transformReferenceBoxRect(style), { }); > // Note that this does not flatten to an affine transform if ENABLE(3D_TRANSFORMS) is off, by design. > > // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924) >@@ -3840,7 +3829,7 @@ RefPtr<CSSValue> ComputedStyleExtractor::valueForPropertyInStyle(const RenderSty > case CSSPropertyPerspectiveOrigin: { > auto list = CSSValueList::createSpaceSeparated(); > if (renderer) { >- auto box = transformReferenceBox(style, *renderer); >+ FloatRect box = renderer->transformReferenceBoxRect(style); > list->append(zoomAdjustedPixelValue(minimumValueForLength(style.perspectiveOriginX(), box.width()), style)); > list->append(zoomAdjustedPixelValue(minimumValueForLength(style.perspectiveOriginY(), box.height()), style)); > } else { >@@ -3896,7 +3885,7 @@ RefPtr<CSSValue> ComputedStyleExtractor::valueForPropertyInStyle(const RenderSty > case CSSPropertyTransformOrigin: { > auto list = CSSValueList::createSpaceSeparated(); > if (renderer) { >- auto box = transformReferenceBox(style, *renderer); >+ FloatRect box = renderer->transformReferenceBoxRect(style); > list->append(zoomAdjustedPixelValue(minimumValueForLength(style.transformOriginX(), box.width()), style)); > list->append(zoomAdjustedPixelValue(minimumValueForLength(style.transformOriginY(), box.height()), style)); > if (style.transformOriginZ()) >diff --git a/Source/WebCore/platform/graphics/FloatOrLayoutRect.h b/Source/WebCore/platform/graphics/FloatOrLayoutRect.h >new file mode 100644 >index 0000000000000000000000000000000000000000..6b8ffc42bcf4431069171ab01f3d0a296f5e5298 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/FloatOrLayoutRect.h >@@ -0,0 +1,91 @@ >+/* >+ * Copyright (c) 2022 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "FloatRect.h" >+#include "LayoutRect.h" >+#include <optional> >+#include <variant> >+ >+namespace WebCore { >+ >+class FloatOrLayoutRect { >+public: >+ FloatOrLayoutRect() = default; >+ >+ FloatOrLayoutRect(const FloatRect& rect) >+ : m_data { rect } >+ { >+ } >+ >+ FloatOrLayoutRect(const LayoutRect& rect) >+ : m_data { rect } >+ { >+ } >+ >+ ~FloatOrLayoutRect() = default; >+ >+ operator FloatRect() const >+ { >+ if (isFloatRect()) >+ return floatRect(); >+ ASSERT(isLayoutRect()); >+ return layoutRect(); >+ } >+ >+ FloatRect rectForPainting(float deviceScaleFactor) const >+ { >+ if (isFloatRect()) >+ return floatRect(); >+ ASSERT(isLayoutRect()); >+ return snapRectToDevicePixels(layoutRect(), deviceScaleFactor); >+ } >+ >+ // Convenience functions: >+ // Using move() the location of the rect can be altered, regardless of its type. >+ void move(const LayoutSize& size) >+ { >+ if (isFloatRect()) { >+ floatRect().move(size); >+ return; >+ } >+ ASSERT(isLayoutRect()); >+ layoutRect().move(size); >+ } >+ >+private: >+ constexpr bool isFloatRect() const { return std::holds_alternative<FloatRect>(m_data); } >+ const FloatRect& floatRect() const { return std::get<FloatRect>(m_data); } >+ FloatRect& floatRect() { return std::get<FloatRect>(m_data); } >+ >+ constexpr bool isLayoutRect() const { return std::holds_alternative<LayoutRect>(m_data); } >+ const LayoutRect& layoutRect() const { return std::get<LayoutRect>(m_data); } >+ LayoutRect& layoutRect() { return std::get<LayoutRect>(m_data); } >+ >+ std::variant<FloatRect, LayoutRect> m_data; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp >index c416be91ff3f56972bcab4a05c68953d89bc6130..3eea20f6a8e70db8b9d29d9b779346675107755f 100644 >--- a/Source/WebCore/rendering/RenderBox.cpp >+++ b/Source/WebCore/rendering/RenderBox.cpp >@@ -766,9 +766,8 @@ LayoutPoint RenderBox::contentBoxLocation() const > return { borderLeft() + paddingLeft() + scrollbarSpace, borderTop() + paddingTop() }; > } > >-LayoutRect RenderBox::referenceBox(CSSBoxType boxType) const >+FloatOrLayoutRect RenderBox::referenceBoxRect(CSSBoxType boxType) const > { >- LayoutRect referenceBox; > switch (boxType) { > case CSSBoxType::ContentBox: > case CSSBoxType::FillBox: >@@ -784,7 +783,9 @@ LayoutRect RenderBox::referenceBox(CSSBoxType boxType) const > case CSSBoxType::BoxMissing: > return borderBoxRect(); > } >- return { }; >+ >+ ASSERT_NOT_REACHED(); >+ return LayoutRect(); > } > > IntRect RenderBox::absoluteContentBox() const >@@ -1460,8 +1461,7 @@ bool RenderBox::hitTestClipPath(const HitTestLocation& hitTestLocation, const La > switch (style().clipPath()->type()) { > case PathOperation::Shape: { > auto& clipPath = downcast<ShapePathOperation>(*style().clipPath()); >- auto referenceBoxRect = referenceBox(clipPath.referenceBox()); >- if (!clipPath.pathForReferenceRect(referenceBoxRect).contains(hitTestLocationInLocalCoordinates, clipPath.windRule())) >+ if (!clipPath.pathForReferenceRect(referenceBoxRect(clipPath.referenceBox())).contains(hitTestLocationInLocalCoordinates, clipPath.windRule())) > return false; > break; > } >diff --git a/Source/WebCore/rendering/RenderBox.h b/Source/WebCore/rendering/RenderBox.h >index ed77770e7e429d5b762c0ebc291baf02f4702325..d350a460dc4535bd3fe9576dac0dc272e7cf4105 100644 >--- a/Source/WebCore/rendering/RenderBox.h >+++ b/Source/WebCore/rendering/RenderBox.h >@@ -167,8 +167,8 @@ public: > LayoutRect contentBoxRect() const; > LayoutPoint contentBoxLocation() const; > >- // .https://drafts.csswg.org/css-transforms-1/#reference-box >- LayoutRect referenceBox(CSSBoxType) const; >+ // https://www.w3.org/TR/css-transforms-1/#reference-box >+ FloatOrLayoutRect referenceBoxRect(CSSBoxType) const final; > > // The content box in absolute coords. Ignores transforms. > IntRect absoluteContentBox() const; >diff --git a/Source/WebCore/rendering/RenderElement.cpp b/Source/WebCore/rendering/RenderElement.cpp >index e932bc74b1fdeb74ae32d2bf80709f7c5eb6dd25..b158571c389e91fb0a21befb4998479aa77a59de 100644 >--- a/Source/WebCore/rendering/RenderElement.cpp >+++ b/Source/WebCore/rendering/RenderElement.cpp >@@ -78,6 +78,7 @@ > #include "RenderView.h" > #include "SVGElementTypeHelpers.h" > #include "SVGImage.h" >+#include "SVGLengthContext.h" > #include "SVGRenderSupport.h" > #include "Settings.h" > #include "ShadowRoot.h" >@@ -2389,4 +2390,38 @@ Overflow RenderElement::effectiveOverflowY() const > return overflowY; > } > >+// https://www.w3.org/TR/css-transforms-1/#transform-box >+FloatOrLayoutRect RenderElement::referenceBoxRect(CSSBoxType boxType) const >+{ >+ // CSS box model code is implemented in RenderBox::referenceBoxRect(). >+ >+ // For the legacy SVG engine, RenderElement is the only class that's >+ // present in the ancestor chain of all SVG renderers. In LBSE the >+ // common class is RenderLayerModelObject. Once the legacy SVG engine >+ // is removed this function should be moved to RenderLayerModelObject. >+ // As this method is used by both SVG engines, we need to place it >+ // here in RenderElement, as temporary solution. >+ if (!is<SVGElement>(element())) >+ return LayoutRect(); >+ >+ switch (boxType) { >+ case CSSBoxType::BoxMissing: >+ case CSSBoxType::ContentBox: >+ case CSSBoxType::PaddingBox: >+ case CSSBoxType::FillBox: >+ return objectBoundingBox(); >+ case CSSBoxType::BorderBox: >+ case CSSBoxType::MarginBox: >+ case CSSBoxType::StrokeBox: >+ return strokeBoundingBox(); >+ case CSSBoxType::ViewBox: >+ FloatSize viewportSize; >+ SVGLengthContext(downcast<SVGElement>(element())).determineViewport(viewportSize); >+ return FloatRect({ }, viewportSize); >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return FloatRect(); >+} >+ > } >diff --git a/Source/WebCore/rendering/RenderElement.h b/Source/WebCore/rendering/RenderElement.h >index 51c552cbd9e7fd2b7cbe9d12dcfa3f131ff7df1b..bb6184bceeb18ccbea647c4fcb0eb9a0cc0fcd5e 100644 >--- a/Source/WebCore/rendering/RenderElement.h >+++ b/Source/WebCore/rendering/RenderElement.h >@@ -22,6 +22,7 @@ > > #pragma once > >+#include "FloatOrLayoutRect.h" > #include "HitTestRequest.h" > #include "LengthFunctions.h" > #include "RenderObject.h" >@@ -258,6 +259,13 @@ public: > virtual void animationFinished(const String& /* name */) { } > virtual void transformRelatedPropertyDidChange() { } > >+ // https://www.w3.org/TR/css-transforms-1/#transform-box >+ FloatOrLayoutRect transformReferenceBoxRect(const RenderStyle& style) const { return referenceBoxRect(transformBoxToCSSBoxType(style.transformBox())); } >+ FloatOrLayoutRect transformReferenceBoxRect() const { return transformReferenceBoxRect(style()); } >+ >+ // https://www.w3.org/TR/css-transforms-1/#reference-box >+ virtual FloatOrLayoutRect referenceBoxRect(CSSBoxType) const; >+ > virtual void suspendAnimations(MonotonicTime = MonotonicTime()) { } > std::unique_ptr<RenderStyle> animatedStyle(); > >diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp >index 850bde48e4928e86dc176b62321feed9b686c3cd..3078402bb389939ef5c528775b9f75f1ce1070b5 100644 >--- a/Source/WebCore/rendering/RenderLayer.cpp >+++ b/Source/WebCore/rendering/RenderLayer.cpp >@@ -1296,21 +1296,18 @@ void RenderLayer::dirtyAncestorChainHasBlendingDescendants() > } > #endif > >-static inline LayoutRect computeReferenceRectFromBox(const RenderBox& box, CSSBoxType boxType, const LayoutSize& offsetFromRoot) >+static inline FloatOrLayoutRect computeReferenceBox(const RenderLayerModelObject& renderer, CSSBoxType boxType, const LayoutSize& offsetFromRoot, const LayoutRect& rootRelativeBounds) > { >- auto referenceBox = box.referenceBox(boxType); >- referenceBox.move(offsetFromRoot); >- return referenceBox; >-} >+ // FIXME: [LBSE] Upstream transform support for RenderSVGModelObject derived renderers > >-static inline LayoutRect computeReferenceBox(const RenderObject& renderer, CSSBoxType boxType, const LayoutSize& offsetFromRoot, const LayoutRect& rootRelativeBounds) >-{ > // FIXME: Support different reference boxes for inline content. > // https://bugs.webkit.org/show_bug.cgi?id=129047 > if (!renderer.isBox()) > return rootRelativeBounds; > >- return computeReferenceRectFromBox(downcast<RenderBox>(renderer), boxType, offsetFromRoot); >+ auto referenceBox = renderer.referenceBoxRect(boxType); >+ referenceBox.move(offsetFromRoot); >+ return referenceBox; > } > > void RenderLayer::updateTransform() >@@ -1332,12 +1329,8 @@ void RenderLayer::updateTransform() > if (hasTransform) { > m_transform->makeIdentity(); > >- // FIXME: [LBSE] Upstream reference box computation for RenderSVGModelObject derived renderers >- FloatRect referenceBox; >- if (is<RenderBox>(renderer())) >- referenceBox = snapRectToDevicePixels(downcast<RenderBox>(renderer()).referenceBox(transformBoxToCSSBoxType(renderer().style().transformBox())), renderer().document().deviceScaleFactor()); >- >- renderer().applyTransform(*m_transform, referenceBox); >+ auto referenceBoxRectForPainting = renderer().transformReferenceBoxRect().rectForPainting(renderer().document().deviceScaleFactor()); >+ renderer().applyTransform(*m_transform, referenceBoxRectForPainting); > makeMatrixRenderable(*m_transform, canRender3DTransforms()); > } > >@@ -1366,10 +1359,10 @@ TransformationMatrix RenderLayer::currentTransform(OptionSet<RenderStyle::Transf > auto styleable = Styleable::fromRenderer(renderBox); > if ((styleable && styleable->isRunningAcceleratedTransformAnimation()) || !options.contains(RenderStyle::TransformOperationOption::TransformOrigin)) { > std::unique_ptr<RenderStyle> animatedStyle = renderBox.animatedStyle(); >- auto pixelSnappedBorderRect = snapRectToDevicePixels(renderBox.referenceBox(transformBoxToCSSBoxType(animatedStyle->transformBox())), renderBox.document().deviceScaleFactor()); >+ auto referenceBoxRectForPainting = renderBox.transformReferenceBoxRect().rectForPainting(renderBox.document().deviceScaleFactor()); > > TransformationMatrix transform; >- animatedStyle->applyTransform(transform, pixelSnappedBorderRect, options); >+ animatedStyle->applyTransform(transform, referenceBoxRectForPainting, options); > > makeMatrixRenderable(transform, canRender3DTransforms()); > return transform; >@@ -1801,11 +1794,11 @@ TransformationMatrix RenderLayer::perspectiveTransform(const LayoutRect& layerRe > return { }; > > auto deviceScaleFactor = renderBox.document().deviceScaleFactor(); >- auto referenceBox = renderBox.referenceBox(transformBoxToCSSBoxType(style.transformBox())); >- auto pixelSnappedReferenceBox = snapRectToDevicePixels(referenceBox, deviceScaleFactor); >+ auto referenceBoxRectForPainting = renderBox.transformReferenceBoxRect().rectForPainting(deviceScaleFactor); >+ // FIXME: [LBSE] Avoid pixel snapping in SVG subtree. > auto snappedLayerRect = snapRectToDevicePixels(layerRect, deviceScaleFactor); > >- auto perspectiveOrigin = pixelSnappedReferenceBox.location() - toFloatSize(snappedLayerRect.location()) + floatPointForLengthPoint(style.perspectiveOrigin(), pixelSnappedReferenceBox.size()); >+ auto perspectiveOrigin = referenceBoxRectForPainting.location() - toFloatSize(snappedLayerRect.location()) + floatPointForLengthPoint(style.perspectiveOrigin(), referenceBoxRectForPainting.size()); > > // A perspective origin of 0,0 makes the vanishing point in the center of the element. > // We want it to be in the top-left, so subtract half the height and width. >@@ -1823,6 +1816,7 @@ FloatPoint RenderLayer::perspectiveOrigin() const > { > if (!renderer().hasTransformRelatedProperty()) > return { }; >+ // FIXME: This uses the wrong, transform-box unaware, geometry. > return floatPointForLengthPoint(renderer().style().perspectiveOrigin(), rendererBorderBoxRect().size()); > } > >@@ -3212,22 +3206,8 @@ std::pair<Path, WindRule> RenderLayer::computeClipPath(const LayoutSize& offsetF > > if (is<ShapePathOperation>(*style.clipPath())) { > auto& clipPath = downcast<ShapePathOperation>(*style.clipPath()); >- >- LayoutRect referenceBox; >- if (is<RenderBox>(renderer())) { >- referenceBox = downcast<RenderBox>(renderer()).referenceBox(clipPath.referenceBox()); >- referenceBox.move(offsetFromRoot); >-#if ENABLE(LAYER_BASED_SVG_ENGINE) >- } else if (is<RenderSVGModelObject>(renderer())) { >- // FIXME: [LBSE] Upstream clipping support for RenderSVGModelObject derived renderers >-#endif >- } else { >- // Reference box for inlines is not well defined: https://github.com/w3c/csswg-drafts/issues/6383 >- referenceBox = rootRelativeBoundsForNonBoxes; >- } >- >- auto snappedReferenceBox = snapRectToDevicePixels(referenceBox, deviceScaleFactor); >- return { clipPath.pathForReferenceRect(snappedReferenceBox), clipPath.windRule() }; >+ auto referenceBoxRect = computeReferenceBox(renderer(), clipPath.referenceBox(), offsetFromRoot, rootRelativeBoundsForNonBoxes); >+ return { clipPath.pathForReferenceRect(referenceBoxRect.rectForPainting(deviceScaleFactor)), clipPath.windRule() }; > } > > if (is<BoxPathOperation>(*style.clipPath()) && is<RenderBox>(renderer())) { >@@ -3269,16 +3249,20 @@ void RenderLayer::setupClipPath(GraphicsContext& context, GraphicsContextStateSa > // Use the border box as the reference box, even though this is not clearly specified: https://github.com/w3c/csswg-drafts/issues/5786. > // clippedContentBounds is used as the reference box for inlines, which is also poorly specified: https://github.com/w3c/csswg-drafts/issues/6383. > auto referenceBox = computeReferenceBox(renderer(), CSSBoxType::BorderBox, offsetFromRoot, clippedContentBounds); >- auto snappedReferenceBox = snapRectToDevicePixels(referenceBox, renderer().document().deviceScaleFactor()); >- auto offset = snappedReferenceBox.location(); > >+ FloatRect referenceBoxRect = referenceBox; >+ referenceBoxRect.setLocation({ }); >+ >+ auto referenceBoxRectForPainting = referenceBox.rectForPainting(renderer().document().deviceScaleFactor()); >+ auto offset = referenceBoxRectForPainting.location(); >+ >+ // FIXME: [LBSE] Avoid pixel snapping in SVG subtree. > auto snappedClippingBounds = snapRectToDevicePixels(clippedContentBounds, renderer().document().deviceScaleFactor()); > snappedClippingBounds.moveBy(-offset); > > stateSaver.save(); > context.translate(offset); >- FloatRect clipPathReferenceBox { { }, referenceBox.size() }; >- clipperRenderer->applyClippingToContext(context, renderer(), clipPathReferenceBox, snappedClippingBounds, renderer().style().effectiveZoom()); >+ clipperRenderer->applyClippingToContext(context, renderer(), referenceBoxRect, snappedClippingBounds, renderer().style().effectiveZoom()); > context.translate(-offset); > } > } >diff --git a/Source/WebCore/rendering/svg/SVGRenderSupport.cpp b/Source/WebCore/rendering/svg/SVGRenderSupport.cpp >index cc38ec7030e60ce1759b13287de25f73d565c858..e2beb4ba8c1157dcbb128649a3ede56e384e8d09 100644 >--- a/Source/WebCore/rendering/svg/SVGRenderSupport.cpp >+++ b/Source/WebCore/rendering/svg/SVGRenderSupport.cpp >@@ -343,26 +343,6 @@ bool SVGRenderSupport::filtersForceContainerLayout(const RenderElement& renderer > 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; >diff --git a/Source/WebCore/rendering/svg/SVGRenderSupport.h b/Source/WebCore/rendering/svg/SVGRenderSupport.h >index 9ccfcbeb577a773dc8807d9539d62a81e5619b89..d43d0c7f758d15fb7046c91be0ca9da53dd85602 100644 >--- a/Source/WebCore/rendering/svg/SVGRenderSupport.h >+++ b/Source/WebCore/rendering/svg/SVGRenderSupport.h >@@ -82,8 +82,6 @@ public: > > static void styleChanged(RenderElement&, const RenderStyle*); > >- static FloatRect transformReferenceBox(const RenderElement&, const SVGElement&, const RenderStyle&); >- > #if ENABLE(CSS_COMPOSITING) > static bool isolatesBlending(const RenderStyle&); > static void updateMaskedAncestorShouldIsolateBlending(const RenderElement&); >diff --git a/Source/WebCore/svg/SVGGraphicsElement.cpp b/Source/WebCore/svg/SVGGraphicsElement.cpp >index dc108e5b23c46da95600a02aac6207ed5b665696..a6099564fac3438cb2b843b093908b722e0dc063 100644 >--- a/Source/WebCore/svg/SVGGraphicsElement.cpp >+++ b/Source/WebCore/svg/SVGGraphicsElement.cpp >@@ -80,12 +80,10 @@ AffineTransform SVGGraphicsElement::animatedLocalTransform() const > > // Honor any of the transform-related CSS properties if set. > if (hasSpecifiedTransform || (style && (style->translate() || style->scale() || style->rotate()))) { >- 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/ > TransformationMatrix transform; >- style->applyTransform(transform, boundingBox); >+ style->applyTransform(transform, renderer()->transformReferenceBoxRect()); > > // Flatten any 3D transform. > matrix = transform.toAffineTransform(); >@@ -100,7 +98,7 @@ AffineTransform SVGGraphicsElement::animatedLocalTransform() const > > // If we didn't have the CSS "transform" property set, we must account for the "transform" attribute. > if (!hasSpecifiedTransform && style) { >- auto boundingBox = SVGRenderSupport::transformReferenceBox(*renderer(), *this, *style); >+ FloatRect boundingBox = renderer()->transformReferenceBoxRect(); > auto t = floatPointForLengthPoint(style->transformOriginXY(), boundingBox.size()) + boundingBox.location(); > matrix.translate(t); > matrix *= transform().concatenate();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 237711
:
454350
|
454351
|
454412
|
454559
|
454562
|
454818
|
455227
|
456619
|
456754
|
456902
|
456979
|
457243