aboutsummaryrefslogtreecommitdiffstats
path: root/components/selectors/parser.rs
Commit message (Collapse)AuthorAgeFilesLines
...
* Move PrecomputedHash bounds to where they’re actually needed.Simon Sapin2018-01-121-13/+22
|
* Reverse the dependency between selectors and malloc_size_ofSimon Sapin2018-01-121-1/+1
|
* style: Use Default for ExtraStyleData instead of Option.Emilio Cobos Álvarez2018-01-121-1/+1
|
* selectors: Allow defining an implementation-dependent field in the matching ↵Emilio Cobos Álvarez2018-01-121-0/+2
| | | | context.
* style: Store ::slotted rules separately on the cascade data, since they may ↵Emilio Cobos Álvarez2018-01-091-1/+9
| | | | | | cross the shadow boundary. MozReview-Commit-ID: EY9nK3169vv
* style: Don't support a list of selectors in ::slotted yet.Emilio Cobos Álvarez2017-12-201-26/+36
| | | | | | Bug: 1425757 Reviewed-by: xidorn MozReview-Commit-ID: G0I0gM2sWTh
* selectors: Add parsing support for ::slotted().Emilio Cobos Álvarez2017-12-141-39/+135
| | | | | | | | | | | | | | | | | | | Without turning it on yet, of course. The reason why I didn't use the general PseudoElement mechanism is because this pseudo is a bit of its own thing, and I found easier to make ::selectors know about it (because you need to jump to the assigned slot) than the other way around. Also, we need to support ::slotted(..)::before and such, and supporting multiple pseudo-elements like that breaks some other invariants around the SelectorMap, and fixing those would require special-casing slotted a lot more in other parts of the code. Let me know if you think otherwise. I also don't like much the boolean tuple return value, but I plan to do some cleanup in the area in a bit, so it should go away soon, I'd hope.
* Auto merge of #19536 - emilio:compound-selector-list, r=mbrubeckbors-servo2017-12-091-0/+28
|\ | | | | | | | | | | | | | | | | | | | | style: Move the code to parse a list of compound selectors. I'll need this for ::slotted(). <!-- 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/19536) <!-- Reviewable:end -->
| * style: Move the code to parse a list of compound selectors.Emilio Cobos Álvarez2017-12-091-0/+28
| | | | | | | | I'll need this for ::slotted().
* | style: Simplify naming and signatures of single-colon pseudo stuff.Emilio Cobos Álvarez2017-12-091-3/+3
|/ | | | Also drop a few FIXMEs while at it, since they look bogus.
* selectors: Allow white space in the brackets of an attribute selector.Cameron McCormack2017-11-181-0/+3
|
* style: Sprinkle some inline in trivial methods.Emilio Cobos Álvarez2017-11-151-0/+13
| | | | | | | These methods are instantiated by the Gecko library, and used during querySelector, which means that they end up being super-hot in micro-benchmarks. MozReview-Commit-ID: K1XJb0QyX5a
* Allow unused imports for AsciiExt in style code.Simon Sapin2017-11-091-1/+1
| | | | See #19128, this part is cherry-picked so Gecko can build with rust nightly.
* selectors: Reformat signatures in the parser module.Emilio Cobos Álvarez2017-10-221-92/+154
| | | | | I was doing something unrelated with this code, and each signature uses a different style. This PR unifies them.
* Fix commonmark Markdown warnings in docs, part 1Matt Brubeck2017-10-171-3/+3
| | | | | | | | Fixes warnings from rust-lang/rust#44229 when `--enable-commonmark` is passed to rustdoc. This is mostly a global find-and-replace for bare URIs on lines by themselves in doc comments.
* style: Use left-to-right indices in the invalidator.Emilio Cobos Álvarez2017-10-161-14/+21
| | | | | This will make easier to create external invalidations, and also makes reasoning about the invalidator a bit easier.
* CSS parsing error types: flatten nested enums somewhatSimon Sapin2017-10-101-93/+95
|
* Update to cssparser 0.22 (source location in error types)Simon Sapin2017-10-101-87/+119
|
* Add support for :scope pseudo-classXidorn Quan2017-10-091-0/+3
|
* Overhaul MallocSizeOf and related things.Nicholas Nethercote2017-09-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes the MallocSizeOf stuff in Stylo work more like the HeapSizeOf stuff already in Servo, except better. In particular, it adds deriving support for MallocSizeOf, which will make it easier to improve coverage. The patch does the following. - Combines servo/components/style/stylesheets/memory.rs and the heapsize crate into a new crate, malloc_size_of. - Forks the heapsize_derive crate, calling it malloc_size_of, so that MallocSizeOf can be derived. - Both the new crates have MIT/Apache licenses, like heapsize, in case they are incorporated into heapsize in the future. - Renames the methods within MallocSizeOf and the related traits so they are more concise. - Removes MallocSizeOfWithGuard. - Adds `derive(MallocSizeOf)` to a lot of types, in some cases replacing an equivalent or almost-equivalent hand-written implementation. - Adds stuff so that Rc/Arc can be handled properly.
* Measure selectors.Nicholas Nethercote2017-09-071-1/+5
| | | | | | | | | This patch adds measurement of Selectors within StyleRule. This requires exposing the pointer within ThinArc. The patch also adds measurement of the several CssRule variants, in order to measure nested CssRules (and PropertyDeclarationBlocks) within them: DocumentRule, MediaRule, PageRule, SupportsRule.
* Use a 1-element smallvec for selector lists.Josh Matthews2017-09-061-5/+12
|
* Bug 1391169 Part 1: Servo-side change Selector to_css function to handle ↵Brad Werth2017-09-011-12/+16
| | | | | | combinators in between universal selectors. MozReview-Commit-ID: EyVrSAICPm
* Report more invalid selectors (bug 1384216).Josh Matthews2017-08-281-6/+11
|
* Report invalid selectors (bug 1384216).Josh Matthews2017-08-281-12/+23
|
* Report more specific invalid attribute selectors (bug 1384216).Josh Matthews2017-08-281-17/+37
|
* Report unexpected attribute selector tokens (bug 1384216).Josh Matthews2017-08-281-36/+23
|
* Report unknown pseudos (bug 1384216).Josh Matthews2017-08-281-7/+7
|
* Use Parser::skip_whitespace in a few places to make Parser::try rewind less.Simon Sapin2017-08-261-16/+3
| | | | | | | | | | | | | | | | | | | | 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 ```
* Auto merge of #18225 - jdm:unused-visitor-argument, r=emiliobors-servo2017-08-251-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 -->
| * Remove unused selector visitor argument.Josh Matthews2017-08-241-1/+1
| |
* | order derivable traits listsClément DAVID2017-08-231-9/+9
|/ | | | | | Ignoring : - **generated**.rs - python/tidy/servo_tidy_tests/rust_tidy.rs
* Upgrade to rustc 1.21.0-nightly (13d94d5fa 2017-08-10)Simon Sapin2017-08-151-1/+1
|
* Update to cssparser 0.19, count line numbers during tokenizationSimon Sapin2017-08-091-14/+14
|
* Use drain() over IntoIter on a few SmallVecs.Bobby Holley2017-08-021-1/+1
| | | | This is all the ones I could find in style/ and selectors/.
* Utilize match_ignore_ascii_case! in more places.Corey Farwell2017-07-291-4/+4
|
* Update cssparser to 0.18Simon Sapin2017-07-241-72/+68
| | | | https://github.com/servo/rust-cssparser/pull/171
* selectors: Don't track class and id ancestor hashes in quirks mode.Emilio Cobos Álvarez2017-07-201-13/+20
| | | | | | | | | 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
* Auto merge of #17539 - jyc:simplify-an-b, r=emiliobors-servo2017-07-191-4/+28
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 -->
| * Simplify <an+b> in selector args when serializing.Jonathan Chan2017-07-181-4/+28
| |
* | Omit serializing the universal selector when possible.Jonathan Chan2017-07-171-3/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Elide the explicit any namespace prefix when lacking default namespace.Jonathan Chan2017-07-171-14/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Replace Namespace components which map to the default namespace with ↵Jonathan Chan2017-07-141-1/+4
|/ | | | | | | | | | | 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
* style: Remove SelectorAndHashes.Emilio Cobos Álvarez2017-07-131-20/+0
|
* style: Remove hashes from style rules and dependencies.Emilio Cobos Álvarez2017-07-131-12/+12
| | | | | | 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.
* Auto merge of #17538 - jyc:selectorText, r=Manishearthbors-servo2017-07-121-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 -->
| * Implement CSSStyleRule.selectorText.Jonathan Chan2017-07-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Allow selector parser to specify pseudo-element which can be used with ↵Xidorn Quan2017-07-121-2/+9
| | | | | | | | single-colon syntax.
* | Add functional pseudo-element support to selectors crate.Xidorn Quan2017-07-121-30/+45
| |
* | Slightly simplify parse_one_simple_selector.Xidorn Quan2017-07-121-14/+11
|/