Commit graph

298 commits

Author SHA1 Message Date
Boris Zbarsky
c531af96ae Make sure we don't recreate boxes just because we have a ::first-line.
Servo part of part 5 of the fix for Gecko bug 1324619.  r=emilio
2017-07-28 22:54:06 -04: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
Bobby Holley
6148db670b Break TraversalFlags::ForReconstruct down into several independent pieces.
These will be useful in followup work.

MozReview-Commit-ID: Dyp9R0PG36v
2017-07-27 14:26:21 -07:00
Bobby Holley
ce295f6daf Pass TraversalFlags from C++ into Rust.
MozReview-Commit-ID: EVUzgnL5coN
2017-07-27 14:25:58 -07:00
Jeremy Chen
000547b999 stylo: remove bogus optimization check in replace_rules() for visited styles.
We skipped updating the rule nodes for visited rules during animation-only restyle.
However, this causes isseus that visited style overrides animation styles on visited element.
So, it turns out that we should update the visited rules even during animation-only restyle.

Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1381235
2017-07-27 19:10:38 +08:00
Cameron McCormack
e36b4340e1 style: Ensure we generate a ReconstructFrame hint when -moz-binding changes on a display:none root. 2017-07-25 15:50:00 +08:00
Emilio Cobos Álvarez
ef4fbfaa6b
Revert "Backed out changeset b10e6ba9cbdb because gecko part had to be backed out."
This reverts commit b96d96d448.

The fix on the Gecko side is trivial, and I can land it after this lands.
2017-07-20 17:26:53 +02:00
Gecko Backout
b96d96d448 Backed out changeset b10e6ba9cbdb because gecko part had to be backed out. r=backout on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/17796
2017-07-20 13:42:53 +00:00
Cameron McCormack
914ba609c0 style: Pass old ComputedValues and old cached struct bits to Gecko_CalcStyleDifference. 2017-07-20 13:10:11 +08: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
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
bors-servo
18c5ba108d Auto merge of #17722 - upsuper:ruby-fixup, r=heycam,bz
Implement style adjustments for ruby

This is the Servo side changes of [bug 1378287](https://bugzilla.mozilla.org/show_bug.cgi?id=1378287) and [bug 1364274](https://bugzilla.mozilla.org/show_bug.cgi?id=1364274).

<!-- 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/17722)
<!-- Reviewable:end -->
2017-07-13 20:02:36 -07:00
Xidorn Quan
6a12de1c1a Add style adjustments for ruby. 2017-07-14 10:53:58 +10:00
Xidorn Quan
2a05c29c30 Rename HAS_TEXT_DECORATION_LINE to match gecko side name. 2017-07-14 10:53:46 +10:00
Emilio Cobos Álvarez
f77bfedb9e
style: Don't early return before updating the root font-size.
We never use the reconstruct path for the root, but feels less handwavy.
2017-07-13 16:00:20 +02:00
Emilio Cobos Álvarez
d15acc219e
style: Allow calling GetBaseComputedStylesForElement for an unstyled element.
Before this refactoring, getComputedStyle could have side effects, and left the
style data in the element, so we could never arrive there without data.

There are a few crashtests that caught this, but this was already broken if you
called animate() on an element deep in a display: none subtree.

MozReview-Commit-ID: 1AvOvhAyOP3
2017-07-12 09:26:38 +02:00
Emilio Cobos Álvarez
c6d5dbbb01
style: Rewrite restyling to split between resolving styles and handling changes.
MozReview-Commit-ID: 4BzjbLbFebF
2017-07-12 09:26:36 +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
Emilio Cobos Álvarez
95a2ac51c4
style: Remove unused AFFECTED_BY_PSEUDO_ELEMENTS StyleRelation.
MozReview-Commit-ID: yHldvHm87b
2017-07-12 08:39:25 +02:00
Josh Matthews
a08371e8eb stylo: Create error reporters linked to documents (bug 1352669) 2017-07-10 20:46:08 -04:00
J. Ryan Stinnett
3463a9c210 Pass through visited style for after change
When a transition update is needed during restyling, `get_after_change_style` is
called to re-cascade without transition rules, and this style is then used for
primary styling instead of the style just computed.

`get_after_change_style` used to ignore visited styles, so this meant that if a
transition update was needed, visited styles were effectively dropped.

To fix the crash here, we pass through the existing visited styles when
re-cascading as part of `get_after_change_style`.

MozReview-Commit-ID: 4HBQAdeJ38B
2017-07-10 13:28:12 -05:00
Emilio Cobos Álvarez
c2cc6b08f8
style: Avoid overriding the root font size from a getDefaultComputedStyle call.
MozReview-Commit-ID: 2WFyGj868fJ
2017-07-08 18:05:31 +02:00
Emilio Cobos Álvarez
5d03ba3cbe
style: Move root font size handling outside of the cascade.
And merge it with the rest of the code handling root font-size changes.

MozReview-Commit-ID: 3rW1C3mXiMd
2017-07-08 18:05:30 +02:00
Hiroyuki Ikezoe
342b7f7698 Return no damage if there is no display property changes 2017-07-07 05:46:41 +09:00
Emilio Cobos Álvarez
e2bf7d037a
stylo: properly handle ::before/::after rules applying to replaced elements.
Bug: 1376352
Reviewed-By: heycam
MozReview-Commit-ID: FO0TyWsPPG7
2017-07-03 13:03:24 +02:00
Boris Zbarsky
824139e615 Make sure to compute visited style if our parent has visited style.
Part 4 of the fix for Gecko bug 1364242: https://bugzilla.mozilla.org/show_bug.cgi?id=1364242
2017-06-29 22:26:14 -07:00
Boris Zbarsky
759038e687 Add a helper method for getting our style parent and its ComputedValues while matching.
Part 3 of the fix for Gecko bug 1364242: https://bugzilla.mozilla.org/show_bug.cgi?id=1364242
2017-06-29 22:22:38 -07:00
Boris Zbarsky
52d1b59515 Implement :visited handling for lazy pseudo-elements in stylo.
Part 2 of the fix for Gecko bug 1364242: https://bugzilla.mozilla.org/show_bug.cgi?id=1364242
2017-06-29 16:22:13 -07:00
bors-servo
79ee821bef Auto merge of #17525 - emilio:text-decoration, r=heycam
style: Fix propagation of text-decoration lines.

This also paves up the ground to be able to fix #16825.

<!-- 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/17525)
<!-- Reviewable:end -->
2017-06-27 12:44:33 -07:00
Boris Zbarsky
d40e27d6e5 Reframe less on restyles that involve nonexistent first-letter frames in Gecko.
Gecko bug 1324618 part 9 servo bits: https://bugzilla.mozilla.org/show_bug.cgi?id=1324618
2017-06-26 23:27:39 -07:00
Boris Zbarsky
40dd807df3 Assert that compute_style_difference is only called with eager pseudos.
Gecko bug 1324618 part 3: https://bugzilla.mozilla.org/show_bug.cgi?id=1324618
2017-06-26 23:24:56 -07:00
Boris Zbarsky
acb27de71c Fix dynamic restyling that changes whether our element may generate a pseudo to clear out stale pseudo styles.
Gecko bug 1324618 part 1: https://bugzilla.mozilla.org/show_bug.cgi?id=1324618
2017-06-26 23:23:04 -07:00
Emilio Cobos Álvarez
69e650ea68
style: Fix propagation of text-decoration lines. 2017-06-26 23:12:18 -07:00
Hiroyuki Ikezoe
ae1ccdd456 Check has_new_animation_style along with for_css_rule_changes() in needs_animations_update(). 2017-06-27 08:26:16 +09: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
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
Emilio Cobos Álvarez
1b2fd3fe85
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
2017-06-21 13:28:57 +02:00
Brian Lewis
0fe381d774 Remove Option wrapper from RuleNode's StyleSource to save one word, add
a None variant to StyleSource as an indicator for a lack of style
source, and refactor all uses with this new form
2017-06-19 21:50:56 +02:00
bors-servo
33766b2714 Auto merge of #17348 - emilio:bup, r=bholley
style: Inline RestyleData.

Bug: 1368236
MozReview-Commit-ID: 49s3SO0PMHf

<!-- 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/17348)
<!-- Reviewable:end -->
2017-06-15 20:28:56 -07:00
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