⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287873 in webkit


Ignore:
Timestamp:
Jan 11, 2022, 4:57:41 AM (5 years ago)
Author:
Nikolas Zimmermann
Message:

[LBSE] Introduce SVGBoundingBoxComputation
https://bugs.webkit.org/show_bug.cgi?id=234632
<rdar://problem/87001334>

Reviewed by Rob Buis.

Upstream SVGBoundingBoxComputation, a utility class
implementing the SVG2 "bounding box computation" algorithm,
as spec'ed in https://svgwg.org/svg2-draft/coords.html#BoundingBoxes.

SVG2 also specifies a new optional argument for getBBox() & friends:
DOMRect getBBox(optional SVGBoundingBoxOptions options = {});

SVGBoundingBoxOptions can be implemented using SVGBoundingBoxComputation:
exposing this to the Web is left for the future, once more of LBSE is ready.

LBSE utilizes SVGBoundingBoxComputation whenever any kind of bounding box
needs to be computed (object / stroke / decorated (e.g. including markers).

Covered by existing tests, no change in behaviour.

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • rendering/svg/LegacyRenderSVGModelObject.h:

(WebCore::LegacyRenderSVGModelObject::visualOverflowRectEquivalent const): Deleted.

  • rendering/svg/RenderSVGModelObject.h:

(WebCore::RenderSVGModelObject::visualOverflowRectEquivalent const):

  • rendering/svg/RenderSVGRoot.cpp:

(WebCore::RenderSVGRoot::layout):

  • rendering/svg/RenderSVGRoot.h:
  • rendering/svg/SVGBoundingBoxComputation.cpp: Added.

(WebCore::SVGBoundingBoxComputation::SVGBoundingBoxComputation):
(WebCore::SVGBoundingBoxComputation::~SVGBoundingBoxComputation):
(WebCore::SVGBoundingBoxComputation::computeDecoratedBoundingBox const):
(WebCore::SVGBoundingBoxComputation::handleShapeOrTextOrInline const):
(WebCore::SVGBoundingBoxComputation::handleRootOrContainer const):
(WebCore::SVGBoundingBoxComputation::handleForeignObjectOrImage const):
(WebCore::SVGBoundingBoxComputation::adjustBoxForClippingAndEffects const):

  • rendering/svg/SVGBoundingBoxComputation.h: Added.

(WebCore::SVGBoundingBoxComputation::computeDecoratedBoundingBox):
(WebCore::SVGBoundingBoxComputation::computeRepaintBoundingBox):
(WebCore::SVGBoundingBoxComputation::computeVisualOverflowRect):

Location:
trunk/Source/WebCore
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287872 r287873  
     12022-01-11  Nikolas Zimmermann  <nzimmermann@igalia.com>
     2
     3        [LBSE] Introduce SVGBoundingBoxComputation
     4        https://bugs.webkit.org/show_bug.cgi?id=234632
     5        <rdar://problem/87001334>
     6
     7        Reviewed by Rob Buis.
     8
     9        Upstream SVGBoundingBoxComputation, a utility class
     10        implementing the SVG2 "bounding box computation" algorithm,
     11        as spec'ed in https://svgwg.org/svg2-draft/coords.html#BoundingBoxes.
     12
     13        SVG2 also specifies a new optional argument for getBBox() & friends:
     14        DOMRect getBBox(optional SVGBoundingBoxOptions options = {});
     15
     16        SVGBoundingBoxOptions can be implemented using SVGBoundingBoxComputation:
     17        exposing this to the Web is left for the future, once more of LBSE is ready.
     18
     19        LBSE utilizes SVGBoundingBoxComputation whenever any kind of bounding box
     20        needs to be computed (object / stroke / decorated (e.g. including markers).
     21
     22        Covered by existing tests, no change in behaviour.
     23
     24        * Sources.txt:
     25        * WebCore.xcodeproj/project.pbxproj:
     26        * rendering/svg/LegacyRenderSVGModelObject.h:
     27        (WebCore::LegacyRenderSVGModelObject::visualOverflowRectEquivalent const): Deleted.
     28        * rendering/svg/RenderSVGModelObject.h:
     29        (WebCore::RenderSVGModelObject::visualOverflowRectEquivalent const):
     30        * rendering/svg/RenderSVGRoot.cpp:
     31        (WebCore::RenderSVGRoot::layout):
     32        * rendering/svg/RenderSVGRoot.h:
     33        * rendering/svg/SVGBoundingBoxComputation.cpp: Added.
     34        (WebCore::SVGBoundingBoxComputation::SVGBoundingBoxComputation):
     35        (WebCore::SVGBoundingBoxComputation::~SVGBoundingBoxComputation):
     36        (WebCore::SVGBoundingBoxComputation::computeDecoratedBoundingBox const):
     37        (WebCore::SVGBoundingBoxComputation::handleShapeOrTextOrInline const):
     38        (WebCore::SVGBoundingBoxComputation::handleRootOrContainer const):
     39        (WebCore::SVGBoundingBoxComputation::handleForeignObjectOrImage const):
     40        (WebCore::SVGBoundingBoxComputation::adjustBoxForClippingAndEffects const):
     41        * rendering/svg/SVGBoundingBoxComputation.h: Added.
     42        (WebCore::SVGBoundingBoxComputation::computeDecoratedBoundingBox):
     43        (WebCore::SVGBoundingBoxComputation::computeRepaintBoundingBox):
     44        (WebCore::SVGBoundingBoxComputation::computeVisualOverflowRect):
     45
    1462022-01-11  Carlos Garcia Campos  <cgarcia@igalia.com>
    247
  • trunk/Source/WebCore/Sources.txt

    r287834 r287873  
    25022502rendering/svg/RenderSVGTransformableContainer.cpp
    25032503rendering/svg/RenderSVGViewportContainer.cpp
     2504rendering/svg/SVGBoundingBoxComputation.cpp
    25042505rendering/svg/SVGInlineFlowBox.cpp
    25052506rendering/svg/SVGInlineTextBox.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r287834 r287873  
    245245                0854B01B1255E4E600B9CDD0 /* RenderSVGTextPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 0854B0091255E4E600B9CDD0 /* RenderSVGTextPath.h */; };
    246246                0854B01D1255E4E600B9CDD0 /* RenderSVGTSpan.h in Headers */ = {isa = PBXBuildFile; fileRef = 0854B00B1255E4E600B9CDD0 /* RenderSVGTSpan.h */; };
     247                0844B01D1255B4E600B9CDD0 /* SVGBoundingBoxComputation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0844B01D1255E4E600B9CDD0 /* SVGBoundingBoxComputation.h */; };
    247248                0854B01F1255E4E600B9CDD0 /* SVGInlineFlowBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 0854B00D1255E4E600B9CDD0 /* SVGInlineFlowBox.h */; };
    248249                0854B0211255E4E600B9CDD0 /* SVGInlineTextBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 0854B00F1255E4E600B9CDD0 /* SVGInlineTextBox.h */; };
     
    61866187                0854B0091255E4E600B9CDD0 /* RenderSVGTextPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGTextPath.h; sourceTree = "<group>"; };
    61876188                0854B00B1255E4E600B9CDD0 /* RenderSVGTSpan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGTSpan.h; sourceTree = "<group>"; };
     6189                0834B00C1244E4E600B9CDD0 /* SVGBoundingBoxComputation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGBoundingBoxComputation.cpp; sourceTree = "<group>"; };
     6190                0844B01D1255E4E600B9CDD0 /* SVGBoundingBoxComputation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGBoundingBoxComputation.h; sourceTree = "<group>"; };
    61886191                0854B00C1255E4E600B9CDD0 /* SVGInlineFlowBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGInlineFlowBox.cpp; sourceTree = "<group>"; };
    61896192                0854B00D1255E4E600B9CDD0 /* SVGInlineFlowBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGInlineFlowBox.h; sourceTree = "<group>"; };
     
    1899518998                                436708AB12D9CA4B00044234 /* RenderSVGViewportContainer.cpp */,
    1899618999                                436708AC12D9CA4B00044234 /* RenderSVGViewportContainer.h */,
     19000                                0834B00C1244E4E600B9CDD0 /* SVGBoundingBoxComputation.cpp */,
     19001                                0844B01D1255E4E600B9CDD0 /* SVGBoundingBoxComputation.h */,
    1899719002                                0854B00C1255E4E600B9CDD0 /* SVGInlineFlowBox.cpp */,
    1899819003                                0854B00D1255E4E600B9CDD0 /* SVGInlineFlowBox.h */,
     
    3731637321                                B22279950D00BF220071B782 /* SVGAnimateTransformElement.h in Headers */,
    3731737322                                B22279980D00BF220071B782 /* SVGAnimationElement.h in Headers */,
     37323                                0844B01D1255B4E600B9CDD0 /* SVGBoundingBoxComputation.h in Headers */,
    3731837324                                B222799C0D00BF220071B782 /* SVGCircleElement.h in Headers */,
    3731937325                                B222799F0D00BF220071B782 /* SVGClipPathElement.h in Headers */,
  • trunk/Source/WebCore/rendering/svg/LegacyRenderSVGModelObject.h

    r286962 r287873  
    6363    SVGElement& element() const { return downcast<SVGElement>(nodeForNonAnonymous()); }
    6464
    65     // FIXME: [LBSE] Upstream SVGBoundingBoxComputation
    66     // LayoutRect visualOverflowRectEquivalent() const { return SVGBoundingBoxComputation::computeVisualOverflowRect(*this); }
    67     LayoutRect visualOverflowRectEquivalent() const { return LayoutRect(); }
    68 
    6965protected:
    7066    LegacyRenderSVGModelObject(SVGElement&, RenderStyle&&);
  • trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.h

    r287538 r287873  
    3535#include "RenderLayer.h"
    3636#include "RenderLayerModelObject.h"
    37 // FIXME: [LBSE] Upstream SVGBoundingBoxComputation
    38 // #include "SVGBoundingBoxComputation.h"
     37#include "SVGBoundingBoxComputation.h"
    3938#include "SVGElement.h"
    4039#include "SVGRenderSupport.h"
     
    7069    LayoutRect frameRectEquivalent() const { return m_layoutRect; }
    7170
    72     LayoutRect visualOverflowRectEquivalent() const
    73     {
    74         // FIXME: [LBSE] Upstream SVGBoundingBoxComputation
    75         // return SVGBoundingBoxComputation::computeVisualOverflowRect(*this);
    76         return LayoutRect();
    77     }
     71    LayoutRect visualOverflowRectEquivalent() const { return SVGBoundingBoxComputation::computeVisualOverflowRect(*this); }
    7872
    7973    void applyTopLeftLocationOffsetEquivalent(LayoutPoint& point) const { point.moveBy(layoutLocation()); }
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp

    r287731 r287873  
    194194    updateLayerInformation();
    195195
    196     /* FIXME: [LBSE] Upstream SVGContainerLayout / SVGBoundingBoxComputation
    197196    {
     197        /* FIXME: [LBSE] Upstream SVGContainerLayout
    198198        SVGContainerLayout containerLayout(*this);
    199199        containerLayout.layoutChildren(needsLayout || SVGRenderSupport::filtersForceContainerLayout(*this));
     200        */
    200201
    201202        SVGBoundingBoxComputation boundingBoxComputation(*this);
     
    203204        m_strokeBoundingBox = boundingBoxComputation.computeDecoratedBoundingBox(SVGBoundingBoxComputation::strokeBoundingBoxDecoration);
    204205    }
    205     */
    206206
    207207    // FIXME: [LBSE] Upstream SVGContainerLayout -- remove SVGRenderSupport::layoutChildren.
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h

    r286842 r287873  
    2727#include "FloatRect.h"
    2828#include "RenderReplaced.h"
    29 // FIXME: [LBSE] Upstream SVGBoundingBoxComputation
    30 // #include "SVGBoundingBoxComputation.h"
     29#include "SVGBoundingBoxComputation.h"
    3130
    3231namespace WebCore {
     
    7372    FloatRect objectBoundingBox() const final { return m_objectBoundingBox; }
    7473    FloatRect strokeBoundingBox() const final { return m_strokeBoundingBox; }
     74    FloatRect repaintRectInLocalCoordinates() const final { return SVGBoundingBoxComputation::computeRepaintBoundingBox(*this); }
    7575
    76     // FIXME: [LBSE] Mark final, add repaintBoundingBox() to RenderObject
    77     FloatRect repaintBoundingBox() const
    78     {
    79         // FIXME: [LBSE] Upstream SVGBoundingBoxComputation
    80         // return SVGBoundingBoxComputation::computeRepaintBoundingBox(*this);
    81         return m_strokeBoundingBox;
    82     }
    83 
    84     LayoutRect visualOverflowRectEquivalent() const
    85     {
    86         // FIXME: [LBSE] Upstream SVGBoundingBoxComputation
    87         // return SVGBoundingBoxComputation::computeVisualOverflowRect(*this);
    88         return LayoutRect();
    89     }
     76    LayoutRect visualOverflowRectEquivalent() const { return SVGBoundingBoxComputation::computeVisualOverflowRect(*this); }
    9077
    9178private:
  • trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp

    r287832 r287873  
    401401}
    402402
    403 FloatRect RenderSVGShape::computeMarkerBoundingBox() const
     403FloatRect RenderSVGShape::computeMarkerBoundingBox(const SVGBoundingBoxComputation::DecorationOptions&) const
    404404{
    405405    if (m_markerPositions.isEmpty())
     
    418418    unsigned size = m_markerPositions.size();
    419419    for (unsigned i = 0; i < size; ++i) {
    420         if (RenderSVGResourceMarker* marker = markerForType(m_markerPositions[i].type, markerStart, markerMid, markerEnd))
     420        if (auto* marker = markerForType(m_markerPositions[i].type, markerStart, markerMid, markerEnd)) {
     421            // FIXME: [LBSE] Upstream RenderSVGResourceMarker changes
     422            // boundaries.unite(marker->computeMarkerBoundingBox(options, marker->markerTransformation(m_markerPositions[i].origin, m_markerPositions[i].angle, strokeWidth())));
    421423            boundaries.unite(marker->markerBoundaries(marker->markerTransformation(m_markerPositions[i].origin, m_markerPositions[i].angle, strokeWidth())));
     424        }
    422425    }
    423426    return boundaries;
  • trunk/Source/WebCore/rendering/svg/RenderSVGShape.h

    r287832 r287873  
    3131#include "FloatRect.h"
    3232#include "RenderSVGModelObject.h"
    33 // FIXME: [LBSE] Upstream SVGBoundingBoxComputation
    34 // #include "SVGBoundingBoxComputation.h"
     33#include "SVGBoundingBoxComputation.h"
    3534#include "SVGGraphicsElement.h"
    3635#include "SVGMarkerData.h"
     
    8180    FloatRect objectBoundingBox() const final { return m_fillBoundingBox; }
    8281    FloatRect strokeBoundingBox() const final { return m_strokeBoundingBox; }
     82    FloatRect repaintRectInLocalCoordinates() const final { return SVGBoundingBoxComputation::computeRepaintBoundingBox(*this); }
    8383
    84     FloatRect repaintRectInLocalCoordinates() const final
    85     {
    86         // FIXME: [LBSE] Upstream SVGBoundingBoxComputation
    87         // return SVGBoundingBoxComputation::computeRepaintBoundingBox(*this); }
    88         return FloatRect();
    89     }
    90 
    91     FloatRect computeMarkerBoundingBox() const;
     84    FloatRect computeMarkerBoundingBox(const SVGBoundingBoxComputation::DecorationOptions&) const;
    9285
    9386protected:
Note: See TracChangeset for help on using the changeset viewer.