Commit graph

29 commits

Author SHA1 Message Date
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01: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
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
bors-servo
6fc71a7644 Auto merge of #19822 - emilio:less-match-public, r=KiChjang
style: More tiny selector-matching cleanup

See each commit individually.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19822)
<!-- Reviewable:end -->
2018-01-19 23:05:18 -06:00
Emilio Cobos Álvarez
c384c21cb6
style: Make the MatchingMode in MatchingContext private.
It used to be the case that MatchingContext was immutable and thus we didn't
care to have accessors.

This is no longer true, so let's make this code a bit nicer.
2018-01-20 02:26:59 +01:00
Emilio Cobos Álvarez
e74fad6259
style: Handle correctly document state invalidation inside negation. 2018-01-20 02:10:57 +01:00
Emilio Cobos Álvarez
9f00a2fdc0
selectors: add an is_nested method to MatchingContext, instead of nesting_level. 2018-01-19 13:32:44 +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
335ca47361
style: Use Default for ExtraStyleData instead of Option. 2018-01-12 12:08:47 +01:00
Emilio Cobos Álvarez
1e27f2883b
selectors: Allow defining an implementation-dependent field in the matching context. 2018-01-12 12:08:38 +01:00
Emilio Cobos Álvarez
3119db724a
selectors: Simplify :visited by only using the "is inside link" information.
Right now we go through a lot of hoops to see if we ever see a relevant link.

However, that information is not needed: if the element is a link, we'll always
need to compute its visited style because its its own relevant link.

If the element inherits from a link, we need to also compute the visited style
anyway.

So the "has a relevant link been found" is pretty useless when we know what are
we inheriting from.

The branches at the beginning of matches_complex_selector_internal were
affecting performance, and there are no good reasons to keep them.

I've verified that this passes all the visited tests in mozilla central, and
that the test-cases too-flaky to be landed still pass.
2017-12-08 05:35:12 +01:00
Xidorn Quan
2dc714f0ac Implement XUL tree pseudo style resolution for stylo. 2017-10-20 14:08:56 +11:00
Emilio Cobos Álvarez
b0e54968ec
style: Make MatchingContext generic over SelectorImpl.
This will help Xidorn implement tree pseudos, and in general makes sense,
allowing to put specific matching data in a selectors implementation.
2017-10-19 11:33:13 +02:00
Emilio Cobos Álvarez
11485edc9e
style: Hide LocalMatchingContext.
This type is a lot of complexity related to a very specific thing such as the
hover and active quirk.

Instead of that, move `nesting_level` to `MatchingContext`, and simplify all
this computing whether the quirk applies upfront, for each complex selector we
test.

This is less error-prone, and also allows simplifying more stuff in a bit.
2017-10-14 17:03:35 +02:00
Xidorn Quan
ab46a0bbe0 Add support for :scope pseudo-class 2017-10-09 22:04:08 +11:00
Emilio Cobos Álvarez
36223fc16d
style: Cleanup MatchingContext construction. 2017-10-07 13:02:32 +02:00
Bobby Holley
438740b912 Implement an nth-index cache.
MozReview-Commit-ID: Ee0um3QXkxl
2017-09-21 15:25:38 -07:00
Bobby Holley
48466bf876 Introduce an NthIndexCache type and pipe it from ThreadLocalStyleContext to MatchingContext.
Some future refactoring here to pass fewer things as parameters would be nice.
2017-09-20 23:22:38 -07:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
Gecko Backout
f022936ebb Backed out changeset a417b9d7712d for vendoring bustage. r=backout on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/17565
2017-07-28 22:06:00 +00:00
Nikhil Shagrithaya
8ebd70d402 Run the async HTML Tokenizer on a new thread 2017-07-24 23:54:07 +05:30
Emilio Cobos Álvarez
6d6c80e79b
style: Remove StyleRelations.
They're unused now. We can add them back if needed.

MozReview-Commit-ID: 92Y2Na0ZbVn
2017-07-12 09:26:55 +02:00
Emilio Cobos Álvarez
95a2ac51c4
style: Remove unused AFFECTED_BY_PSEUDO_ELEMENTS StyleRelation.
MozReview-Commit-ID: yHldvHm87b
2017-07-12 08:39:25 +02:00
Emilio Cobos Álvarez
4434509088
style: Add an AllLinksVisitedAndUnvisited for invalidation.
Otherwise, tests like the following fail, given we always match as unvisited,
and we'd never mark the link as needing invalidation.

<!doctype html>
<style>
a {
  color: red !important;
}

.foo :visited {
  color: green !important;
}
</style>
<div>
  <a href="https://google.es">visit me</a>
  <button onclick="this.parentNode.className = 'foo'">Then click me</button>
</div>

Bug: 1368240
MozReview-Commit-ID: LDv6S28c4ju
2017-06-13 13:27:06 +02:00
Simon Sapin
b82713924c Pre-compute classes and IDs case-sensitivity 2017-06-13 00:36:12 +02:00
Simon Sapin
9316c41bf7 Make MatchingContext::quirks_mode field private, add read-only accessor. 2017-06-13 00:35:56 +02:00
Simon Sapin
700aaf2bd6 Move MatchingContext to a new module 2017-06-13 00:31:29 +02:00