Bug 264010
| Summary: | Include additional translation in getBBox for SVGUseElement | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Ahmad Saleem <ahmad.saleem792> |
| Component: | SVG | Assignee: | Ahmad Saleem <ahmad.saleem792> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | karlcow, sabouhallawa, webkit-bug-importer, zimmermann |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar, WPTImpact |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| URL: | https://jsfiddle.net/onav6d90/show | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=305044 | ||
Ahmad Saleem
Hi Team,
While going through Blink's commit, I came across another failing test case:
Test Case: https://jsfiddle.net/onav6d90/show
^ Fails in Safari Technology Preview 181 and WebKit ToT. Passes in Chrome Canary 120 and Firefox Nightly 121.
Blink Commit: https://chromium.googlesource.com/chromium/blink/+/99b52757a16d0a300b77c83c27c443d70ba78f9c
Just wanted to raise, so we can fix it.
Thanks!
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/118082623>
Ahmad Saleem
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGContainer.h:
> Make it public:
FloatRect objectBoundingBox() const final { return m_objectBoundingBox.value_or(FloatRect()); }
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGTransformableContainer.h:
> Add as public:
const FloatSize& additionalTranslation() const { return m_additionalTranslation; }
* Source/WebCore/svg/SVGUseElement.cpp:
FloatRect SVGUseElement::getBBox(StyleUpdateStrategy styleUpdateStrategy)
{
if (styleUpdateStrategy == AllowStyleUpdate)
protectedDocument()->updateLayoutIgnorePendingStylesheets({ LayoutOptions::TreatContentVisibilityHiddenAsVisible, LayoutOptions::TreatContentVisibilityAutoAsVisible }, this);
if (!renderer())
return { };
auto* transformableContainer = dynamicDowncast<LegacyRenderSVGTransformableContainer>(renderer());
// Don't apply the additional translation if the oBB is invalid.
if (!transformableContainer->isObjectBoundingBoxValid())
return { };
// FIXME: Preferably this would just use objectBoundingBox() (and hence
// don't need to override SVGGraphicsElement::getBBox at all) and be
// correct without additional work. Although it does not work due to
// problem stemming from including the additional translation directly
// on the renderer corresponding to the SVGUseElement.
FloatRect bbox = transformableContainer->objectBoundingBox();
bbox.move(transformableContainer->additionalTranslation());
return bbox;
}
* Source/WebCore/svg/SVGUseElement.h:
FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) override;
_____________________
It compiles and progresses.
Ahmad Saleem
It progresses 'SVGGraphicsElement.getBBox-05.html' ->
FAIL use with fill assert_approx_equals: use1.getBBox().x {"fill":true,"stroke":false,"markers":false,"clipped":false} expected 70 +/- 0.1 but got 20
to
PASS use with fill
Ahmad Saleem
Pull request: https://github.com/WebKit/WebKit/pull/51242
EWS
Committed 302400@main (e53a0bba5e47): <https://commits.webkit.org/302400@main>
Reviewed commits have been landed. Closing PR #51242 and removing active labels.