Open Bug 1610827 Opened 5 years ago Updated 2 years ago

drawSnapshot ignores fragments from DOMRect values

Categories

(Core :: Web Painting, defect, P3)

defect

Tracking

()

People

(Reporter: whimboo, Unassigned)

References

Details

Attachments

(2 files)

Using an instance of a DOMRect with values containing fragments, drawSnapshot ignores those and as such has an offset for recording the content by 1px. Instead the values have to be rounded up or down to the next largest whole number. And that is what Chrome is using:

DOMRect(100.2, 100.6, 100.3, 100.7)
DOMRect(101, 101, 100, 100)

Specifically it uses Math.ceil() for left and top, and Math.floor() for width, and height.

I noticed that problem when implementing screenshot tests for the remote agent, and comparing screenshots pixel by pixel. For now I will do the workaround in our code.

Matt, could you please check that? Thanks.

Flags: needinfo?(matt.woodrow)
Attached file HTML testcase (deleted) —

This is the HTML testcase which places the element at 100.5px/100.5px.

Attached image screenshot.png (deleted) —

Actually by using the above example, which is better to compare differences, the output is exactly the same between Firefox and Chrome.

I assume that the is no way to ensure that the element can exactly be captured for fractional values?

Component: Graphics → Web Painting

I don't think we can easily capture fractional pixels.

The current code is rounding the provided rect outwards to make it include the fractional area. It sounds like chrome might be rounding in, to only include whole pixels within the fractional area.

Changing the behaviour there is pretty easy, we just need to decide what is the most useful.

https://searchfox.org/mozilla-central/rev/df94cd5ba431234bc220ac081def0801fe44b89e/gfx/ipc/CrossProcessPaint.cpp#185

Flags: needinfo?(matt.woodrow)

The priority flag is not set for this bug.
:mattwoodrow, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(matt.woodrow)
Flags: needinfo?(matt.woodrow)
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: