Commit graph

370 commits

Author SHA1 Message Date
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
Andrew Osmond
868238bf65 Bug 1791622 - Ensure FontFaceSet::Delete removes entries in the correct order. r=jfkthame
FontFaceSet and FontFaceSetImpl maintain independent but matching lists
of FontFace and FontFaceImpl objects respectively. When
FontFaceSet::Delete is called, we should remove from the FontFaceSet
first instead of the FontFaceSetImpl because FontFaceSetImpl::Delete
calls back into FontFaceSet to update its status if the removed FontFace
was the last object holding it back from a status change.

Differential Revision: https://phabricator.services.mozilla.com/D159857
2022-10-25 14:05:29 +00:00
Andrew Osmond
c5989fee52 Bug 1072107 - Part 9. Expose FontFaceSet on workers. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D149254
2022-07-07 21:24:11 +00:00
Andrew Osmond
15c3439858 Bug 1072107 - Part 8. Provide worker variant of FontFaceSetImpl. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D149252
2022-07-07 21:24:11 +00:00
Andrew Osmond
ae9f0f107d Bug 1072107 - Part 7. Make FontFaceLoader check for associated document. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D150542
2022-07-07 21:24:10 +00:00
Andrew Osmond
e28f840226 Bug 1072107 - Part 6. Dispatch font calls and callbacks as necessary. r=emilio
Also update thread assertions.

Differential Revision: https://phabricator.services.mozilla.com/D149253
2022-07-07 21:24:10 +00:00
Andrew Osmond
091dc0483c Bug 1771493 - Part 4. Split FontFaceSetDocumentImpl from FontFaceSetImpl. r=emilio
This patch splits document specific functionality from FontFaceSetImpl
into a new class FontFaceSetDocumentImpl. This will make it easier to
fork FontFaceSetImpl for workers.

Differential Revision: https://phabricator.services.mozilla.com/D147819
2022-06-28 21:47:01 +00:00
Andrew Osmond
e134d17fa0 Bug 1771493 - Part 1. Split FontFace(Set) into DOM facing and implementation classes. r=emilio
This patch aims to split the implementation details of FontFace(Set)
into FontFace(Set)Impl classes. The Impl variants have threadsafe
refcounting and are intended to be the basis for worker support for
FontFace(Set). We need threadsafe objects to pass around because parts
of the stack can only run on the main thread (network loading of font
data, graphics initialization of a font) even if the FontFace(Set)
itself lives on a DOM worker thread. Given the DOM facing objects are
cycle collected, we need additional indirection to support this use
case.

This patch should be a non-functional change.

Differential Revision: https://phabricator.services.mozilla.com/D147505
2022-06-28 21:46:59 +00:00
Marian-Vasile Laza
dfecbedace Backed out 5 changesets (bug 1771493) for causing bustages on FontFaceSetDocumentImpl.obj. CLOSED TREE
Backed out changeset 07513973391f (bug 1771493)
Backed out changeset 22f567c00af3 (bug 1771493)
Backed out changeset 609a5d93bf08 (bug 1771493)
Backed out changeset 1f5b0b087930 (bug 1771493)
Backed out changeset aa5527055ad1 (bug 1771493)
2022-06-28 22:21:00 +03:00
Andrew Osmond
bcd996398e Bug 1771493 - Part 5. Fix missing headers for FontFaceSet. CLOSED TREE
Differential Revision: https://phabricator.services.mozilla.com/D150483
2022-06-28 16:43:38 +00:00
Andrew Osmond
1eaa8eb15b Bug 1771493 - Part 4. Split FontFaceSetDocumentImpl from FontFaceSetImpl. r=emilio
This patch splits document specific functionality from FontFaceSetImpl
into a new class FontFaceSetDocumentImpl. This will make it easier to
fork FontFaceSetImpl for workers.

Differential Revision: https://phabricator.services.mozilla.com/D147819
2022-06-28 15:58:11 +00:00
Andrew Osmond
12b14bddea Bug 1771493 - Part 1. Split FontFace(Set) into DOM facing and implementation classes. r=emilio
This patch aims to split the implementation details of FontFace(Set)
into FontFace(Set)Impl classes. The Impl variants have threadsafe
refcounting and are intended to be the basis for worker support for
FontFace(Set). We need threadsafe objects to pass around because parts
of the stack can only run on the main thread (network loading of font
data, graphics initialization of a font) even if the FontFace(Set)
itself lives on a DOM worker thread. Given the DOM facing objects are
cycle collected, we need additional indirection to support this use
case.

This patch should be a non-functional change.

Differential Revision: https://phabricator.services.mozilla.com/D147505
2022-06-28 15:58:09 +00:00
Bogdan Szekely
c94fbd38ae Backed out 4 changesets (bug 1771493) for causing build bustages on FontFaceSet.cpp CLOSED TREE
Backed out changeset 3f2605087550 (bug 1771493)
Backed out changeset 5e6bf07c9c27 (bug 1771493)
Backed out changeset fbfb5b7dfb30 (bug 1771493)
Backed out changeset 93b7e171c74a (bug 1771493)
2022-06-28 17:57:11 +03:00
Andrew Osmond
9ddbae6df8 Bug 1771493 - Part 4. Split FontFaceSetDocumentImpl from FontFaceSetImpl. r=emilio
This patch splits document specific functionality from FontFaceSetImpl
into a new class FontFaceSetDocumentImpl. This will make it easier to
fork FontFaceSetImpl for workers.

Differential Revision: https://phabricator.services.mozilla.com/D147819
2022-06-28 14:27:21 +00:00
Andrew Osmond
87c60b39a6 Bug 1771493 - Part 1. Split FontFace(Set) into DOM facing and implementation classes. r=emilio
This patch aims to split the implementation details of FontFace(Set)
into FontFace(Set)Impl classes. The Impl variants have threadsafe
refcounting and are intended to be the basis for worker support for
FontFace(Set). We need threadsafe objects to pass around because parts
of the stack can only run on the main thread (network loading of font
data, graphics initialization of a font) even if the FontFace(Set)
itself lives on a DOM worker thread. Given the DOM facing objects are
cycle collected, we need additional indirection to support this use
case.

This patch should be a non-functional change.

Differential Revision: https://phabricator.services.mozilla.com/D147505
2022-06-28 14:27:20 +00:00
Emilio Cobos Álvarez
9fc2aa47fc Bug 1773558 - Move fixed-point font types to Rust. r=layout-reviewers,jfkthame
Now that cbindgen and rust support const generics, it seems more simple.

This centralizes all the relevant font constants etc in rust and avoids
conversions when going from rust to C++ and vice versa.

Differential Revision: https://phabricator.services.mozilla.com/D148847
2022-06-13 00:59:23 +00:00
Noemi Erli
841e350bc4 Backed out changeset 7585591a9bad (bug 1773558) for causing failures in system-fonts.html 2022-06-12 19:02:33 +03:00
Emilio Cobos Álvarez
e441089ca0 Bug 1773558 - Move fixed-point font types to Rust. r=layout-reviewers,jfkthame
Now that cbindgen and rust support const generics, it seems more simple.

This centralizes all the relevant font constants etc in rust and avoids
conversions when going from rust to C++ and vice versa.

Differential Revision: https://phabricator.services.mozilla.com/D148847
2022-06-12 10:48:58 +00:00
Jonathan Kew
5e5b3f791c Bug 1768554 - Fix thread-safety of gfxFontFamily::GetFontList callers. r=lsalzman
Callers that use the family's list of fonts need to hold a read lock for as
long as they're accessing the list.

Alternatively, the work can be moved into a gfxFontFamily method that locks
internally.

Differential Revision: https://phabricator.services.mozilla.com/D145924
2022-05-10 09:52:14 +00:00
Jonathan Kew
b9ae2c638e Bug 1717029 - Clean up status checks in FontFaceSet::CheckLoadingFinished(). r=layout-reviewers,emilio
No functional change, this just makes it more explicit that each possible status
value is being considered, and unifies the handling of the two arrays.

Differential Revision: https://phabricator.services.mozilla.com/D118200
2021-06-26 14:40:53 +00:00
Emilio Cobos Álvarez
fb069248c0 Bug 1716045 - Unify font-family storage. r=mats,jfkthame
This changes font-family storage to reuse the rust types, removing a
bunch of code while at it. This allows us to, for example, use a single
static font family for -moz-bullet and clone it, rather than creating a
lot of expensive copies.

Differential Revision: https://phabricator.services.mozilla.com/D118011
2021-06-18 19:35:50 +00:00
Mats Palmgren
58a3ef1c19 Bug 1542807 part 5 - Don't apply CSP rules for the document to fonts loaded from User and UserAgent origin sheets. r=ckerschb
As for document.fonts, I don't think we intentionally meant to apply
CSP to User/UserAgent fonts.  The document certainly has no authority
to block those from loading.  (We already have a separate principal
for these which is further evidence that this was unintentional
and we can use the same bit (mUseOriginPrincipal) to avoid CSP.)

Differential Revision: https://phabricator.services.mozilla.com/D111695
2021-06-14 01:22:06 +00:00
Mats Palmgren
14bc280a27 Bug 1542807 part 4 - Exclude fonts loaded from User and UserAgent origin sheets from 'document.fonts'. r=jfkthame
Per https://github.com/w3c/csswg-drafts/issues/6126 these were
never intended to be included in the first place so this is just
fixing a bug.  Note that I'm leaving them in the mRuleFaces array
so that the font loading machinery works the same as before.
I'm just excluding them when queried by document.fonts.

Differential Revision: https://phabricator.services.mozilla.com/D111694
2021-06-14 01:22:06 +00:00
Butkovits Atila
ed3da455ae Backed out 7 changesets (bug 1542807) for causing failures at inert-retargeting-iframe.tentative.html. CLOSED TREE
Backed out changeset e9ef32fa2f2e (bug 1542807)
Backed out changeset 8fa0cb199975 (bug 1542807)
Backed out changeset 38daf64afe59 (bug 1542807)
Backed out changeset e3aee052c495 (bug 1542807)
Backed out changeset a71056d4c7cc (bug 1542807)
Backed out changeset cf91e7d0a37f (bug 1542807)
Backed out changeset eee949e5fd67 (bug 1542807)
2021-06-12 01:38:25 +03:00
Mats Palmgren
2047e29464 Bug 1542807 part 5 - Don't apply CSP rules for the document to fonts loaded from User and UserAgent origin sheets. r=ckerschb
As for document.fonts, I don't think we intentionally meant to apply
CSP to User/UserAgent fonts.  The document certainly has no authority
to block those from loading.  (We already have a separate principal
for these which is further evidence that this was unintentional
and we can use the same bit (mUseOriginPrincipal) to avoid CSP.)

Differential Revision: https://phabricator.services.mozilla.com/D111695
2021-06-11 18:10:39 +00:00
Mats Palmgren
204b70d75a Bug 1542807 part 4 - Exclude fonts loaded from User and UserAgent origin sheets from 'document.fonts'. r=jfkthame
Per https://github.com/w3c/csswg-drafts/issues/6126 these were
never intended to be included in the first place so this is just
fixing a bug.  Note that I'm leaving them in the mRuleFaces array
so that the font loading machinery works the same as before.
I'm just excluding them when queried by document.fonts.

Differential Revision: https://phabricator.services.mozilla.com/D111694
2021-06-11 18:10:39 +00:00
Jonathan Kew
87da9bf675 Bug 1694123 - Pass userfont source index to font loader and decoder tasks, to avoid potential race with the field in the gfxUserFontEntry being reset on the main thread. r=layout-reviewers,emilio
This is a preliminary step that is needed in order for the following patch to be safe. (It's
mostly just plumbing, although the patch looks big because we need to pass the index through
so many functions.)

The issue is that loading a font resource involves a couple of tasks that happen asynchronously -
fetching the data from the network, and decoding/sanitizing the font data. We have an implicit
assumption that once a font load has been initiated, the state of the associated gfxUserFontEntry
will not change; in particular, we depend on mSrcIndex remaining constant, because we may use it
to index into the mSrcList array and access the gfxFontFaceSrc record again in the various
completion tasks that are executed after the async steps finish.

But the following patch breaks this assumption, because it may reset mSrcIndex at arbitrary times
when we discover that we need to re-resolve the @font-face to potentially recognize a src:local()
resource that was earlier in the list, but was previously unavailable. If this happens while
a font-load is doing its off-main-thread work, then when it completes, it will end up accessing
the wrong gfxFontFaceSrc record, which would result at least in incorrect behavior, but can also
result in a crash (e.g. if the record is of the wrong type altogether, such as trying to use the
principal or URI fields from a record of type src:local).

To avoid this problem, we should pass the source index at the time the font load is initiated
through to the OMT tasks and back to their main-thread completion routines, so that we do not
depend on the field in the gfxUserFontEntry remaining frozen. This makes the loading process
safe even if the source index in the entry gets reset while loading tasks are in progress.

Differential Revision: https://phabricator.services.mozilla.com/D110911
2021-04-06 16:23:17 +00:00
Jonathan Kew
39edce2d71 Bug 1698495 - Implement size-adjust font scaling in gfx/thebes font code. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D110024
2021-03-29 21:14:44 +00:00
Simon Giesecke
cc730d05dd Bug 1184468 - Use nsTHashtable::Keys where possible. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D108588
2021-03-24 17:56:50 +00:00
Simon Giesecke
613e20d136 Bug 1184468 - Use nsBaseHashtable::Values. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D108587
2021-03-24 17:56:49 +00:00
Simon Giesecke
628cc55f22 Bug 708901 - Migrate to nsTHashSet in layout. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D108597
2021-03-24 17:56:46 +00:00
Csoregi Natalia
f54ee076ae Backed out 13 changesets (bug 708901, bug 1184468) for causing build bustage on GeckoViewHistory.cpp. CLOSED TREE
Backed out changeset b1e4c01e63b8 (bug 708901)
Backed out changeset 37b52cce83c0 (bug 708901)
Backed out changeset eee75f33f060 (bug 708901)
Backed out changeset 479bf64c7986 (bug 708901)
Backed out changeset 15a8fb94d15d (bug 708901)
Backed out changeset be31ccd9a61d (bug 708901)
Backed out changeset fc54f4eaedd5 (bug 708901)
Backed out changeset 03c3a56c3d13 (bug 708901)
Backed out changeset 73f11d3c1298 (bug 708901)
Backed out changeset aed22fd80893 (bug 708901)
Backed out changeset 74d8249fbe7e (bug 708901)
Backed out changeset acb725eb3c1d (bug 1184468)
Backed out changeset 70f3ea6efec4 (bug 1184468)
2021-03-24 19:26:20 +02:00
Simon Giesecke
c73f87b72b Bug 708901 - Migrate to nsTHashSet in layout. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D108597
2021-03-24 16:58:58 +00:00
Jonathan Kew
6aa01e5aa4 Bug 1681691 - Add support for metrics overrides to gfxUserFontEntry, dom::FontFace, etc r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D109289
2021-03-23 17:10:24 +00:00
smolnar
03eae2c9a5 Backed out 8 changesets (bug 1681691) for causing wpt failures in idlharness.https.html. CLOSED TREE
Backed out changeset dda736a69ceb (bug 1681691)
Backed out changeset 64edecd0df6f (bug 1681691)
Backed out changeset a19844063d00 (bug 1681691)
Backed out changeset 5dd06c73f703 (bug 1681691)
Backed out changeset 1bc4081f95e4 (bug 1681691)
Backed out changeset e7887dc9a3c6 (bug 1681691)
Backed out changeset d9b488c09c23 (bug 1681691)
Backed out changeset b45b607fee4d (bug 1681691)
2021-03-23 12:00:39 +02:00
Jonathan Kew
31e403716c Bug 1681691 - Add support for metrics overrides to gfxUserFontEntry, dom::FontFace, etc r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D109289
2021-03-23 08:37:07 +00:00
Cosmin Sabou
193a73a5ea Backed out 10 changesets (bug 1681691) for wpt failures on fontface-override-descriptor-getter-setter.sub.html and idlharness.https.html. CLOSED TREE
Backed out changeset e43fba82fb31 (bug 1681691)
Backed out changeset 104675869016 (bug 1681691)
Backed out changeset 536bbc4b9ecd (bug 1681691)
Backed out changeset bb53155c3dd0 (bug 1681691)
Backed out changeset 9f9c3c13801a (bug 1681691)
Backed out changeset af79bc7f7919 (bug 1681691)
Backed out changeset e86d980f511e (bug 1681691)
Backed out changeset 12418707741d (bug 1681691)
Backed out changeset 8d5c2106a2b4 (bug 1681691)
Backed out changeset 4805e23e62d2 (bug 1681691)
2021-03-22 20:37:38 +02:00
Jonathan Kew
9c404e3453 Bug 1681691 - Add support for metrics overrides to gfxUserFontEntry, dom::FontFace, etc r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D109289
2021-03-22 15:40:54 +00:00
Simon Giesecke
ad01a10a3b Bug 1634281 - Use nsTHashMap instead of nsDataHashtable. r=xpcom-reviewers,necko-reviewers,jgilbert,nika,valentin
Note that this patch only transforms the use of the nsDataHashtable type alias
to a directly equivalent use of nsTHashMap. It does not change the specification
of the hash key type to make use of the key class deduction that nsTHashMap
allows for in some cases. That can be done in a separate step, but requires more
attention.

Differential Revision: https://phabricator.services.mozilla.com/D106008
2021-03-10 10:47:47 +00:00
Simon Giesecke
8ecfb38a41 Bug 1691913 - Remove uses of nsDataHashtable::GetValue. r=xpcom-reviewers,necko-reviewers,dragana,nika
GetValue is going to be removed in a subsequent patch. It is no longer needed,
because it can be replaced by functions already provided by nsBaseHashtable,
in particular Lookup and Contains.

Also, its name was confusing, since it specifically returns a pointer that
allows and is intended for modifying the entry within the hashtable, rather
than returning by-value. According to the naming rules to be set on
nsBaseHashtable, it would also needed to be renamed to "Lookup*. Removing
its uses saves this effort.

Differential Revision: https://phabricator.services.mozilla.com/D105476
2021-03-01 09:59:30 +00:00
Simon Giesecke
9af107a839 Bug 1691913 - Rename nsBaseHashtable::Put to InsertOrUpdate. r=xpcom-reviewers,necko-reviewers,jgilbert,dragana,nika
This makes the naming more consistent with other functions called
Insert and/or Update. Also, it removes the ambiguity whether
Put expects that an entry already exists or not, in particular because
it differed from nsTHashtable::PutEntry in that regard.

Differential Revision: https://phabricator.services.mozilla.com/D105473
2021-02-26 09:11:46 +00:00
Simon Giesecke
4f75368dcb Bug 1691913 - Rename nsBaseHashtable::GetOrInsert(With) to LookupOrInsert(With). r=xpcom-reviewers,necko-reviewers,jgilbert,dragana,nika
The functions should be called "Lookup" rather than "Get" because they return
a DataType& (rather than UserDataType).

Differential Revision: https://phabricator.services.mozilla.com/D105472
2021-02-26 09:11:45 +00:00
Simon Giesecke
d2caea36fa Bug 1691894 - Simplify uses of WithEntryHandle that only use OrInsert(With) by using GetOrInsertWith. r=xpcom-reviewers,necko-reviewers,jgilbert,nika
Differential Revision: https://phabricator.services.mozilla.com/D104676
2021-02-22 12:07:46 +00:00
Simon Giesecke
40403773d0 Bug 1688833 - Migrate LookupForAdd to WithEntryHandle in layout. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D104202
2021-02-09 18:19:39 +00:00
Emilio Cobos Álvarez
039592f4d8 Bug 1682003 - Avoid UTF-8 -> UTF-16 conversion during CSSOM serialization. r=heycam
This lifts a bunch of string conversions higher up the stack, but allows
us to make the servo code use utf-8 unconditionally, and seemed faster
in my benchmarking (see comment 0).

It should also make a bunch of attribute setters faster too (like
setting .cssText), now that we use UTF8String for them (we couldn't
because we couldn't specify different string types for the getter and
setters).

Differential Revision: https://phabricator.services.mozilla.com/D99590
2020-12-17 14:04:35 +00:00
Simon Giesecke
971b645fe3 Bug 1660470 - Add missing include directives/forward declarations. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D87865
2020-11-23 16:21:38 +00:00
Simon Giesecke
de7bab0f06 Bug 1650145 - Replace all value uses of Empty[C]String by 0-length _ns literals. r=froydnj,geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D82325
2020-09-23 15:17:15 +00:00
Simon Giesecke
96f3e7e019 Bug 1654992 - Use std::move instead of SwapElements where possible. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D84807
2020-08-04 11:27:07 +00:00
Noemi Erli
381fca9783 Backed out 4 changesets (bug 1654992, bug 1654991) for causing timeous in mask-opacity-1e.html
Backed out changeset 11f0f54c6e0a (bug 1654992)
Backed out changeset a353dd5b3f08 (bug 1654991)
Backed out changeset 6a7964ba549f (bug 1654991)
Backed out changeset cf3bfb91d98c (bug 1654991)
2020-08-03 22:09:36 +03:00
Simon Giesecke
032d2ac9d3 Bug 1654992 - Use std::move instead of SwapElements where possible. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D84807
2020-08-03 14:54:18 +00:00