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

13251 Коммитов

Автор SHA1 Сообщение Дата
Mats Palmgren 12bca02735 Bug 1607954 part 1 - [css-grid][css-align] Implement style system support for Masonry layout. r=emilio
This implements support for this CSS Masonry layout proposal:
https://github.com/w3c/csswg-drafts/issues/4650

I've intentionally left out a shorthand (place-tracks?) for now until
we have a draft CSS spec for this.

Differential Revision: https://phabricator.services.mozilla.com/D67061
2020-04-28 01:18:44 +00:00
Emilio Cobos Álvarez b8fbb6ead5 Bug 1509418 - Collect ancestor hashes from single-length :is and :where selector lists. r=heycam,boris
We can only collect hashes from single-length selectors, as described in
the comment.

Differential Revision: https://phabricator.services.mozilla.com/D71458
2020-04-23 19:20:35 +00:00
Emilio Cobos Álvarez f92b952261 Bug 1509418 - Handle disjoint selectors in the selector map. r=heycam,boris
This way, something like:

  *:where(.foo, .bar)

Will end up twice on the selector map, just as if you would've written
.foo, .bar.

But we're a bit careful to not be wasteful, so:

  .foo:where(div, span)

Will still end up using the .foo bucket.

It needs a bit of borrow-checker gymnastics to avoid cloning the entry
in the common path. It's a bit gross but not too terrible I think.

Differential Revision: https://phabricator.services.mozilla.com/D71457
2020-04-23 19:20:27 +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 8165749eb7 Bug 1509418 - Collect ancestor hashes from single-length :is and :where selector lists. r=heycam,boris
We can only collect hashes from single-length selectors, as described in
the comment.

Differential Revision: https://phabricator.services.mozilla.com/D71458
2020-04-23 19:20:35 +00:00
Emilio Cobos Álvarez bfd3683e13 Bug 1509418 - Handle disjoint selectors in the selector map. r=heycam,boris
This way, something like:

  *:where(.foo, .bar)

Will end up twice on the selector map, just as if you would've written
.foo, .bar.

But we're a bit careful to not be wasteful, so:

  .foo:where(div, span)

Will still end up using the .foo bucket.

It needs a bit of borrow-checker gymnastics to avoid cloning the entry
in the common path. It's a bit gross but not too terrible I think.

Differential Revision: https://phabricator.services.mozilla.com/D71457
2020-04-23 19:20:27 +00: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
Daniel Holbert 4adb473174 Bug 1626458 part 1: Remove pref for CSS Containment (layout.css.contain.enabled) r=AlaskanEmily
(Since we've been shipping with it default-enabled for a while now.)

See https://bugzilla.mozilla.org/show_bug.cgi?id=1466008#c9 through #c13 for
notes on the reftest.list change.

Differential Revision: https://phabricator.services.mozilla.com/D71861
2020-04-23 05:01:07 +00:00
Simon Sapin 5af9f4fc2a Bug 1631721 - Remove hashglobe r=manishearth
Differential Revision: https://phabricator.services.mozilla.com/D71743
2020-04-23 00:19:51 +00:00
Simon Sapin 08ac9e2e6c Bug 1631721 - Use std::alloc instead of hashbrown::alloc in fallible r=manishearth
This works even if the Rust standard library’s allocator is not `libc::malloc`,
so we can remove the `known_system_malloc `feature flag
and make the `fallible` crate unconditional.

Differential Revision: https://phabricator.services.mozilla.com/D71742
2020-04-23 00:19:51 +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
Simon Sapin cbe24024bb Bug 1631721 - Vendor the hashbrown crate r=manishearth
This is the hash map implementation now used in the Rust standard library:

* https://blog.rust-lang.org/2019/07/04/Rust-1.36.0.html#a-new-hashmapk-v-implementation
* https://github.com/rust-lang/rust/pull/58623
* https://crates.io/crates/hashbrown

Differential Revision: https://phabricator.services.mozilla.com/D71740
2020-04-23 00:19:50 +00:00
Emilio Cobos Álvarez 6341ebf29a Bug 1632363 - Fix some warnings introduced by the previous patches.
MANUAL PUSH: Avoid reviewer information from previous patches from
getting lost.
2020-04-23 05:11:04 +02:00
Martin Robinson 2561f2d680 Bug 1632363 - Add support for canceling CSS transitions. r=emilio
This change adds support for canceling CSS transitions when a property
is no longer transitionable or when an element becomes styled with
display:none. Support for canceling and replacing CSS transitions when
the end value changes is still pending. This change also takes advantage
of updating the constellation message to fix a bug where transition
events could be sent for closed pipelines.

Cherry-picked from https://github.com/servo/servo/pull/26244
(though this is not part of the Gecko build).
2020-04-23 05:10:23 +02:00
Martin Robinson 34bc586539 Bug 1632363 - Eliminate `AnimationFrame`. r=emilio
This intermediate data structure doesn't really buy us anything and is a
bit confusing.

Cherry-picked from https://github.com/servo/servo/pull/26214
(though this is not part of the Gecko build).
2020-04-23 05:10:21 +02:00
Anthony Ramine 9c1d8b545f Bug 1632363 - Make the rule tree actually threadsafe. r=emilio
RuleTree::gc is now a safe method that any thread can call
at any time, and StrongRuleNode values can all be dropped
whenever their owner want to, on any thread.

Cherry-picked from https://github.com/servo/servo/pull/26227
2020-04-23 05:10:20 +02:00
Anthony Ramine 7b4fc703a7 Bug 1632363 - Change Map::get_or_insert_with to Map::entry. r=emilio
Cherry-picked from https://github.com/servo/servo/pull/26227
2020-04-23 05:10:18 +02:00
Emilio Cobos Álvarez 2550d855b2 Bug 1631232 - Ensure that we hold an actual reference to the root, not to a field of a node we can just GC below. r=nox
Differential Revision: https://phabricator.services.mozilla.com/D71542
2020-04-20 11:07:22 +00:00
Anthony Ramine cf2f0bb18e Bug 1631232 - Always upgrade existing weak child references in the rule tree. r=emilio
Just because we didn't find a child when read-locking a node children list
doesn't mean it still won't exist while we wait to upgrade the read lock
into a write lock to create the child.

This cherry-picks https://github.com/servo/servo/pull/26220

MANUAL PUSH: So that I can preserve reviewer information.
2020-04-19 12:25:55 +02:00
Emilio Cobos Álvarez c1c10e4f44 Bug 1631154 - Fix a size test that was trying to test a now-private type.
MANUAL PUSH: bustage on a CLOSED TREE
2020-04-18 04:33:40 +02:00
Emilio Cobos Álvarez 57516a9b50 Bug 1631154 - Rustfmt and fix Servo build.
MANUAL PUSH: Review information would be lost.
2020-04-18 04:04:24 +02:00
Emilio Cobos Álvarez 73ce034b20 Bug 1631154 - Fix some rebase messups. 2020-04-18 04:04:24 +02:00
Martin Robinson 08a4e2cbc2 Bug 1631154 - Add an iterator for transition properties. r=emilio
This simplifies the code a bit and also will allow us to more easily
make improvements to servo's animation implementation in the future.
2020-04-18 04:04:24 +02:00
Anthony Ramine 54e5523868 Bug 1631154 - Introduce a new type UnsafeBox<T> in the rule tree. r=emilio
This lets us rely less on raw pointers, thus better tracking the lifetime
of the rule node values while dropping strong references etc.
2020-04-18 04:04:24 +02:00
Anthony Ramine 06ea2dd325 Bug 1631154 - Make StrongRuleNode::downgrade be unsafe. r=emilio 2020-04-18 04:04:24 +02:00
Anthony Ramine 49a6858e5c Bug 1631154 - Make StrongRuleNode::ensure_child take a StrongRuleNode for the root. r=emilio 2020-04-18 04:04:24 +02:00
Anthony Ramine a8dec99fc8 Bug 1631154 - Remove WeakRuleNode::clone. r=emilio
MallocSizeOf for RuleTree should not keep around weak references in
case someone runs a GC meanwhile.
2020-04-18 04:04:24 +02:00
Anthony Ramine f71e5d7ef4 Bug 1631154 - Make WeakRuleNode::from_ptr be unsafe. r=emilio 2020-04-18 04:04:24 +02:00
Anthony Ramine 47d8182814 Bug 1631154 - Make StrongRuleNode::from_ptr be unsafe. r=emilio 2020-04-18 04:04:24 +02:00
Anthony Ramine 2d243f239d Bug 1631154 - Move the meat of the rule tree to a submodule "core". r=emilio 2020-04-18 04:04:24 +02:00
Anthony Ramine 971b28fce9 Bug 1631154 - Move CascadeLevel to its own rule_tree submodule. r=emilio 2020-04-18 04:04:24 +02:00
Anthony Ramine ebdcec89d4 Bug 1631154 - Refactor rule tree children. r=emilio
We move the data structure to its own module for better
encapsulation of unsafe code.
2020-04-18 04:04:24 +02: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
Emilio Cobos Álvarez b69a3cb639 Bug 1630676 - Fix two regressions from the previous patches.
MANUAL PUSH: Review information for upstream patches would get lost otherwise.
2020-04-16 21:17:50 +02:00
Emilio Cobos Álvarez 2be2ef7470 Bug 1630676 - Reformat recent changes, various build fixes, and tidy fixes. 2020-04-16 21:17:50 +02:00
Josh Matthews 1f61fd94da Bug 1630676 - Refactor some Servo-only animations code. 2020-04-16 21:17:44 +02:00
Anthony Ramine e0efb285ff Bug 1630676 - Rearrange FontLanguageOverride. r=emilio
Creating one from a u32 should be unsafe because we rely on the fact that the
value is a valid &str.
2020-04-16 21:17:43 +02:00
Anthony Ramine cd9ba34b12 Bug 1630676 - Replace ScopedTLS::unsafe_get by ScopedTLS::into_slots. r=emilio
We only ever look at the slots after we are done with the thread pool,
so we don't need to expose any unsafety to inspect the slots.
2020-04-16 21:17:42 +02:00
Anthony Ramine 26b6ee1d3a Bug 1630676 - Don't use transmute to create PaintOrder values. r=emilio
I checked that rustc optimises the code just as well as with the transmute.

https://rust.godbolt.org/z/w6UJN4
2020-04-16 21:17:41 +02: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
Tipowol 538f9d20c8 Bug 1630676 - Update Servo's attribute length parsing code to match spec. 2020-04-16 21:17:40 +02:00
Martin Robinson 51ad515388 Bug 1630676 - Cherry-pick some layout-2020 changes. 2020-04-16 21:17:39 +02:00
Josh Matthews 785ded933e Bug 1630676 - Update ipc-channel and crossbeam-channel in Servo. 2020-04-16 21:17:39 +02:00
Simon Sapin 0158f5c65e Bug 1630676 - Fix some errors and formatting changes when updating rustc to 1.43.0-nightly (5d04ce67f 2020-02-13). 2020-04-16 21:17:38 +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