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

178 Коммитов

Автор SHA1 Сообщение Дата
Emilio Cobos Álvarez fe36177806 Bug 1637651 - Assume non-quirks mode for style Link header preloads. r=smaug
This is an issue I found while going through this code and
writing/debugging a test for the bug at hand. Without this, the test in
the actual fix for this bug will fail to actually reuse the preloaded
stylesheet.

It seems reasonable to assume that the intersection of quirks mode
documents using link preload headers is small (and in that case we'd
parse the sheet twice, but oh well).

Differential Revision: https://phabricator.services.mozilla.com/D103567
2021-02-01 23:23:50 +00:00
Emilio Cobos Álvarez 38919a1a21 Bug 1673885 - Don't expose incomplete sheets in LinkStyle.sheet / Document.styleSheets. r=nordzilla
This matches other browsers, and common sense to some extent.

The code is a bit awkward because I want this behind a pref for now, as
it's not precisely a zero-risk change.

Differential Revision: https://phabricator.services.mozilla.com/D95065
2020-11-01 15:45:40 +00:00
Narcis Beleuzu 9e31b464f7 Backed out changeset 1ee5fddc1caf (bug 1673885) for wpt failures on ttwf-cssom-doc-ext-load-tree-order.html CLOSED TREE 2020-10-31 02:43:31 +02:00
Emilio Cobos Álvarez 2c6198ff82 Bug 1673885 - Don't expose incomplete sheets in LinkStyle.sheet / Document.styleSheets. r=nordzilla
This matches other browsers, and common sense to some extent.

The code is a bit awkward because I want this behind a pref for now, as
it's not precisely a zero-risk change.

Differential Revision: https://phabricator.services.mozilla.com/D95065
2020-10-30 23:30:14 +00:00
Narcis Beleuzu dc2519c7ca Backed out changeset 702857fa260e (bug 1673885) for wpt failures on ttwf-cssom-doc-ext-load-count.html CLOSED TREE 2020-10-30 23:08:37 +02:00
Emilio Cobos Álvarez f8d2ad7b26 Bug 1673885 - Don't expose incomplete sheets in LinkStyle.sheet / Document.styleSheets. r=nordzilla
This matches other browsers, and common sense to some extent.

The code is a bit awkward because I want this behind a pref for now, as
it's not precisely a zero-risk change.

Differential Revision: https://phabricator.services.mozilla.com/D95065
2020-10-30 19:24:22 +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
Emilio Cobos Álvarez 45dcbc2d5c Bug 1645987 - Isolate sheet cache by partitioned principal. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D80678
2020-06-24 06:47:38 +00:00
Honza Bambas 6018bc4a66 Bug 1603542 - Properly mark CSS preloads as used when processing stylesheet tags or imports, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D76528
2020-06-23 17:18:47 +00:00
Emilio Cobos Álvarez 3dba84f650 Bug 1645122 - Properly block onload when coalescing loads with other documents. r=heycam
If two loading documents hit the sheet cache and we coalesce the
resource load, there's nothing that prevents the load event on the
second document from firing right now, and there should be.

While at it, also fix the handling of the pending load count, though
it has no correctness impact on the particular test we're fixing here...

We were never decrementing it, which is of course wrong. However it
kinda ended up working because it just causes us to not defer more
loads.

The new assertions and responsibility of the counter should ensure it
stays correct.

Differential Revision: https://phabricator.services.mozilla.com/D80583
2020-06-23 08:27:54 +00:00
Emilio Cobos Álvarez 8c691e51cb Bug 1646776 - Don't set an URL for pending constructable stylesheet parses. r=heycam
This shouldn't have any behavior change, but it makes the code make a
bit more sense. Rather than counting inline stylesheets like a pending
load, we won't (but note that any @import inside it will).

The SheetLoadData::mURL it's supposed to be the url of the stylesheet,
so for StyleSheet::Replace it should be null.

Differential Revision: https://phabricator.services.mozilla.com/D80379
2020-06-23 02:54:58 +00:00
Emilio Cobos Álvarez 9541790d6a Bug 1646776 - Add some logging for sheet cache misses for the same URI. r=heycam
This makes it easy to see why your test is not failing without your
patch, for example ;)

Note that we log only when the URIs are the same, which
I think is a reasonable compromise in verbosity.

Differential Revision: https://phabricator.services.mozilla.com/D80288
2020-06-22 10:48:44 +00:00
Emilio Cobos Álvarez 939c7c466b Bug 1642591 - Don't make referrer policy a cache miss for sub-resource {pre,}loads. r=mayhemer,tnikkel
For preload we're already effectively not using it, I think, due to
bug 1642325.

For images, this matches the spec, see earlier comments in this bug and
https://bugzilla.mozilla.org/show_bug.cgi?id=1174921#c17.  I think it
makes sense for other sub-resources to align as well.

Differential Revision: https://phabricator.services.mozilla.com/D79812
2020-06-18 14:06:20 +00:00
Noemi Erli 22b81ffefa Backed out 2 changesets (bug 1603542) for causing assertion failures in Loader.cpp CLOSED TREE
Backed out changeset cc70c96b63e0 (bug 1603542)
Backed out changeset c3dcacdd97c4 (bug 1603542)
2020-06-17 18:37:45 +03:00
Honza Bambas 4339a72958 Bug 1603542 - Properly mark CSS preloads as used when processing stylesheet tags or imports, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D76528
2020-06-17 14:07:16 +00:00
Emilio Cobos Álvarez 901e5fd0d7 Bug 1645180 - Don't under-report use counters for documents that hit the shared sheet cache. r=firefox-style-system-reviewers,heycam
This makes us refactor a bit more our setup but I think the end it's
worth it.

Differential Revision: https://phabricator.services.mozilla.com/D79377
2020-06-13 02:03:08 +00:00
Emilio Cobos Álvarez 5df2b6ec58 Bug 1599160 - Stop synthesizing performance timing entries for cache sheets. r=mayhemer
This basically undoes D77842, but it was better done on top than just
removing the patch from the stack. I could squash them if desired.

The previous patch to respect caching headers makes tests much much more
happy, to the point where I'm not sure whether we really need this or
not. Your call whether we should keep it or not.

Differential Revision: https://phabricator.services.mozilla.com/D78660
2020-06-12 19:06:12 +00:00
Emilio Cobos Álvarez e5fe143835 Bug 1599160 - Better integration of the shared stylesheet cache with the network cache. r=tnikkel,mayhemer,heycam
Make the stylesheet cache respect the same headers as the image cache
does. This makes no-cache stylesheets work as they do now, which is
useful for developers that want to develop sites locally, and for
shift-reloads, etc.

Differential Revision: https://phabricator.services.mozilla.com/D78659
2020-06-12 19:06:04 +00:00
Emilio Cobos Álvarez 10eb040bda Bug 1599160 - Add a performance resource entry when hitting the cache for the first time in a document. r=mayhemer,valentin
This matches other browsers, our current behavior, and the test
expectations from various WPTs.

Differential Revision: https://phabricator.services.mozilla.com/D77842
2020-06-12 19:05:56 +00:00
Emilio Cobos Álvarez f3e71a1931 Bug 1599160 - Allow caching stylesheets across documents. r=heycam
This patch implements a per-process cache of parsed stylesheets for
non-inline sheets. The entries are evicted when the document gets
destroyed and there's no other document with the same principal around.

This works fine in practice even when navigating because CC happens
pretty late, but we could add an extra timer if we deem it worth it.

I had to adapt some tests so that they keep passing. They were already
clearing various image / network caches so it seems fine to also clear
this one.

Note that there's a very subtle change in the load data key: We only
miss the cache if the referrer _policy_ is different, not if the
referrer is different. While that is slightly dubious, that is the only
think that makes this effort somewhat worth it. Otherwise stylesheets
would have to be re-fetched if the referrer is different, which
effectively would mean to re-parse it if the document URI is different,
which is bad.

It seems like the network cache only keys on the referrer policy, so it
seems fine to do the same.

Differential Revision: https://phabricator.services.mozilla.com/D77457
2020-06-12 19:31:32 +00:00
Razvan Maries 7b30d6e82e Backed out 7 changesets (bug 1599160) for damp failures. CLOSED TREE
Backed out changeset edb0e17f3c98 (bug 1599160)
Backed out changeset 64b42ac358e6 (bug 1599160)
Backed out changeset ce1521b895e1 (bug 1599160)
Backed out changeset 0b0ff0ad8db7 (bug 1599160)
Backed out changeset c7ef05dae614 (bug 1599160)
Backed out changeset 466cfd0ad5db (bug 1599160)
Backed out changeset b3f28494f0e7 (bug 1599160)
2020-06-12 02:40:38 +03:00
Emilio Cobos Álvarez d1db9f246c Bug 1599160 - Stop synthesizing performance timing entries for cache sheets. r=mayhemer
This basically undoes D77842, but it was better done on top than just
removing the patch from the stack. I could squash them if desired.

The previous patch to respect caching headers makes tests much much more
happy, to the point where I'm not sure whether we really need this or
not. Your call whether we should keep it or not.

Differential Revision: https://phabricator.services.mozilla.com/D78660
2020-06-11 11:42:08 +00:00
Emilio Cobos Álvarez 5048e0ec84 Bug 1599160 - Better integration of the shared stylesheet cache with the network cache. r=tnikkel,mayhemer,heycam
Make the stylesheet cache respect the same headers as the image cache
does. This makes no-cache stylesheets work as they do now, which is
useful for developers that want to develop sites locally, and for
shift-reloads, etc.

Differential Revision: https://phabricator.services.mozilla.com/D78659
2020-06-11 11:42:01 +00:00
Emilio Cobos Álvarez d999791a43 Bug 1599160 - Add a performance resource entry when hitting the cache for the first time in a document. r=mayhemer,valentin
This matches other browsers, our current behavior, and the test
expectations from various WPTs.

Differential Revision: https://phabricator.services.mozilla.com/D77842
2020-06-11 11:41:59 +00:00
Emilio Cobos Álvarez 208b60eed2 Bug 1599160 - Allow caching stylesheets across documents. r=heycam
This patch implements a per-process cache of parsed stylesheets for
non-inline sheets. The entries are evicted when the document gets
destroyed and there's no other document with the same principal around.

This works fine in practice even when navigating because CC happens
pretty late, but we could add an extra timer if we deem it worth it.

I had to adapt some tests so that they keep passing. They were already
clearing various image / network caches so it seems fine to also clear
this one.

Note that there's a very subtle change in the load data key: We only
miss the cache if the referrer _policy_ is different, not if the
referrer is different. While that is slightly dubious, that is the only
think that makes this effort somewhat worth it. Otherwise stylesheets
would have to be re-fetched if the referrer is different, which
effectively would mean to re-parse it if the document URI is different,
which is bad.

It seems like the network cache only keys on the referrer policy, so it
seems fine to do the same.

Differential Revision: https://phabricator.services.mozilla.com/D77457
2020-06-11 11:42:46 +00:00
Emilio Cobos Álvarez 5f15c64dda Bug 1642224 - Make sheet loads always have a sensible triggering principal. r=ckerschb
I'm going to need to always have a principal at hand for bug 1599160,
and this helps with that.

This fixes the assumptions in the comment here:

  https://searchfox.org/mozilla-central/rev/5e4d4827aa005d031580d2d17a01bae1af138b2e/layout/style/Loader.cpp#1408-1411

Which are not always true I think.

In particular, we may not always do a non-system load without an
associated DOM node. For link headers, we use the document loader, but
there's no DOM node to get a hand to. In those cases, before this patch
we're currently loading using the system principal, which seems wrong.

Differential Revision: https://phabricator.services.mozilla.com/D77614
2020-06-08 09:11:26 +00:00
Emilio Cobos Álvarez f8b1e141b1 Bug 1642232 - Remove SheetState::Unknown. r=jwatt
It's unused.

Differential Revision: https://phabricator.services.mozilla.com/D77615
2020-05-31 18:56:03 +00:00
Emilio Cobos Álvarez 2f5607b8d0 Bug 1642221 - Rename SheetLoadData::mLoaderPrincipal to mTriggeringPrincipal. r=jwatt
I'm about to introduce the concept of "Loader principal" (as in "the
principal of the CSS loader"), and SheetLoadData already has an
mLoaderPrincipal.

However SheetLoadData's principal is just the triggering principal (the
principal that initiated the load). So name it that with consistency
with SheetInfo::mTriggeringPrincipal etc.

Differential Revision: https://phabricator.services.mozilla.com/D77613
2020-05-31 17:11:57 +00:00
Emilio Cobos Álvarez 5223bb118d Bug 1641861 - Remove some useless includes from Loader.h. r=xidorn
Differential Revision: https://phabricator.services.mozilla.com/D77456
2020-05-29 13:48:11 +00:00
Emilio Cobos Álvarez 1ed9a59aaf Bug 1640158 - Remove useless principal-passing in the CSS loader. r=ckerschb
The only caller that passes that principal is the only caller that calls
into LoadSheet with a loader that has a document anyway.

And the principal we're passing is Document::NodePrincipal(), which is
what we'd end up using anyway, so the new code is exactly equivalent, as
far as I can tell.

Differential Revision: https://phabricator.services.mozilla.com/D76469
2020-05-25 09:42:01 +00:00
Emilio Cobos Álvarez c3b7227771 Bug 1639392 - Merge nsIStyleSheetLinkingElement and nsStyleLinkElement, and call it LinkStyle. r=jwatt
Which is the spec term. nsIStyleSheetLinkingElement is even more
confusing since it may not be an element at all (see: processing
instructions).

Differential Revision: https://phabricator.services.mozilla.com/D76071
2020-05-21 03:07:16 +00:00
Emilio Cobos Álvarez e41d05d0ca Bug 1639262 - Get the right "is preload" value to CreateSheet. r=nordzilla
This could also cause mismatches in the cache for no good reason.

Differential Revision: https://phabricator.services.mozilla.com/D76003
2020-05-21 00:06:25 +00:00
Emilio Cobos Álvarez a147afc07d Bug 1639262 - Avoid duplicate entries in the stylesheet cache. r=nordzilla,firefox-style-system-reviewers
When the loader finds an already-complete stylesheet, it will call
PostLoadEvent to fire the load event of the relevant <link> element,
etc.

For that, it'll mint a SheetLoadData, with various fields hard-coded.
That causes us to eventually insert the sheet in mCompleteSheets, but
with a different key, which means we'll end up with two copies of the
same stylesheet in the cache, than when reporting memory we'll report
twice.

Fix it by constructing the right load data a bit sooner, and add an
assertion to ensure this doesn't happen anymore.

Differential Revision: https://phabricator.services.mozilla.com/D76000
2020-05-20 21:16:04 +00:00
Ting-Yu Lin 0865183345 Bug 1638917 - Replace mozilla::Tuple with std::tuple in layout. r=emilio
Also, replace mozilla::Tie with std::tie, and use C++17 structured
binding at some places where they make sense.

Differential Revision: https://phabricator.services.mozilla.com/D75821
2020-05-19 03:59:23 +00:00
Emilio Cobos Álvarez 52792dc151 Bug 1636974 - Unbust base toolchain builds by working around a GCC bug. CLOSED TREE
MANUAL PUSH: Unbust base toolchain builds, CLOSED TREE
2020-05-12 20:47:25 +02:00
Emilio Cobos Álvarez ed46f1f078 Bug 1636974 - Make SheetLoadData know whether it's a preload on construction. r=mayhemer
And make a bunch of other stuff const while at it.

Differential Revision: https://phabricator.services.mozilla.com/D74860
2020-05-12 16:36:11 +00:00
Razvan Maries d70a3f8735 Backed out 2 changesets (bug 1636974) for wpt perma failures at subresource-integrity.html. CLOSED TREE
Backed out changeset 74820b124af2 (bug 1636974)
Backed out changeset f53ceddd5fe3 (bug 1636974)
2020-05-12 22:46:15 +03:00
Emilio Cobos Álvarez d7e8e84ac7 Bug 1636974 - Unbust base toolchain builds by working around a GCC bug.
MANUAL PUSH: Unbust base toolchain builds, CLOSED TREE
2020-05-12 20:48:00 +02:00
Emilio Cobos Álvarez d17a489ef0 Bug 1636974 - Make SheetLoadData know whether it's a preload on construction. r=mayhemer
And make a bunch of other stuff const while at it.

Differential Revision: https://phabricator.services.mozilla.com/D74860
2020-05-12 16:36:11 +00:00
Simon Giesecke 8aa47bcfb7 Bug 1613985 - Use default for equivalent-to-default constructors/destructors in layout. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D66016

--HG--
extra : moz-landing-system : lando
2020-03-17 09:38:32 +00:00
Emilio Cobos Álvarez 256c124f94 Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:

This was done by applying:

```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
         from subprocess import Popen, PIPE, check_output, CalledProcessError

         diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
-        args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+        args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']

         if not output_file:
             args.append("-i")
```

Then running `./mach clang-format -c <commit-hash>`

Then undoing that patch.

Then running check_spidermonkey_style.py --fixup

Then running `./mach clang-format`

I had to fix four things:

 * I needed to move <utility> back down in GuardObjects.h because I was hitting
   obscure problems with our system include wrappers like this:

0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94              ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94     MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94                                ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)

   Which I really didn't feel like digging into.

 * I had to restore the order of TrustOverrideUtils.h and related files in nss
   because the .inc files depend on TrustOverrideUtils.h being included earlier.

 * I had to add a missing include to RollingNumber.h

 * Also had to partially restore include order in JsepSessionImpl.cpp to avoid
   some -WError issues due to some static inline functions being defined in a
   header but not used in the rest of the compilation unit.

Differential Revision: https://phabricator.services.mozilla.com/D60327

--HG--
extra : moz-landing-system : lando
2020-01-20 16:19:48 +00:00
Emilio Cobos Álvarez aa3a695712 Bug 1609996 - Remove mozilla/Move.h. r=froydnj
rg -l 'mozilla/Move.h' | xargs sed -i 's/#include "mozilla\/Move.h"/#include <utility>/g'

Further manual fixups and cleanups to the include order incoming.

Differential Revision: https://phabricator.services.mozilla.com/D60323

--HG--
extra : moz-landing-system : lando
2020-01-20 16:18:20 +00:00
Jonathan Kingston 84c462a2d0 Bug 1605814 - Don't capture CSP nonce when loading a child sheet. r=emilio,ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D58686

--HG--
extra : moz-landing-system : lando
2020-01-13 11:47:25 +00:00
Emilio Cobos Álvarez 2c0c593033 Bug 1600376 - Remove useless namespace qualifications in layout/style. r=jwatt
All these things are in the mozilla namespace and such. Clean up a bit.

Differential Revision: https://phabricator.services.mozilla.com/D55319

--HG--
extra : moz-landing-system : lando
2019-11-30 11:57:10 +00:00
Emilio Cobos Álvarez 231400e386 Bug 1594449 - followup: fix some CSS loader comments. r=mayhemer
Relatedly: We only use this to determine priority. It seems we prioritize
<link rel=preload> over <link rel=stylesheet>, is that intended?

That seems a bit weird, as the preloads from the parser are likely to be used
very soon.

Differential Revision: https://phabricator.services.mozilla.com/D55225

--HG--
extra : moz-landing-system : lando
2019-11-29 12:55:51 +00:00
Honza Bambas ce072f8e6a Bug 1594449 - <link rel="preload"> implemented as a speculative load initiated during the prescan phase in the HTML5 parser, disabled by default, only supports "script" and "styles" types, r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D52019

--HG--
extra : moz-landing-system : lando
2019-11-27 21:45:12 +00:00
Thomas Nguyen 32ab8293ff Bug 1528697 - Expose ReferrerPolicy.webidl and use referrerpolicy enum r=smaug
ReferrerPolicy gets tossed back and forth as a uint32_t and
ReferrerPolicy enum in header file. Expose ReferrerPolicyValues from
webidl file and use consistently in native code.

Differential Revision: https://phabricator.services.mozilla.com/D41954

--HG--
extra : moz-landing-system : lando
2019-08-21 13:24:45 +00:00
Emilio Cobos Álvarez 86651be7e1 Bug 1571530 - Make PrepareSheet take a reference. r=heycam
Differential Revision: https://phabricator.services.mozilla.com/D41561

--HG--
extra : moz-landing-system : lando
2019-08-16 10:56:18 +00:00
Emilio Cobos Álvarez 36d3f1e1b9 Bug 1571530 - Cleanup confusing lifetime of SheetLoadData. r=heycam
Saving a refcount bump is not worth the churn. Use a proper RefPtr<>
everywhere instead of manual refcounting, and don't make DoSheetComplete call
NS_RELEASE unconditionally.

Also, make clear by using references where null is expected or not.

Also, properly use a RefPtr in mPendingDatas, since they are strong pointers,
in fact.

Finally, remove some unused macros from nsCSSValue of which this code was the
last consumer.

Differential Revision: https://phabricator.services.mozilla.com/D41090

--HG--
extra : moz-landing-system : lando
2019-08-16 10:56:09 +00:00
Emilio Cobos Álvarez 6779b66f01 Bug 1571530 - Remove various bool arguments in sheet loader APIs. r=heycam
They're bad, specially if they do vastly different thing in overloaded
functions, like aUseSystemPrincipal and aIsPreload. :)

Differential Revision: https://phabricator.services.mozilla.com/D40851

--HG--
extra : moz-landing-system : lando
2019-08-16 10:56:05 +00:00