From 7c91c0996b0e12d799bad794c2698d10f08a24f0 Mon Sep 17 00:00:00 2001 From: Sandor Molnar Date: Fri, 7 Jun 2024 11:06:26 +0300 Subject: [PATCH] Backed out changeset 6f3c000986ca (bug 1019326) for causing mochitest failures @ dom/svg/test/test_getBBox-options.html CLOSED TREE --- dom/svg/SVGGraphicsElement.cpp | 6 +- dom/svg/test/bbox-helper.svg | 2 - ...s-helper.svg => getBBox-method-helper.svg} | 34 +-- dom/svg/test/mochitest.toml | 4 +- dom/svg/test/test_bbox.xhtml | 1 - dom/svg/test/test_getBBox-method.html | 248 ++++++++++++++++++ dom/svg/test/test_getBBox-options.html | 244 ----------------- layout/svg/SVGClipPathFrame.cpp | 11 +- layout/svg/SVGUtils.cpp | 20 +- 9 files changed, 288 insertions(+), 282 deletions(-) rename dom/svg/test/{getBBox-options-helper.svg => getBBox-method-helper.svg} (93%) create mode 100644 dom/svg/test/test_getBBox-method.html delete mode 100644 dom/svg/test/test_getBBox-options.html diff --git a/dom/svg/SVGGraphicsElement.cpp b/dom/svg/SVGGraphicsElement.cpp index 7b951b5e9478..52bb023e6155 100644 --- a/dom/svg/SVGGraphicsElement.cpp +++ b/dom/svg/SVGGraphicsElement.cpp @@ -102,7 +102,7 @@ already_AddRefed SVGGraphicsElement::GetBBox( } uint32_t flags = 0; if (aOptions.mFill) { - flags |= SVGUtils::eBBoxIncludeFillGeometry; + flags |= SVGUtils::eBBoxIncludeFill; } if (aOptions.mStroke) { flags |= SVGUtils::eBBoxIncludeStroke; @@ -114,11 +114,11 @@ already_AddRefed SVGGraphicsElement::GetBBox( flags |= SVGUtils::eBBoxIncludeClipped; } if (flags == 0) { - return do_AddRef(new SVGRect(this, {})); + return do_AddRef(new SVGRect(this, gfx::Rect())); } if (flags == SVGUtils::eBBoxIncludeMarkers || flags == SVGUtils::eBBoxIncludeClipped) { - flags |= SVGUtils::eBBoxIncludeFillGeometry; + flags |= SVGUtils::eBBoxIncludeFill; } flags |= SVGUtils::eUseUserSpaceOfUseElement; return do_AddRef(new SVGRect(this, ToRect(SVGUtils::GetBBox(frame, flags)))); diff --git a/dom/svg/test/bbox-helper.svg b/dom/svg/test/bbox-helper.svg index df011a8b545e..40aa01cb2aa2 100644 --- a/dom/svg/test/bbox-helper.svg +++ b/dom/svg/test/bbox-helper.svg @@ -36,8 +36,6 @@ - - diff --git a/dom/svg/test/getBBox-options-helper.svg b/dom/svg/test/getBBox-method-helper.svg similarity index 93% rename from dom/svg/test/getBBox-options-helper.svg rename to dom/svg/test/getBBox-method-helper.svg index 57289734379f..8172b2d864c0 100644 --- a/dom/svg/test/getBBox-options-helper.svg +++ b/dom/svg/test/getBBox-method-helper.svg @@ -147,28 +147,28 @@ 99 - - - - - - - - +
-There are issues of dynamic loading required for tiling. According to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed. +There are issues of dynamic loading required for tiling. Accroding to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed.
-There are issues of dynamic loading required for tiling. According to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed. +There are issues of dynamic loading required for tiling. Accroding to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed.
-There are issues of dynamic loading required for tiling. According to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed. +There are issues of dynamic loading required for tiling. Accroding to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed.
- +
-There are issues of dynamic loading required for tiling. According to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed. +There are issues of dynamic loading required for tiling. Accroding to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed.
-There are issues of dynamic loading required for tiling. According to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed. +There are issues of dynamic loading required for tiling. Accroding to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed.
-There are issues of dynamic loading required for tiling. According to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed. +There are issues of dynamic loading required for tiling. Accroding to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed.
-There are issues of dynamic loading required for tiling. According to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed. +There are issues of dynamic loading required for tiling. Accroding to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed.
-There are issues of dynamic loading required for tiling. According to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed. +There are issues of dynamic loading required for tiling. Accroding to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed.
diff --git a/dom/svg/test/mochitest.toml b/dom/svg/test/mochitest.toml index c18ab706b942..ac9792386002 100644 --- a/dom/svg/test/mochitest.toml +++ b/dom/svg/test/mochitest.toml @@ -15,7 +15,7 @@ support-files = [ "bounds-helper.svg", "dataTypes-helper.svg", "fragments-helper.svg", - "getBBox-options-helper.svg", + "getBBox-method-helper.svg", "getCTM-helper.svg", "getSubStringLength-helper.svg", "matrixUtils.js", @@ -82,7 +82,7 @@ support-files = [ ["test_fragments.html"] -["test_getBBox-options.html"] +["test_getBBox-method.html"] ["test_getCTM.html"] diff --git a/dom/svg/test/test_bbox.xhtml b/dom/svg/test/test_bbox.xhtml index c77f2c7092e2..19e1aadf2cbd 100644 --- a/dom/svg/test/test_bbox.xhtml +++ b/dom/svg/test/test_bbox.xhtml @@ -77,7 +77,6 @@ function run() { checkBBox("v", 95, 45, 10, 155, 0.001); checkBBox("h", 195, 45, 105, 55, 0.001); checkBBox("e", 95, 95, 10, 10, 0.001); - checkBBox("none", 0, 0, 10, 10, 0.001); checkBBox("use_v", 195, 145, 10, 155, 0.001); checkBBox("use_h", 295, 145, 105, 55, 0.001); checkBBox("use_e", 195, 195, 10, 10, 0.001); diff --git a/dom/svg/test/test_getBBox-method.html b/dom/svg/test/test_getBBox-method.html new file mode 100644 index 000000000000..bad8f1ffedef --- /dev/null +++ b/dom/svg/test/test_getBBox-method.html @@ -0,0 +1,248 @@ + + + + + Test case for Bug 999964 + + + + + +Mozilla Bug 999964 +

+ + + + +
+
+
+ + diff --git a/dom/svg/test/test_getBBox-options.html b/dom/svg/test/test_getBBox-options.html deleted file mode 100644 index 442c3c7b6564..000000000000 --- a/dom/svg/test/test_getBBox-options.html +++ /dev/null @@ -1,244 +0,0 @@ - - - - - Test case for Bug 999964 - - - - - -Mozilla Bug 999964 -

- - - - -
-
-
- - diff --git a/layout/svg/SVGClipPathFrame.cpp b/layout/svg/SVGClipPathFrame.cpp index 3dc01a57fa7c..b7691f0647b5 100644 --- a/layout/svg/SVGClipPathFrame.cpp +++ b/layout/svg/SVGClipPathFrame.cpp @@ -424,15 +424,15 @@ SVGBBox SVGClipPathFrame::GetBBoxForClipPathFrame(const SVGBBox& aBBox, } nsIContent* node = GetContent()->GetFirstChild(); - SVGBBox unionBBox; + SVGBBox unionBBox, tmpBBox; for (; node; node = node->GetNextSibling()) { if (nsIFrame* frame = node->GetPrimaryFrame()) { ISVGDisplayableFrame* svg = do_QueryFrame(frame); if (svg) { gfxMatrix matrix = SVGUtils::GetTransformMatrixInUserSpace(frame) * aMatrix; - SVGBBox tmpBBox = svg->GetBBoxContribution( - gfx::ToMatrix(matrix), SVGUtils::eBBoxIncludeFillGeometry); + tmpBBox = svg->GetBBoxContribution(gfx::ToMatrix(matrix), + SVGUtils::eBBoxIncludeFill); SVGClipPathFrame* clipPathFrame; if (SVGObserverUtils::GetAndObserveClipPath(frame, &clipPathFrame) != SVGObserverUtils::eHasRefsSomeInvalid && @@ -449,8 +449,9 @@ SVGBBox SVGClipPathFrame::GetBBoxForClipPathFrame(const SVGBBox& aBBox, } if (clipPathThatClipsClipPath) { - unionBBox.Intersect(clipPathThatClipsClipPath->GetBBoxForClipPathFrame( - aBBox, aMatrix, aFlags)); + tmpBBox = clipPathThatClipsClipPath->GetBBoxForClipPathFrame(aBBox, aMatrix, + aFlags); + unionBBox.Intersect(tmpBBox); } return unionBBox; } diff --git a/layout/svg/SVGUtils.cpp b/layout/svg/SVGUtils.cpp index 727bf26a051d..d6bd12b6b893 100644 --- a/layout/svg/SVGUtils.cpp +++ b/layout/svg/SVGUtils.cpp @@ -809,7 +809,8 @@ gfxRect SVGUtils::GetClipRectForFrame(const nsIFrame* aFrame, float aX, const auto& rect = effects->mClip.AsRect(); nsRect coordClipRect = rect.ToLayoutRect(); - nsIntRect clipPxRect = coordClipRect.ToOutsidePixels(AppUnitsPerCSSPixel()); + nsIntRect clipPxRect = coordClipRect.ToOutsidePixels( + aFrame->PresContext()->AppUnitsPerDevPixel()); gfxRect clipRect = gfxRect(clipPxRect.x, clipPxRect.y, clipPxRect.width, clipPxRect.height); if (rect.right.IsAuto()) { @@ -908,14 +909,17 @@ gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, // Account for 'clipped'. if (aFlags & SVGUtils::eBBoxIncludeClipped) { gfxRect clipRect; + float x, y, width, height; gfxRect fillBBox = svg->GetBBoxContribution({}, SVGUtils::eBBoxIncludeFill).ToThebesRect(); + x = fillBBox.x; + y = fillBBox.y; + width = fillBBox.width; + height = fillBBox.height; // XXX Should probably check for overflow: clip too. bool hasClip = aFrame->StyleDisplay()->IsScrollableOverflow(); if (hasClip) { - clipRect = SVGUtils::GetClipRectForFrame(aFrame, 0.0f, 0.0f, - fillBBox.width, fillBBox.height); - clipRect.MoveBy(fillBBox.TopLeft()); + clipRect = SVGUtils::GetClipRectForFrame(aFrame, x, y, width, height); if (aFrame->IsSVGForeignObjectFrame() || aFrame->IsSVGUseFrame()) { clipRect = matrix.TransformBounds(clipRect); } @@ -923,14 +927,14 @@ gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, SVGClipPathFrame* clipPathFrame; if (SVGObserverUtils::GetAndObserveClipPath(aFrame, &clipPathFrame) == SVGObserverUtils::eHasRefsSomeInvalid) { - bbox = gfxRect(); + bbox = gfxRect(0, 0, 0, 0); } else { if (clipPathFrame) { SVGClipPathElement* clipContent = static_cast(clipPathFrame->GetContent()); if (clipContent->IsUnitsObjectBoundingBox()) { - matrix.PreTranslate(fillBBox.TopLeft()); - matrix.PreScale(fillBBox.width, fillBBox.height); + matrix.PreTranslate(gfxPoint(x, y)); + matrix.PreScale(width, height); } else if (aFrame->IsSVGForeignObjectFrame()) { matrix = gfxMatrix(); } @@ -945,7 +949,7 @@ gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, } if (bbox.IsEmpty()) { - bbox = gfxRect(); + bbox = gfxRect(0, 0, 0, 0); } } }