Skip to content

Commit

Permalink
Bug 1854720 [wpt PR 42030] - Rewrite (behind a flag) HTML direction i…
Browse files Browse the repository at this point in the history
…nheritance and invalidation for dir=auto, a=testonly

Automatic update from web-platform-tests
Rewrite (behind a flag) HTML direction inheritance and invalidation for dir=auto

This rewrites significant aspects of inheritance of HTML direction
(which affects the unshipped :dir() selector and also the shipped
dirname attribute), including its invalidation, to match current spec
proposals regarding how the inheritance operates on Shadow DOM, and to
improve invalidation in response to dynamic changes.  Inheritance of
direction now operates on the node tree, except that shadow roots and
slots both inherit from the shadow host.  It previously operated on the
flat tree.  This change should not affect the computed values of the CSS
direction property, since the HTML direction is only mapped to CSS
direction on elements where the HTML direction is not inherited.

This also restructures the shadow tree-related invalidation code for
dir=auto to match the changes implemented in
https://crrev.com/26b1b30268b7af4f0e44f298c10338a65e656f40 , which made
dir=auto operate on the node tree, and the additional behavior
implemented in
https://crrev.com/6abc9cbde67c0700be364c7aab86cb29188c7d5d that
implemented special rules (looking at slotted children) for <slot
dir=auto>.  Certain text-like form controls also have similar special
rules in which they look at their value.  This change can affect the
computed values of the CSS direction property when the direction
computed by dir=auto is different.

The invalidation code for these two distinct things was (in the old
code) too tied together to cleanly separate these changes.

The reason these changes are the next step of work is because they
change (when CSSPseudoDirEnabled) the one caller that passed a
stay_within parameter to CalculateAndAdjustAutoDirectionality that is
different from this; this enables further (smaller) refactoring that I
believe will be needed to fix the failure of
external/wpt/shadow-dom/directionality/dir-shadow-41.html in the
still-unlanded WPT PR at
web-platform-tests/wpt#29820 .  I believe this
existing using of stay_within does not make sense; it doesn't make sense
to try to partially traverse the descendants of a dir=auto element with
a different termination point.  The traversal of a dir=auto element
should always start at its start and should terminate at the first
strong character or the end of the contents that should influence the
dir=auto.  (There are cases where the interaction of the stay_within and
the use of NodeTraversal/FlatTreeTraversal meant that the stay_within
parameter was missed entirely and the tree was searched beyond the
contents that should be; this is a step towards the refactoring needed
to fix that.)

This is based on the proposed behavior described in:
whatwg/html#3699 (comment)
which is in the process of being specified in:
whatwg/html#9166
whatwg/html#9452
whatwg/html#9554

Bug: 576815
Change-Id: Ic31a3f801f64042a3b4979afdc4e141f45e3b228
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4811757
Reviewed-by: Di Zhang <dizhanggchromium.org>
Commit-Queue: David Baron <dbaronchromium.org>
Cr-Commit-Position: refs/heads/main{#1199647}

--

wpt-commits: ce9459e524221bf8f2b7ba04bc21af109a89eb14
wpt-pr: 42030

UltraBlame original commit: aec4219a5821fe2ff388eb0d57bc1783df7e5eb0
  • Loading branch information
marco-c committed Sep 29, 2023
1 parent a6b23fe commit f7ef17e
Show file tree
Hide file tree
Showing 2 changed files with 2,114 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,157 @@ direction
"
)
;
test
(
(
)
=
>
{
let
container1
=
document
.
createElement
(
"
div
"
)
;
document
.
body
.
appendChild
(
container1
)
;
let
container2
=
document
.
createElement
(
"
div
"
)
;
for
(
let
container
of
[
container1
container2
]
)
{
container
.
dir
=
"
rtl
"
;
let
e
=
document
.
createElement
(
"
div
"
)
;
assert_true
(
e
.
matches
(
"
:
dir
(
ltr
)
"
)
)
;
container
.
appendChild
(
e
)
;
assert_false
(
e
.
matches
(
"
:
dir
(
ltr
)
"
)
)
;
e
.
remove
(
)
;
assert_true
(
e
.
matches
(
"
:
dir
(
ltr
)
"
)
)
;
}
container1
.
remove
(
)
;
}
"
dir
inheritance
is
correct
after
insertion
and
removal
from
document
"
)
;
Loading

0 comments on commit f7ef17e

Please sign in to comment.