Closed Bug 1103184 Opened 9 years ago Closed 9 years ago
Support "object-fit" & "object-position" on <canvas>
Just realized that we should probably support "object-fit" & "object-position" on HTML5 <canvas>. Right now, they have no effect on <canvas>, but they probably should, since it's a replaced element. (They also do have an effect in Chrome.) Testcase attached. - Works in Chrome 41 (renders as a circle, respecting "object-fit") - Doesn't work in Firefox Nightly. (stretches to fill the <canvas>'s CSS width/height)
This should do it, I think. This fixes the attached testcase. (This requires the GetIntrinsicSize impl that I'm adding in bug 1104354, too.) Just requesting feedback instead of review at the moment, because I want to test more thoroughly & add reftests. (It's likely done or near-done, though.) For reference: - the "GetOpaqueRegion" changes are similar to the nsImageFrame changes that I had to make in bug 1101128 (but they're bit simpler here, because nsImageFrame can be fragmented but nsHTMLCanvasFrame cannot). - the BuildLayer changes here are very similar to the nsVideoFrame::BuildLayer changes that I made over in bug 624647 -- here's a link to those changes, for reference: https://hg.mozilla.org/integration/mozilla-inbound/rev/466d3ff030e6#l3.29 (BTW: I also realized today that we can simplify those^ nsVideoFrame changes by keeping around the old "area" local-var. I've got a trivial followup patch to land as soon as the tree reopens that does that. In the meantime, this patch here uses the existing 'area' rect, instead of exactly matching the nsVideoFrame changeset.)
Just ended up needing one more change -- need to pass the right clip flags (& not necessarily assume that drawing will be constrained to the content-box). (I'm using the same nsStyleUtil::ObjectPropsMightCauseOverflow() helper-method that I added/used for this over in Bug 624647, in mozilla-central changeset a083cd9a7c8c )
Posting the tests as a separate patch. They're just modified copies of existing tests (plus the script I used to do the modifications, for archival sake), so I'm not bothering with review on them -- but feedback is welcome, of course!
Attachment #8528813 - Flags: review?(roc) → review+
Thanks! Landed: https://hg.mozilla.org/integration/mozilla-inbound/rev/052e9649b6ba https://hg.mozilla.org/integration/mozilla-inbound/rev/b5c23a7a6d8c
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.