Commit graph

175 commits

Author SHA1 Message Date
Manish Goregaokar
5cd296a264
stylo: Replace all hashtable collections with ones from style::hash 2017-08-31 16:28:30 -07:00
Emilio Cobos Álvarez
dcbe196ed5
style: Remove NODE_NEEDS_DIRTY_ON_VIEWPORT_SIZE_CHANGE.
Recascading is enough.
2017-08-28 14:40:48 +02:00
Emilio Cobos Álvarez
97338d0e84
stylo: Make a few functions output more useful debug information. 2017-08-27 00:14:12 +02:00
Bobby Holley
994074fca6 Clean up bit clearing. 2017-08-26 10:22:03 -07: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
0f37b209cb
stylo: Remove a lot of the restyle damage related complexity.
The only reason why we had the `existing_style_for_style_damage` bit is to apply
some optimizations that we don't have anymore.

I still want to reintroduce a few of them, at least for the non-eager
pseudo-element case... But I think I won't need this at all.

This allows us to remove a fair amount of Gecko code too.
2017-08-20 13:59:46 +02:00
Bobby Holley
8a3761972d Bonus fix: Be more robust about clearing descendants bits under display:none subtrees.
MozReview-Commit-ID: 9KQVOpdEjwF
2017-08-15 14:25:50 -07:00
Hiroyuki Ikezoe
015a249afc Cleanup code that was used for verifying styling results for throttled animation flush in post traversal.
Now that we do process normal traversal even in the case of throttled animation
flush so that we don't need to do special handling for the case.

Note about the comment in has_current_styles():
the remaining animation hints is not caused by either this patch or the
previous patch in this patch series, it's been there in the first place, but
it should be fixed somehow later. See bug 1389675.

MozReview-Commit-ID: JojHufxNCiS
2017-08-11 18:52:36 -07:00
Bobby Holley
24a52b7990 Do all descendant bit propagation from Gecko over FFI.
Deduplicating code is nice, and it will help us when we make the bit
propagation more complicated in upcoming patches.

MozReview-Commit-ID: KIQnNJVayrM
2017-08-11 17:00:37 -07:00
Bobby Holley
f4ccbf3687 Hoist StyleNew{Children,Subtree} into their own paths.
The buggy animation handling isn't a regression, since currently we pass
UnstyledChildrenOnly in those cases, which blocks the animation traversal
in Servo_TraverseSubtree.

In general I really wanted to handle these two paths together. But there's
enough broken with the NewChildren path that I wanted to scope the buginess
as tightly as possible. And I really need to separate the handling here from
StyleDocument() to make the restyle root stuff work.

MozReview-Commit-ID: 9F0mcQl7AAX
2017-08-11 10:53:08 -07:00
Hiroyuki Ikezoe
0841db70ee Set restyle subtree restyle hint if the element animates display style from 'none' to other.
When display style is changed from 'none' to other in animation-only restyle
we need to resolve descendant elements' style that were in the display:none
subtree.

Three possible ways to resolve the descendant elements' style;

1) Traversing unstyled elements in animation-only restyle
   We can't simply traverse unstyled elements in the animation-only restyle
   since when we decided to traverse the unstyled elements we don't know yet
   the elements will be initially styled or are in display:none subtree. It
   will result that the new elements are styled in animation-only restyle,
   it's undesirable.

2) Creating a SequentialTask and resolve the descendants' style with
   ServoStyleSet::StyleNewSubtree()
   We can't resolve the descendants' styles with ServoStyleSet::StyleNewSubtree()
   in SequentialTask since at the moment we are still in servo traversal (i.e.
   sInServoTraversal is true). That means AutoSetInServoTraversal fails
   in PrepareAndTraverseSubtree().

3) Creating a SequentialTask and set restyle subtree hint and defer descendants'
   restyle in a subsequent normal traversal
   Note that, when we process throttled animations flush, we don't process
   normal traversal so the descendants will not be traversed until normal
   restyle happens but it will not be a big problem since it's really rare
   that user clicks display animation element just at the right moment when
   display property changes from none to other.  Also, if it will be really
   a problem, we should process *only* transform animations on the compositor,
   it's ideally right thing to do. Display property never runs on the
   compositor.

This patch takes the third approach.
2017-08-02 18:35:01 +09:00
Bobby Holley
ce295f6daf Pass TraversalFlags from C++ into Rust.
MozReview-Commit-ID: EVUzgnL5coN
2017-07-27 14:25:58 -07: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
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
9d21f9e6ce
style: Remove (mostly) unused has_current_styles.
MozReview-Commit-ID: DV9HfvbUjBY
2017-07-24 10:05:37 +02:00
Emilio Cobos Álvarez
55d9151dd3
style: Minor reformatting.
MozReview-Commit-ID: KVCfX3LqccF
2017-07-24 10:05:26 +02:00
Emilio Cobos Álvarez
4e0492c5d1
style: Move the RELEVANT_LINK_VISITED flag to servo.
And kill one GetParentAllowServo call while at it, and some other dumbness...

Bug: 1383307
Reviewed-by: Manishearth
2017-07-23 05:22:18 +02: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
Emilio Cobos Álvarez
fe8638a618
style: More ComputedValuesInner cleanup.
MozReview-Commit-ID: 8rkAP3pMEpD
2017-07-18 17:35:59 +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
Manish Goregaokar
74519cc1a7 stylo: Make Servo Arc types use ptr to T instead of ptr to ArcInner<T> 2017-07-17 18:03:09 -07:00
Manish Goregaokar
808b1f509b stylo: Use ComputedValuesInner instead of ComputedValues when we don't need it 2017-07-17 18:02:25 -07:00
Emilio Cobos Álvarez
bf9369b29d
script: Move the layout_wrapper outside of script.
This allows us to have ensure_data() and clear_data() functions on the TElement
trait, instead of hacking around it adding methods in random traits.

This also allows us to do some further cleanup, which I'd rather do in a
followup.
2017-07-15 16:41:12 +02:00
Emilio Cobos Álvarez
cc94a8b7cb
style: Undo the optimization for grabbing animation rules from the style data.
This is unfortunate, but for now it complicates things, I would like not needing
a ElementData to get the style of an Element in order to fix all the
getDefaultComputedStyle bugs.

MozReview-Commit-ID: LZvsdFEqrDE
2017-07-12 08:39:35 +02:00
Bobby Holley
3330653dc8 Rip out the generic abstractions around ThreadLocalStyleContext.
MozReview-Commit-ID: 5WTLuk323Ac
2017-07-05 16:37:17 -07:00
Emilio Cobos Álvarez
02b61ed1a1
style: Refactor XBL rule matching to add another API to iterate the Stylists.
This will allow us to query the relevant stylists for invalidation.

Bug: 1375969
Reviewed-By: TYLin
MozReview-Commit-ID: EIIzbr2pEqN
2017-06-28 16:02:08 -07:00
Cameron McCormack
0b2b30f301 style: Remove unused TElement::children_and_traversal_children_might_differ.
MozReview-Commit-ID: GUmuxpdvAa8
2017-06-28 11:58:50 -07:00
Boris Zbarsky
18ab0087ae Add some comments to may_generate_pseudo; no real behavior changes for now.
Gecko bug 1324618 part 2: https://bugzilla.mozilla.org/show_bug.cgi?id=1324618
2017-06-26 23:24:08 -07:00
bors-servo
6342a4b455 Auto merge of #17471 - aethanyc:fix-pseudo-element-matching-xbl, r=emilio
stylo: Fix pseudo element matching for rules in XBL stylesheets

This change was reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1372876

<!-- 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/17471)
<!-- Reviewable:end -->
2017-06-22 19:53:37 -07:00
J. Ryan Stinnett
2b5c56e6a8 Move match and cascade temporaries to CurrentElementInfo
Before this change, the `ComputedStyle` struct that is part of permanent style
data per element holds 2 `StrongRuleNode`s (unvisited and visited) and 2
`Arc<ComputedValues>` (unvisited and visited).

Both rule nodes and the visited values don't actually need to be here.  This
patch moves these 3 to new temporary storage in `CascadeInputs` on
`CurrentElementInfo` during the match and cascade process.  Rule nodes are
pushed down inside the `ComputedValues` for later access after the cascade.
(Visited values were already available there.)

The permanent style data per element now has just the `Arc<ComputedValues>` for
itself and eager pseudo-elements (plus the `RestyleHint`).

MozReview-Commit-ID: 3wq52ERMpdi
2017-06-22 15:47:32 -05:00
Ting-Yu Lin
1795af5e57 stylo: Fix pseudo element matching for rules in XBL stylesheets (bug 1372876)
MozReview-Commit-ID: JeliK45G8MT
2017-06-22 22:37:51 +08:00
bors-servo
7d785e75cd Auto merge of #17447 - emilio:root-disconnected-subtree, r=heycam,Manishearth
style: Be more strict when setting the root font size.

Before this commit, we assumed that if the element had no parent element, it was
the root of the document, which is plain false, since we can arrive there from,
let's say, getComputedStyle on a detached node.

Bug: 1374062
Reviewed-By: heycam
MozReview-Commit-ID: 65DxdzXgd0J

<!-- 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/17447)
<!-- Reviewable:end -->
2017-06-22 04:17:04 -07:00
Emilio Cobos Álvarez
6fefe522a3
style: Assert we never style a root element from another document.
Right now when calling getComputedStyle with an element from another document,
we return the style using the pres context of that document, not of the document
of the window getComputedStyle was called on, so this holds.

But it will stop holding if we ever change this, so assert it doesn't happen.

Bug: 1374062
Reviewed-By: Manishearth
MozReview-Commit-ID: 3g8yQWWdsen
2017-06-21 19:55:02 +02:00
Bobby Holley
db8f59407f Hoist sink into selectors.
It probably makes more sense (eventually) to put it in SmallVec.

MozReview-Commit-ID: AIBKCLiMNN2
2017-06-20 11:59:10 -07: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
b894c361e0
style: expose methods to get ::before, ::after, and the other NAC.
Reviewed-By: heycam
Bug: 1371130

MozReview-Commit-ID: JVeQevmjI3j
2017-06-20 12:16:31 +02:00
Simon Sapin
a5bb55790f Untry style 2017-06-18 13:18:13 +02:00
Emilio Cobos Álvarez
ffc45e9aaa
style: Inline RestyleData.
Bug: 1368236
MozReview-Commit-ID: 49s3SO0PMHf
2017-06-16 03:36:18 +02:00
Ting-Yu Lin
e80cb09be3 stylo: Fix pseudo element matching for XBL stylesheets (Bug 1371577)
MozReview-Commit-ID: GzWbztqW0V1
2017-06-14 17:58:15 +08: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
Bobby Holley
a98fff1af8 Hoist ApplicableDeclaration{Block,List} into a separate file.
MozReview-Commit-ID: EXnAzfyoZ1e
2017-06-12 12:13:21 -07:00
Cameron McCormack
c65b9a307c style: Remove unused TElement::layout_parent_element. 2017-06-09 18:37:37 +08:00
Cameron McCormack
719709f0d5 style: Add TNode::children_and_traversal_children_might_differ.
This will be used to optimize out traversing the real DOM children when
propagating restyle hints.
2017-06-09 18:37:36 +08: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
Manish Goregaokar
618efc6357 stylo: Remove TElement::attr_equals 2017-06-08 16:25:35 -07:00
Ting-Yu Lin
2411749fcf stylo: Get rules from Gecko XBL stylesheets in cascading (Bug 1290276) 2017-06-08 11:18:44 +08:00
Cameron McCormack
f492c8fe6e style: Match :lang() using snapshots correctly. 2017-06-08 09:37:09 +08:00
J. Ryan Stinnett
56b44d2709 Pull decls from Gecko for link preshints
Based on a link's active state and the visited handling mode, pull in link,
vlink, and alink preshint declaration blocks from Gecko as needed.

MozReview-Commit-ID: A6udMYbzQnK
2017-06-02 14:34:39 -05:00
Emilio Cobos Álvarez
fe74e70a2d
Bug 1369187: style: Add an API to fast-reject eager pseudos. r=bholley
Also, do nothing for now (we'll hook the Gecko pieces here when the time comes).

Let me know if you want to hold-off landing this.

MozReview-Commit-ID: 6PIhfp6sxk4
2017-06-01 21:09:26 +02:00