Commit Graph
287 Commits
Author SHA1 Message Date
Emilio Cobos Álvarez 9161ed4dbd Bug 1914449 - Fix stylesheet cloning in presence of both @layer and @import. r=zrhoffman,firefox-style-system-reviewers
Hopefully the test for bug 1912996 would catch this.

Differential Revision: https://phabricator.services.mozilla.com/D220083
2024-08-26 13:01:59 +00:00
Emilio Cobos Álvarez f13512e295 Bug 1914106 - Deal with insertRule edge-case. r=jwatt
When there's trailing garbage after an @import rule we throw, but we
still trigger the load (that's not great but not trivial to change).

Deal with that case before calling ImportRuleLoaded().

Differential Revision: https://phabricator.services.mozilla.com/D219783
2024-08-22 05:39:07 +00:00
Daniel Holbert cd7fd0677f Bug 1896711 part 5: Use MakeRefPtr/MakeAndAddRef to reduce boilerplate, in layout/style. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D210390
2024-05-15 07:29:21 +00:00
Emilio Cobos Álvarez 41f597d3c0 Bug 1880718 - Make sure that constructable stylesheets has the right url data after construction. r=dshin
ReplaceSync did this, but if you don't call Replace() / ReplaceSync()
after construction we end up with the Servo_StyleSheet_Empty which has a
dummy URL data.

Differential Revision: https://phabricator.services.mozilla.com/D204603
2024-03-15 15:47:21 +00:00
Emilio Cobos Álvarez 1e6e3bfc0b Bug 1884759 - Don't use a mutex to handle parse promise blocking. r=firefox-style-system-reviewers,zrhoffman
It's more heavy-weight than it needs to be.

Differential Revision: https://phabricator.services.mozilla.com/D204287
2024-03-13 09:52:02 +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
Emilio Cobos Álvarez 9f34f1c216 Bug 1873290 - Update the relevant global on association for already-complete stylesheets. r=smaug
When an stylesheet comes from the stylesheet cache and gets cloned, it
is already complete, but we only associate it to a document afterwards.

Make sure to set the relevant global then.

Depends on D197960

Differential Revision: https://phabricator.services.mozilla.com/D197961
2024-01-09 11:42:11 +00:00
Emilio Cobos Álvarez 6716f6ea35 Bug 1864815 - Fix up cssRules when calling replace() repeatedly. r=nordzilla
Differential Revision: https://phabricator.services.mozilla.com/D195234
2023-12-01 18:18:13 +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
Emilio Cobos Álvarez 61a902a848 Bug 1863874 - Deal with an assert that doesn't really hold with StyleSheet.replace().
MANUAL PUSH: Trivial orange fix CLOSED TREE
2023-11-20 21:20:21 +01:00
Emilio Cobos Álvarez 241423a5c7 Bug 1863874 - Remove a line that's no longer needed and causes asserts in debug builds.
SetComplete is called below, and the constructor doc acts as associated
doc, so there's no need for this line.

MANUAL PUSH: Orange fix CLOSED TREE
2023-11-20 19:16:43 +01:00
Emilio Cobos Álvarez a2a5209102 Bug 1863874 - Don't set the relevant global on stylesheets until sheet is complete. r=mccr8
We don't expose the sheet to script until the sheet becomes complete, so
we can do this.

Differential Revision: https://phabricator.services.mozilla.com/D194096
2023-11-20 17:32:06 +00:00
Emilio Cobos Álvarez 3a05d81c7f Bug 1859538 - Allow chrome stylesheets to be parsed in parallel. r=layout-reviewers,desktop-theme-reviewers,dao,Gijs,tlouw
This changes -moz-bool-pref from @supports to @media, bringing various
improvements:

 * @media (-moz-bool-pref) properly reacts to dynamic changes.
 * We no longer need to parse chrome:// stylesheets in the main thread
   (-moz-bool-pref was the only thing that forced us to do that).

This makes privileged and non-privileged stylesheets more similar.

Differential Revision: https://phabricator.services.mozilla.com/D191196
2023-10-19 10:50:27 +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
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
Emilio Cobos Álvarez 83f6ffef76 Bug 1847546 - Don't do duplicate work on style elements from the innerHTML setter. r=smaug
Right now, when binding to the tree we queue a runnable to update the
stylesheet, even though mEnableUpdates is false.

Even though the redundant update is nowadays always cached, it's just
wasted work, and the code is simpler without it.

This will be tested by bug 1771113, which is what made me look at this.

We need to tweak a bit the dispatch of applicable state change events
for DevTools, because for a case like:

  div.attachShadow({ mode: "open" }).innerHTML = `<style>...</style>`;

Before we'd go through the stylesheet cache here due to the redundant
update:

  https://searchfox.org/mozilla-central/rev/fb43eb3bdf5b51000bc7dfe3474cbe56ca2ab63c/layout/style/SharedStyleSheetCache.cpp#161-165

But now we won't, and the code in StyleSheet.cpp wasn't quite correct /
didn't dispatch the event.

Nobody listens to style-sheet-applicable-state-changed, so remove that
code while at it.

Differential Revision: https://phabricator.services.mozilla.com/D185559
2023-08-07 20:21:34 +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 e11ddfc877 Bug 1835062 - Make CSSStyleRule a GroupRule. r=smaug,dshin
Lazily create the rule list since most style rules won't have child
rules.

Remaining failures in the cssom tests are tracked in other bugs.

Differential Revision: https://phabricator.services.mozilla.com/D180649
2023-06-14 09:36:22 +00:00
Stanca Serban 44700a590b Backed out changeset 4c6c30b03e25 (bug 1835062) for causing multiple failures in browser_parsable_css.js. CLOSED TREE 2023-06-14 04:55:44 +03:00
Emilio Cobos Álvarez c2abf9de97 Bug 1835062 - Make CSSStyleRule a GroupRule. r=smaug,dshin
Lazily create the rule list since most style rules won't have child
rules.

Remaining failures in the cssom tests are tracked in other bugs.

Differential Revision: https://phabricator.services.mozilla.com/D180649
2023-06-14 00:18:40 +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 057cadb272 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 1f06787277 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 5c9b936c47 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
Emilio Cobos Álvarez 8f5d7d53d5 Bug 1832173 - Remove HasArcFFI for some types. r=boris
See blocked bug.

For non-Locked types we can just use the same underlying type at the FFI
boundary. Port StylesheetContents and CssUrlData to this set-up.
CssUrlData is already generated by cbindgen anyways.

Differential Revision: https://phabricator.services.mozilla.com/D177559
2023-05-11 00:36:24 +00:00
Emilio Cobos Álvarez 79e2754796 Bug 1831539 - Remove HasBoxFFI. r=boris
HasBoxFFI and HasArcFFI aren't great, see bug 1831242 as for examples of
why.

HasArcFFI requires a bit more care, but HasBoxFFI doesn't give us much
benefit. Instead use the same type in the FFI boundary.

Differential Revision: https://phabricator.services.mozilla.com/D177252
2023-05-09 11:07:26 +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
Olli Pettay 1b9b031994 Bug 1800347, use RenderBlocking priority for async css parsing, r=emilio
Depends on D161954

Differential Revision: https://phabricator.services.mozilla.com/D161955
2022-11-16 09:23:28 +00:00
Olli Pettay 048bd344c4 Bug 1777574, automate CC zone handling, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D155084
2022-09-07 11:22:51 +00:00
Emilio Cobos Álvarez abf8ddf50c Bug 1769771 - Improve DevTools support for constructable stylesheets. r=nchevobbe
These should be trivial fixes for the most part, just fixing assumptions
for constructable stylesheets which have no owner node. Since Gecko
internally also has the concept of "associated document", let's just use
that.

We don't have the authored text around for these. We could keep it
around but I'd kinda prefer we didn't have to just for devtools, since
it seems to me we already need to deal with rules not being there
(imagine e.g. an empty style element with all the rules inserted via
script with insertRule()). So returning the empty string should be
reasonable for now...

Writing some tests now...

Differential Revision: https://phabricator.services.mozilla.com/D146682
2022-05-19 22:32:28 +00:00
Emilio Cobos Álvarez a0cf4e0fd6 Bug 1768215 - Use the right referrer info for constructable stylesheets. r=jfkthame
Document::GetReferrerInfo is not what we want (that is the referrer of
the document itself).

What we want is to use the document _as_ the referrer. That's what
regular stylesheets do, and that fixes our chrome only rules enabled
check.

Differential Revision: https://phabricator.services.mozilla.com/D145794
2022-05-06 16:42:41 +00:00
Emilio Cobos Álvarez f782f19d4e Bug 1752392 - Don't drop CSSStyleSheet.cssRules from CSSStyleSheet.replace/Sync(). r=firefox-style-system-reviewers,layout-reviewers,boris
As per spec this object should always return the same JS object.

Differential Revision: https://phabricator.services.mozilla.com/D144569
2022-04-28 15:40:19 +00:00
Cristian Tuns b4bc8b3c5f Backed out 2 changesets (bug 1644102, bug 1752392) for causing mochitest failures in test_parseStyleSheetImport.html CLOSED TREE
Backed out changeset b5c0bdafaf5e (bug 1644102)
Backed out changeset 092814d96f1d (bug 1752392)
2022-04-28 05:37:52 -04:00
Emilio Cobos Álvarez 1bc49f1fbf Bug 1752392 - Don't drop CSSStyleSheet.cssRules from CSSStyleSheet.replace/Sync(). r=firefox-style-system-reviewers,layout-reviewers,boris
As per spec this object should always return the same JS object.

Differential Revision: https://phabricator.services.mozilla.com/D144569
2022-04-27 23:50:48 +00:00
Emilio Cobos Álvarez d9d1bb5bf0 Bug 1729488 - Refactor shared sheet cache into something more reusable. r=jwatt
This moves the style-specific bits of the shared style sheet cache into
a super-class, and leaves the generic "sub-resource management" bits
inside a base class. In order to implement it you need to provide some
types, mainly:

  * Loader, which implements LoaderPrincipal() and allows you to key per
    principal. The idea is that this would be the
    {CSS,Script,Image}Loader object.

  * Key (self explanatory). We might want to introduce a common key to
    share the cache partitioning logic.

  * Value, which represents the final cached value. This is expected to
    be a StyleSheet / Stencil / imgRequestProxy.

  * LoadingValue, which must inherit from
    SharedSubResourceCacheLoadingValueBase (which contains the linked
    list and the state that the cache manages). It also must provide a
    ValueForCache() and ExpirationTime() members. For style, this is the
    SheetLoadData. For script this will probably be the
    ScriptLoadRequest. For images it might be enough with the
    imgRequestProxy, but we might need something else, haven't looked
    into it too deeply yet.

We move the use counters into the stylesheet since that's both more
similar to how we treat StyleSheetContents and easier (that way we don't
need to add some sort of "extra data" thing to the cache).

Differential Revision: https://phabricator.services.mozilla.com/D124820
2021-10-05 15:15:22 +00:00
Emilio Cobos Álvarez a3cb442543 Bug 1730669 - Simplify requesting node set up in the CSS loader. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D125527
2021-09-15 16:43:30 +00:00
Emilio Cobos Álvarez eca75548b1 Bug 1729330 - Add a simple CSSLayerRule implementation. r=smaug
The specifics of how this is going to work are still getting spec'd /
discussed in https://github.com/w3c/csswg-drafts/issues/6576, but this
allows DevTools to work fine and the feature to be complete enough for
Nightly experimentation (with the other in-flight patches).

Otherwise devtools crashes when trying to inspect pages that use them.

Differential Revision: https://phabricator.services.mozilla.com/D124656
2021-09-08 11:18:32 +00:00
Emilio Cobos Álvarez 996e1d0730 Bug 1719963 - Restore EnsureUniqueInner() call for now. r=jfkthame
This effectively reverts the behavior to the one before bug 1711437
(making the CC setup sound again), but without a big backout.

Fixing the CC setup of @import rules properly is a bit more involved
than what I anticipated and I don't want to have DevTools folks blocked
for too long, nor have this crash in-tree for too long either.

Differential Revision: https://phabricator.services.mozilla.com/D122819
2021-08-17 09:26:29 +00:00
Emilio Cobos Álvarez 64c5bc4ff9 Bug 1711437 - Don't EnsureUniqueInner from the cssRules getter. r=layout-reviewers,jfkthame
Instead, fix up the various content data structures when the stylesheet
is mutated. This makes reading a stylesheet not disable style sharing.

Differential Revision: https://phabricator.services.mozilla.com/D115203
2021-07-20 13:17:02 +00:00
Dorel Luca 50c9bd5973 Backed out changeset 0e17878eeb86 (bug 1711437) for causing Bug 1719963. a=backout DONTBUILD 2021-07-14 00:36:05 +03:00
Emilio Cobos Álvarez 0aa7c71572 Bug 1711437 - Don't EnsureUniqueInner from the cssRules getter. r=layout-reviewers,jfkthame
Instead, fix up the various content data structures when the stylesheet
is mutated. This makes reading a stylesheet not disable style sharing.

Differential Revision: https://phabricator.services.mozilla.com/D115203
2021-07-12 16:02:58 +00:00