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

Do style propagation to generated content in LayoutObject.

It belongs with the other anonymous LayoutObject propagation code.
There are still two loops for pseudo elements where we propagate style
to anonymous table boxes like before but propagate style from the
pseudo element to the generated content directly, skipping other
anonymous boxes, in a separate loop. This is just keeping the same
functionality for generated content without trying to propagate style
through others anonymous boxes. Left a TODO for that.

Change-Id: I3c38bc9d831b8a767fd601d47e4db0f81923ba47
Reviewed-on: https://chromium-review.googlesource.com/c/1328041Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606780}
parent 3fe2afdd
......@@ -184,29 +184,6 @@ bool PseudoElement::LayoutObjectIsNeeded(const ComputedStyle& style) const {
return PseudoElementLayoutObjectIsNeeded(&style);
}
void PseudoElement::DidRecalcStyle(StyleRecalcChange change) {
// If the pseudo element is being re-attached, its anonymous LayoutObjects for
// generated content will be destroyed and possibly recreated during layout
// tree rebuild. Thus, propagating style to generated content now is futile.
if (change == kReattach)
return;
if (!GetLayoutObject())
return;
// The layoutObjects 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.
LayoutObject* layout_object = GetLayoutObject();
for (LayoutObject* child = layout_object->NextInPreOrder(layout_object);
child; child = child->NextInPreOrder(layout_object)) {
// We only manage the style for the generated content items.
if (!child->IsText() && !child->IsQuote() && !child->IsImage())
continue;
child->SetPseudoStyle(layout_object->MutableStyle());
}
}
Node* PseudoElement::InnerNodeForHitTesting() const {
return ParentOrShadowHostNode();
}
......
......@@ -62,8 +62,6 @@ class CORE_EXPORT PseudoElement : public Element {
PseudoElement(Element*, PseudoId);
private:
void DidRecalcStyle(StyleRecalcChange) override;
PseudoId pseudo_id_;
};
......
......@@ -2372,7 +2372,6 @@ void LayoutObject::PropagateStyleToAnonymousChildren() {
child = child->NextSibling()) {
if (!child->IsAnonymous() || child->StyleRef().StyleType() != kPseudoIdNone)
continue;
if (child->AnonymousHasStylePropagationOverride())
continue;
......@@ -2394,6 +2393,24 @@ void LayoutObject::PropagateStyleToAnonymousChildren() {
child->SetStyle(std::move(new_style));
}
if (StyleRef().StyleType() == kPseudoIdNone)
return;
// Propagate style from pseudo elements to generated content. We skip children
// with pseudo element StyleType() in the for-loop above and skip over
// descendants which are not generated content in this subtree traversal.
//
// TODO(futhark): It's possible we could propagate anonymous style from pseudo
// elements through anonymous table layout objects in the recursive
// implementation above, but it would require propagating the StyleType()
// somehow because there is code relying on generated content having a certain
// StyleType().
for (LayoutObject* child = NextInPreOrder(this); child;
child = child->NextInPreOrder(this)) {
if (child->IsText() || child->IsQuote() || child->IsImage())
child->SetPseudoStyle(MutableStyle());
}
}
void LayoutObject::SetStyleWithWritingModeOf(scoped_refptr<ComputedStyle> style,
......
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