Commit Graph
587 Commits
Author SHA1 Message Date
tannal d5f6f0a0af Bug 1898653 Remove layout.css.inline-style-caching.always-enabled pref r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D219100
2024-08-14 08:00:11 +00:00
Emilio Cobos Álvarez a44b49af0b Bug 1910698 - Add a struct to represent JS caller location and more general warning source location. r=smaug,necko-reviewers,anti-tracking-reviewers,dom-storage-reviewers,pbz,kershaw,janv
Use it liberally across the tree. This could be cleaned up even more in the future.

Differential Revision: https://phabricator.services.mozilla.com/D218114
2024-08-01 17:12:48 +00:00
Tooru Fujisawa ecf0093f0f Bug 1905597 - Add nsContentUtils::ShouldBypassSubResourceCache. r=emilio
JS loader will going to use the same condition for bypassing sub resource cache.

Differential Revision: https://phabricator.services.mozilla.com/D215597
2024-07-10 06:24:34 +00:00
Tooru Fujisawa 1c0e44639b Bug 1893402 - Part 1: Accumulate the cache-ability of redirect responses for CSS cache. r=emilio,necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D208844
2024-05-17 11:20:59 +00:00
Tamas Szentpeteri 4214cd6de9 Backed out 2 changesets (bug 1893402) for causing mochitest failures regarding nsGlobalWindowInner. CLOSED TREE
Backed out changeset e909b94c1280 (bug 1893402)
Backed out changeset beef636e1562 (bug 1893402)
2024-05-17 00:16:25 +03:00
Tooru Fujisawa 9f8759ef16 Bug 1893402 - Part 1: Accumulate the cache-ability of redirect responses for CSS cache. r=emilio,necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D208844
2024-05-16 15:40:41 +00:00
Emilio Cobos Álvarez 6617a0e493 Bug 1892660 - Add a metric for async stylesheet load time. r=jesup
Differential Revision: https://phabricator.services.mozilla.com/D208660
2024-05-02 22:40:56 +00:00
sunil mayya 97971f8448 Bug 1864817 - implement OnDataFinished for CSSLoader. r=jesup,necko-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D189403
2024-03-10 14:12:04 +00:00
Cosmin Sabou ad055c9c92 Backed out changeset 9da36d4b3b14 (bug 1864817) for causing frequent StyleSheet related failures. CLOSED TREE 2024-03-09 03:43:15 +02:00
sunil mayya 4cb5965fd1 Bug 1864817 - implement OnDataFinished for CSSLoader. r=jesup,necko-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D189403
2024-03-08 20:58:37 +00:00
Frédéric Wang daf0fac8b4 Bug 1880528 - Introduce preference for fetch priority adjustment of style load. r=valentin,necko-reviewers
This introduces preferences loading style. See D201997 for the
rationale, test coverage and why there is no behavior change.

Note that current behavior for deferred style is to always set
PRIORITY_LOW, so the fetchpriority attribute has no effect.

Some preference names could be more verbose to match the if
branches in `Loader::AdjustPriority` but note that it is not
clear whether "deferred preload style" can actually happen,
see bug 1879335.

Differential Revision: https://phabricator.services.mozilla.com/D202052
2024-02-19 13:35:40 +00:00
Frédéric Wang 3a7e5f1d1d Bug 1878831 - Use SheetLoadData::ShouldDefer() in Loader::AdjustPriority. r=emilio
This is shorter, clearer and more consistent with the case when
StaticPrefs::network_fetchpriority_enabled() is disabled. No
behavior changes.

Differential Revision: https://phabricator.services.mozilla.com/D200925
2024-02-08 15:08:10 +00:00
Tom Schuster 694c3e8534 Bug 1872839 - Remove aMimeTypeGuess parameter from nsIContentPolicy. r=freddyb
Differential Revision: https://phabricator.services.mozilla.com/D197794
2024-01-08 15:47:42 +00:00
Mirko Brodesser 3406916a51 Bug 1865610: part 3) Add fetchpriority attribute support for preloaded stylesheets. r=smaug,emilio,necko-reviewers,jesup
Includes corresponding Link header fields.

Differential Revision: https://phabricator.services.mozilla.com/D191866
2023-11-23 14:36:12 +00:00
Mirko Brodesser 2a72b3ab97 Bug 1865610: part 1) Add partial support for the "fetchpriority" attribute for loading style sheets from <link> elements or Link header fields. r=smaug,emilio,valentin
Includes only support for dynamically loading style sheets from `<link>`
elements and `Link` header fields.
The remaining support, including preloading, is completed in part 3.

Differential Revision: https://phabricator.services.mozilla.com/D191745
2023-11-23 14:36:11 +00:00
Emilio Cobos Álvarez 488a396e1b Bug 1855861 - Make stylesheet load events only fire if the sheet has an owner node. r=smaug
This matches the behavior of other browsers, and avoids having to keep
alive the link element and thus associated document etc for too long.

Differential Revision: https://phabricator.services.mozilla.com/D192834
2023-11-06 17:05:10 +00:00
Mirko Brodesser 1dd1e649f9 Bug 1839315: part 3) Remove no-op method PreloaderBase::PrioritizeAsPreload. r=necko-reviewers,valentin
Because it's confusing.

Differential Revision: https://phabricator.services.mozilla.com/D190015
2023-10-11 10:21:56 +00:00
Emilio Cobos Álvarez d02e297b2d Bug 1624819 - Remove TaskCategory and other quantum dom remnants. r=smaug,media-playback-reviewers,credential-management-reviewers,cookie-reviewers,places-reviewers,win-reviewers,valentin,mhowell,sgalich,alwu
Sorry this is not a particularly easy patch to review. But it should be
mostly straight-forward.

I kept Document::Dispatch mostly for convenience, but could be
cleaned-up too / changed by SchedulerGroup::Dispatch. Similarly maybe
that can just be NS_DispatchToMainThread if we add an NS_IsMainThread
check there or something (to preserve shutdown semantics).

Differential Revision: https://phabricator.services.mozilla.com/D190450
2023-10-10 08:51:12 +00:00
Mirko Brodesser 46646e51f1 Bug 1856942: part 6) Rename DecrementOngoingLoadCount to DecrementOngoingLoadCountAndMaybeUnblockOnload. r=emilio
Complements part 1.

Differential Revision: https://phabricator.services.mozilla.com/D190057
2023-10-05 09:07:04 +00:00
Mirko Brodesser 1e9a17f70a Bug 1856942: part 5) Factor async loading of a sheet out of Loader::LoadSheet. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D190048
2023-10-05 09:07:04 +00:00
Mirko Brodesser 7589c53787 Bug 1856942: part 4) Factor potentially coalescing the load out of Loader::LoadSheet. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D190047
2023-10-05 09:07:03 +00:00
Mirko Brodesser 93dac82216 Bug 1856942: part 3) Factor potentially deferring loading the sheet out of Loader::LoadSheet. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D190046
2023-10-05 09:07:03 +00:00
Mirko Brodesser 4580bfbbc8 Bug 1856942: part 2) Factor sync loading of sheet out of Loader::LoadSheet. r=emilio
In another patch, `::LoadSheet` needs to be extended to support the
`fetchpriority` attribute (see
https://bugzilla.mozilla.org/show_bug.cgi?id=1839315).

`Loader::LoadSheet` is already 350 lines long
(https://searchfox.org/mozilla-central/rev/29bdf6ff9965a647c6f64d63fed2b5bd094532c7/layout/style/Loader.cpp#1147-1495).
To avoid further growing `Loader::LoadSheet`, details are abstract away
in this and following parts.

This is in line with
<https://google.github.io/styleguide/cppguide.html#Write_Short_Functions>.

Differential Revision: https://phabricator.services.mozilla.com/D190045
2023-10-05 09:07:02 +00:00
Mirko Brodesser 953d8f3682 Bug 1856942: part 1) Rename IncrementOngoingLoadCount to IncrementOngoingLoadCountAndMaybeBlockOnload. r=emilio
Emilio: perhaps take a look at all patches of this bug first before
commenting.

Differential Revision: https://phabricator.services.mozilla.com/D190044
2023-10-05 09:07:02 +00:00
Jan Varga 272327b326 Bug 1855134 - Move existing MOZ_TRY macros to a dedicated header file; r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D189226
2023-09-28 20:46:07 +00:00
Emilio Cobos Álvarez 9cb5936334 Bug 1850414 - Simplify style sheet source-map URL code. r=layout-reviewers,firefox-style-system-reviewers,webidl,smaug,boris
The old code was basically doing string copies that are totally
redundant, in a not-very performant way too.

This was from the time where stylo had to live with the old style
engine, and there's no need to keep the copy around anymore.

Differential Revision: https://phabricator.services.mozilla.com/D186974
2023-08-30 09:27:06 +00:00
Emilio Cobos Álvarez 2ad7f748ea Bug 1847440 - Always store relative line numbers in CSS rules. r=zrhoffman
CSS rules were storing absolute rather than relative line numbers (this
was done to match the old style system).

So when we hit the cached inline stylesheet code-path, for which we
share the CSS rules of the stylesheet, for the cache hit the line
numbers were completely off.

This particular page was probably regressed by bug 1834081, but the
issue could happen before with Shadow DOM.

Always store relative numbers and convert to absolute when asked by the
inspector, rather than the other way around.

This is simpler and makes the cache work.

Differential Revision: https://phabricator.services.mozilla.com/D185916
2023-08-16 09:37:27 +00:00
Tom Schuster 5e8eb43ee6 Bug 1607009 - Move nonce getting to SheetLoadData. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D183965
2023-07-31 14:49:55 +00:00
Emilio Cobos Álvarez 10a824e989 Bug 1824886 - Don't make privileged sync loads block the document load event. r=TYLin,masayuki
This fixes the windows WPT failures in comment 23. The issue is that the
new accessiblecaret.css makes us delay the load event by a tick even in
about:blank.

Depends on D173998

Differential Revision: https://phabricator.services.mozilla.com/D182878
2023-07-09 11:34:06 +00:00
Emilio Cobos Álvarez c8d2c23403 Bug 1824886 - Rewrite AnonymousContent to use a shadow tree. r=smaug,TYLin,sfoster,devtools-reviewers,nchevobbe
Subtle things:

 * We now have shadow trees in NAC, inception! Only a couple lines of
   code in the style system had to be changed to match :host rules and
   so properly.

 * Had to make highlighters.css contentaccessible, because otherwise we
   can't load it from the shadow tree. I don't think it's a big deal.

 * I removed some of the code from highlighters.css that claimed that
   stuff inherited from the html element. That's just no longer true.

 * Had to switch from `setAttribute("style", ...)` to `.style = ...;`.
   This is needed because CSSOM from chrome code bypasses CSP (as
   AnonymousContent did), but setAttribute() doesn't, see bug 1424474.

Differential Revision: https://phabricator.services.mozilla.com/D173998
2023-07-09 11:34:05 +00:00
Stanca Serban 27c720052b Backed out changeset 1c835137f532 (bug 1824886) for causing multiple failures. CLOSED TREE 2023-07-06 02:11:59 +03:00
Emilio Cobos Álvarez 8053b896a6 Bug 1824886 - Rewrite AnonymousContent to use a shadow tree. r=smaug,TYLin,sfoster,devtools-reviewers,nchevobbe
Subtle things:

 * We now have shadow trees in NAC, inception! Only a couple lines of
   code in the style system had to be changed to match :host rules and
   so properly.

 * Had to make highlighters.css contentaccessible, because otherwise we
   can't load it from the shadow tree. I don't think it's a big deal.

 * I removed some of the code from highlighters.css that claimed that
   stuff inherited from the html element. That's just no longer true.

 * Had to switch from `setAttribute("style", ...)` to `.style = ...;`.
   This is needed because CSSOM from chrome code bypasses CSP (as
   AnonymousContent did), but setAttribute() doesn't, see bug 1424474.

Differential Revision: https://phabricator.services.mozilla.com/D173998
2023-07-05 21:59:44 +00:00
Cosmin Sabou 20fa44fbeb Backed out 2 changesets (bug 1824886) for causing failures on browser_all_files_referenced.js. CLOSED TREE
Backed out changeset 650ef77d1c4d (bug 1824886)
Backed out changeset 1c835137f532 (bug 1824886)
2023-07-06 00:42:53 +03:00
Emilio Cobos Álvarez b1433254b6 Bug 1824886 - Rewrite AnonymousContent to use a shadow tree. r=smaug,TYLin,sfoster,devtools-reviewers,nchevobbe
Subtle things:

 * We now have shadow trees in NAC, inception! Only a couple lines of
   code in the style system had to be changed to match :host rules and
   so properly.

 * Had to make highlighters.css contentaccessible, because otherwise we
   can't load it from the shadow tree. I don't think it's a big deal.

 * I removed some of the code from highlighters.css that claimed that
   stuff inherited from the html element. That's just no longer true.

 * Had to switch from `setAttribute("style", ...)` to `.style = ...;`.
   This is needed because CSSOM from chrome code bypasses CSP (as
   AnonymousContent did), but setAttribute() doesn't, see bug 1424474.

Differential Revision: https://phabricator.services.mozilla.com/D173998
2023-07-05 18:21:31 +00:00
Emilio Cobos Álvarez a4d1d401d3 Bug 1839580 - For async-parsed stylesheets, fire the load event sooner. r=smaug
This avoids one extra task hop when we finish parsing the stylesheet.

Differential Revision: https://phabricator.services.mozilla.com/D181613
2023-06-21 20:36:58 +00:00
Norisz Fay 0d2751bb99 Backed out changeset dfcc0494fe8d (bug 1839580) for causing wpt and mochitest failures CLOSED TREE 2023-06-21 21:23:18 +03:00
Emilio Cobos Álvarez 773b5291c4 Bug 1839580 - For async-parsed stylesheets, fire the load event sooner. r=smaug
This avoids one extra task hop when we finish parsing the stylesheet.

Differential Revision: https://phabricator.services.mozilla.com/D181613
2023-06-21 16:01:43 +00:00
Emilio Cobos Álvarez fc38392bdf Bug 1838045 - Make <link rel=stylesheet> load event scheduling saner. r=smaug
The spec asks to post a task, see html.spec.whatwg.org/#update-a-style-block

What we were doing is quite crazy. Unifying the scheduling between
<style> and <link rel=stylesheet> on the patch above causes failures on
some mochitests.

Some of them aren't really related to these and are a pre-existing bug,
see bug 1838346.

Differential Revision: https://phabricator.services.mozilla.com/D180895
2023-06-14 21:42:31 +00:00
Emilio Cobos Álvarez 90c0207ad5 Bug 1838045 - Fix load event on cached inline style sheets. r=mstange
Turns out we do fire load events on these (I thought they were only for
sheets with imports).

Simplify a bit some related code for links. Callers / observers need to
deal with SheetComplete being called sync anyways because of this:

  https://searchfox.org/mozilla-central/rev/962a843f6d96283c45162c788dc72bf217fca7df/layout/style/Loader.cpp#1873

So this removes the need for SheetLoadData to be a runnable etc.

Differential Revision: https://phabricator.services.mozilla.com/D180840
2023-06-14 21:42:31 +00:00
Emilio Cobos Álvarez 16bf3d7db8 Bug 1836818 - Tweak chrome document check so that it also applies to about:logins. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D180070
2023-06-06 10:34:38 +00:00
Emilio Cobos Álvarez c093254455 Bug 1834786 - Don't return cached stylesheets if the sheet principal doesn't match. r=dholbert
Otherwise stuff accessing stylesheets from a sandbox and content might
conflict, and we might incorrectly deny giving access to a CSSStyleSheet's
rules.

Differential Revision: https://phabricator.services.mozilla.com/D178971
2023-05-28 20:43:32 +00:00
Emilio Cobos Álvarez fde8301b8d Bug 1834081 - Cache inline stylesheets regardless of shadow dom. r=mstange
Some pages (like Reddit) would have duplicate multi-kilobyte stylesheets
even at the top level.

Differential Revision: https://phabricator.services.mozilla.com/D178548
2023-05-21 05:56:39 +00:00
Stanca Serban 2062147122 Backed out changeset 4bccba55c49f (bug 1834081) for causing wpt failures in layer-statement-before-import.html. CLOSED TREE 2023-05-20 01:56:32 +03:00
Emilio Cobos Álvarez 4957230707 Bug 1834081 - Cache inline stylesheets regardless of shadow dom. r=mstange
Some pages (like Reddit) would have duplicate multi-kilobyte stylesheets
even at the top level.

Differential Revision: https://phabricator.services.mozilla.com/D178548
2023-05-19 19:25:27 +00:00
Narcis Beleuzu 76631cd1eb Backed out changeset f7d99dea33ac (bug 1834081) for Loader.cpp 2023-05-19 20:51:47 +03:00
Emilio Cobos Álvarez 6552f8126d Bug 1834081 - Cache inline stylesheets regardless of shadow dom. r=mstange
Some pages (like Reddit) would have duplicate multi-kilobyte stylesheets
even at the top level.

Differential Revision: https://phabricator.services.mozilla.com/D178548
2023-05-19 16:16:26 +00:00
Kershaw Chang f446ba9e37 Bug 1808323 - Add telemetry for the page load time and the time to first paint for sites that supports Early Hints response, r=manuel,necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D165966
2023-05-02 08:08:44 +00:00
Emilio Cobos Álvarez c195031050 Bug 1825825 - Simplify NAC setup. r=smaug
Make all UA widgets also NAC.

Keep the UA widget flag but break at anonymous subtree boundaries, so
that only nodes inside the UA widget directly (and not NAC from those)
get the flag.

This is important because two callers depend on this difference:

 * The style system, since we still want to match content rules from
   stylesheets in the UA widget. We also match user rules, which is a
   bit sketchy, but that was the previous behavior, will file a
   follow-up for that.

 * The reflector code, since we want the scope for UA widgets to not
   include the NAC nodes inside that UA widget. nsINode::IsInUAWidget
   got it wrong.

After this patch, ChromeOnlyAccess is equivalent to
IsInNativeAnonymousSubtree, so we should probably unify the naming.
That's left for a follow-up patch because I don't have a strong
preference.

Differential Revision: https://phabricator.services.mozilla.com/D174310
2023-04-05 09:19:15 +00:00
Emilio Cobos Álvarez 8dabbf6590 Bug 1823686 - Share URLExtraData between SVG attribute mapping and style attribute. r=smaug
I don't think there's ever a way these should differ.

Got some include hell from removing ReferrerInfo.h from Document.h but
hopefully should be straight-forward to review.

Depends on D173154

Differential Revision: https://phabricator.services.mozilla.com/D173155
2023-03-22 14:54:43 +00:00
Emilio Cobos Álvarez 6739a7c89e Bug 1823686 - Unify ReferrerInfo::CreateFor{InternalCSS,SVG}Resources, since they're the same. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D173154
2023-03-22 11:50:56 +00:00