Closed
Bug 1150704
Opened 9 years ago
Closed 9 years ago
Move the dest rect algorithm from nsDisplayImage::GetOpaqueRect() into nsDisplayImage::GetDestRect()
Categories
(Core :: Layout: Images, Video, and HTML Frames, defect)
Core
Layout: Images, Video, and HTML Frames
Tracking
()
RESOLVED
FIXED
mozilla40
Tracking | Status | |
---|---|---|
firefox40 | --- | fixed |
People
(Reporter: seth, Assigned: seth)
References
Details
Attachments
(2 files)
4.70 KB,
patch
|
dholbert
:
review+
|
Details | Diff | Splinter Review |
4.97 KB,
patch
|
Details | Diff | Splinter Review |
It looks like no callers actually want the behavior of nsDisplayImage::GetDestRect(). That method just returns the border box of the image, but now that object-fit and object-position have been implemented, that doesn't correctly capture the actual dest rect we'll use to draw, and when we infer other values like the scale we're using to draw the image, we get wrong results if we assume that the border box is the correct dest rect. We have a correct algorithm implemented already, in nsDisplayImage::GetOpaqueRect(). Let's move that algorithm into GetDestRect(), replacing the original algorithm, and make GetOpaqueRect() call GetDestRect().
Assignee | ||
Comment 1•9 years ago
|
||
Here's the patch. Heads up: this is based off of the patches in bug 1150774, not off of trunk.
Attachment #8587894 -
Flags: review?(dholbert)
Assignee | ||
Comment 2•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=78b331bdd0b7
Assignee | ||
Comment 3•9 years ago
|
||
The try run looks good.
Comment 4•9 years ago
|
||
Comment on attachment 8587894 [details] [diff] [review] Use the same dest rect calculation for nsDisplayImage::GetOpaqueRegion and nsDisplayImage::GetDestRect > /* virtual */ nsRegion > nsDisplayImage::GetOpaqueRegion(nsDisplayListBuilder* aBuilder, > bool* aSnap) > { > *aSnap = true; > if (mImage && mImage->IsOpaque()) { >- // OK, the entire region painted by the image is opaque. But what is that >- // region? It's the image's "dest rect" (the rect where a full copy of >- // the image is mapped), clipped to the container's content box (which is >- // what GetBounds() returns). So, we grab those rects and intersect them. >- const nsRect frameContentBox = GetBounds(aSnap); [...] >+ return nsRegion(GetDestRect()); So GetOpaqueRegion would now no longer meaningfully populating its "aSnap" outparam. That seems bad. (I guess it doesn't break any tests, but that's likely also bad. :)) Maybe GetOpaqueRegion() and GetDestRect() should *each* call a new helper-function, which takes the aSnap outparam (something like "GetDestRectImpl(bool* aSnap)") and that's where this logic would all live?
Assignee | ||
Comment 5•9 years ago
|
||
(In reply to Daniel Holbert [:dholbert] from comment #4) > Maybe GetOpaqueRegion() and GetDestRect() should *each* call a new > helper-function, which takes the aSnap outparam (something like > "GetDestRectImpl(bool* aSnap)") and that's where this logic would all live? How about GetDestRect() just takes an aSnap parameter with a default value of nullptr, and we only populate it if it's non-null? Seems a shame to introduce another level of indirection just for this issue. =)
Comment 6•9 years ago
|
||
That works for me! (I didn't suggest that because I thought GetDestRect was defined on some superclass. But given that it's nsDisplayImage-specific, we can tweak it cleanly, like you suggested.)
Comment 7•9 years ago
|
||
Comment on attachment 8587894 [details] [diff] [review] Use the same dest rect calculation for nsDisplayImage::GetOpaqueRegion and nsDisplayImage::GetDestRect r=me with comment 5
Attachment #8587894 -
Flags: review?(dholbert) → review+
Assignee | ||
Comment 8•9 years ago
|
||
Thanks for the review! Here's an updated version of the patch that implements the change in comment 5.
Assignee | ||
Comment 9•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=aa4937633d3f
Assignee | ||
Comment 10•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/1b6ea2dab47b
Comment 11•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/1b6ea2dab47b
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox40:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
Updated•6 years ago
|
Product: Core → Core Graveyard
Updated•6 years ago
|
Product: Core Graveyard → Core
You need to log in
before you can comment on or make changes to this bug.
Description
•