Commit graph

59 commits

Author SHA1 Message Date
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
Julian Seward
c85633f48e
stylo: Add uses of fallible Vec, SmallVec and HashMap facilities.
Bug: 1395064
Reviewed-by: emilio
2017-09-10 16:42:06 +02:00
Emilio Cobos Álvarez
56282f4fab
style: Reword a TODO in the stylesheet invalidation code.
We already run that for removals.
2017-09-09 00:10:00 +02:00
Nicholas Nethercote
ae1216a717 Measure SmallVecs in SelectorMap and InvalidationMap. 2017-09-06 15:39:20 +10:00
bors-servo
122e49d516 Auto merge of #18271 - legnaleurc:propagate_dirty_bits, r=emilio
Propagate dirty bits after invalidation if needed.

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

Follow up for [bug 1388298](https://bugzil.la/1388298).

---
<!-- 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: -->
- [ ] 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/18271)
<!-- Reviewable:end -->
2017-09-05 14:18:52 -05:00
Emilio Cobos Álvarez
cdbb5b56aa
style: Convert the visited dependentness of a dependency in a binary enum. 2017-09-05 19:43:52 +02:00
Emilio Cobos Álvarez
cc31397a2e
style: Don't waste a whole selector map for each class / id in the document.
It's just useless.
2017-09-05 19:43:51 +02:00
Nicholas Nethercote
d880efcab3
Measure the stylist during memory reporting. 2017-09-05 19:43:50 +02:00
Wei-Cheng Pan
22ace048cb Propagate dirty bits after invalidation if needed. 2017-09-04 18:21:01 +08:00
Emilio Cobos Álvarez
8c3cc9ba1f Hook the recursive invalidation traversal up to the stack checker machinery.
MozReview-Commit-ID: 3tX3gHFTBT
2017-08-25 18:39:20 -07:00
Emilio Cobos Álvarez
723d31a4d8
style: Remove SharedStyleContext::quirks_mode. 2017-08-25 12:23:30 +02: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
Bobby Holley
d4aa8e3cef Track the restyle root and use it to do less work during the traversal.
MozReview-Commit-ID: A8O3JOpsv4E
2017-08-22 19:34:46 -07:00
Emilio Cobos Álvarez
aa0c320f4f
style: Keep dirty bit invariants during invalidation.
There's the question of whether should we be recursing into the invalidation
code for elements without data... Probably not, but that's a somewhat more
risky change.

Bug: 1391444
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-21 17:54:12 +02:00
Emilio Cobos Álvarez
9e0dd19e7e
style: Skip state pseudo-classes when finding a pseudo-element.
Bug: 1391577
Reviewed-by: heycam
MozReview-Commit-ID: 1ICBijtcf2b
2017-08-20 09:12:57 +02:00
Emilio Cobos Álvarez
d1725b1f19
style: Replicate the list of stylesheets on the layout thread.
This is a patch that unifies a bit how Gecko and Stylo stylesheets work, in
order to be able to eventually move the stylesheets into the stylist, and be
able to incrementally update the invalidation map.
2017-08-18 14:31:35 +02:00
Emilio Cobos Álvarez
4c80cccbd2
stylo: Cleanup a bit of the Stylist clear setup.
This moves us to clear on rebuild, which allows us to remove yet another place
where we track stylist dirtiness.

Bug: 1390255
Reviewed-by: heycam
MozReview-Commit-ID: nihQbUAbh8
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-16 08:49:41 +02:00
Simon Sapin
b5a4b8d6a0 Upgrade to rustc 1.21.0-nightly (13d94d5fa 2017-08-10) 2017-08-15 14:10:44 +02:00
Cameron McCormack
db6a09f24f style: Move cached media query results into per-origin data. 2017-08-13 18:50:59 +08:00
Cameron McCormack
16937ba7cd style: Move invalidation map into PerOriginCascadeData. 2017-08-09 19:27:53 +08:00
Emilio Cobos Álvarez
8eef60ae1f
stylo: Fix restyle hint conversion to handle eRestyle_ForceDescendants correcty. 2017-08-01 17:13:01 +01:00
bors-servo
255c9d00da Auto merge of #17895 - bholley:clean_up_traversal, r=emilio
Clean up traversal modes

https://bugzilla.mozilla.org/show_bug.cgi?id=1384769

<!-- 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/17895)
<!-- Reviewable:end -->
2017-07-27 18:29:29 -05:00
Bobby Holley
ce295f6daf Pass TraversalFlags from C++ into Rust.
MozReview-Commit-ID: EVUzgnL5coN
2017-07-27 14:25:58 -07:00
Nazım Can Altınova
43cf493832 style: Implement parsing/serialization for @font-feature-values rule 2017-07-27 13:37:57 -07:00
Emilio Cobos Álvarez
4c391ca6ba
style: Avoid exponential blowup when processing invalidations of the same kind.
Bug: 1383981
Reviewed-by: heycam
MozReview-Commit-ID: HZ97UwvblkQ
2017-07-27 13:03:22 +02:00
Emilio Cobos Álvarez
af2b429557
style: Avoid looking at descendant hints to check whether the element needs a restyle. 2017-07-24 12:12:08 +02:00
Emilio Cobos Álvarez
2d57e001aa
style: Remove bogus assertion.
Bug: 1381682
Reviewed-by: heycam
MozReview-Commit-ID: E6bKyBdMUue
2017-07-19 09:44:00 +02:00
Hiroyuki Ikezoe
f91126ba86 Add has_current_styles_for_traversal().
In animation-only restyle, we just need to check the element
has animation restyle hints or has recascade self which is a result
of animation-only restyle for ancestors.
has_current_styles() in Servo_ResolveStyle() is intentionally left there,
it will be changed in a subsequent patch.
2017-07-18 19:13:50 +09: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
Emilio Cobos Álvarez
9394ea9644
style: Remove unneeded bounds in SelectorMap and related code.
MozReview-Commit-ID: CWwdVCwWijn
2017-07-13 03:34:33 +02:00
Emilio Cobos Álvarez
1263075776
stylo: Fix StyleSheetInner/Stylesheet mapping
The key of this patch is the split between Stylesheet and StylesheetContents.

Gecko will use StylesheetContents, which maps to a ServoStyleSheetInner.
2017-07-02 15:49:40 +02:00
Emilio Cobos Álvarez
f8346e598e
style: Look at XBL stylists to collect dependencies too.
Bug: 1375969
Reviewed-By: heycam
MozReview-Commit-ID: 72wZj6o667V
2017-06-28 16:02:10 -07:00
Emilio Cobos Álvarez
215d14b37e
style: Factor out computation for a given InvalidationMap.
Bug: 1375969
Reviewed-By: heycam
MozReview-Commit-ID: 9qSr1LcsKK5
2017-06-28 16:02:09 -07:00
bors-servo
6b99318f55 Auto merge of #17443 - emilio:smallwat, r=SimonSapin
style: Don't use SmallVec::into_iter to move into another vector.

See bug 1374848 for why.

<!-- 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/17443)
<!-- Reviewable:end -->
2017-06-22 00:14:38 -07:00
Emilio Cobos Álvarez
1572bd0948
style: Don't use SmallVec::into_iter to move into another vector.
See bug 1374848 for why.
2017-06-21 01:39:15 +02: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
Emilio Cobos Álvarez
84a8bbc8a6
style: Remove extra-optimistic optimization.
We can't really do this :(
2017-06-20 15:36:16 +02:00
Emilio Cobos Álvarez
ae5a6c9c69
style: Get restyle hints right in presence of XBL.
Bug: 1371130
Reviewed-By: heycam
MozReview-Commit-ID: 56lMyXEYT1I
2017-06-20 13:09:36 +02:00
Emilio Cobos Álvarez
459b22a985
style: Invalidate style using the DOM tree, and scan pseudo-elements and NAC separately.
Bug: 1371130
Reviewed-By: heycam
MozReview-Commit-ID: IU1TbVf4Zz9
2017-06-20 12:17:54 +02:00
Hiroyuki Ikezoe
9b166c5cda Use mutate_data() instead of get_data().map() with borrow_mut(). 2017-06-19 14:55:36 +09:00
Emilio Cobos Álvarez
ffc45e9aaa
style: Inline RestyleData.
Bug: 1368236
MozReview-Commit-ID: 49s3SO0PMHf
2017-06-16 03:36:18 +02:00
Emilio Cobos Álvarez
f9c268922d
style: Kill StoredRestyleHint.
Reviewed-By: bholley
Bug: 1368236
MozReview-Commit-ID: 43Cf0rJyhzO
2017-06-14 13:11:10 +02:00
Emilio Cobos Álvarez
6b0f4c0410
style: Move one-off checks out of the recursive invalidation function.
There isn't a need to pay the cost for them multiple times.

Bug: 1372068
MozReview-Commit-ID: 3K2mRcWTheJ
2017-06-13 13:27:09 +02:00
Emilio Cobos Álvarez
36bac58863
style: Don't try to go down the tree if there aren't invalidations.
This can happen when adding an empty stylesheet, for example.

Bug: 1372068
MozReview-Commit-ID: Jtm4eJBWjEA
2017-06-13 13:27:08 +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
Emilio Cobos Álvarez
fdf9093466
style: Add missing visitedness check while invalidating elements.
This is needed for the omta test to pass. This is pretty much the equivalent to
the old restyle hints code.

Bug: 1368240
MozReview-Commit-ID: BLUfw5Wxpxd
2017-06-13 13:27:02 +02:00
Emilio Cobos Álvarez
14bb57c08f
style: Properly handle invalidation of eager pseudo-elements.
Bug: 1368240
MozReview-Commit-ID: EkzDVhC3GPH
2017-06-13 13:26:46 +02:00
Emilio Cobos Álvarez
cb06375fe2
style: Implement a more fine-grained invalidation method.
This commit also removes the old restyle_hints module and splits it into
multiple modules under components/style/invalidation/element/.

The basic approach is to walk down the tree using compound selectors as needed,
in order to do as little selector-matching as possible.

Bug: 1368240
MozReview-Commit-ID: 2YO8fKFygZI
2017-06-13 13:26:41 +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
Cameron McCormack
c533097e20 style: Distinguish between the tree structures used for traversal and selector matching.
This patch renames TNode::parent_element to traversal_parent, since it returns
the parent from the perspective of traversal (which in Gecko uses the
flattened tree).  It also renames TNode::children to traversal_children
for the saem reason.

We keep parent_element and children functions on TNode to use for selector
matching, which must be done on the real DOM tree structure.
2017-06-09 18:37:35 +08:00