style: Make element-backed pseudos inherit from NAC subtree roots and other NAC inherit from their parents.

Currently, NAC always inherits from the closest non-NAC ancestor element,
regardless of whether it is for an element-backed pseudo or not.

This patch changes the inheritance so that for element-backed pseudos, we
inherit from the closest native anonymous root's parent, and for other NAC we
inherit from the parent.

This prevents the following two issues and allows us to remove the
NODE_IS_NATIVE_ANONYMOUS flag:

 * Avoiding inheriting from the non-NAC ancestor in XBL bindings bound to NAC.

   - This is no longer a problem since we apply the rule only if we're a
     pseudo-element, and all pseudo-elements are in native anonymous subtrees.

   - This also allows to remove the hack that propagates the
     NODE_IS_NATIVE_ANONYMOUS flag from the ::cue pseudo-element from
     BindToTree.

 * Inheriting from the wrong thing if we're a nested NAC subtree.

   - We no longer look past our NAC subtree, with the exception of
     ::-moz-number-text's pseudo-elements, for which we do want to propagate
     ::placeholder to.

A few rules from forms.css have been modified because they're useless or needed
to propagate stuff to the anonymous form control in input[type="number"] which
previously inherited from the input itself.

Bug: 1460382
Reviewed-by: heycam
MozReview-Commit-ID: IDKYt3EJtSH
This commit is contained in:
Emilio Cobos Álvarez 2018-05-10 18:48:08 +02:00
parent 92e2adf45f
commit 5507d53611
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
6 changed files with 53 additions and 49 deletions

View file

@ -433,9 +433,10 @@ pub fn recalc_style_at<E, D, F>(
if compute_self {
child_cascade_requirement = compute_style(traversal_data, context, element, data);
if element.is_native_anonymous() {
// We must always cascade native anonymous subtrees, since they inherit
// styles from their first non-NAC ancestor.
if element.is_in_native_anonymous_subtree() {
// We must always cascade native anonymous subtrees, since they
// may have pseudo-elements underneath that would inherit from the
// closest non-NAC ancestor instead of us.
child_cascade_requirement = cmp::max(
child_cascade_requirement,
ChildCascadeRequirement::MustCascadeChildren,