Commit b436a235 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Propagate to anonymous first-letter children in LayoutObject.

Remove the propagation from DidRecalcStyle as we already did the
propagation in LayoutObject.

TEST=fast/css-generated-content/

Change-Id: I0f8a101020d1920071dd329ee00ebd86174e5d08
Reviewed-on: https://chromium-review.googlesource.com/c/1329928
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607161}
parent b7e03360
...@@ -343,31 +343,6 @@ void FirstLetterPseudoElement::AttachFirstLetterTextLayoutObjects(LayoutText* fi ...@@ -343,31 +343,6 @@ void FirstLetterPseudoElement::AttachFirstLetterTextLayoutObjects(LayoutText* fi
first_letter_text->Destroy(); first_letter_text->Destroy();
} }
void FirstLetterPseudoElement::DidRecalcStyle(StyleRecalcChange) {
LayoutObject* layout_object = GetLayoutObject();
if (!layout_object)
return;
// The layout objects inside pseudo elements are anonymous so they don't get
// notified of RecalcStyle and must have the style propagated downward
// manually similar to LayoutObject::PropagateStyleToAnonymousChildren.
for (LayoutObject* child = layout_object->NextInPreOrder(layout_object);
child; child = child->NextInPreOrder(layout_object)) {
// We need to re-calculate the correct style for the first letter element
// and then apply that to the container and the text fragment inside.
if (child->Style()->StyleType() == kPseudoIdFirstLetter) {
child->SetPseudoStyle(layout_object->MutableStyle());
continue;
}
// We only manage the style for the generated content items.
if (!child->IsText() && !child->IsQuote() && !child->IsImage())
continue;
child->SetPseudoStyle(layout_object->MutableStyle());
}
}
Node* FirstLetterPseudoElement::InnerNodeForHitTesting() const { Node* FirstLetterPseudoElement::InnerNodeForHitTesting() const {
// When we hit a first letter during hit testing, hover state and events // When we hit a first letter during hit testing, hover state and events
// should be triggered on the parent of the real text node where the first // should be triggered on the parent of the real text node where the first
......
...@@ -62,7 +62,6 @@ class CORE_EXPORT FirstLetterPseudoElement final : public PseudoElement { ...@@ -62,7 +62,6 @@ class CORE_EXPORT FirstLetterPseudoElement final : public PseudoElement {
explicit FirstLetterPseudoElement(Element*); explicit FirstLetterPseudoElement(Element*);
scoped_refptr<ComputedStyle> CustomStyleForLayoutObject() override; scoped_refptr<ComputedStyle> CustomStyleForLayoutObject() override;
void DidRecalcStyle(StyleRecalcChange) override;
void AttachFirstLetterTextLayoutObjects(LayoutText* first_letter_text); void AttachFirstLetterTextLayoutObjects(LayoutText* first_letter_text);
......
...@@ -2406,10 +2406,18 @@ void LayoutObject::PropagateStyleToAnonymousChildren() { ...@@ -2406,10 +2406,18 @@ void LayoutObject::PropagateStyleToAnonymousChildren() {
// implementation above, but it would require propagating the StyleType() // implementation above, but it would require propagating the StyleType()
// somehow because there is code relying on generated content having a certain // somehow because there is code relying on generated content having a certain
// StyleType(). // StyleType().
for (LayoutObject* child = NextInPreOrder(this); child; LayoutObject* child = NextInPreOrder(this);
child = child->NextInPreOrder(this)) { while (child) {
if (!child->IsAnonymous()) {
// Don't propagate into non-anonymous descendants of pseudo elements. This
// can typically happen for ::first-letter inside ::before. The
// ::first-letter will propagate to its anonymous children separately.
child = child->NextInPreOrderAfterChildren(this);
continue;
}
if (child->IsText() || child->IsQuote() || child->IsImage()) if (child->IsText() || child->IsQuote() || child->IsImage())
child->SetPseudoStyle(MutableStyle()); child->SetPseudoStyle(MutableStyle());
child = child->NextInPreOrder(this);
} }
} }
......
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