Commit graph

170 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
76c0ae565e style: Fix ::marker invalidation when we need to potentially insert a marker as a result of a style change.
Differential Revision: https://phabricator.services.mozilla.com/D24888
2019-04-12 12:19:37 +02:00
Mats Palmgren
ab8c00e41a style: Add support for the ::marker pseudo element on list items. Alias :-moz-list-bullet/number to that in the parser.
Bug: 205202
Reviewed-by: emilio
2019-03-27 14:29:24 +01:00
Emilio Cobos Álvarez
95ee1a5adf style: Use a single RestyleHint representation.
Differential Revision: https://phabricator.services.mozilla.com/D22828
2019-03-27 14:29:05 +01:00
Cameron McCormack
7efbd9cde6 style: Remove unnecessary mem::transmute in MediaListKey.
Differential Revision: https://phabricator.services.mozilla.com/D16147
2019-01-13 21:58:28 +01:00
Emilio Cobos Álvarez
5f173c463e style: Rustfmt recent changes. 2019-01-07 00:32:54 +01:00
Emilio Cobos Álvarez
8929087d83 style: Update the Rust target version for bindgen.
This brings us alignas support and also associated constants for bitfield enums.

Differential Revision: https://phabricator.services.mozilla.com/D15334
2019-01-07 00:32:50 +01:00
Simon Sapin
be69f9c3e6 Rustfmt has changed its default style :/ 2018-12-28 13:17:47 +01:00
Emilio Cobos Álvarez
7f5a9e0f45 style: Handle nested slots correctly in slotted matching and invalidation.
The patch and test should be pretty much self-descriptive.

Differential Revision: https://phabricator.services.mozilla.com/D14063
2018-12-16 13:35:06 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
b1822a39fa cargo fix --edition --features gecko 2018-11-10 17:47:28 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
3e0250ae61
style: Only no-op visited <-> unvisited changes.
Other changes should really be (and are) indistinguishable.

Differential Revision: https://phabricator.services.mozilla.com/D4847
2018-09-05 19:11:18 +02:00
Cameron McCormack
4ee3b56d54
style: Use an Atom to represent Direction values in pseudo-classes.
Differential Revision: https://phabricator.services.mozilla.com/D4730
2018-09-03 12:33:13 +02:00
Emilio Cobos Álvarez
dceb58664e
style: Remove an assertion that doesn't hold in some cases. 2018-09-03 12:32:05 +02:00
Emilio Cobos Álvarez
a0cb37d29d
style: Simplify visited-related code in invalidation.
We match with AllLinksVisitedAndUnvisited for style invalidation, and we already
do a subtree restyle because :visited matching doesn't depend on the actual
element state.

So all this stuff is just not needed. The comment points to the attribute tests
in bug 1328509, but those still trivially pass with this change.

I think this was unneeded since I introduced AllLinksVisitedAndUnvisited, or
maybe since https://github.com/servo/servo/pull/19520. In any case it doesn't
really matter, and I already had done this cleanup in my WIP patches for
bug 1406622, but I guess this is a slightly more suitable place to land them :)

Differential Revision: https://phabricator.services.mozilla.com/D3305
2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
87b1e1cdc9
style: no-op visited changes earlier if visited links are disabled.
We force a repaint from ContentStateChangedInternal if visited links are
disabled, and that's observable. Let's cut it off as early as we can to avoid
timing attacks even when :visited is disabled.

Differential Revision: https://phabricator.services.mozilla.com/D3304
2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
0ae47b2659
style: Cleanup invalidation processor constructor.
It used to be this way because of lifetime issues (plus the shadow
datas were in RwLocks at some point IIRC). Now we guarantee that as long as the
element is away the cascade data is as well, so we don't need to thread it
around.

Differential Revision: https://phabricator.services.mozilla.com/D2768
2018-08-08 01:37:50 +02:00
Emilio Cobos Álvarez
bbcd7e414a
style: Remove unused selectors methods.
Differential Revision: https://phabricator.services.mozilla.com/D2767
2018-08-08 01:37:45 +02:00
Emilio Cobos Álvarez
c3289ad46e
style: Improve logging for attribute changes.
And general Element logging. We now print all the attributes for comparison.

If this turns out to be too verbose we can change it to diff them or something.

Differential Revision: https://phabricator.services.mozilla.com/D2471
2018-08-08 01:36:03 +02:00
Nicholas Nethercote
fc9df0bcf3
style: Convert FnvHash{Set,Map} instances to FxHash{Set,Map}.
Bug: 1477628
Reviewed-by: heycam
2018-08-08 01:34:35 +02:00
Emilio Cobos Álvarez
02d27ad3dd
style: Make svg:use use an actual shadow tree.
This fixes a couple fuzz bugs and prevents special-casing <svg:use> even more in
bug 1431255.

Unfortunately not as many hacks went away as I'd have hoped, since we still need
to match document rules, see the linked SVGWG issues.

But blocks_ancestor_combinators goes away, which is nice since it's on a very
hot path.

Bug: 1450250
Reviewed-by: heycam
Differential Revision: https://phabricator.services.mozilla.com/D2154

MozReview-Commit-ID: C4mthjoSNFh
2018-07-24 03:30:12 +02:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Bobby Holley
f7ae1a37e3 Manual fixups so that the rustfmt output won't trigger tidy. 2018-04-10 17:33:25 -07:00
Emilio Cobos Álvarez
eaefaa890e
style: Implement the functional :host(..) selector.
We could invalidate in a slightly more fine-grained way, but I don't think it's
worth the churn vs. keeping the special-cases minimal.

Bug: 1452640
Reviewed-by: xidorn
MozReview-Commit-ID: 5DkQrgwg9GW
2018-04-10 08:04:09 +02:00
Emilio Cobos Álvarez
db5db13559
style: Implement the non-functional :host selector.
Kinda tricky because :host only matches rules on the shadow root where the rules
come from. So we need to be careful during invalidation and style sharing.

I didn't use the non_ts_pseudo_class_list bits because as soon as we implement
the :host(..) bits we're going to need to special-case it anyway.

The general schema is the following:

 * Rightmost featureless :host selectors are handled inserting them in the
   host_rules hashmap. Note that we only insert featureless stuff there. We
   could insert all of them and just filter during matching, but that's slightly
   annoying.

 * The other selectors, like non-featureless :host or what not, are added to the
   normal cascade data. This is harmless, since the shadow host rules are never
   matched against the host, so we know they'll just never match, and avoids
   adding more special-cases.

 * Featureless :host selectors to the left of a combinator are handled during
   matching, in the special-case of next_element_for_combinator in selectors.
   This prevents this from being more invasive, and keeps the usual fast path
   slim, but it's a bit hard to match the spec and the implementation.

   We could keep a copy of the SelectorIter instead in the matching context to
   make the handling of featureless-ness explicit in match_non_ts_pseudo_class,
   but we'd still need the special-case anyway, so I'm not fond of it.

 * We take advantage of one thing that makes this sound. As you may have
   noticed, if you had `root` element which is a ShadowRoot, and you matched
   something like `div:host` against it, using a MatchingContext with
   current_host == root, we'd incorrectly report a match. But this is impossible
   due to the following constraints:

    * Shadow root rules aren't matched against the host during styling (except
      these featureless selectors).

    * DOM APIs' current_host needs to be the _containing_ host, not the element
      itself if you're a Shadow host.

Bug: 992245
Reviewed-by: xidorn
MozReview-Commit-ID: KayYNfTXb5h
2018-04-09 12:19:05 +02:00
Emilio Cobos Álvarez
9fa2618197
style: Add infrastructure to match :host. 2018-03-14 15:10:05 +01:00
Emilio Cobos Álvarez
ef4ea7cc49
style: Separate the XBL and shadow dom styling bits.
Bug: 1441022
Reviewed-by: xidorn
MozReview-Commit-ID: 2W0BmZ8wWXg
2018-03-07 15:42:28 +01:00
Emilio Cobos Álvarez
13f61a6e5f
style: Indent properly a couple more functions. 2018-02-24 23:23:16 +01:00
Emilio Cobos Álvarez
f2efd04a5d
style: Make Element::id not clone the attribute. 2018-02-24 22:45:43 +01:00
Emilio Cobos Álvarez
98c9292ecb
style: Remove get_ prefix from get_state and get_id. 2018-02-24 22:45:42 +01:00
Emilio Cobos Álvarez
7ab4b21bc3
selectors: Remove the get_ prefix from get_local_name and get_namespace. 2018-02-24 22:45:38 +01:00
Xidorn Quan
f518e55c28 Add sizeof for AuthorStyles. 2018-02-19 15:12:13 +11:00
Emilio Cobos Álvarez
5e64cb3516
style: Make XBL / Shadow DOM use something more light-weight than a Stylist.
It's just a struct aggregating stylesheets + CascadeData, with a quirks_mode
parameter because XBL sucks so bad.

Bug: 1436059
Reviewed-by: xidorn
MozReview-Commit-ID: 7q99tSNXo0K
2018-02-16 13:42:36 +01:00
Emilio Cobos Álvarez
1804f135ec
style: Optimize @keyframes rule insertions.
Bug: 1435214
Reviewed-by: xidorn,hiro
MozReview-Commit-ID: AHwhZynLBv
2018-02-05 11:54:01 +01:00
Emilio Cobos Álvarez
9c66b07b67
style: Make insertion of @font-face rules not necessarily restyle the whole document.
Bug: 1435214
Reviewed-by: xidorn
MozReview-Commit-ID: 5ewKiShUHNi
2018-02-05 11:24:40 +01:00
Emilio Cobos Álvarez
4d9ce6b880
style: Temporarily use OrderMap on Gecko.
This will allow us to discard std hash map as a source of crashes.
2018-01-31 16:29:35 +01:00
Emilio Cobos Álvarez
125f275b5a
style: Fix sheet invalidation in quirks mode documents.
Bug: 1433589
2018-01-30 16:08:53 +01:00
Emilio Cobos Álvarez
61e60a87e5
selectors: Never match ::slotted on <slot>s.
This fixes the test from https://github.com/w3c/web-platform-tests/pull/9212 in
Gecko.
2018-01-27 17:57:17 +01:00
Emilio Cobos Álvarez
657d8b8e31
style: Look at the snapshots when invalidating due to stylesheet changes.
Otherwise removal of stylesheets may get out of sync with other DOM changes, and
we may fail to invalidate the style of the affected elements.

Bug: 1432850
Reviewed-by: bz
MozReview-Commit-ID: DrMTgLzQcnk
2018-01-27 02:34:27 +01:00
Emilio Cobos Álvarez
8e25c9e674
style: Track the visited-handling-mode on the MatchingContext.
Instead of on the stack.

This fixes bugs where we're not passing the value around correctly, like from
::-moz-any.

This is a fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1431539.
2018-01-19 13:22:37 +01:00
Emilio Cobos Álvarez
e4f08ee2bb
selectors: Add a MatchingContext::nest function, make nesting_level private. 2018-01-19 12:40:17 +01:00
Emilio Cobos Álvarez
665690bba6
style: Hook in the document invalidator.
Bug: 1409672
Reviewed-by: xidorn
MozReview-Commit-ID: EoSMrYPS7dl
2018-01-17 18:03:16 +01:00
Emilio Cobos Álvarez
7bdeeaa702
style: Fix slotted invalidation.
This is a partial revert of
ce1d8cd232

If you're in a shadow tree, you may not be slotted but you still need to look at
the slotted rules, since a <slot> could be a descendant of yours.

Just use the same invalidation map everywhere, and remove complexity.

This means that we can do some extra work while trying to gather invalidation
if there are slotted rules, but I don't think it's a problem.

The test is ported from https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/fast/css/invalidation/slotted.html?l=1&rcl=58d68fdf783d7edde1c82a642e037464861f2787

Curiously, Blink fails the test as written, presumably because they don't flush
styles from getComputedStyle correctly (in their test they do via
updateStyleAndReturnAffectedElementCount), due to <slot>s not being in the flat
tree in their implementation.

Bug: 1429846
Reviewed-by: heycam
MozReview-Commit-ID: 6b7BQ6bGMgd
2018-01-17 14:35:19 +01:00
Xidorn Quan
d0fd92221c Optimize selector matching for some common cases. 2018-01-17 09:46:57 +11:00
Simon Sapin
c14b766ff5 Rename SelectorMethods to Visit, after its one method. 2018-01-12 15:26:56 +01:00
Emilio Cobos Álvarez
335ca47361
style: Use Default for ExtraStyleData instead of Option. 2018-01-12 12:08:47 +01:00
Emilio Cobos Álvarez
9a1f20f1e8
style: Add a comment about figuring out what the best way to deal with XBL is. 2018-01-12 12:08:46 +01:00
Emilio Cobos Álvarez
a69d229615
style: Use a more compact form for should_process_descendants. 2018-01-12 12:08:43 +01:00