Commit graph

200 commits

Author SHA1 Message Date
Bastien Orivel
29b4eec141 Bump bitflags to 1.0 in every servo crate 2017-10-30 23:36:06 +01:00
Emilio Cobos Álvarez
2b94c79d5a
style: inline a local-variable which is no longer used more than once. 2017-10-26 18:31:03 +02:00
Emilio Cobos Álvarez
529f33eb6f
selectors: Be consistent about how we get next elements for selector-matching.
This fixes bug 1412011.

MozReview-Commit-ID: JgLoBNjA3m8
2017-10-26 18:24:07 +02:00
Emilio Cobos Álvarez
22dc480272
selectors: Deindent some selector-matching code.
MozReview-Commit-ID: B0ixSTcRS4S
2017-10-26 18:23:06 +02:00
Emilio Cobos Álvarez
191c39f28c
style: Make invalidations with offset zero "universal" invalidations.
We'll use this for querySelector / querySelectorAll.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:46 +02:00
Emilio Cobos Álvarez
e1aa829d67
selectors: Reformat signatures in the parser module.
I was doing something unrelated with this code, and each signature uses a
different style. This PR unifies them.
2017-10-22 16:33:04 +02:00
bors-servo
5ab0ac1620 Auto merge of #18971 - mbrubeck:var, r=emilio
Use env::var_os to read paths from the environment

This avoids unnecessary UTF-8 validation on OsStrings that we just pass
back to the OS.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because they are code cleanup only

<!-- 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/18971)
<!-- Reviewable:end -->
2017-10-21 08:09:22 -05:00
Matt Brubeck
c169f52b25 Use env::var_os to read paths from the environment
This avoids unnecessary UTF-8 validation on OsStrings that we just pass
back to the OS.
2017-10-20 09:03:21 -07:00
Xidorn Quan
2dc714f0ac Implement XUL tree pseudo style resolution for stylo. 2017-10-20 14:08:56 +11:00
Gecko Backout
11c64178d8 Backed out changeset e64e659c077d: servo PR #18809 and revendor for reftest failures, e.g. in layout/reftests/bugs/392435-1.html. r=backout on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/18809
2017-10-19 21:26:51 +00:00
bors-servo
fe16c1d5c3 Auto merge of #18809 - Eijebong:bitflags, r=nox
Update bitflags to 1.0 in every servo crate

It still needs dependencies update to remove all the other bitflags
versions.

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because it's a dependency update

<!-- 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/18809)
<!-- Reviewable:end -->
2017-10-19 10:35:08 -05:00
Bastien Orivel
e8e2d0a4b2 Update bitflags to 1.0 in every servo crate
It still needs dependencies update to remove all the other bitflags
versions.
2017-10-19 15:01:17 +02: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
Matt Brubeck
efc3683cc7 Fix commonmark Markdown warnings in docs, part 1
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.
2017-10-17 11:24:57 -07:00
Emilio Cobos Álvarez
f1cc225e97
style: Use left-to-right indices in the invalidator.
This will make easier to create external invalidations, and also makes reasoning
about the invalidator a bit easier.
2017-10-16 08:54:00 +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
Emilio Cobos Álvarez
48c85151dc
selectors: Remove useless assertion.
The code below asserts the same in a more fine-grained way.
2017-10-14 17:03:34 +02:00
Emilio Cobos Álvarez
bcfe523c99
selectors: Reformat some signatures in selectors::matching. 2017-10-14 17:03:33 +02:00
Simon Sapin
c496aa16a0 Rename the 'unstable' feature of the selectors crate to 'bench' 2017-10-12 17:19:02 +02:00
Simon Sapin
46ea99d54b CSS parsing error types: flatten nested enums somewhat 2017-10-10 13:28:30 +02:00
Simon Sapin
c0f8f15f39 Update to cssparser 0.22 (source location in error types) 2017-10-10 13:28:17 +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
Emilio Cobos Álvarez
4f984a6428
selectors: Remove unused crate. 2017-09-25 02:01:55 +02:00
Bobby Holley
438740b912 Implement an nth-index cache.
MozReview-Commit-ID: Ee0um3QXkxl
2017-09-21 15:25:38 -07:00
Bobby Holley
ab9edf3d69 Hoist index computation into a helper.
MozReview-Commit-ID: ALeggMDh92m
2017-09-20 23:22:44 -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
Bobby Holley
8b6c5988b5 Hoist the LRU cache into its own crate to share it with selectors. 2017-09-20 23:22:20 -07:00
Tom Tromey
c48226ff6f Preserve sourceURL comment on style sheets
In addition to the sourceMappingURL comment, there is a second special
comment, "sourceURL", that can be used to set the "display name" of a
style sheet for developer tools.  This name is also used as the base
URL for the source-map URL resolution algorithm.  sourceURL is
described here:
https://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/
The devtools feature bug is here:
https://bugzilla.mozilla.org/show_bug.cgi?id=880831

This patch changes servo to preserve and expose this value for use in M-C.
2017-09-14 12:39:18 -06:00
Tom Tromey
4768597b13 Remove get_location_with_offset
Now that rust-cssparser reports 1-based locations, bump the required
cssparser version and remove get_location_with_offset.  Previously,
some code paths were not calling get_location_with_offset; see
https://bugzilla.mozilla.org/show_bug.cgi?id=1398869 for some
background.
2017-09-12 07:35:55 -06:00
Nicholas Nethercote
32548e5312 Overhaul MallocSizeOf and related things.
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.
2017-09-12 12:37:51 +10:00
Boris Zbarsky
b2c56345d7 Update rust-cssparser to 0.20.2.
This reduces memory consumption of list-valued properties in the common case of one entry in the list.
2017-09-11 10:55:27 -04:00
Nicholas Nethercote
61877b7316 Measure selectors.
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.
2017-09-07 15:01:11 +10:00
Josh Matthews
3ae7781b5f Use a 1-element smallvec for selector lists. 2017-09-06 12:13:40 -07:00
bors-servo
fd95696d31 Auto merge of #18344 - bradwerth:selectorSerialize, r=SimonSapin
Change selector::to_css function to handle combinators in between universal selectors.

https://bugzilla.mozilla.org/show_bug.cgi?id=1391169
https://reviewboard.mozilla.org/r/172368/

---
<!-- 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
- [ ] These changes fix #__ (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/18344)
<!-- Reviewable:end -->
2017-09-01 23:41:10 -05:00
Brad Werth
51f3a16e19 Bug 1391169 Part 1: Servo-side change Selector to_css function to handle combinators in between universal selectors.
MozReview-Commit-ID: EyVrSAICPm
2017-09-01 09:03:04 -07:00
Xidorn Quan
2bca62045f Parse at-rule without block in two stages 2017-09-01 16:21:22 +10:00
Josh Matthews
4016371e1d Report more invalid selectors (bug 1384216). 2017-08-28 17:21:57 -07:00
Josh Matthews
9a7cceb0a1 Report invalid selectors (bug 1384216). 2017-08-28 17:21:07 -07:00
Josh Matthews
408c34a76d Report more specific invalid attribute selectors (bug 1384216). 2017-08-28 17:20:45 -07:00
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
Fernando Jiménez Moreno
4119584c55 Remove unused SelectorIter import 2017-08-25 10:56:39 +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
Ting-Yu Lin
a23596d377 Improve debug log related to selector matching
Move debug log in matches_complex_selector_internal to the front so that the
entire complex selector can be printed.

MozReview-Commit-ID: KXBDpbzBv0I
2017-08-24 17:05:35 +08: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
Ting-Yu Lin
0e82ca1d3a style: Skip matching :nth-child if element is the root of anonymous subtree
This implement the logic in Gecko's nsNthIndexCache::GetNthIndex().

MozReview-Commit-ID: 8lzK9iIbfzo
2017-08-16 14:25:01 +08:00
Simon Sapin
b5a4b8d6a0 Upgrade to rustc 1.21.0-nightly (13d94d5fa 2017-08-10) 2017-08-15 14:10:44 +02:00