Closed Bug 1369904 Opened 7 years ago Closed 7 years ago

SVG getBBox & objectBoundingBox units are incorrect on Mac/Android

Categories

(Core :: SVG, defect)

53 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: amelia.bellamy.royds, Assigned: longsonr)

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36

Steps to reproduce:

1. Create an SVG path where the control points of Bezier curves extend outside the bounding box (the tight rectangle that encloses all points on the path itself).
2. Apply a gradient or pattern that is scaled to use `objectBoundingBox` units to this path
3. View it in a version of Firefox that uses Skia as the underlying graphics library (Mac or Android)

or

2. Query `getBBox()` on the path element on one of the problematic operating systems.

or

Run test case: https://codepen.io/AmeliaBR/pen/dRyPJE/?editors=1111


Actual results:

The gradient is scaled too large, matching the too-large getBBox rectangle that includes the control points.


Expected results:

The bounding box should be scaled to the fill-region bounding box; it should not be affected by control points.

In the linked demo, this means that all the gradients should have the same scale and same bounding box printed to the console (x=0, y=0, width=100, height=100).

___________________________

Firefox on Windows and Linux has the correct results. IE/Edge are also correct.
Current versions of Blink and WebKit return correct results for getBBox, but use the too-large box for objectBoundingBox scaling.

Per Chromium but https://bugs.chromium.org/p/chromium/issues/detail?id=230599:

> The current implementation relies on SkPath::getBounds(), which
computes a conservative result (includes control points).

> Use SkPathOps::TightBounds() instead, for an exact answer.

I assume the same problem and solution apply for Firefox.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached patch patch with test (obsolete) — Splinter Review
Assignee: nobody → longsonr
Attachment #8874178 - Flags: review?(jmuizelaar)
Comment on attachment 8874178 [details] [diff] [review]
patch with test

Review of attachment 8874178 [details] [diff] [review]:
-----------------------------------------------------------------

I'll let Lee take this one.
Attachment #8874178 - Flags: review?(jmuizelaar) → review?(lsalzman)
Comment on attachment 8874178 [details] [diff] [review]
patch with test

It would be simpler to just call mPath.computeTightBounds() instead of mPath.getBounds(). This way we don't have to separately call TightBounds and don't need to import the SkPathOps.h header either.
that's simpler, thanks for the suggestion Lee.
Attachment #8874178 - Attachment is obsolete: true
Attachment #8874178 - Flags: review?(lsalzman)
Attachment #8876980 - Flags: review?(lsalzman)
Attachment #8876980 - Flags: review?(lsalzman) → review+
Pushed by longsonr@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3e62702024b0
Bounding box should not include control points. r=lsalzman
https://hg.mozilla.org/mozilla-central/rev/3e62702024b0
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: