Commit 76a8e1fb authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

[Squad] Move parts of CanGeneratePseudoElement to ComputedStyle.

Bug: 836126
Change-Id: Ifd1705c3d72af1c9250f97279a03f439ee08d478
Reviewed-on: https://chromium-review.googlesource.com/1109824
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarAnders Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569250}
parent 3d359ef5
......@@ -809,21 +809,14 @@ PseudoElement* StyleResolver::CreatePseudoElementIfNeeded(Element& parent,
if (!parent.CanGeneratePseudoElement(pseudo_id))
return nullptr;
ComputedStyle* parent_style = parent.MutableComputedStyle();
DCHECK(parent_style);
// The first letter pseudo element has to look up the tree and see if any
// of the ancestors are first letter.
if (pseudo_id < kFirstInternalPseudoId && pseudo_id != kPseudoIdFirstLetter &&
!parent_style->HasPseudoStyle(pseudo_id)) {
return nullptr;
}
if (pseudo_id == kPseudoIdFirstLetter &&
(parent.IsSVGElement() ||
!FirstLetterPseudoElement::FirstLetterTextLayoutObject(parent)))
return nullptr;
ComputedStyle* parent_style = parent.MutableComputedStyle();
DCHECK(parent_style);
if (ComputedStyle* cached_style =
parent_style->GetCachedPseudoStyle(pseudo_id)) {
if (!PseudoElementLayoutObjectIsNeeded(cached_style))
......
......@@ -3994,17 +3994,8 @@ scoped_refptr<ComputedStyle> Element::GetUncachedPseudoStyle(
bool Element::CanGeneratePseudoElement(PseudoId pseudo_id) const {
if (pseudo_id == kPseudoIdBackdrop && !IsInTopLayer())
return false;
if (const ComputedStyle* style = GetComputedStyle()) {
if (style->Display() == EDisplay::kNone)
return false;
if (style->Display() == EDisplay::kContents) {
// For display: contents elements, we still need to generate ::before and
// ::after, but the rest of the pseudo-elements should only be used for
// elements with an actual layout object.
return pseudo_id == kPseudoIdBefore || pseudo_id == kPseudoIdAfter;
}
return true;
}
if (const ComputedStyle* style = GetComputedStyle())
return style->CanGeneratePseudoElement(pseudo_id);
return false;
}
......
......@@ -2218,6 +2218,21 @@ class ComputedStyle : public ComputedStyleBase,
InterpolationQuality GetInterpolationQuality() const;
bool CanGeneratePseudoElement(PseudoId pseudo) const {
// The first letter pseudo element has to look up the tree and see if any
// of the ancestors are first letter.
if (pseudo != kPseudoIdFirstLetter && !HasPseudoStyle(pseudo))
return false;
if (Display() == EDisplay::kNone)
return false;
if (Display() != EDisplay::kContents)
return true;
// For display: contents elements, we still need to generate ::before and
// ::after, but the rest of the pseudo-elements should only be used for
// elements with an actual layout object.
return pseudo == kPseudoIdBefore || pseudo == kPseudoIdAfter;
}
private:
void SetVisitedLinkBackgroundColor(const StyleColor& v) {
SetVisitedLinkBackgroundColorInternal(v);
......
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