Commit graph

121 commits

Author SHA1 Message Date
est31
642b7c3ea1 Remove unused code from selector and style crates 2019-06-07 15:14:21 +02:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
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
Emilio Cobos Álvarez
0ae47b2659
style: Cleanup invalidation processor constructor.
It used to be this way because of lifetime issues (plus the shadow
datas were in RwLocks at some point IIRC). Now we guarantee that as long as the
element is away the cascade data is as well, so we don't need to thread it
around.

Differential Revision: https://phabricator.services.mozilla.com/D2768
2018-08-08 01:37:50 +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
db5db13559
style: Implement the non-functional :host selector.
Kinda tricky because :host only matches rules on the shadow root where the rules
come from. So we need to be careful during invalidation and style sharing.

I didn't use the non_ts_pseudo_class_list bits because as soon as we implement
the :host(..) bits we're going to need to special-case it anyway.

The general schema is the following:

 * Rightmost featureless :host selectors are handled inserting them in the
   host_rules hashmap. Note that we only insert featureless stuff there. We
   could insert all of them and just filter during matching, but that's slightly
   annoying.

 * The other selectors, like non-featureless :host or what not, are added to the
   normal cascade data. This is harmless, since the shadow host rules are never
   matched against the host, so we know they'll just never match, and avoids
   adding more special-cases.

 * Featureless :host selectors to the left of a combinator are handled during
   matching, in the special-case of next_element_for_combinator in selectors.
   This prevents this from being more invasive, and keeps the usual fast path
   slim, but it's a bit hard to match the spec and the implementation.

   We could keep a copy of the SelectorIter instead in the matching context to
   make the handling of featureless-ness explicit in match_non_ts_pseudo_class,
   but we'd still need the special-case anyway, so I'm not fond of it.

 * We take advantage of one thing that makes this sound. As you may have
   noticed, if you had `root` element which is a ShadowRoot, and you matched
   something like `div:host` against it, using a MatchingContext with
   current_host == root, we'd incorrectly report a match. But this is impossible
   due to the following constraints:

    * Shadow root rules aren't matched against the host during styling (except
      these featureless selectors).

    * DOM APIs' current_host needs to be the _containing_ host, not the element
      itself if you're a Shadow host.

Bug: 992245
Reviewed-by: xidorn
MozReview-Commit-ID: KayYNfTXb5h
2018-04-09 12:19:05 +02: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
Jon Leighton
fe583fc5d0 Add layout RPC query for getting an element's style
This enables us to implement Element::has_css_layout_box() in a more
direct way, and also enables us to remove some of the existing more
specific queries.

Fixes #19811.
2018-01-28 10:59:45 +01:00
Emilio Cobos Álvarez
14661e470f
style: Add a couple FIXMEs I've noticed while working on this.
::slotted is hard.
2018-01-12 12:08:40 +01:00
Emilio Cobos Álvarez
b91efadd8d
style: Move invalidation::element::collector to invalidation::element::state_and_attributes.
Since it's what that file is about.
2018-01-11 14:49:31 +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
Emilio Cobos Álvarez
af879523ea
style: Make all keywords CamelCase for consistency.
This prevents confusion and paves the ground for derive(Parse) of them.
2017-12-06 02:35:10 +01:00
Emilio Cobos Álvarez
02ad6d3d90
style: Require an nth-index cache for invalidation. 2017-11-29 21:22:29 +01:00
Emilio Cobos Álvarez
49fe3d1c9f
style: Remove "reconstructed ancestor" checks.
This is only useful to avoid restyling NAC subtrees, but _not_ for ::before or
::after, in most cases. These subrees are small, and reframing is also not too
common, so I don't think it warrants the complexity.
2017-11-10 17:03:01 +01:00
Emilio Cobos Álvarez
57121a2e15
style: Remove the skip_applying_damage "optimization".
We already remove all change hints down the tree when finding a reframe hint
using ClearServoRestyleFromSubtree in ServoRestyleManager, so this is useless.

MozReview-Commit-ID: 1twx7iPt79x
2017-11-09 15:21:53 +01:00
Bastien Orivel
29b4eec141 Bump bitflags to 1.0 in every servo crate 2017-10-30 23:36:06 +01:00
Emilio Cobos Álvarez
1b32709d95
style: avoid selector refcount churn during invalidation.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:49 +02:00
Emilio Cobos Álvarez
258efb70df
style: Move MatchingContext to the InvalidationProcessor.
This avoids threading the quirks mode and nth-index cache around, and prevents
having to thread even more arguments down for the querySelector stuff (at least
VisitedHandlingMode and the style scope).

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:48 +02: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
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
7c2265360f
style: Stop threading the ElementData around the invalidator. 2017-10-17 08:57:34 +02:00
Emilio Cobos Álvarez
40d9cd99b5
style: Don't require a full SharedStyleContext for TreeStyleInvalidator.
We only use it to get the quirks mode, and a shared style context is a pretty
heavy-weight struct.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-17 08:57:33 +02:00
Emilio Cobos Álvarez
e447f819a2
style: Make InvalidationProcessor methods be &mut self.
This would allow querySelector / querySelectorAll to mutate the list of matched
nodes as it sees fit.
2017-10-13 12:17:02 +02:00
Emilio Cobos Álvarez
a5e2f2c76c
style: Isolate all the restyling related logic in the invalidator in an InvalidationProcessor trait.
Ditto, no change in behavior.
2017-10-13 12:17:00 +02:00
Emilio Cobos Álvarez
b9b3e592dd
style: Split the invalidation collection from the invalidator step.
This is the first step in reusing the invalidation machinery for other stuff,
potentially including QuerySelector / QuerySelectorAll.
2017-10-13 12:16:59 +02:00
Emilio Cobos Álvarez
aba1cf8cd5
style: Allow passing an nth-index-cache to the invalidation code. 2017-10-02 21:02:28 +02:00
Emilio Cobos Álvarez
891bc7d174
style: Massage the resolver code so it's cleaner and prevents the problem.
This way all the borrows stay in the sharing code, and prevents an extra borrow
on a cache hit, which is not a big deal but nice.
2017-09-18 04:57:50 +02:00
Bobby Holley
1c9b39a8e8 Do a second pass on the sharing cache to reuse style by rule node identity.
MozReview-Commit-ID: H67j3Sbt3gr
2017-09-13 22:06:39 -07:00
Bobby Holley
7a7070e075 Add some wrapper types to propagate styles out of style resolver.
We'll use these next to propagate information about style reuse to the ElementDataFlags.

MozReview-Commit-ID: Dya6vgzydpL
2017-09-13 22:06:33 -07:00
Bobby Holley
50cee3e133 Eliminate RestyleData entirely.
Without this change, the previous commit increases the size of ElementData.

MozReview-Commit-ID: 87BZuXINiT9
2017-09-12 10:33:51 -07:00
Bobby Holley
61cad869d9 Hoist flags out of RestyleData.
MozReview-Commit-ID: 8emE83lykh3
2017-09-12 10:22:50 -07: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
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
fcd6e79659
style: Inline a bunch of trivial stuff we're paying calls for in Geckolib. 2017-08-22 12:48:14 +02:00
Bobby Holley
05a1b682bb Avoid leaving stale ANCESTOR_WAS_RECONSTRUCTED bits in the tree.
MozReview-Commit-ID: 76q5XxK2o2a
2017-08-15 14:25:50 -07:00
Nicholas Nethercote
1a40101d2f Overhaul ComputedValues measurement, and add style structs measurement. 2017-08-14 10:49:48 +10:00
Bobby Holley
49bdb5bb4e Be more careful about the flags we clear for forgetful traversals.
MozReview-Commit-ID: ETDL8KsInAn
2017-08-09 10:52:04 -07:00
Bobby Holley
54c52910e4 Introduce a new flag and use it to be more permissive about cousin sharing.
MozReview-Commit-ID: BCJg0Ycsy6M
2017-08-05 01:07:02 -07:00
Nicholas Nethercote
526e9691f8 stylo: Measure Elements and ComputedValues.
The patch provides FFI access to Gecko's SeenPtrs type from Rust, in
order to record what has already been measured when measuring Arcs. (The
SeenPtrs must be initialized on the Gecko side because the same table is
reused for measuring all Elements within a window, because Elements can
share ComputedValues.) I have confirmed with DMD that this is working
correctly.

The patch also introduces MallocSizeOfRepeats, which is like
MallocSizeOf but takes a SizeOfState, which holds a SeenPtrs table.
2017-08-03 09:15:38 +10:00
Boris Zbarsky
91d4956da5 Don't reconstruct the layout object when going from no pseudo to pseudo with no content for ::before and ::after.
Fixes Gecko bug 1376073.  r=emilio
2017-07-28 17:45:29 -04:00
Emilio Cobos Álvarez
b4d26619d3
style: Improve the assertion message in restyle_kind(). 2017-07-24 12:13:19 +02:00
Emilio Cobos Álvarez
f2fe3facf3
style: Update has_current_styles_for_this_traversal to not look at animation hints in non-animation traversals.
MozReview-Commit-ID: 4bwwIGcoXqA
2017-07-24 10:05:48 +02:00
Emilio Cobos Álvarez
55d9151dd3
style: Minor reformatting.
MozReview-Commit-ID: KVCfX3LqccF
2017-07-24 10:05:26 +02:00
Bobby Holley
cd31ae82b2 Bring back concise logging for ElementData.
This was removed recently in the ComputedValues patch, and makes traversal
logging rather unusable.

MozReview-Commit-ID: 5Jisfj9QxBM
2017-07-19 20:43:23 -07:00
Michael Partheil
b07ebbae6b Replace all uses of the style::stylearc alias with servo_arc.
The alias is left there temporarilly and will be removed completely in a later commit where
also components/style/gecko/generated/structs_{debug|release}.rs are re-generated (they still
use the old alias).
2017-07-19 09:29:05 +02:00
Hiroyuki Ikezoe
9c05481923 Skip snapshot handling during animation-only restyle. 2017-07-18 19:14:25 +09:00
Hiroyuki Ikezoe
ae55e51aaf Factor out restyle_kind_for_animation. 2017-07-18 19:13:24 +09:00
Bobby Holley
b7de96e702 Pass a callback to recalc_style_at to avoid traversing children twice.
MozReview-Commit-ID: DIHXaVNzbFM
2017-07-15 14:45:51 -07:00