Commit graph

309 commits

Author SHA1 Message Date
Cameron McCormack
36e4d0a511 style: Adjust display:contents to display:inline for NAC (including ::before/::after). 2017-06-16 09:37:57 +08: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
dc521b2799
style: Remove damage_handled, and use a reconstructed_ancestor bit instead.
Reviewed-By: bholley
Bug: 1368236
MozReview-Commit-ID: 8KK0YfhiS2
2017-06-14 13:15:00 +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
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
Bobby Holley
a98fff1af8 Hoist ApplicableDeclaration{Block,List} into a separate file.
MozReview-Commit-ID: EXnAzfyoZ1e
2017-06-12 12:13:21 -07:00
Nazım Can Altınova
15fe48f3f6
stylo: Support :hover and :active quirk 2017-06-10 22:18:32 +03: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
Boris Zbarsky
f9205440b5 Parent mismatch should not clear style sharing cache.
We can have cousins in the cache whose parent doesn't match ours, and other
cousins whose parent does.  When we encounter one of the former, that's not a
reason to stop lookin for the latter.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1369620
2017-06-05 16:31:58 -04:00
Cameron McCormack
19b61dfc08 style: Recascade the document when rem units are used and the root font-size changes. 2017-06-04 10:03:11 +08:00
Emilio Cobos Álvarez
93c39b0730
Bug 1369187: style: Assert that if we find an eager, element-backed pseudo, it's ::before or ::after. r=bholley
This holds because ::first-line and ::first-letter are not element-backed.

MozReview-Commit-ID: 67FU15pCLqW
2017-06-01 21:10:45 +02: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
Hiroyuki Ikezoe
47124e1787 Don't process visited rules during animation-only restyle. 2017-05-31 05:48:57 +09:00
Hiroyuki Ikezoe
636c47da29 Set the dirty flag of DeclarationBlock when the DeclarationBlock is modified and clear the flag when it's resyled. 2017-05-31 05:48:27 +09:00
Emilio Cobos Álvarez
7db2776348
s/CachedStyleSharingData/ValidationData.
I still think CachedStyleSharingData should be the name, but not going to fight
over it.
2017-05-30 11:23:59 +02:00
Emilio Cobos Álvarez
03952a0c27
style: Also cache the class list in the CurrentElementInfo.
This patch also removes all notion of style sharing from matching.rs, which is
nice.
2017-05-29 22:54:17 +02:00
Manish Goregaokar
314d7d36e2 Don't set root font size when styling NAC
MozReview-Commit-ID: 12CEdFLSJTh
2017-05-26 22:06:44 -07:00
Cameron McCormack
cc44f05f44 style: Add support for resolving default computed styles. 2017-05-25 14:19:59 +08:00
J. Ryan Stinnett
f12af6c8d6 Filter visited cascade to only visited dependent properties
Speed up the visited cascade by only running it for the properties that are
actually visited dependent.  (These are only the properties where the separate
set of visited styles is even read at all, so running the rest is wasted work.)

MozReview-Commit-ID: 5B7wYtuH974
2017-05-24 18:08:19 -05:00
J. Ryan Stinnett
2afaa4fcba Rule replacement for visited rules
Since visited rules are stored separately, we need also run `replace_rules` for
those in addition to regular rules.

MozReview-Commit-ID: 4KYhOBXm88O
2017-05-24 18:07:54 -05:00
J. Ryan Stinnett
a7882cfeb9 Match and cascade visited styles
To support visited styles, we match and cascade a separate set of styles any
time we notice that an element has a relevant link.

The visited rules and values are held in `ComputedStyle` alongside the
regular rules and values, which simplifies supporting various APIs like
`cascade_primary_and_pseudos` which expect easy access to previously matched
rules.

To simplify passing the additional values around, an additional reference to the
visited `ComputedValues` is placed inside the regular `ComputedValues`.

MozReview-Commit-ID: 2ebbjcfkfWf
2017-05-24 18:07:44 -05:00
Manish Goregaokar
a19dd8142e Rollup merge of #17014 - hiikezoe:animation-rules-in-norma-restyle, r=emilio,birtles
Animation rules in norma restyle

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

This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1366631 and https://bugzilla.mozilla.org/show_bug.cgi?id=1367225

- [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 for stylo

<!-- 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/17014)
<!-- Reviewable:end -->
2017-05-24 11:59:28 -07:00
Hiroyuki Ikezoe
976b3ba6e7 Don't process style attribute changes in animation-only restyle. 2017-05-24 14:00:31 +09:00
Hiroyuki Ikezoe
a921d1af22 Make replace_rules returning boolean.
We only use whether the return value is IMPORTANT_RULES_CHANGED or not, so we
can just return true if an important rules was changed in the function.
Also, we can just return false in case of animation rules changes sine for
animation we can ensure there is no importan rules.
Because of these changes, replace_rule_node does not borrow |result| so that
we can drop a scope there.
2017-05-24 14:00:17 +09:00
Hiroyuki Ikezoe
fce7c2d885 Check ElementHasAnimations before trying to get animations rules.
In case of ::before and ::after element, the generated content has no
ElementHasAnimations flag, their parent has the flag.
2017-05-24 11:12:10 +09:00
Hiroyuki Ikezoe
4935d972e5 Use animation values that have been processed during animation-only restyle for normal restyle. 2017-05-24 11:11:57 +09:00
Hiroyuki Ikezoe
35e0e3aa11 Move AnimationRules into declaration_block.rs. 2017-05-24 11:11:42 +09:00
Hiroyuki Ikezoe
d30c4fe79d Use SMIL override value that has been processed during animation-only restyles for normal restyle.
In the case where we process an element which has SMIL animations in normal travesal
the SMIL styles must have been computed in animation-only restyles. So we
have only to pick the computed styles instead of recomputing it.
2017-05-24 11:11:26 +09:00
cku
6143e95d74 Stylo: match both ::placehoder & ::moz-placeholder for placeholder pseudo-elements. 2017-05-24 00:34:52 +08:00
bors-servo
e24d96cdd0 Auto merge of #16983 - emilio:indir-data, r=nox
style: Remove unneeded indirection in traversal code.

<!-- 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/16983)
<!-- Reviewable:end -->
2017-05-23 04:58:53 -05:00
bors-servo
1306b16d5a Auto merge of #16968 - HeyZoos:stylist-accessors, r=emilio
Stylist accessors

<!-- Please describe your changes on the following line: -->
Add accessor methods for the `device` and `ruleset` fields in the `Stylist` struct.

---
<!-- 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
- [X] These changes fix #16857 (github issue number if applicable).
<!-- Either: -->
- [X] There are tests for these changes

<!-- 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/16968)
<!-- Reviewable:end -->
2017-05-22 20:12:46 -05:00
Emilio Cobos Álvarez
d5f8b91d91
style: Remove unneeded indirection in traversal code. 2017-05-21 16:47:22 +02:00
Hiroyuki Ikezoe
6a72b66e7b Create a SequentialTask for updating CSS animations in the case where the traversal is triggered by CSS rule changes. 2017-05-21 15:18:15 +09:00
Emilio Cobos Álvarez
311c403522
style: Move all the style sharing code outside matching.rs
This is just a code health change. I want to move it away to keep matching.rs as
simple as possible.
2017-05-21 02:30:51 +02:00
bors-servo
05a26a2996 Auto merge of #16967 - emilio:after, r=heycam,emilio
Bug 1366144: Correctly diff ::before and ::after pseudo-element styles if there's no generated content. r=heycam

<!-- 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/16967)
<!-- Reviewable:end -->
2017-05-20 13:44:31 -05:00
Cameron McCormack
a397590838
style: Refactor RestyleHint to be a struct.
Later PRs will add additional data to it that is not so easy to
represent using bitflags.
2017-05-20 16:28:09 +02:00
Cameron McCormack
c13be5cd13
style: List the matched rules with trace-level logging is enabled. 2017-05-20 16:27:06 +02:00
Cameron McCormack
8b7a414b1c
style: Use RestyleDamage to determine whether we must continue cascading style changes to children. 2017-05-20 16:25:39 +02:00
Emilio Cobos Álvarez
605974a112
Bug 1366144: Correctly diff ::before and ::after pseudo-element styles if there's no generated content. r=heycam
MozReview-Commit-ID: BHSxMJd0G0O
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-20 16:20:59 +02:00
bors-servo
3ca7f4fc92 Auto merge of #16961 - emilio:bloom-simplify, r=heycam
style: Move some bloom filter code outside of matching.rs

Also simplify it, while we're at it.

<!-- 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/16961)
<!-- Reviewable:end -->
2017-05-20 09:15:27 -05:00
Boris Chiou
63dc43648e Trigger restyle if important rules are changed.
If we add/remove important rules, we may need to update a list of all important
rules (in Gecko) which overrides animation properties. Therefore, we need to
set a flag if we update the primary rules which includes important ones.

If we have animations on this element, we update its effect properties, and
also send a task to update cascade results.

Calling get_properties_overriding_animations() might cases some impact
on performance because we need to walk the rule tree, so if possible, we could
just store this set into TNode to avoid finding the properties for both old
and new rules each time. This could be a future work if necessary.
2017-05-20 20:04:56 +08:00
Emilio Cobos Álvarez
4824f74a3f
style: Move some bloom filter code outside of matching.rs
Also simplify it, while we're at it.
2017-05-20 03:16:34 +02:00
heyzoos
4196156bb9 Change device and rule_set references to accessors 2017-05-18 22:18:16 -05:00
bors-servo
c6c960a661 Auto merge of #16909 - emilio:simplify-cascade, r=bholley
style: Refactor the cascade function.

The `cascade_primary_or_pseudo` function was nice when we shared more code, but
right now I think it just makes it harder to understand what's going on.

<!-- 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/16909)
<!-- Reviewable:end -->
2017-05-17 11:19:56 -05:00
Emilio Cobos Álvarez
e8d1c5316d
style: Refactor the cascade function.
The `cascade_primary_or_pseudo` function was nice when we shared more code, but
right now I think it just makes it harder to understand what's going on.
2017-05-17 16:32:30 +02:00
Emilio Cobos Álvarez
522f8489d6
Bug 1364850: Move PseudoElement to be just another combinator in selectors. r=bholley
MozReview-Commit-ID: 8OoOIodkKJ5
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-17 10:58:24 +02:00
J. Ryan Stinnett
e385b81fc3 Create a MatchingContext to group related matching args
MozReview-Commit-ID: 7XZTn7HDXrm
2017-05-16 09:19:28 -05:00
bors-servo
7ca393a960 Auto merge of #16874 - bholley:applicable_declarations_smallvec, r=emilio
Use a SmallVec when gathering applicable declarations

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

<!-- 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/16874)
<!-- Reviewable:end -->
2017-05-15 23:19:43 -05:00
Emilio Cobos Álvarez
84f5a90668
Bug 1364412: Use the pseudo selector to reject state selectors. r=bholley
MozReview-Commit-ID: 73dnp6nZpdU
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-16 02:49:30 +02:00
bors-servo
a51da06dd9 Auto merge of #16877 - bzbarsky:moz-anonymous-content, r=emilio
Implement :-moz-anonymous-content in stylo

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

---
<!-- 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
- [X] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1364591

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because they're tested by Gecko tests.

<!-- 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/16877)
<!-- Reviewable:end -->
2017-05-15 16:38:14 -05:00