Commit 70e693f2 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

[Squad] Do not ask for cached pseudo element style.

The goal is to remove the need for a pseudo style cache for pseudo
elements which have a PseudoElement on which we store a ComputedStyle
and a LayoutObject.

This CL removes an extra call to PseudoStyle() which would access the
pseudo style cache to re-retrieve the ComputedStyle(). Instead use
GetNonAttachedStyle() which would be set by the RecalcStyle() call for
re-attachment, or to null if the PseudoElement is no longer needed.

Bug: 836126
Change-Id: Ide807be656843fcbfad35fce7b2f3ed1c858a0f6
Reviewed-on: https://chromium-review.googlesource.com/1096761Reviewed-by: default avatarAnders Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566384}
parent b114f864
......@@ -2251,8 +2251,11 @@ StyleRecalcChange Element::RecalcOwnStyle(StyleRecalcChange change) {
scoped_refptr<ComputedStyle> new_style = PropagateInheritedProperties(change);
if (!new_style)
new_style = StyleForLayoutObject();
if (!new_style)
if (!new_style) {
DCHECK(IsPseudoElement());
SetNeedsReattachLayoutTree();
return kReattach;
}
StyleRecalcChange local_change =
ComputedStyle::StylePropagationDiff(old_style.get(), new_style.get());
......@@ -3851,18 +3854,16 @@ void Element::UpdatePseudoElement(PseudoId pseudo_id,
if (element->NeedsStyleRecalc())
MutableComputedStyle()->RemoveCachedPseudoStyle(pseudo_id);
// PseudoElement styles hang off their parent element's style so if we
// needed a style recalc we should Force one on the pseudo.
element->RecalcStyle(change == kUpdatePseudoElements ? kForce : change);
// Wait until our parent is not displayed or
// PseudoElementLayoutObjectIsNeeded is false, otherwise we could
// continuously create and destroy PseudoElements when
// LayoutObject::IsChildAllowed on our parent returns false for the
// PseudoElement's GetLayoutObject for each style recalc.
if (!CanGeneratePseudoElement(pseudo_id) ||
!PseudoElementLayoutObjectIsNeeded(
PseudoStyle(PseudoStyleRequest(pseudo_id))))
bool remove_pseudo = !CanGeneratePseudoElement(pseudo_id);
if (!remove_pseudo) {
// PseudoElement styles hang off their parent element's style so if we
// needed a style recalc we should Force one on the pseudo.
element->RecalcStyle(change == kUpdatePseudoElements ? kForce : change);
remove_pseudo =
element->NeedsReattachLayoutTree() &&
!PseudoElementLayoutObjectIsNeeded(element->GetNonAttachedStyle());
}
if (remove_pseudo)
GetElementRareData()->SetPseudoElement(pseudo_id, nullptr);
} else if (pseudo_id == kPseudoIdFirstLetter && element &&
change >= kUpdatePseudoElements &&
......
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