Skip to content

Commit 056dd5e

Browse files
committed
Bug 1982701: Exclude element-backed pseudos from NAC ancestor-traversal in GetCorrectedParent. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D261209
1 parent 7a6d336 commit 056dd5e

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

layout/generic/nsIFrame.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11257,12 +11257,14 @@ static nsIFrame* GetCorrectedParent(const nsIFrame* aFrame) {
1125711257
}
1125811258

1125911259
// Prevent a NAC pseudo-element from inheriting from its NAC parent, and
11260-
// inherit from the NAC generator element instead.
11261-
if (pseudo != PseudoStyleType::NotPseudo) {
11260+
// inherit from the NAC generator element instead. (We exclude element-backed
11261+
// pseudos from this check, since they're not NAC.)
11262+
if (pseudo != PseudoStyleType::NotPseudo &&
11263+
!PseudoStyle::IsElementBackedPseudo(pseudo)) {
1126211264
MOZ_ASSERT(aFrame->GetContent());
1126311265
Element* element = Element::FromNode(aFrame->GetContent());
11264-
// Make sure to avoid doing the fixup for non-element-backed pseudos like
11265-
// ::first-line and such.
11266+
// Make sure to only do the fixup for anonymous content pseudos (i.e. avoid
11267+
// fixup for ::first-line and such).
1126611268
if (element && !element->IsRootOfNativeAnonymousSubtree() &&
1126711269
element->GetPseudoElementType() == aFrame->Style()->GetPseudoType()) {
1126811270
while (parent->GetContent() &&
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1982701">
2+
<style>
3+
*::first-line {}
4+
</style>
5+
<script>
6+
window.addEventListener("DOMContentLoaded", () => {
7+
a.showModal()
8+
})
9+
</script>
10+
<dialog id="a">
11+
<details>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1982701">
3+
<style>
4+
.wrapper::first-line { background: cyan }
5+
</style>
6+
<div class="wrapper">
7+
WrapperFirstLine<br>
8+
WrapperSecondLine<br>
9+
<dialog id="a" open>
10+
<details>
11+
<summary>This is the summary</summary>
12+
These are the details
13+
</details>
14+
</dialog>
15+
</div>

0 commit comments

Comments
 (0)