Граф коммитов

892 Коммитов

Автор SHA1 Сообщение Дата
Lee Salzman ebbda1906f Bug 1847244 - Finish plumbing will-read-frequently through WindowRenderer. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D185451
2023-08-05 01:05:47 +00:00
Jonathan Kew e1d47efe18 Bug 1845828 - patch 2 - Quantize font size for canvas2d by reducing precision, rather than using an arbitrary fixed quantum. r=gfx-reviewers,lsalzman
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
2023-08-03 13:32:29 +00:00
Peter Van der Beken 9fba1d5220 Bug 1846277 - Remove nsGlobalWindow.h. r=dom-core,necko-reviewers,jesup,farre
Differential Revision: https://phabricator.services.mozilla.com/D184973
2023-08-02 20:41:48 +00:00
Jonathan Kew a48b3d6216 Bug 1841692 - patch 3 - Fix sign error when returning canvas2d TextMetrics.emHeightDescent. r=gfx-reviewers,lsalzman
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
2023-08-01 11:27:32 +00:00
Jonathan Kew 99602c82b2 Bug 1832955 - Support font-relative units when parsing letterSpacing/wordSpacing for offscreen canvas. r=gfx-reviewers,lsalzman,emilio
Differential Revision: https://phabricator.services.mozilla.com/D184938
2023-08-01 09:27:16 +00:00
Emilio Cobos Álvarez e6cea60db2 Bug 1846293 - Improve flush handing in Canvas2D. r=dholbert
Don't keep weak pointers before flushing.

Differential Revision: https://phabricator.services.mozilla.com/D184950
2023-07-31 16:48:09 +00:00
Lee Salzman b2d67698b9 Bug 1846079 - Ensure pruned point begins first sub-path if necessary. r=aosmond
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
2023-07-30 14:31:09 +00:00
Jonathan Kew 68ad20d8aa Bug 1517786 - Implement the getContextAttributes() method for CanvasRenderingContext2D. r=gfx-reviewers,lsalzman,emilio
This has been in the HTML spec for a while now (see https://html.spec.whatwg.org/multipage/canvas.html#2dcontext),
so we should probably go ahead and implement it.

Differential Revision: https://phabricator.services.mozilla.com/D184499
2023-07-26 08:12:15 +00:00
Iulian Moraru abf5dcc71d Backed out changeset 9ee735b99363 (bug 1517786) for causing wpt failures related to CanvasRenderingContext2D. CLOSED TREE 2023-07-26 04:02:26 +03:00
Jonathan Kew 2231ef7c87 Bug 1517786 - Implement the getContextAttributes() method for CanvasRenderingContext2D. r=gfx-reviewers,lsalzman,emilio
This has been in the HTML spec for a while now (see https://html.spec.whatwg.org/multipage/canvas.html#2dcontext),
so we should probably go ahead and implement it.

Differential Revision: https://phabricator.services.mozilla.com/D184499
2023-07-25 18:37:34 +00:00
Zach Hoffman 98ad5a0692 Bug 1844295 - Don't duplicate ParsingMode in rust and C++. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D184409
2023-07-25 10:00:59 +00:00
Jonathan Kew 2f24a40aea Bug 1844356 - Refactor CanvasRenderingContext2D::Stroke() and Fill() functions. r=gfx-reviewers,aosmond
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
2023-07-19 15:19:53 +00:00
Andrew Osmond 71792018b4 Bug 1833876. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D179483
2023-07-18 16:29:47 +00:00
Jonathan Kew 999b340a1a Bug 1842467 - patch 1 - Implement the fontStretch attribute for canvas2d. r=gfx-reviewers,webidl,lsalzman,smaug
Differential Revision: https://phabricator.services.mozilla.com/D183088
2023-07-10 11:14:54 +00:00
Andrew Osmond e8d3205ad7 Bug 1781527 - Part 3. Implement support for surfaces requiring scaling/crop rects with canvas. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D182208
2023-07-10 00:26:47 +00:00
Andrew Osmond a975416b44 Bug 1781527 - Part 2. Implement means to use VideoFrame with ImageBitmap and CanvasRenderingContext2D. r=chunmin,webidl,gfx-reviewers,smaug,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D150679
2023-07-10 00:26:47 +00:00
Cristian Tuns 982856d479 Backed out 4 changesets (bug 1781527) for causing Assertion failures in ImageBitmap.cpp CLOSED TREE
Backed out changeset d3ca9e70625b (bug 1781527)
Backed out changeset f6c56b5e6450 (bug 1781527)
Backed out changeset 34d140bc5b99 (bug 1781527)
Backed out changeset f7a2f2b89ba8 (bug 1781527)
2023-07-09 18:53:20 -04:00
Andrew Osmond 8d5b297ee9 Bug 1781527 - Part 3. Implement support for surfaces requiring scaling/crop rects with canvas. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D182208
2023-07-09 21:03:46 +00:00
Andrew Osmond caa1f6d751 Bug 1781527 - Part 2. Implement means to use VideoFrame with ImageBitmap and CanvasRenderingContext2D. r=chunmin,webidl,gfx-reviewers,smaug,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D150679
2023-07-09 21:03:46 +00:00
Jonathan Kew 6c6d97166b Bug 1778910 - Hook up rendering support for canvas2d fontVariantCaps, and add WPT reftests. r=gfx-reviewers,lsalzman
The behavior in some of these cases is open to debate, as the spec is quite unclear;
see https://github.com/whatwg/html/issues/8103. What I've implemented here gives the
same rendering result as Chrome for these tests, so hopefully we can get this clarified
in the spec as well.

Differential Revision: https://phabricator.services.mozilla.com/D182567
2023-07-06 19:05:53 +00:00
Jonathan Kew c5a0f7995c Bug 1778910 - Implement setting/getting the fontVariantCaps attribute on Canvas2D context (note: no rendering support yet). r=gfx-reviewers,webidl,lsalzman,saschanaz
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
2023-07-06 19:05:53 +00:00
Butkovits Atila a1194a7700 Backed out 3 changesets (bug 1778910) for causing failures at fontVariantCaps.
Backed out changeset 75478b5852a3 (bug 1778910)
Backed out changeset d59f1e7c17c5 (bug 1778910)
Backed out changeset d87582a5c11f (bug 1778910)
2023-07-04 19:13:05 +03:00
Jonathan Kew 90a4380b28 Bug 1778910 - Hook up rendering support for canvas2d fontVariantCaps, and add WPT reftests. r=gfx-reviewers,lsalzman
The behavior in some of these cases is open to debate, as the spec is quite unclear;
see https://github.com/whatwg/html/issues/8103. What I've implemented here gives the
same rendering result as Chrome for these tests, so hopefully we can get this clarified
in the spec as well.

Differential Revision: https://phabricator.services.mozilla.com/D182567
2023-07-04 12:16:57 +00:00
Jonathan Kew ff18a2e8b3 Bug 1778910 - Implement setting/getting the fontVariantCaps attribute on Canvas2D context (note: no rendering support yet). r=gfx-reviewers,webidl,lsalzman,saschanaz
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
2023-07-04 12:16:57 +00:00
Jonathan Kew c2251d42ce Bug 1840075 - Implement support for the OpenType BASE (baselines) table, and use it to back canvas2d TextMetrics attributes and textBaseline alignment. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D181882
2023-06-23 19:17:56 +00:00
Jonathan Kew 757b4f3a91 Bug 1839662 - Convert canvas2d attributes from strings to WebIDL enums. r=gfx-reviewers,webidl,lsalzman,smaug
This shouldn't change behavior; it just aligns our WebIDL declarations
with the spec, and slightly simplifies the code.

Differential Revision: https://phabricator.services.mozilla.com/D181671
2023-06-23 16:28:13 +00:00
Jonathan Kew 2b58d82d11 Bug 1839614 - patch 3 - Implement support for the textRendering attribute in canvas. r=gfx-reviewers,webidl,smaug,peterv,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D181638
2023-06-23 15:12:19 +00:00
Jeff Muizelaar 9d4f461de7 Bug 1839470 - Pass arcs through to the PathBuilder. r=lsalzman
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
2023-06-21 12:26:11 +00:00
Jeff Muizelaar 928d179fd7 Bug 1839424 - Handle transform changes more simply. r=lsalzman
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
2023-06-21 03:52:59 +00:00
Jonathan Kew 73e039d3c4 Bug 1838905 - patch 1 - Normalize values to lowercase when storing canvas2d letter/word-spacing attributes. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D181277
2023-06-17 07:26:24 +00:00
Jonathan Kew 9e55e5df92 Bug 1838768 - Quantize used font-size for canvas text, to improve caching behavior when font size is arbitrarily varying. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D181216
2023-06-16 17:36:12 +00:00
Jonathan Kew bc3b00d427 Bug 1838658 - patch 1 - Handle the 'small-caps' variant when OffscreenCanvas is parsing and serializing the 'font' attribute. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D181147
2023-06-16 08:40:39 +00:00
Jonathan Kew 2ff08b8aee Bug 1838647 - Fix canvas2d handling of invalid font attribute containing a CSS variable reference. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D181107
2023-06-16 08:37:25 +00:00
Lee Salzman 8869a88331 Bug 1837729 - Ensure zero-length non-closed paths are capped. r=aosmond
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
2023-06-16 05:54:18 +00:00
Andrew Osmond 62bf794063 Bug 1792758 - Part 2. Expose CanvasFilter on OffscreenCanvasRenderingContext2D. r=webidl,lsalzman,emilio,smaug
This patch exposes the filter operation for OffscreenCanvas and works
off the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D179995
2023-06-09 13:38:40 +00:00
Nika Layzell bfebcdae69 Bug 1837090 - Support [NeedsSubjectPrincipal] on workers, r=peterv
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
2023-06-07 15:58:51 +00:00
Andrew Osmond 80c7c674a6 Bug 691187 - Prune zero-length segments for canvas strokes. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D179462
2023-06-02 19:06:15 +00:00
Cristian Tuns ec6e03eda9 Backed out changeset 50707b02bc59 (bug 691187) for causing mochitest failures in test_bug1567544.html CLOSED TREE 2023-06-02 09:40:34 -04:00
Andrew Osmond 9975cde84f Bug 691187 - Prune zero-length segments for canvas strokes. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D179462
2023-06-02 12:48:31 +00:00
Tim Huang 723aed3bb9 Bug 1835989 - Calculate the canvas random noises before we allocate the ArrayData in CanvasRenderingContext2D. r=lsalzman
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
2023-05-31 16:39:33 +00:00
Tim Huang 05d8e8c08e Bug 1833213 - Clone the image data if canvas randomization is enabled in CanvasRenderingContext2D::GetImageDataArray(). r=tjr,lsalzman
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
2023-05-17 21:43:48 +00:00
Emilio Cobos Álvarez a7526d2a34 Bug 1832173 - Finish removing HasArcFFI. r=boris
Use the actual Locked<T> types around (via a typedef, just for
convenience).

Differential Revision: https://phabricator.services.mozilla.com/D177824
2023-05-12 22:31:38 +00:00
Butkovits Atila cc740ca292 Backed out changeset f6e3d050b3e7 (bug 1832173) for causing bustages at CanvasRenderingContext2D.cpp. CLOSED TREE 2023-05-13 01:16:03 +03:00
Emilio Cobos Álvarez 7fc0f42cee Bug 1832173 - Finish removing HasArcFFI. r=boris
Use the actual Locked<T> types around (via a typedef, just for
convenience).

Differential Revision: https://phabricator.services.mozilla.com/D177824
2023-05-12 21:37:19 +00:00
Jonathan Kew 10c3cdf1fc Bug 1778909 - Implement letterSpacing and wordSpacing attributes for Canvas2D text. r=saschanaz,emilio
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
2023-05-12 20:54:21 +00:00
Tim Huang 07cbc511d5 Bug 1816189 - Part 4: Add random noise when extracting data from canvas element when canvas randomization is enabled. r=tjr,lsalzman
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
2023-05-08 14:04:35 +00:00
Tim Huang d72f344231 Bug 1816189 - Part 3: Moving ShouldResistFingerprinting() to nsICanvasRenderingContextInternal from ClientWebCLContext and add a RFPTarget as an input argument. r=tjr,lsalzman
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
2023-05-08 14:04:34 +00:00
Dan Robertson 903da59f75 Bug 1822116 - image-orientation: none should apply to CORS image requests. r=emilio
The image-orientation: none property should apply to images that use
CORS.

Differential Revision: https://phabricator.services.mozilla.com/D175051
2023-04-13 01:41:53 +00:00
Emilio Cobos Álvarez d27874678a Bug 1811950 - Allow WorkerGlobalScope.fonts to fail. r=aosmond,webidl,saschanaz
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
2023-04-11 13:44:53 +00:00
Emilio Cobos Álvarez 0354d36d5d Bug 1792860 - Keep checking for shell destruction.
MANUAL PUSH: Trivial orange fix CLOSED TREE
2023-04-10 22:49:02 +02:00