Commit graph

145 commits

Author SHA1 Message Date
Josh Matthews
73e903ad3c Report unexpected attribute selector tokens (bug 1384216). 2017-08-28 17:20:17 -07:00
Josh Matthews
8e20a6a110 Report unknown pseudos (bug 1384216). 2017-08-28 17:19:28 -07:00
Simon Sapin
dc5dfafbba Use Parser::skip_whitespace in a few places to make Parser::try rewind less.
Gecko’s CSS parsing microbenchmarks before:

```
  43.437 ±  0.391 ms    Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench
  29.244 ±  0.042 ms    Stylo.Gecko_nsCSSParser_ParseSheet_Bench
 281.884 ±  0.028 ms    Stylo.Servo_DeclarationBlock_SetPropertyById_Bench
 426.242 ±  0.008 ms    Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench
```

After:

```
  29.779 ±  0.254 ms    Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench
  28.841 ±  0.031 ms    Stylo.Gecko_nsCSSParser_ParseSheet_Bench
 296.240 ±  4.744 ms    Stylo.Servo_DeclarationBlock_SetPropertyById_Bench
 293.855 ±  4.304 ms    Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench
```
2017-08-26 01:44:45 +02:00
bors-servo
69e28f0709 Auto merge of #18225 - jdm:unused-visitor-argument, r=emilio
Remove unused selector visitor argument.

The real win here is avoiding cloning the iterator when nobody actually uses it.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] There are tests for these changes

<!-- 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/18225)
<!-- Reviewable:end -->
2017-08-25 01:10:03 -05:00
Josh Matthews
ffa9dd1c7c Remove unused selector visitor argument. 2017-08-24 18:17:25 -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
Simon Sapin
b5a4b8d6a0 Upgrade to rustc 1.21.0-nightly (13d94d5fa 2017-08-10) 2017-08-15 14:10:44 +02:00
Simon Sapin
7382dad939 Update to cssparser 0.19, count line numbers during tokenization 2017-08-09 22:37:16 +02:00
Bobby Holley
5a421d7c5f Use drain() over IntoIter on a few SmallVecs.
This is all the ones I could find in style/ and selectors/.
2017-08-02 15:42:57 -07:00
Corey Farwell
befe538472 Utilize match_ignore_ascii_case! in more places. 2017-07-29 09:58:09 +00:00
Simon Sapin
eb98ae6e04 Update cssparser to 0.18
https://github.com/servo/rust-cssparser/pull/171
2017-07-24 11:39:12 +02:00
Emilio Cobos Álvarez
f879ebcc99
selectors: Don't track class and id ancestor hashes in quirks mode.
It's incorrect to track classes and id selectors in a quirks-mode document,
since they should match case-insensitively.

Bug: 1382812
Reviewed-by: bholley
MozReview-Commit-ID: 4uvrfYsWb1v
2017-07-20 22:42:35 +02:00
bors-servo
81f6b9a1c7 Auto merge of #17539 - jyc:simplify-an-b, r=emilio
Simplify <an+b> in selector args when serializing.

<!-- Please describe your changes on the following line: -->

---
<!-- 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 is part of a series to fix #17182

<!-- Either: -->
I am running this to identify what tests will fail; as the other PRs in the series are merged, I believe the tests that pass will change as well.

- [ ] 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/17539)
<!-- Reviewable:end -->
2017-07-19 03:59:50 -07:00
Jonathan Chan
f0e83f6d8a Simplify <an+b> in selector args when serializing. 2017-07-18 11:53:52 -07:00
Jonathan Chan
1301bcdf10 Omit serializing the universal selector when possible.
If omitting the universal selector in the serialization is possible, we
should do it so we obtain a shorter serialization (to match the behavior
asserted in cssom/serialize-namespaced-type-selectors.html).

For example, if someone writes *|*::before and there is no default
namespace, we should serialize to ::before; however, if there is a
default namespace, we should serialize to *|*::before.
(This is the test case "Universal selector in any namespace followed by
pseudo element).

This matches the behavior implemented by WebKit; that one case in
particular isn't implemented by Gecko, but other cases where the
universal selector should be elided are implemented by Gecko but were not
previously by Servo.
2017-07-17 10:52:17 -07:00
Jonathan Chan
989b707623 Elide the explicit any namespace prefix when lacking default namespace.
Once again it seems we don't need to preserve the original prefix name,
and this lets to_css serialize to the shortest form when there is no
default namespace and the *| prefix is used.

Selectors § 6.1.1 says:

    Element type selectors that have no namespace component (no namespace
    separator) represent elements without regard to the element's namespace
    (equivalent to "*|") unless a default namespace has been declared for
    namespaced selectors (e.g. in CSS, in the style sheet). If a default
    namespace has been declared, such selectors will represent only elements
    in the default namespace.

Then if there is no default namespace, *| (which we write as
QNamePrefix::ExplicitAnyNamespace) is equivalent to what we write as
QNamePrefix::ImplicitAnyNamespace; the latter has a shorter
serialization, so we should use that.
2017-07-17 10:43:24 -07:00
Jonathan Chan
bd5ff3b4ce Replace Namespace components which map to the default namespace with DefaultNamespace.
It seems we don't need to preserve the original prefix name, and this
conveniently leads to_css to now implement CSSOM's requirement to elide
the namespace prefix during serialization when it maps to the default
namespace.

https://drafts.csswg.org/cssom/#serialize-a-simple-selector
2017-07-14 12:19:03 -07:00
Emilio Cobos Álvarez
445b8fb3e8
style: Remove SelectorAndHashes. 2017-07-13 05:44:55 +02:00
Emilio Cobos Álvarez
dee4aea264
style: Remove hashes from style rules and dependencies.
Dependencies are very numerous, and now we shouldn't be getting so many of them.

Style rules just don't need them, so it's a waste of memory.
2017-07-13 05:44:53 +02:00
bors-servo
4b6e79337e Auto merge of #17538 - jyc:selectorText, r=Manishearth
Implement CSSStyleRule.selectorText.

We parse when assigning using the namespaces of the stylesheet. It isn't
clear if the spec says to do that (Firefox doesn't support the setter at
all, Chrome does, Safari doesn't); the spec issue is here:
https://github.com/w3c/csswg-drafts/issues/1511

Also fix ToCss implementation of AttrSelectorOperator to not pad with
spaces, to conform with CSSOM. This means we have to update some unit
tests that expect operators with spaces around them in attribute
selectors to roundtrip.

See the "attribute selector" section of "Serializing Selectors" here:
https://drafts.csswg.org/cssom/#serializing-selectors

CSSStyleRule.selectorText is specified here:
https://drafts.csswg.org/cssom/#dom-cssstylerule-selectortext

<!-- Please describe your changes on the following line: -->

---
<!-- 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 is part of a series to fix #17182

<!-- Either: -->
I am running this to identify what tests will fail; as the other PRs in the series are merged, I believe the tests that pass will change as well.

- [ ] 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/17538)
<!-- Reviewable:end -->
2017-07-12 11:08:35 -07:00
Jonathan Chan
92ec8f15f0 Implement CSSStyleRule.selectorText.
We parse when assigning using the namespaces of the stylesheet. It isn't
clear if the spec says to do that (Firefox doesn't support the setter at
all, Chrome does, Safari doesn't); the spec issue is here:
https://github.com/w3c/csswg-drafts/issues/1511

Also fix ToCss implementation of AttrSelectorOperator to not pad with
spaces, to conform with CSSOM. This means we have to update some unit
tests that expect operators with spaces around them in attribute
selectors to roundtrip.

See the "attribute selector" section of "Serializing Selectors" here:
https://drafts.csswg.org/cssom/#serializing-selectors

CSSStyleRule.selectorText is specified here:
https://drafts.csswg.org/cssom/#dom-cssstylerule-selectortext
2017-07-12 01:03:58 -07:00
Xidorn Quan
38577fd6ee Allow selector parser to specify pseudo-element which can be used with single-colon syntax. 2017-07-12 15:07:25 +10:00
Xidorn Quan
706d54401e Add functional pseudo-element support to selectors crate. 2017-07-12 15:07:24 +10:00
Xidorn Quan
d138fd1a32 Slightly simplify parse_one_simple_selector. 2017-07-12 15:07:22 +10:00
Josh Matthews
0b43d0072c stylo: Update rust-cssparser; extract more specific error types when reporting (bug 1352669). 2017-07-10 20:46:12 -04:00
Gecko Backout
32269fa7cc Backed out changeset fec394734f83 (bug 17624) for build bustage a=backout CLOSED TREE
Backs out https://github.com/servo/servo/pull/17624
2017-07-06 21:58:15 +00:00
Josh Matthews
f5a3830ea2 stylo: Update rust-cssparser; extract more specific error types when reporting (bug 1352669). 2017-07-06 14:32:37 -04:00
Simon Sapin
7e0254b530 Drive-by fix "unused import" warning. 2017-07-05 13:58:06 +02:00
Bobby Holley
1104cdc580 Invert the order of each compound selector.
MozReview-Commit-ID: JkBjqyYgbrB
2017-06-20 11:59:11 -07:00
Bobby Holley
1fc1d64e80 Hoist specificity computation into a new private builder module.
This patch doesn't modify any of the code because making a few things pub. I
did this first to make the next patch easier to audit.

MozReview-Commit-ID: 7PYxoS5bVGN
2017-06-20 11:59:11 -07:00
Bobby Holley
1d242ad760 Store selectors in matching order, rather than parse order.
We add a slow in-place reverse during parsing to achieve this for now, which
gets fixed up later on.

MozReview-Commit-ID: 42QkOzSgV3T
2017-06-20 11:59:10 -07:00
Bobby Holley
fac5aeb092 Stop creating unnecessarily-large SmallVecs for specific tasks.
MozReview-Commit-ID: IM9aAjSeJI9
2017-06-20 11:59:10 -07:00
Bobby Holley
2159d48382 Stop using parse_compound_selector for negation parsing.
This makes the code easier to work with, and fixes a bug where we don't currently
reject pseudo-elements within :not().

MozReview-Commit-ID: Cgl9w0PBsN3
2017-06-20 11:59:09 -07:00
Simon Sapin
316cd35767 Untry 2017-06-18 13:21:51 +02:00
Simon Sapin
b83afdedc8 Upgrade cssparser to 0.15 2017-06-16 15:05:46 +02:00
Emilio Cobos Álvarez
151b636562
style: Add a way to match a single compound selector.
Also improve the ergonomics of matches_complex_selector.

Bug: 1368240
MozReview-Commit-ID: 9DWDvyZmetM
2017-06-13 10:58:47 +02:00
Simon Sapin
5bccf98aa4 ID and class selectors are ASCII case-insensitive in quirks mode.
https://bugzilla.mozilla.org/show_bug.cgi?id=1363778
2017-06-12 23:33:53 +02:00
Bobby Holley
6e3e7b282c Pack the fourth ancestor hash into the upper byte of the first three hashes.
MozReview-Commit-ID: KbtKQzLmwVO
2017-06-12 12:13:04 -07:00
Fernando Jiménez Moreno
2cc940384d stylo: Implement GetSpecificity for ServoStyleRule 2017-06-12 14:40:16 +02:00
Nazım Can Altınova
15fe48f3f6
stylo: Support :hover and :active quirk 2017-06-10 22:18:32 +03:00
Josh Matthews
27ae1ef2e7 Thread ParseError return values through CSS parsing. 2017-06-09 16:46:25 -04:00
Boris Zbarsky
537cf52707 Fix revalidation selectors when pseudo-elements are involved. 2017-06-08 01:19:50 -04:00
J. Ryan Stinnett
6b1b8bbee8 Log element during selector matching
MozReview-Commit-ID: D8eFyRCy5BR
2017-06-07 14:23:53 -05:00
Fernando Jiménez Moreno
36f3255484 Bug 1367615 - Stylo: implement inIDOMUtils.getSelectorCount and inIDOMUtils.getSelectorTextFromIndex 2017-06-07 17:42:29 +02:00
Bobby Holley
586a21e1dd Make a bunch of types 'static.
The reasoning for this is explained in a comment in the next patch.

MozReview-Commit-ID: FQgDY77mg3B
2017-06-06 19:09:16 -07:00
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