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

180 Коммитов

Автор SHA1 Сообщение Дата
Boris Chiou 63df6026b6 Bug 1676782 - Part 2: Hook @scroll-timeline rule into style system. r=emilio
We add scroll-timeline rule into the stylesheet rule type, and add a new
perference to protect it: layout.css.scroll-linked-animations.enabled.

We will use this perference for animation-timeline property as well.

Differential Revision: https://phabricator.services.mozilla.com/D125765
2021-09-17 20:25:36 +00:00
Emilio Cobos Álvarez 0f945d081b Bug 1728348 - Add some scaffolding for @layer rules. r=boris
Not hooked anywhere yet, so this doesn't change behavior, but adds the
basic data model etc.

Adding parsing support requires some changes to cssparser to allow the
same at rule to be block and statement-like at the same time, so better
done separately.

Differential Revision: https://phabricator.services.mozilla.com/D124079
2021-09-03 09:12:43 +00:00
Emilio Cobos Álvarez e54b955075 Bug 1718337 - More fine-grained viewport units invalidation. r=layout-reviewers,jfkthame
This should speed up window resize significantly.

Differential Revision: https://phabricator.services.mozilla.com/D118878
2021-07-07 11:16:20 +00:00
Emilio Cobos Álvarez bc46dae04f Bug 1697998 - Invalidate a bit more aggressively when a pseudo-element matches, in order to also invalidate the cached pseudo-styles on the parent. r=mats
This should probably be fine. If it becomes a perf issue somehow we can
implement the RESTYLE_PSEUDOS hint or what not.

Differential Revision: https://phabricator.services.mozilla.com/D108338
2021-03-15 21:05:01 +00:00
Emilio Cobos Álvarez a3e653759b Bug 1696447 - Share CascadeData instances across ShadowRoots. r=boris
This should be both a memory and speed win for pages using a lot of
Shadow DOM.

In order to make the cache properly work we need to start keying media query
results on the actual StyleSheetContents, as that's what we share on Gecko, but
that should all be fine.

Differential Revision: https://phabricator.services.mozilla.com/D107266
2021-03-10 12:34:09 +00:00
Emilio Cobos Álvarez 50404c19c1 Bug 1695251 - Cherry-pick various servo changes.
All formatting and not-part-of-the-gecko-build changes.

Differential Revision: https://phabricator.services.mozilla.com/D106634
2021-02-26 17:00:55 +00:00
Emilio Cobos Álvarez 076ee57756 Bug 1682174 - Remove layout.css.moz-any-is-is.enabled. r=boris
We shipped this, let's remove the MozAny code.

Differential Revision: https://phabricator.services.mozilla.com/D99607
2020-12-16 20:24:03 +00:00
Emilio Cobos Álvarez 31a5bb70b4 Bug 1678881 - Avoid some allocations in selector serialization. r=xidorn
The allocations in display_to_css_identifier show up in the profiles of
bug 1675628.

Differential Revision: https://phabricator.services.mozilla.com/D97856
2020-11-22 01:02:22 +00:00
Emilio Cobos Álvarez a44649b0ba Bug 1673930 - Use document quirks mode rather than sheet quirks mode for stylesheet invalidation. r=nordzilla
In order to determine whether classes or ids are case insensitive we
need the document quirks mode. The sheet quirks mode almost always
matches, but may not match when sheets are added by privileged APIs.

Differential Revision: https://phabricator.services.mozilla.com/D95061
2020-10-30 19:47:19 +00:00
Emilio Cobos Álvarez 711e7aa60e Bug 1659718 - Bail out when collecting invalidations for nested rules if any of them make us fully invalid. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D87446
2020-08-20 10:45:42 +00:00
Emilio Cobos Álvarez b800731028 Bug 1655751 - Invalidate for CSSOM changes in a more fine-grained way. r=heycam
Also, for changes in CSS declarations, like changing
cssRules[i].style.color or something, we end up avoiding a lot of the
work we were doing.

This page still trips us in the sense that they add a stylesheet, then
call getBoundingClientRect(), then insert more rules in the stylesheet,
which causes us to rebuild a lot of the cascade data.

We could try to detect appends to the last stylesheet on the list or
something I guess, and avoid rebuilding the cascade data in some cases.

Depends on D85615

Differential Revision: https://phabricator.services.mozilla.com/D85616
2020-08-10 18:00:44 +00:00
Emilio Cobos Álvarez 3e6d61cbd1 Bug 1655751 - Fix a silly mistake in which we'd prefer a local name / tag invalidation to an id invalidation. r=heycam
ID invalidations should always win.

This also prefers invalidations deeper in the subtree to higher up.

Differential Revision: https://phabricator.services.mozilla.com/D85615
2020-08-10 18:00:29 +00:00
Emilio Cobos Álvarez 12c7ce039a Bug 1652698 - Make stylesheet invalidation faster. r=heycam
This fixes performance issues when there's a massive number of rules and
a massive DOM.

Instead of going through all rules for all the DOM, we now look stuff in
hashmaps.

Differential Revision: https://phabricator.services.mozilla.com/D83506
2020-07-20 07:40:17 +00:00
Cameron McCormack 82b32f112e Bug 1643246 - Don't use attribute selectors for determining if a select is a drop down or a list box. r=emilio
Instead add a pseudo-class that does the expected size="" attribute parsing.

Removing the Gtk-specific rule setting the text color since it doesn't
seem to have any effect currently.

Differential Revision: https://phabricator.services.mozilla.com/D83448
2020-07-17 09:56:53 +00:00
Emilio Cobos Álvarez 3eaf5b6acb Bug 1646811 - Sync some comment changes from servo.
Depends on D80244

Differential Revision: https://phabricator.services.mozilla.com/D80245
2020-06-18 18:14:10 +00:00
Simon Sapin 7c14e4e23e Bug 1633410 - Back out bug 1631721.
Rebased and squashed.

Differential Revision: https://phabricator.services.mozilla.com/D78174
2020-06-18 15:25:33 +00:00
Emilio Cobos Álvarez b774002cf9 Bug 1646546 - Switch all callsites of try() to try_parse() in the style crate. r=boris
Fully automated via:

  $ rg -l '\.try\(' | xargs sed -i 's/\.try(/.try_parse(/g'
  $ cd servo/components/style && cargo +nightly fmt

Differential Revision: https://phabricator.services.mozilla.com/D80099
2020-06-17 22:27:37 +00:00
Emilio Cobos Álvarez a58560613e Bug 1643201 - Rustfmt recent changes.
Depends on D78203

Differential Revision: https://phabricator.services.mozilla.com/D78204
2020-06-04 00:35:41 +00:00
Emilio Cobos Álvarez 31ea245f41 Bug 1643201 - Miscellaneous build fixes.
Depends on D78198

Differential Revision: https://phabricator.services.mozilla.com/D78199
2020-06-04 00:35:08 +00:00
Emilio Cobos Álvarez 99ed9d65e3 Bug 1640843 - Finer grained invalidation for attribute changes. r=heycam
This should help out quite a bit with uBO, which has lots of very
general attribute selectors. We invalidate per attribute name rather
than using a SelectorMap, which prevents matching for attribute
selectors that can't have changed.

The idea is that this should be generally cheaper, though there are
cases where this would be a slight pesimization. For example, if there's
an attribute selector like:

  my-specific-element[my-attribute] { /* ... */ }

And you change `my-attribute` in an element that isn't a
`my-specific-element`, before that the SelectorMap would've prevented us
from selector-matching completely. Now we'd still run selector-matching
for that (though the matching would be pretty cheap).

However I think this should speed up things generally, let's see what
the perf tests think before landing this though.

Differential Revision: https://phabricator.services.mozilla.com/D76825
2020-05-27 09:17:47 +00:00
Emilio Cobos Álvarez b50a39c2d3 Bug 1639533 - Fix a no-longer valid assumption in pseudo-element matching / invalidation code. r=heycam
After bug 1632647, we can have pseudo-classes inside :not / :is /
:where, which the invalidation and matching code weren't handling.

Add a few tests for this stuff working as expected.

Differential Revision: https://phabricator.services.mozilla.com/D76160
2020-05-20 23:53:34 +00:00
Emilio Cobos Álvarez 7ff7bc8cc2 Bug 1509418 - Optimize invalidation by scanning the rightmost compound inside :where() and :is() with the outer visitor. r=heycam,boris
See the comment about why this is valuable. For a selector like:

    .foo:is(.bar) > .baz

Before this patch we'd generate an Dependency for .bar like this:

    Dependency {
        selector: .bar,
        offset: 0,
        parent: Some(Dependency {
            selector: .foo:is(.bar) > .baz,
            offset: 1, // Pointing to the `>` combinator.
            parent: None,
        }),
    }

After this patch we'd generate just:

    Dependency {
        selector: .foo:is(.bar) > .baz,
        offset: 1, // Pointing to the `>` combinator.
        parent: None,
    }

This is not only less memory but also less work. The reason for that is that,
before this patch, when .bar changes, we'd look the dependency, and see there's
a parent, and then scan that, so we'd match `.bar` two times, one for the
initial dependency, and one for .foo:is(.bar).

Instead, with this we'd only check `.foo:is(.bar)` once.

Differential Revision: https://phabricator.services.mozilla.com/D71423
2020-04-23 19:20:17 +00:00
Emilio Cobos Álvarez 2975274c6b Bug 1509418 - Make Invalidation work in terms of a dependency, not a selector. r=heycam,boris
That way we can look at the parent dependency as described in the previous
patch. An alternative would be to add a:

    parent_dependency: Option<&'a Dependency>

on construction to `Invalidation`, but this way seems slightly better to avoid
growing the struct. It's not even one more indirection because the selector is
contained directly in the Dependency struct.

Differential Revision: https://phabricator.services.mozilla.com/D71422
2020-04-23 19:20:10 +00:00
Emilio Cobos Álvarez 40a0b1a6d6 Bug 1509418 - Keep track of nested dependencies for :where() and :is(). r=heycam,boris
The tricky part of :is() and :where() is that they can have combinators inside,
so something like this is valid:

  foo:is(#bar > .baz) ~ taz

The current invalidation logic is based on the assumption that you can
represent a combinator as a (selector, offset) tuple, which are stored in the
Dependency struct. This assumption breaks with :is() and :where(), so we need
to make them be able to represent a combinator in an "inner" selector.

For this purpose, we add a `parent` dependency. With it, when invalidating
inside the `:is()` we can represent combinators inside as a stack.

The basic idea is that, for the example above, when an id of "bar" is added or
removed, we'd find a dependency like:

    Dependency {
        selector: #bar > .baz,
        offset: 1, // pointing to the `>` combinator
        parent: Some(Dependency {
            selector: foo:is(#bar > .baz) > taz,
            offset: 1, // Pointing to the `~` combinator.
            parent: None,
        })
    }

That way, we'd start matching at the element that changed, towards the right,
and if we find an element that matches .baz, instead of invalidating that
element, we'd look at the parent dependency, then double-check that the whole
left-hand-side of the selector (foo:is(#bar > .baz)) actually changed, and then
keep invalidating to the right using the parent dependency as usual.

This patch only builds the data structure and keeps the code compiling, the
actual invalidation work will come in a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D71421
2020-04-23 19:20:03 +00:00
Cosmin Sabou dacaa0fa0b Backed out 6 changesets (bug 1509418) for causing dt failures on several files. CLOSED TREE
Backed out changeset 0de514478e3c (bug 1509418)
Backed out changeset 859910d9fee2 (bug 1509418)
Backed out changeset 0abf5d38ab61 (bug 1509418)
Backed out changeset f572e241c626 (bug 1509418)
Backed out changeset 6398c8f1b4d4 (bug 1509418)
Backed out changeset ebef9346b5b1 (bug 1509418)
2020-04-24 08:38:05 +03:00
Emilio Cobos Álvarez 31dc1cb456 Bug 1509418 - Optimize invalidation by scanning the rightmost compound inside :where() and :is() with the outer visitor. r=heycam,boris
See the comment about why this is valuable. For a selector like:

    .foo:is(.bar) > .baz

Before this patch we'd generate an Dependency for .bar like this:

    Dependency {
        selector: .bar,
        offset: 0,
        parent: Some(Dependency {
            selector: .foo:is(.bar) > .baz,
            offset: 1, // Pointing to the `>` combinator.
            parent: None,
        }),
    }

After this patch we'd generate just:

    Dependency {
        selector: .foo:is(.bar) > .baz,
        offset: 1, // Pointing to the `>` combinator.
        parent: None,
    }

This is not only less memory but also less work. The reason for that is that,
before this patch, when .bar changes, we'd look the dependency, and see there's
a parent, and then scan that, so we'd match `.bar` two times, one for the
initial dependency, and one for .foo:is(.bar).

Instead, with this we'd only check `.foo:is(.bar)` once.

Differential Revision: https://phabricator.services.mozilla.com/D71423
2020-04-23 19:20:17 +00:00
Emilio Cobos Álvarez 9c9a799887 Bug 1509418 - Make Invalidation work in terms of a dependency, not a selector. r=heycam,boris
That way we can look at the parent dependency as described in the previous
patch. An alternative would be to add a:

    parent_dependency: Option<&'a Dependency>

on construction to `Invalidation`, but this way seems slightly better to avoid
growing the struct. It's not even one more indirection because the selector is
contained directly in the Dependency struct.

Differential Revision: https://phabricator.services.mozilla.com/D71422
2020-04-23 19:20:10 +00:00
Emilio Cobos Álvarez 9a6a14fb98 Bug 1509418 - Keep track of nested dependencies for :where() and :is(). r=heycam,boris
The tricky part of :is() and :where() is that they can have combinators inside,
so something like this is valid:

  foo:is(#bar > .baz) ~ taz

The current invalidation logic is based on the assumption that you can
represent a combinator as a (selector, offset) tuple, which are stored in the
Dependency struct. This assumption breaks with :is() and :where(), so we need
to make them be able to represent a combinator in an "inner" selector.

For this purpose, we add a `parent` dependency. With it, when invalidating
inside the `:is()` we can represent combinators inside as a stack.

The basic idea is that, for the example above, when an id of "bar" is added or
removed, we'd find a dependency like:

    Dependency {
        selector: #bar > .baz,
        offset: 1, // pointing to the `>` combinator
        parent: Some(Dependency {
            selector: foo:is(#bar > .baz) > taz,
            offset: 1, // Pointing to the `~` combinator.
            parent: None,
        })
    }

That way, we'd start matching at the element that changed, towards the right,
and if we find an element that matches .baz, instead of invalidating that
element, we'd look at the parent dependency, then double-check that the whole
left-hand-side of the selector (foo:is(#bar > .baz)) actually changed, and then
keep invalidating to the right using the parent dependency as usual.

This patch only builds the data structure and keeps the code compiling, the
actual invalidation work will come in a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D71421
2020-04-23 19:20:03 +00:00
Simon Sapin 67ea7f6752 Bug 1631721 - Use hashbrown instead of hashglobe r=manishearth
Differential Revision: https://phabricator.services.mozilla.com/D71741
2020-04-23 00:19:51 +00:00
Emilio Cobos Álvarez 2769a14cc2 Bug 1629735 - Implement parsing / selector-matching for :is() and :where(). r=heycam
This implements the easy / straight-forward parts of the :where / :is
selectors.

The biggest missing piece is to handle properly invalidation when there
are combinators present inside the :where. That's the hard part of this,
actually.

But this is probably worth landing in the interim. This fixes some of
the visitors that were easy to fix.

Differential Revision: https://phabricator.services.mozilla.com/D70788
2020-04-17 13:37:59 +00:00
Anthony Ramine 40593d91fb Bug 1630676 - Don't expose any AtomicRefCell directly from style traits.
This lets us experiment with how we store this data on the DOM side.
2020-04-16 21:17:41 +02:00
Ciure Andrei aec781a233 Backed out 11 changesets (bug 1630676) for causing multiple failures CLOSED TREE
Backed out changeset c1fbe364b76c (bug 1630676)
Backed out changeset 629970c8f0b7 (bug 1630676)
Backed out changeset 1530f4a9aef2 (bug 1630676)
Backed out changeset a5b60fb5a0e1 (bug 1630676)
Backed out changeset a6e1a31c3e0d (bug 1630676)
Backed out changeset 4df9717e28f0 (bug 1630676)
Backed out changeset c76b0b0e503b (bug 1630676)
Backed out changeset 3c89aec57d0a (bug 1630676)
Backed out changeset 369cf504584d (bug 1630676)
Backed out changeset d7eff4acb616 (bug 1630676)
Backed out changeset 1d47c9354eeb (bug 1630676)
2020-04-16 21:45:51 +03:00
Anthony Ramine 451e932aaa Bug 1630676 - Don't expose any AtomicRefCell directly from style traits.
This lets us experiment with how we store this data on the DOM side.
2020-04-16 18:37:49 +02:00
Emilio Cobos Álvarez 2a451d978e Bug 1618509 - Allow to export a shadow part under multiple names. r=jwatt
Other browsers allow this and the spec doesn't really disallow it, so fix it,
add a test and carry on.

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

--HG--
extra : moz-landing-system : lando
2020-03-09 13:04:21 +00:00
Emilio Cobos Álvarez d40bfe4265 Bug 1604173 - Rustfmt recent changes.
Differential Revision: https://phabricator.services.mozilla.com/D57314

--HG--
extra : moz-landing-system : lando
2019-12-16 13:34:20 +00:00
Emilio Cobos Álvarez 4695746608 Bug 1601732 - Update in-tree dependencies to smallvec 1.0. r=glandium
We're vendoring it already so no reason not to. Only a couple dependencies left
after these to get rid of 0.6.

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

--HG--
extra : moz-landing-system : lando
2019-12-05 23:30:59 +00:00
enordin d3412ea23d Bug 1598600 - Refactor InvalidationMap flags to bitflags r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D55862

--HG--
extra : moz-landing-system : lando
2019-12-05 00:13:49 +00:00
Emilio Cobos Álvarez f628d09be6 Bug 1600436 - Rustfmt recent changes.
Differential Revision: https://phabricator.services.mozilla.com/D55357

--HG--
extra : moz-landing-system : lando
2019-11-30 14:13:04 +00:00
Emilio Cobos Álvarez a46d4afe4b Bug 1559076 - Invalidate parts in nested shadow trees correctly. r=heycam
Differential Revision: https://phabricator.services.mozilla.com/D54010

--HG--
extra : moz-landing-system : lando
2019-11-21 10:32:10 +00:00
Emilio Cobos Álvarez 74823e8b90 Bug 1559076 - Implement shadow part forwarding (minus invalidation). r=heycam
Some of the stuff, in particular inside GeckoBindings stuff should be
refactored to be less ugly and duplicate a bit less code, but the rest of the
code should be landable as is.

Some invalidation changes are already needed because we weren't matching with
the right shadow host during invalidation (which made existing ::part() tests
fail).

Pending invalidation work:

 * Making exportparts work right on the snapshots.
 * Invalidating parts from descendant hosts.

They're not very hard but I need to think how to best implement it:

 * Maybe get rid of ShadowRoot::mParts and just walk DOM descendants in the
   Shadow DOM.

 * Maybe implement a ElementHasExportPartsAttr much like HasPartAttr and use
   that to keep the list of elements.

 * Maybe invalidate :host and ::part() together in here[1]

 * Maybe something else.

Opinions?

[1]: https://searchfox.org/mozilla-central/rev/131338e5017bc0283d86fb73844407b9a2155c98/servo/components/style/invalidation/element/invalidator.rs#561

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

--HG--
extra : moz-landing-system : lando
2019-11-21 10:32:32 +00:00
Emilio Cobos Álvarez e75a804980 Bug 1591987 - Fix ElementWrapper::is_link. r=jwatt
And do a full restyle only when the state goes from visited to unvisited or vice
versa. That is, use regular invalidation for addition or removals of href
attributes, for example.

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

--HG--
extra : moz-landing-system : lando
2019-11-05 10:24:36 +00:00
Emilio Cobos Álvarez a57fd16889 Bug 1506842 - Always restyle / repaint when a visited query finishes. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D50810

--HG--
extra : moz-landing-system : lando
2019-11-04 16:55:33 +00:00
Emilio Cobos Álvarez 6a021aec24 Bug 1591297 - Remove some XBL code in the style system. r=hiro
Differential Revision: https://phabricator.services.mozilla.com/D50554

--HG--
extra : moz-landing-system : lando
2019-10-25 12:19:21 +00:00
Emilio Cobos Álvarez e8cd2193b5 Bug 1579585 - Use fallible allocation for stylesheet invalidation. r=jwatt
If the sets get too big we cannot allocate anything else, we'll just empty them
and invalidate the whole document.

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

--HG--
extra : moz-landing-system : lando
2019-09-23 19:08:22 +00:00
Emilio Cobos Álvarez 4505c339ab Bug 1576229 - Account for user stylesheets for Shadow DOM invalidation. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D43992

--HG--
extra : moz-landing-system : lando
2019-08-30 14:35:34 +00:00
Emilio Cobos Álvarez 9ed6555245 Bug 1560777 - Rustfmt and fix tidy on recent changes. 2019-06-23 13:16:03 +02:00
Emilio Cobos Álvarez 86c78d4e72 Bug 1560777 - Remove various bits of dead code removed in upstream servo. r=emilio 2019-06-23 13:10:27 +02:00
violet e6d794f2b0 Bug 1547633 - Invalidate style for ::selection r=emilio
This patch invalidates the style for `::selection`, which will restore the behavior before the regression.

However, it's still not quite correct, because repaint is not triggered. Given that `::selection` requires some major change to implement https://github.com/w3c/csswg-drafts/issues/2474, we can address this problem later.

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

--HG--
extra : moz-landing-system : lando
2019-06-22 10:09:51 +00:00
Emilio Cobos Álvarez 103cf22ede Bug 1505489 - Add plumbing code to invalidate shadow parts. r=heycam
Still does nothing, since we still do not collect part rules, but this is all
the plumbing that should allow us to invalidate parts when attributes or state
change on their ancestors.

Depends on D32641

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

--HG--
extra : moz-landing-system : lando
2019-06-11 17:41:51 +00:00
Evgeniy Reizner 8e33a62cdd Bug 1556388 - Do not use borrowed types in the selectors::Element trait. r=emilio
This cherry-picks https://github.com/servo/servo/pull/23463 with a few fixes for
the Gecko build.
2019-06-03 09:12:17 -04:00