Commit graph

56 commits

Author SHA1 Message Date
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Bobby Holley
afe484e46b
style: Allow placeholder import sheets.
This is necessary because we can't create GeckoStyleSheets off-main-thread,
so we need a placeholder until it can be filled in.

Bug: 1454030
Reviewed-by: emilio
MozReview-Commit-ID: ssRme4fLYg
2018-04-17 20:01:27 +02:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Emilio Cobos Álvarez
9c77f0b977
style: Better Shadow DOM assertions.
Bug: 1445682
Reviewed-by: xidorn
Differential Revision: https://phabricator.services.mozilla.com/D748
2018-03-19 13:58:18 +01:00
Emilio Cobos Álvarez
ef4ea7cc49
style: Separate the XBL and shadow dom styling bits.
Bug: 1441022
Reviewed-by: xidorn
MozReview-Commit-ID: 2W0BmZ8wWXg
2018-03-07 15:42:28 +01:00
Xidorn Quan
f518e55c28 Add sizeof for AuthorStyles. 2018-02-19 15:12:13 +11:00
Emilio Cobos Álvarez
5e64cb3516
style: Make XBL / Shadow DOM use something more light-weight than a Stylist.
It's just a struct aggregating stylesheets + CascadeData, with a quirks_mode
parameter because XBL sucks so bad.

Bug: 1436059
Reviewed-by: xidorn
MozReview-Commit-ID: 7q99tSNXo0K
2018-02-16 13:42:36 +01:00
Emilio Cobos Álvarez
88cc2798c4
style: Move more stuff to the place it belongs to.
In particular, `rebuild` is now done entirely by CascadeData, which simplifies
more stuff.

The eventual final state for this is that the data structure we use to store the
XBL / Shadow DOM stuff will be something like:

  struct AuthorStyles { CascadeData, AuthorSheetCollection }

MozReview-Commit-ID: 8TExtP58L4X
2018-02-09 19:45:04 +01:00
Emilio Cobos Álvarez
7edd25890d
style: Introduce AuthorStyleSheetSet.
MozReview-Commit-ID: K3ciocPJuz3
2018-02-09 19:45:03 +01:00
Emilio Cobos Álvarez
5e8dd8a2d4
style: Move the stylesheet set methods under a macro to reuse it soon.
MozReview-Commit-ID: 50Srw4Mjw18
2018-02-09 19:45:02 +01:00
Emilio Cobos Álvarez
a254dc12a4
style: Move author-style-disabled handling to push_applicable_declarations.
This will make it easier to handle it properly for Shadow DOM, though this patch
doesn't do that.

This also makes some method inline and infallible for convenience, since nobody
checks the errors anyway.

Bug: 1436798
Reviewed-by: bholley
MozReview-Commit-ID: Hq3erAUs5tf
2018-02-09 19:44:53 +01:00
Emilio Cobos Álvarez
438251cbfc
style: Make AuthorStylesEnabled an enum.
Chances are we need to pass it around in a bit.

Also invert the boolean because I don't want to reason about double negations,
even if they're simple.

MozReview-Commit-ID: KhX4lDKwDoj
2018-02-09 13:27:35 +01:00
Emilio Cobos Álvarez
bbc6857c06
style: Rename OriginValidity to DataValidity.
MozReview-Commit-ID: FpsYUlWLWTt
2018-02-09 13:27:33 +01:00
Emilio Cobos Álvarez
01915d84db
style: Assert we don't try to do dumb stuff.
MozReview-Commit-ID: 6DpkiwUdccD
2018-02-09 13:27:33 +01:00
Emilio Cobos Álvarez
c88d339db2
style: Move the dirty bit to SheetCollection.
MozReview-Commit-ID: DO9vv9vmSzF
2018-02-09 13:27:31 +01:00
Emilio Cobos Álvarez
f1516d228f
style: Rename StylesheetSet to DocumentStylesheetSet.
MozReview-Commit-ID: 5Xl1eRLu1VF
2018-02-09 13:27:30 +01:00
Bobby Holley
1d6841b9fd Avoid stylist flushes when sheets are appended and then removed again before flushing layout.
MozReview-Commit-ID: CHgbqfHnjwI
2018-02-01 09:14:07 -08:00
Emilio Cobos Álvarez
657d8b8e31
style: Look at the snapshots when invalidating due to stylesheet changes.
Otherwise removal of stylesheets may get out of sync with other DOM changes, and
we may fail to invalidate the style of the affected elements.

Bug: 1432850
Reviewed-by: bz
MozReview-Commit-ID: DrMTgLzQcnk
2018-01-27 02:34:27 +01:00
Emilio Cobos Álvarez
ce1d8cd232
style: Make invalidation state also be with the ::slotted rules.
MozReview-Commit-ID: GYmsXYvL9vj
2018-01-09 14:26:03 +01:00
Matt Brubeck
3005a26daf style: Use the ? operator for Option 2017-12-09 08:29:53 -08:00
Nicholas Nethercote
4506f0d30c Replace all uses of the heapsize crate with malloc_size_of.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.

This patch makes the following changes to the `malloc_size_of` crate.

- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
  (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).

- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
  support that operation.

- For `HashSet`/`HashMap`, falls back to a computed estimate when
  `enclosing_size_of_op` isn't available.

- Adds an extern "C" `malloc_size_of` function that does the actual heap
  measurement; this is based on the same functions from the `heapsize` crate.

This patch makes the following changes elsewhere.

- Converts all the uses of `heapsize` to instead use `malloc_size_of`.

- Disables the "heapsize"/"heap_size" feature for the external crates that
  provide it.

- Removes the `HeapSizeOf` implementation from `hashglobe`.

- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
  doesn't derive those types, unlike `heapsize`.
2017-10-18 22:20:37 +11:00
Emilio Cobos Álvarez
cb31e782aa
style: Share user agent cascade data across documents.
MozReview-Commit-ID: KcyuTHD0bt9
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-09-15 09:26:23 +02:00
Emilio Cobos Álvarez
0a9309aa96
style: Unify how servo and Gecko handle UA sheets. 2017-09-14 20:33:43 +02:00
bors-servo
bb2030a493 Auto merge of #18494 - frewsxcv:frewsxcv-size-hint, r=jdm
Implement `size_hint` for more iterators.

```
implement size hint for
more iterators because why
not we like fast things
```

<!-- 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/18494)
<!-- Reviewable:end -->
2017-09-13 19:38:32 -05:00
Corey Farwell
9cd4535364 Implement size_hint for more iterators.
```
implement size hint for
more iterators because why
not we like fast things
```
2017-09-13 20:29:27 -04:00
Emilio Cobos Álvarez
d7a3bec6d7
style: Add a comment about why the raw pointer is ok. 2017-09-13 19:52:49 +02:00
Emilio Cobos Álvarez
31079e2e3d
style: Disable "removed" assertion in Gecko. 2017-09-13 19:12:49 +02:00
Emilio Cobos Álvarez
02d1264047
style: Store stylesheets per origin.
This will allow us to cache UA sheets across documents.

MozReview-Commit-ID: 5rYIKTmC6iw
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-09-13 16:01:35 +02:00
Emilio Cobos Álvarez
fca2f48f86
style: Remove outdated comment.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-23 14:10:45 +02:00
Emilio Cobos Álvarez
3fd8a534d7
style: Rename SheetRebuildKind::rebuild_invalidation to should_rebuild_invalidation.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-23 14:10:45 +02:00
Emilio Cobos Álvarez
bf45a20760
style: Implement finer-grained stylist rebuilds.
MozReview-Commit-ID: ALsH9kSqHb0
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-23 11:06:42 +02:00
Emilio Cobos Álvarez
1c67a7dc14
style: Ensure the flusher is completely consumed before getting dropped.
This will be necessary for future patches.

MozReview-Commit-ID: FgWaoRCMdw2
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-23 09:30:47 +02:00
Emilio Cobos Álvarez
15594dda10
style: Add a StylesheetFlusher abstraction to enable more incremental rebuilds.
MozReview-Commit-ID: 8RBUUErm4bm
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-23 09:30:46 +02:00
Emilio Cobos Álvarez
029ab24671
style: Add a no-op constructor of StyleSheetEntry, in preparation for more changes.
MozReview-Commit-ID: 6Kz0S7YYmFC
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-23 09:26:22 +02:00
Emilio Cobos Álvarez
e1517d62af
style: Simplify and improve the per origin stylesheet invalidation setup.
MozReview-Commit-ID: adDDRhNnOw
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-23 09:26:21 +02:00
Emilio Cobos Álvarez
a98fd5e2b6
style: Make the StyleSheetSet::flush API slightly nicer.
MozReview-Commit-ID: LfJxZA9zhaE
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-23 09:24:50 +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
0701c0c953
style: Add docs about the lack of device in the stylesheet set.
Also add a few comments and similar about pending invalidation work, and avoid
passing a device in script, since the work it performs scanning the stylesheet
is just thrown away in the `flush_without_invalidations` call.
2017-08-22 16:55:53 +02:00
Emilio Cobos Álvarez
cbf388a5fd
style: Move the StyleSheetSet into the Stylist.
This will allow tracking whether there have been only additions to the
stylesheet set, and in that case don't destroy and completely rebuild the
invalidation map.
2017-08-22 16:55:52 +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
Cameron McCormack
84451e521b style: Only flush stylesheet invalidations for origins that have changed. 2017-08-13 18:51:04 +08:00
Cameron McCormack
f9d1a0e2d1 style: Split style sheet invalidations per-origin. 2017-08-13 18:50:58 +08:00
Emilio Cobos Álvarez
43d58fc01a
stylo: Run the stylehseet invalidation pass also for stylesheet removals.
People apparently do all sorts of silly stuff with stylesheets, see Google Inbox
in bug 1379203.

Bug: 1379433
Reviewed-By: heycam
MozReview-Commit-ID: 4x2d3glOFu8
2017-07-09 14:17:19 +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
Brad Werth
c617649e67 Add an update_stylesheet method to StylesheetSet.
MozReview-Commit-ID: KlRkApYL8wk
2017-06-20 12:24:39 -07:00
Emilio Cobos Álvarez
5c66d3c77a
Cache effective media query results.
This patch also makes RulesIterator not iterate over rules for which we don't
process nested rules.

There's nothing depending on this behavior right now afaik, and this will make
us duplicate less code in following patches.

Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1357461
MozReview-Commit-ID: CaMFQtAVnJF
2017-06-03 14:43:44 +02:00
Emilio Cobos Álvarez
b5232c940d
style: Move the stylesheet invalidation code to another submodule.
Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1357461
MozReview-Commit-ID: DIzZXoHycZs
2017-06-03 14:18:56 +02:00
Emilio Cobos Álvarez
f569274cca
Bug 1357583: Add a bunch of logging, shortcuts, and look also at the rightmost selector while invalidating sheets. r=heycam
MozReview-Commit-ID: 2XGcOCTa7MV
2017-05-29 20:27:38 +02:00