Commit Graph
390 Commits
Author SHA1 Message Date
Daniel Holbert b9eb620914 Bug 2036982: Use MakeAndAddRef to replace some new/forget() patterns in layout/style. r=layout-reviewers,firefox-style-system-reviewers,emilio
MakeAndAddRef exists partly to serve as syntactic sugar to combine statements
like this.  And this lets us reduce our count of manual 'new' statements,
which is a nice plus.

One exception was "new StyleSheet" which has a private constructor and hence
can't use MakeAndAddRef, so in that instance I used do_AddRef(new) to stuff the
newly-allocated object into a smart pointer, in a way that we can consistently
grep for across the codebase when auditing our new/delete invocations.

Differential Revision: https://phabricator.services.mozilla.com/D298473
2026-05-06 22:31:29 +00:00
Daniel Holbert 1d19a6df13 Bug 2036984: Allocate reference-counted objects with MakeRefPtr instead of 'new', in layout/style. r=layout-reviewers,firefox-style-system-reviewers,emilio
This is mostly just changing `new Foo()` to `MakeRefPtr<Foo>()`.

Notablye exceptions:
* In one case where the result gets stuck in a `nsCOMPtr` instead of a `RefPtr`,
  I use `MakeAndAddRef` instead, to follow precedent from elsewhere in the
  codebase (and avoid the appearance of a pointer-type-mixup).
* In cases where the class has a private constructor, we can't use MakeRefPtr,
  so I use `do_AddRef(new Foo())` to make it slightly clearer (in an easily
  greppable way) that the 'new' invocation is instantly being stuffed into
  a smart pointer.

Differential Revision: https://phabricator.services.mozilla.com/D298475
2026-05-06 22:31:27 +00:00
Emilio Cobos Álvarez 406b05d943 Bug 2026296 - Improve handling of Post-traversal tasks. r=jfkthame,firefox-style-system-reviewers,layout-reviewers,dshin
Differential Revision: https://phabricator.services.mozilla.com/D292814
2026-04-09 19:54:35 +00:00
Sylvestre Ledru 55481ac4b5 Bug 2023419 - Remove Emacs/Vim modelines from layout/ r=emilio,firefox-style-system-reviewers,layout-reviewers
replaced by .editorconfig

Differential Revision: https://phabricator.services.mozilla.com/D287852
2026-03-17 12:05:43 +00:00
Valentin Gosu 44bd5382c0 Bug 2006028 - Remove predictor code r=necko-reviewers,firefox-style-system-reviewers,emilio,kershaw,extension-reviewers,toolkit-telemetry-reviewers,manuel,robwu
The network predictor used the HTTP cache as a database to learn browsing
patterns and make speculative DNS prefetches, TCP preconnects, and resource
prefetches. While this provided performance benefits for repeat visits to
frequently-accessed sites, it came with significant costs: I/O on every page
load, CPU overhead for prediction algorithms, memory for caching learned
patterns, and substantial IPC complexity with six message types coordinating
predictions between processes.

A large part of the functionality the predictor was meant to improve is now
available to webdevelopers. HTTP 103 Early Hints allow servers to explicitly
specify resources to preload while generating the response.
And Speculation Rules API will enable content authors to declaratively specify
prefetch/prerender behavior based on their knowledge of site structure and user
intent, providing immediate accuracy without a learning period.

The network.predictor.enable-hover-on-ssl preference is retained as it controls
simpler hover-triggered speculative connections that don't require the
predictor's learning system. This removal simplifies the codebase while
steering users toward more accurate, standards-based optimization mechanisms.

The one feature of the predictor which was never used was learning websites
that are opened soon after startup. There was no action taken based on this
info, and we could already predict this info based on the history database.

Differential Revision: https://phabricator.services.mozilla.com/D276437
2025-12-18 22:56:37 +00:00
Atila Butkovits 79e1b89109 Revert "Bug 2006028 - Remove predictor code r=necko-reviewers,firefox-style-system-reviewers,emilio,kershaw" for causing failures at test_basic.js.
This reverts commit 117ed7db99.
2025-12-16 09:52:23 +00:00
Valentin Gosu 117ed7db99 Bug 2006028 - Remove predictor code r=necko-reviewers,firefox-style-system-reviewers,emilio,kershaw
The network predictor used the HTTP cache as a database to learn browsing
patterns and make speculative DNS prefetches, TCP preconnects, and resource
prefetches. While this provided performance benefits for repeat visits to
frequently-accessed sites, it came with significant costs: I/O on every page
load, CPU overhead for prediction algorithms, memory for caching learned
patterns, and substantial IPC complexity with six message types coordinating
predictions between processes.

A large part of the functionality the predictor was meant to improve is now
available to webdevelopers. HTTP 103 Early Hints allow servers to explicitly
specify resources to preload while generating the response.
And Speculation Rules API will enable content authors to declaratively specify
prefetch/prerender behavior based on their knowledge of site structure and user
intent, providing immediate accuracy without a learning period.

The network.predictor.enable-hover-on-ssl preference is retained as it controls
simpler hover-triggered speculative connections that don't require the
predictor's learning system. This removal simplifies the codebase while
steering users toward more accurate, standards-based optimization mechanisms.

The one feature of the predictor which was never used was learning websites
that are opened soon after startup. There was no action taken based on this
info, and we could already predict this info based on the history database.

Differential Revision: https://phabricator.services.mozilla.com/D276437
2025-12-16 08:58:03 +00:00
Jonathan Kew a6cb564e82 Bug 1979061 - Don't eagerly call FlushUserFontSet() every time a face is added/removed. r=firefox-style-system-reviewers,emilio
AFAICS this isn't really necessary, and becomes extremely expensive when the font set is large.

Differential Revision: https://phabricator.services.mozilla.com/D272550
2025-11-14 10:50:51 +00:00
Emilio Cobos Álvarez a8a2311474 Bug 1976457 - Sort includes in layout/. r=janv,dshin
Interesting bit is layout/.clang-format, the rest is all automated.

Differential Revision: https://phabricator.services.mozilla.com/D256616
2025-07-09 13:24:00 +00:00
Daniel Holbert 094ddb8fc2 Bug 1966423 followup: Use SetCapacity to preallocate space for promises in FontFaceSet::Load. r=emilio
This patch doesn't change behavior; it just does a single preallocation to
avoid wasting time on repeated allocations (and allocation-failure-checks) as
we incrementally append to an array.

Differential Revision: https://phabricator.services.mozilla.com/D250115
2025-06-06 15:20:17 +00:00
Daniel Holbert 7e9c62c306 Bug 1966423: Hold stronger references to FontFaces. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D250114
2025-06-06 15:20:14 +00:00
Florian Quèze 9885783942 Bug 1956726 - remove leftover Telemetry.h includes in .cpp files, r=chutten,geckoview-reviewers,cookie-reviewers,win-reviewers,dom-storage-reviewers,gstoll,valentin,m_kato,janv.
Differential Revision: https://phabricator.services.mozilla.com/D244351
2025-04-08 13:03:02 +00:00
Peter Van der Beken 9e9199880e Bug 1640839 - Stop generating a sentinel value at the end of WebIDL enums. r=mccr8,jgilbert,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D201344
2024-03-02 07:50:25 +00:00
Natalia Csoregi 10b9ceb789 Backed out 13 changesets (bug 1640839) for causing bustage on Element.cpp CLOSED TREE
Backed out changeset 179ceb82c9e5 (bug 1640839)
Backed out changeset 73f498a821f0 (bug 1640839)
Backed out changeset dc2d3d0e0365 (bug 1640839)
Backed out changeset ddc989ac0509 (bug 1640839)
Backed out changeset e595bb3feea8 (bug 1640839)
Backed out changeset c85aca04e27f (bug 1640839)
Backed out changeset 98e8e3a4047a (bug 1640839)
Backed out changeset 59ef180517db (bug 1640839)
Backed out changeset af2f5e293662 (bug 1640839)
Backed out changeset 89aa6d9dc598 (bug 1640839)
Backed out changeset 67b722a722f9 (bug 1640839)
Backed out changeset 24a9665c6ced (bug 1640839)
Backed out changeset d93f199385e9 (bug 1640839)
2024-03-01 18:23:08 +02:00
Peter Van der Beken e0fa109cb0 Bug 1640839 - Stop generating a sentinel value at the end of WebIDL enums. r=mccr8,jgilbert,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D201344
2024-03-01 14:31:15 +00:00
Emilio Cobos Álvarez 3bbfb2e943 Bug 1817122 - Make AsyncEventDispatcher(Event) take ownership of the event. r=smaug,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D190059
2023-10-04 19:37:39 +00:00
Gregory Pappas 2adef5bddc Bug 1851553 - Remove layout.css.font-loading-api.workers.enabled pref r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D188412
2023-09-19 07:44:05 +00:00
Narcis Beleuzu 2e1ec1b85c Backed out changeset f30ae9e2e715 (bug 1851553) for wr failure on fontface-descriptor-updates.html . CLOSED TREE 2023-09-19 09:34:02 +03:00
Gregory Pappas 7323600cff Bug 1851553 - Remove layout.css.font-loading-api.workers.enabled pref r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D188412
2023-09-18 22:21:06 +00:00
Gregory Pappas 723cd1163b Bug 1851091 - Remove layout.css.font-loading-api.enabled pref r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D187346
2023-09-04 18:12:54 +00:00
Emilio Cobos Álvarez d8324af55d 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 90c12bb82f 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 aeb00f5e9f 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 4252f2198f 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 142ac4b2ca 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 f9c92c7431 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 719267821f 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 c4c2b34441 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 2058ad3030 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 5343eeb7eb 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 ba8e50c2ab 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 4964867caa 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 8ea9717f2f 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 d6ec6d6ab4 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 9cc60e956c 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 42a711655b 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 fbf29a9961 Backed out changeset 7585591a9bad (bug 1773558) for causing failures in system-fonts.html 2022-06-12 19:02:33 +03:00
Emilio Cobos Álvarez 152643ec11 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 bfbd12ff97 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 6d7e761d67 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 8b7d1120ed 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 c50393b1de 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 825a2a32c7 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 c8f6a1fcf4 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 d43792a9f6 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 29a0624339 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 828d190348 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 37ba622a03 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 87c754b1bd 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 9e995a79e8 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