Commit graph

50 commits

Author SHA1 Message Date
Bobby Holley
f105d3438d Fix up unit tests.
MozReview-Commit-ID: 9eyOhoQ02qX
2017-06-05 19:44:13 -07:00
Bobby Holley
442211723c Eliminate redundant parse_selector.
MozReview-Commit-ID: 6eBVgT9ri5Q
2017-06-05 19:44:12 -07:00
Bobby Holley
27568de567 Use ThinArc in Selector.
MozReview-Commit-ID: Axvq0rbqA7Y
2017-06-05 19:44:10 -07:00
Bobby Holley
e8a56e969f Make ParseVec bigger.
MozReview-Commit-ID: DszMC031Xlj
2017-06-05 19:44:08 -07:00
Bobby Holley
852efb825f Use dynamically-sized Arcs for Selector.
MozReview-Commit-ID: hq0jYrx8Sg
2017-06-05 19:44:06 -07:00
Bobby Holley
992059c856 Move around specificity computation so that we know it by the time we mint the Selector.
This is important to make the selector immutable, which needs to happen when we stick it in an Arc.

MozReview-Commit-ID: BaMbOEbYC3D
2017-06-05 19:44:02 -07:00
Bobby Holley
1281fd9353 Stop slicing selectors when noting dependencies, and match with an offset instead.
MozReview-Commit-ID: KLqmdRKygO0
2017-06-05 19:44:01 -07:00
Bobby Holley
5ddabef636 Collapse Selector, SelectorInner, and ComplexSelector into a single Selector.
The refcounting is still internal. We'll fix that up next.

MozReview-Commit-ID: CTxZNaR3Qgj
2017-06-05 19:44:00 -07:00
Bobby Holley
713c9a63f6 Move the ancestor hashes out of Selector.
MozReview-Commit-ID: 5mipXnjgSED
2017-06-05 19:43:58 -07:00
Bobby Holley
e3d3c5a7b2 Hoist specificity_and_flags into ComplexSelector (soon to be Selector).
In the upcoming patches we'll eliminate the existing Selector and SelectorInner,
and ComplexSelector will become an Arc-managed |Selector|. So the tuple-indexed
setup is just temporary.

MozReview-Commit-ID: 4CcOYeHGUED
2017-06-05 19:29:23 -07:00
Simon Sapin
c968842653 Don’t visit attribute selectors that never match. 2017-05-18 17:13:20 +02:00
Simon Sapin
76166bce58 Add more enum types to avoid unreachable!() for selector case-sensitivity 2017-05-18 17:13:19 +02:00
Simon Sapin
853b688d0b Only non-namespaced attributes can have implicitly case-insensitive values 2017-05-18 17:13:16 +02:00
Simon Sapin
94b4a32c18 Make some attr values case-insensitive in selectors
https://bugzilla.mozilla.org/show_bug.cgi?id=1363531
2017-05-18 17:13:15 +02:00
Simon Sapin
9376abdd2c Shrink selectors::Component, add case-insensitive for other attr selectors
* https://bugzilla.mozilla.org/show_bug.cgi?id=1364148
* https://bugzilla.mozilla.org/show_bug.cgi?id=1364162
2017-05-18 17:13:14 +02:00
Simon Sapin
83c7824fda Simplify rust-selectors API for attribute selectors 2017-05-18 17:13:13 +02:00
Simon Sapin
0b1e51de53 Rename CaseSensitivity::CaseInsensitive to AsciiCaseInsensitive 2017-05-18 17:13:11 +02:00
Emilio Cobos Álvarez
522f8489d6
Bug 1364850: Move PseudoElement to be just another combinator in selectors. r=bholley
MozReview-Commit-ID: 8OoOIodkKJ5
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-17 10:58:24 +02:00
Simon Sapin
685b9efed6 Move "is universal" logic from stylist.rs to selectors/parser.rs 2017-05-16 18:41:27 +02:00
Simon Sapin
390e688058 Fix serialization of namespace and universal selectors
Fix #16017
Fix #16020
2017-05-16 16:44:28 +02:00
Simon Sapin
984d696717 Turns out, we never actual hash selectors 2017-05-16 10:24:50 +02:00
Simon Sapin
fd357f08cf Add size_of tests for geckolib selectors 2017-05-16 10:24:41 +02:00
Emilio Cobos Álvarez
10560ae043
Bug 1364412: Allow pseudo-element selectors to store state. r=bholley
MozReview-Commit-ID: CzAwg2uxqO2
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-16 02:49:22 +02:00
Emilio Cobos Álvarez
e09ae428eb
style: Account for cousin sharing in the revalidation logic.
Fixes bug 1361013.
2017-05-01 20:22:16 +02:00
Bobby Holley
b4d05919e2 Unbust unit tests.
Not sure how this managed to get past bors before.
2017-04-29 16:07:39 -07:00
Emilio Cobos Álvarez
7a556a7f03
Bug 1360399: Don't deduplicate revalidation selectors. r=bholley
It's unfortunate, but it's a correctness issue. I was looking at the
expectations update here:

 * 659cddddd4

And investigating it I realised that it's wrong to coalesce selectors like that,
because we keep the bloom filter flags.

So in the test cases disabled, we have a selector that looks like this:

msub > :not(:first-child),
msup > :not(:first-child),
msubsup > :not(:first-child),
mmultiscripts > :not(:first-child) {
    -moz-script-level: +1;
    -moz-math-display: inline;
}

And an element that looks like this:

<msubsup><mi></mi><mi></mi></msubsup>

We're only inserting the first selector msub > :not(:first-child) into the set,
so when we're going to match the <mi> elements we fast-reject it in both cases
due to the bloom filter, so they share style.

I can't see an easy way to fix this keeping the deduplication. If we keep it, we
need to remove the bloom filter optimization, which means that we'd trash the
cache for every first-child in the document (the :not(:first-child) effectively
becomes a global rule).

MozReview-Commit-ID: 9VPkmdj9zDg
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-28 02:57:54 +02:00
Bobby Holley
7e69cf82be Store SelectorInner and only revalidate up to the rightmost ancestor combinator.
MozReview-Commit-ID: HiTGVhwuvCE
2017-04-27 11:12:51 -07:00
Bobby Holley
32c624e585 Require Clone for SelectorImpl so that all the types that are parameterized on it can derive(Clone).
It's not clear to me why this is a requirement, but it seems to be one.

MozReview-Commit-ID: JM0DKjHHfT
2017-04-27 11:12:45 -07:00
Bobby Holley
a1e90d1b24 Downgrade selectors not() behavior to level 3.
MozReview-Commit-ID: 6p750Ml2wzm
2017-04-25 15:43:20 -07:00
Bobby Holley
fe97033aa8 Use a SmallVec during selector parsing.
This significantly reduces realloc time at the expense of some additional
mmemmoves, but pencils out to a small win on my machine.

We wanted to do this anyway, and this avoids needing to remove the smallvec
dependency from Selectors and then add it back again.

MozReview-Commit-ID: HW4kDxzLACp
2017-04-20 15:04:52 -07:00
Bobby Holley
cebacc7faa Rename SimpleSelector to Component.
MozReview-Commit-ID: JfaZpHSkG8h
2017-04-20 15:04:48 -07:00
Bobby Holley
cf06e2bf1e Use Boxed slices for Empty and MozAny.
MozReview-Commit-ID: CmVK3u0vYn0
2017-04-20 15:00:50 -07:00
Bobby Holley
6d66ec5e11 Store selectors and combinators inline in a single sequence.
This improves cache locality and reduces allocations during parsing.

Note that this reverses the iteration order within a sequence of simple selectors,
but that shouldn't matter.
2017-04-20 15:00:43 -07:00
bors-servo
195100f3ca Auto merge of #16495 - coalman:tidy-brace-alignment, r=emilio
Make tidy check that opening and closing braces that begin a line do …

…so with proper alignment.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [X] These changes fix #16486 (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/16495)
<!-- Reviewable:end -->
2017-04-19 03:06:31 -05:00
Bobby Holley
69e3870cdd Store bloom filter hashes inline.
MozReview-Commit-ID: F07JkdduLaI
2017-04-18 20:07:55 -07:00
Bobby Holley
9524c5cb57 Introduce SelectorInner and use it for top-level matching.
MozReview-Commit-ID: DxG6USsPIkh
2017-04-18 20:07:53 -07:00
coalman
fc34b9a14d Fix indentation errors in servo rust code that tidy now finds. 2017-04-18 14:56:13 -04:00
bors-servo
fd89ddf4bb Auto merge of #16347 - tictakk:ticbranch, r=emilio
Removing recursion from ComplexSelector

<!-- Please describe your changes on the following line: -->
Using a smallvec instead of recursively calling to_css for ComplexSelector to handle running out of stack.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #16019  (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/16347)
<!-- Reviewable:end -->
2017-04-16 21:02:06 -05:00
Matthew
ec04de4ab7 Removing recursion from ComplexSelector
formatting

formatting
2017-04-16 21:52:50 -04:00
Emilio Cobos Álvarez
a0c2bdf775
style: Smoke-test the dependency tracking logic.
MozReview-Commit-ID: J5HWdS1H49s
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-13 09:37:01 +08:00
Emilio Cobos Álvarez
9e33cd5643
style: Simplify dependency visitor, avoid tracking dependencies of nested complex selectors separately. 2017-04-13 01:01:00 +08:00
Emilio Cobos Álvarez
568fa4cc0d
style: Fix dynamic changes of attributes when combined with :not. 2017-04-13 01:00:59 +08:00
Emilio Cobos Álvarez
8dfef0416f
selectors: Remove unused visit_simple_selectors. 2017-04-09 18:15:56 +08:00
Emilio Cobos Álvarez
0ea58d1ffa
style: Stop special-casing a few attributes for style sharing, and use a visitor to track dependencies.
Also, simplify all the pre-snapshot attribute hacks in the script and style
code.

MozReview-Commit-ID: 6c9ipeb7Tnr
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-09 18:15:50 +08:00
Emilio Cobos Álvarez
1748150497
selectors: Remove custom attribute-affecting logic and sibling-affecting logic from rust-selectors.
MozReview-Commit-ID: BjZY6TjJbcb
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-09 05:49:47 +02:00
Emilio Cobos Álvarez
e29b84de18
style: Hash less stuff in the bloom filter, using the precomputed hashes we have. 2017-04-08 02:02:11 +02:00
Emilio Cobos Álvarez
65ebbb7c56
selectors: Unbust tests, and add a way to override the hash for the bloom filter. 2017-04-08 02:00:31 +02:00
Matt Brubeck
2872c8bfab Bug 1340683 - stylo: Implement the :-moz-any pseudo-class 2017-03-16 11:44:47 -07:00
Bobby Holley
a69eed6956 Fixes to pass tidy. 2017-02-07 23:01:06 -08:00
Bobby Holley
8915e53cee Move rust-selectors in-tree. 2017-02-07 22:53:10 -08:00