Commit 2ba13f1a authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

DL: Skip pseudo elements style recalc for locked elements

We shouldn't do style recalc for things under locked elements, including
pseudo elements.

Bug: 1000997
Change-Id: Ie183d8ccd67639fe49af8548f720982dc025f284
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1797947Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695904}
parent caacf910
......@@ -66,6 +66,7 @@ class CORE_EXPORT DisplayLockContext final
enum StyleType {
kStyleUpdateNotRequired,
kStyleUpdateSelf,
kStyleUpdatePseudoElements,
kStyleUpdateChildren,
kStyleUpdateDescendants
};
......
......@@ -2737,14 +2737,32 @@ void Element::RecalcStyle(const StyleRecalcChange change) {
// display locking can happen..
display_lock_style_scope.DidUpdateSelfStyle();
if (!display_lock_style_scope.ShouldUpdateChildStyle()) {
if (child_change.RecalcChildren()) {
// If we should've calculated the style for children but was blocked,
// notify so that we'd come back.
// Note that the if-clause wouldn't catch cases where
// ChildNeedsStyleRecalc() is true but child_change.RecalcChildren() is
// false. Since we are retaining the child dirty bit, that case is
// automatically handled without needing to notify it here.
display_lock_style_scope.NotifyUpdateWasBlocked(
DisplayLockContext::kStyleUpdateDescendants);
} else if (child_change.TraversePseudoElements(*this)) {
display_lock_style_scope.NotifyUpdateWasBlocked(
DisplayLockContext::kStyleUpdatePseudoElements);
}
if (HasCustomStyleCallbacks())
DidRecalcStyle(child_change);
return;
}
if (child_change.TraversePseudoElements(*this)) {
UpdatePseudoElement(kPseudoIdBackdrop, child_change);
UpdatePseudoElement(kPseudoIdBefore, child_change);
}
const bool should_update_child_style =
display_lock_style_scope.ShouldUpdateChildStyle();
if (child_change.TraverseChildren(*this) && should_update_child_style) {
if (child_change.TraverseChildren(*this)) {
SelectorFilterParentScope filter_scope(*this);
if (ShadowRoot* root = GetShadowRoot()) {
if (child_change.TraverseChild(*root))
......@@ -2765,20 +2783,9 @@ void Element::RecalcStyle(const StyleRecalcChange change) {
UpdateFirstLetterPseudoElement(StyleUpdatePhase::kRecalc);
}
if (should_update_child_style) {
ClearChildNeedsStyleRecalc();
// We've updated all the children that needs an update (might be 0).
display_lock_style_scope.DidUpdateChildStyle();
} else if (child_change.RecalcChildren()) {
// If we should've calculated the style for children but was blocked,
// notify so that we'd come back.
// Note that the if-clause wouldn't catch cases where
// ChildNeedsStyleRecalc() is true but child_change.RecalcChildren() is
// false. Since we are retaining the child dirty bit, that case is
// automatically handled without needing to notify it here.
display_lock_style_scope.NotifyUpdateWasBlocked(
DisplayLockContext::kStyleUpdateDescendants);
}
if (HasCustomStyleCallbacks())
DidRecalcStyle(child_change);
......
<!doctype HTML>
<html>
<meta charset="utf8">
<title>Display Locking: pseudo elements</title>
<link rel="author" title="Rakina Zata Amni" href="mailto:rakina@chromium.org">
<link rel="help" href="https://github.com/WICG/display-locking">
<style>
#container::before {
content: "a";
color: blue;
}
#container::after {
content: "b";
color: green;
}
</style>
<div id="log">PASS</div>
<div id="container"></div>
</script>
</html>
<!doctype HTML>
<html class="reftest-wait">
<meta charset="utf8">
<title>Display Locking: pseudo elements</title>
<link rel="author" title="Rakina Zata Amni" href="mailto:rakina@chromium.org">
<link rel="help" href="https://github.com/WICG/display-locking">
<link rel="match" href="pseudo-elements-visible-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="resources/utils.js"></script>
<style>
#container::before {
content: "a";
color: blue;
}
.hasAfter::after {
content: "b";
color: green;
}
</style>
<div id="log"></div>
<div id="container" style="display:none;"></div>
<script>
function finishTest(status_string) {
if (document.getElementById("log").innerHTML === "")
document.getElementById("log").innerHTML = status_string;
takeScreenshot();
}
async function runTest() {
// Trigger reattachment in #container and the ::after pseudo element.
container.classList.add("hasAfter");
container.style = "";
setInvisible(container).then(() => { setVisible(container).then(() => {finishTest("PASS");}); });
}
window.onload = runTest;
</script>
</html>
<!doctype HTML>
<html class="reftest-wait">
<meta charset="utf8">
<title>Display Locking: pseudo elements</title>
<link rel="author" title="Rakina Zata Amni" href="mailto:rakina@chromium.org">
<link rel="help" href="https://github.com/WICG/display-locking">
<link rel="match" href="pass-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="resources/utils.js"></script>
<style>
#container::before {
content: "a";
color: blue;
}
.hasAfter::after {
content: "b";
color: green;
}
</style>
<div id="log"></div>
<div id="container" style="display:none;"></div>
<script>
function finishTest(status_string) {
if (document.getElementById("log").innerHTML === "")
document.getElementById("log").innerHTML = status_string;
takeScreenshot();
}
async function runTest() {
// Trigger reattachment in #container and the ::after pseudo element.
container.classList.add("hasAfter");
container.style = "";
setInvisible(container).then(() => { finishTest("PASS");} );
}
window.onload = runTest;
</script>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment