Quantizing to quarter-pixel size is too coarse for extremely small sizes
(that will subsequently be scaled up, as here); it's also arguably finer
than needed at very large sizes. So instead of using a constant, this
patch makes us quantize the size by dropping the low bits of precision
from the mantissa, so that the quantization scales along with the size
being used.
Depends on D184819
Differential Revision: https://phabricator.services.mozilla.com/D184820
Trying to enable this, I noticed that we're returning it with the wrong sign;
it's expected to be measured positive-downwards.
Depends on D184606
Differential Revision: https://phabricator.services.mozilla.com/D184607
The Canvas2D specification says that if a path has no active sub-paths, and a
primitive is drawn, that the first point of that primitive becomes the start of
the newly created sub-path that will be created for it.
So if we prune a point when a path has no active sub-paths, and then a new
primitive comes in that does not start with that same point, we risk not
installing the pruned point as the start of that new sub-path.
To solve this, we need to detect if a path has no active sub-paths while
we are building it. This adds PathBuilder::IsActive() to help with that.
Then before we go to add a primitive, we check if there is a pruned point
on a path that is not active yet, and if so, install the correct start
point with a MoveTo.
This also makes IsActive and IsEmpty required so to ensure all our path
implementations behave consistently rather than having any surprising
unimplemented behavior.
Differential Revision: https://phabricator.services.mozilla.com/D184891
No behavior change, just hoisting duplicate code out into a helper as the methods to draw
the current path vs a passed-in path are largely identical.
Differential Revision: https://phabricator.services.mozilla.com/D183996
Surprisingly, this is sufficient to pass the existing WPT tests for fontVariantCaps.
(They only test setting and reading the attribute, but don't verify that it actually
has any effect on rendering!)
Rendering tests will be added in the next patch, along with hooking up the behavior.
Differential Revision: https://phabricator.services.mozilla.com/D182566
Surprisingly, this is sufficient to pass the existing WPT tests for fontVariantCaps.
(They only test setting and reading the attribute, but don't verify that it actually
has any effect on rendering!)
Rendering tests will be added in the next patch, along with hooking up the behavior.
Differential Revision: https://phabricator.services.mozilla.com/D182566
Instead of decomposing arcs into beziers in Canvas let the PathBuilder
decide what to do with it.
This lets PathBuilderRecording keep arcs as arcs which reduces the serialization
overhead and will make it possible for us to detects circles in a subsequent change.
Differential Revision: https://phabricator.services.mozilla.com/D181542
This changes how we deal with transform changes during path construction.
Previously, we would switch to storing the path in device space and keeping it
there until it was used.
This switches us to the same strategy that WebKit and Blink use: Just transform
the old path to the new user space.
There are definitely some cases where this will give worse performance but it's
simpler and it also means we'll have the same performance characteristics as
other browsers. It also makes it easier for us to pass arcs down to the underlying
DrawTarget.
Differential Revision: https://phabricator.services.mozilla.com/D181501
As per the Canvas2D spec:
"Points with no lines coming out of them must have two caps placed back-to-back as if it was really two points connected to each other by an infinitesimally short straight line in the direction of the point's directionality (as defined above)."
Therefor, if there is a zero-length sub-path that is not closed, we need to ensure that line caps are drawn for it.
To do this, we track whether any zero-length segments are pruned with a flag that gets cleared if the sub-path is
either closed or a non-zero-length segment follows.
Differential Revision: https://phabricator.services.mozilla.com/D181163
We've supported nsIPrincipal off-main-thread since bug 1443925, and
nsIPrincipal has been used as the JSPrincipals on workers and worklets
since bug 1804093.
This change updates the signature of these methods to match the main
thread, and provides the subject principal off-main-thread as well as on
the main thread.
Differential Revision: https://phabricator.services.mozilla.com/D180158
We calculate the canvas random noises after allocating the ArrayData
that shouldn't be GC'ed. However, GC can happen when generating the
random noises. This could have potential issue that ArrayData get GC'ed
when it shouldn't be.
This patch fixes this by moving the calculation of random noises before
allocating the Array Data.
Differential Revision: https://phabricator.services.mozilla.com/D179538
When introducing the random noises to the image data in
CanvasRenderingContext2D::GetImageDataArray would also alter the actual
image buffer. This will change the random noises every time we call the
function because the random noises is generated according to the image
data. This is undesirable and the random noises should remain the
same in the browsing session with the same canvas.
To fix this issue, we clone the actual image data if canvas randomization is
enabled and introduce noises to the cloned data, which doesn't change
the actual image buffer. So, the random nosies will remain consistent in
a single browser session.
We also fix some minor issues in this patch.
Differential Revision: https://phabricator.services.mozilla.com/D178327
For OffscreenCanvas, currently only absolute CSS <length> values are accepted when
setting the letterSpacing and wordSpacing attributes, as we have no context to resolve
other units.
Other types of length are accepted for in-document <canvas> elements.
As a followup, we should try to add support for font-relative units (em, ch, etc),
resolved against the canvas context's font attribute. These are potentially useful
for authors, and at least em is required for some of the existing WPT tests.
Differential Revision: https://phabricator.services.mozilla.com/D177019
This patch introduces random noises to data extraction functions of
canvas element and offscreen canvas. The random noise is based on the
random key of the cookieJarSettings and the image data itself.
The random noises would interfere the ability of fingerprinters that
use canvas data to fingerprint users. The random noise will make unique
canvas finerprint to for every browsing session. Therefore, fingerprinter
cannot use canvas fingerprint to tracker individuals across browsing
sessions.
Differential Revision: https://phabricator.services.mozilla.com/D175499
This patch moves ShouldResistFingerprinting() and add a RFPTarget as
input argument. We will use this function to check if canvas
fingerprinting protection is enabled.
We also modify the caller to pass the right RFPTarget for Canvas image
data extraction prompt. Note that, we need to set the default argument
for the function to known because it's used for WebGL fingerprinting
protection too. However, We don't cut over this part in this patch and
will do it in a future bug.
Differential Revision: https://phabricator.services.mozilla.com/D175608
It can fail when canceling the worker (though I couldn't reproduce the
crash locally). Some things were already accounting for it.
Rename some things for consistency.
Differential Revision: https://phabricator.services.mozilla.com/D175126