Title: [275935] trunk/Source/WebCore
- Revision
- 275935
- Author
- [email protected]
- Date
- 2021-04-13 23:59:58 -0700 (Tue, 13 Apr 2021)
Log Message
Make SVGElement::getBoundingBox retrieve bbox from RenderObject
https://bugs.webkit.org/show_bug.cgi?id=224482
Patch by Rob Buis <[email protected]> on 2021-04-13
Reviewed by Zalan Bujtas.
Make SVGElement::getBoundingBox retrieve bbox from RenderObject.
Also make it const and return an Optional.
* dom/Element.cpp:
(WebCore::Element::boundsInRootViewSpace):
(WebCore::Element::absoluteEventBounds):
(WebCore::Element::boundingAbsoluteRectWithoutLayout):
* page/ResizeObservation.cpp:
(WebCore::ResizeObservation::computeObservedSize const):
* svg/SVGElement.cpp:
(WebCore::SVGElement::getBoundingBox const):
(WebCore::SVGElement::getBoundingBox): Deleted.
* svg/SVGElement.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (275934 => 275935)
--- trunk/Source/WebCore/ChangeLog 2021-04-14 06:24:06 UTC (rev 275934)
+++ trunk/Source/WebCore/ChangeLog 2021-04-14 06:59:58 UTC (rev 275935)
@@ -1,3 +1,24 @@
+2021-04-13 Rob Buis <[email protected]>
+
+ Make SVGElement::getBoundingBox retrieve bbox from RenderObject
+ https://bugs.webkit.org/show_bug.cgi?id=224482
+
+ Reviewed by Zalan Bujtas.
+
+ Make SVGElement::getBoundingBox retrieve bbox from RenderObject.
+ Also make it const and return an Optional.
+
+ * dom/Element.cpp:
+ (WebCore::Element::boundsInRootViewSpace):
+ (WebCore::Element::absoluteEventBounds):
+ (WebCore::Element::boundingAbsoluteRectWithoutLayout):
+ * page/ResizeObservation.cpp:
+ (WebCore::ResizeObservation::computeObservedSize const):
+ * svg/SVGElement.cpp:
+ (WebCore::SVGElement::getBoundingBox const):
+ (WebCore::SVGElement::getBoundingBox): Deleted.
+ * svg/SVGElement.h:
+
2021-04-13 Kimmo Kinnunen <[email protected]>
AudioSourceProviderAVFObjC should lock all multithreaded objects
Modified: trunk/Source/WebCore/dom/Element.cpp (275934 => 275935)
--- trunk/Source/WebCore/dom/Element.cpp 2021-04-14 06:24:06 UTC (rev 275934)
+++ trunk/Source/WebCore/dom/Element.cpp 2021-04-14 06:59:58 UTC (rev 275935)
@@ -1451,9 +1451,8 @@
if (isSVGElement() && renderer()) {
// Get the bounding rectangle from the SVG model.
SVGElement& svgElement = downcast<SVGElement>(*this);
- FloatRect localRect;
- if (svgElement.getBoundingBox(localRect))
- quads.append(renderer()->localToAbsoluteQuad(localRect));
+ if (auto localRect = svgElement.getBoundingBox())
+ quads.append(renderer()->localToAbsoluteQuad(*localRect));
} else {
// Get the bounding rectangle from the box model.
if (renderBoxModelObject())
@@ -1512,9 +1511,8 @@
if (isSVGElement()) {
// Get the bounding rectangle from the SVG model.
SVGElement& svgElement = downcast<SVGElement>(*this);
- FloatRect localRect;
- if (svgElement.getBoundingBox(localRect, SVGLocatable::DisallowStyleUpdate))
- result = LayoutRect(renderer()->localToAbsoluteQuad(localRect, UseTransforms, &includesFixedPositionElements).boundingBox());
+ if (auto localRect = svgElement.getBoundingBox())
+ result = LayoutRect(renderer()->localToAbsoluteQuad(*localRect, UseTransforms, &includesFixedPositionElements).boundingBox());
} else {
auto* renderer = this->renderer();
if (is<RenderBox>(renderer)) {
@@ -1650,9 +1648,8 @@
if (isSVGElement() && renderer && !renderer->isSVGRoot()) {
// Get the bounding rectangle from the SVG model.
SVGElement& svgElement = downcast<SVGElement>(*this);
- FloatRect localRect;
- if (svgElement.getBoundingBox(localRect, SVGLocatable::DisallowStyleUpdate))
- quads.append(renderer->localToAbsoluteQuad(localRect));
+ if (auto localRect = svgElement.getBoundingBox())
+ quads.append(renderer->localToAbsoluteQuad(*localRect));
} else if (auto pair = listBoxElementBoundingBox(*this)) {
renderer = pair.value().first;
quads.append(renderer->localToAbsoluteQuad(FloatQuad { pair.value().second }));
Modified: trunk/Source/WebCore/page/ResizeObservation.cpp (275934 => 275935)
--- trunk/Source/WebCore/page/ResizeObservation.cpp 2021-04-14 06:24:06 UTC (rev 275934)
+++ trunk/Source/WebCore/page/ResizeObservation.cpp 2021-04-14 06:59:58 UTC (rev 275935)
@@ -56,9 +56,8 @@
LayoutSize ResizeObservation::computeObservedSize() const
{
if (m_target->isSVGElement()) {
- FloatRect svgRect;
- if (downcast<SVGElement>(*m_target).getBoundingBox(svgRect))
- return LayoutSize(svgRect.width(), svgRect.height());
+ if (auto svgRect = downcast<SVGElement>(*m_target).getBoundingBox())
+ return LayoutSize(svgRect->width(), svgRect->height());
}
auto* box = m_target->renderBox();
if (box) {
Modified: trunk/Source/WebCore/svg/SVGElement.cpp (275934 => 275935)
--- trunk/Source/WebCore/svg/SVGElement.cpp 2021-04-14 06:24:06 UTC (rev 275934)
+++ trunk/Source/WebCore/svg/SVGElement.cpp 2021-04-14 06:59:58 UTC (rev 275935)
@@ -293,14 +293,13 @@
return m_svgRareData->instances();
}
-bool SVGElement::getBoundingBox(FloatRect& rect, SVGLocatable::StyleUpdateStrategy styleUpdateStrategy)
+Optional<FloatRect> SVGElement::getBoundingBox() const
{
- // FIXME: should retrieve the value from the associated RenderObject.
if (is<SVGGraphicsElement>(*this)) {
- rect = downcast<SVGGraphicsElement>(*this).getBBox(styleUpdateStrategy);
- return true;
+ if (auto renderer = this->renderer())
+ return renderer->objectBoundingBox();
}
- return false;
+ return WTF::nullopt;
}
SVGElement* SVGElement::correspondingElement() const
Modified: trunk/Source/WebCore/svg/SVGElement.h (275934 => 275935)
--- trunk/Source/WebCore/svg/SVGElement.h 2021-04-14 06:24:06 UTC (rev 275934)
+++ trunk/Source/WebCore/svg/SVGElement.h 2021-04-14 06:59:58 UTC (rev 275935)
@@ -91,7 +91,7 @@
// The instances of an element are clones made in shadow trees to implement <use>.
const HashSet<SVGElement*>& instances() const;
- bool getBoundingBox(FloatRect&, SVGLocatable::StyleUpdateStrategy = SVGLocatable::AllowStyleUpdate);
+ Optional<FloatRect> getBoundingBox() const;
SVGElement* correspondingElement() const;
RefPtr<SVGUseElement> correspondingUseElement() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes