| Index: third_party/WebKit/Source/core/dom/Element.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
|
| index 469bc7a952c742e9449d340a4b81df0a039a8166..a5d4867ec8678c508135c87fc9a69df3ed48df64 100644
|
| --- a/third_party/WebKit/Source/core/dom/Element.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Element.cpp
|
| @@ -1529,7 +1529,8 @@ const AtomicString Element::imageSourceURL() const {
|
| }
|
|
|
| bool Element::layoutObjectIsNeeded(const ComputedStyle& style) {
|
| - return style.display() != EDisplay::None;
|
| + return style.display() != EDisplay::None &&
|
| + style.display() != EDisplay::Contents;
|
| }
|
|
|
| LayoutObject* Element::createLayoutObject(const ComputedStyle& style) {
|
| @@ -1667,9 +1668,15 @@ void Element::attachLayoutTree(const AttachContext& context) {
|
| data->clearComputedStyle();
|
| }
|
|
|
| - if (!isActiveSlotOrActiveInsertionPoint())
|
| - LayoutTreeBuilderForElement(*this, context.resolvedStyle)
|
| - .createLayoutObjectIfNeeded();
|
| + if (!isActiveSlotOrActiveInsertionPoint()) {
|
| + LayoutTreeBuilderForElement builder(*this, context.resolvedStyle);
|
| + builder.createLayoutObjectIfNeeded();
|
| +
|
| + if (ComputedStyle* style = builder.resolvedStyle()) {
|
| + if (!layoutObject() && shouldStoreNonLayoutObjectComputedStyle(*style))
|
| + storeNonLayoutObjectComputedStyle(style);
|
| + }
|
| + }
|
|
|
| addCallbackSelectors();
|
|
|
| @@ -1692,6 +1699,22 @@ void Element::attachLayoutTree(const AttachContext& context) {
|
|
|
| ContainerNode::attachLayoutTree(context);
|
|
|
| + // Quite unfortunately, if we're a display: contents node reattaching our
|
| + // subtree we need to reattach the parent's *after* attaching all our
|
| + // children. We might be able to be more granular here, but otherwise we don't
|
| + // always properly rebuild the layout tree due to anonymous boxes, for
|
| + // example. See css-display-3/display-contents-reattachment.html, which fails
|
| + // without this, for example, due to misplaced flex anonymous blocks.
|
| + //
|
| + // Also, don't do it if we're a pseudo-element, because it's pointless and
|
| + // causes infinite recursion if the parent doesn't have display: contents.
|
| + if (hasDisplayContentsStyle() && !isPseudoElement() && parentNode() &&
|
| + !parentNode()->needsAttach()) {
|
| + parentNode()->reattachLayoutTree();
|
| + DCHECK(!needsAttach());
|
| + return;
|
| + }
|
| +
|
| createPseudoElementIfNeeded(PseudoIdAfter);
|
| createPseudoElementIfNeeded(PseudoIdBackdrop);
|
|
|
| @@ -1966,6 +1989,9 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) {
|
| // https://codereview.chromium.org/30453002/
|
| layoutObject->setStyleInternal(newStyle.get());
|
| }
|
| + } else if (localChange != NoChange &&
|
| + shouldStoreNonLayoutObjectComputedStyle(*newStyle)) {
|
| + storeNonLayoutObjectComputedStyle(newStyle);
|
| }
|
|
|
| if (getStyleChangeType() >= SubtreeStyleChange)
|
| @@ -3128,6 +3154,42 @@ const ComputedStyle* Element::ensureComputedStyle(
|
| return elementStyle->addCachedPseudoStyle(result.release());
|
| }
|
|
|
| +const ComputedStyle* Element::nonLayoutObjectComputedStyle() const {
|
| + if (layoutObject() || !hasRareData())
|
| + return nullptr;
|
| +
|
| + return elementRareData()->computedStyle();
|
| +}
|
| +
|
| +bool Element::hasDisplayContentsStyle() const {
|
| + if (const ComputedStyle* style = nonLayoutObjectComputedStyle())
|
| + return style->display() == EDisplay::Contents;
|
| + return false;
|
| +}
|
| +
|
| +bool Element::shouldStoreNonLayoutObjectComputedStyle(
|
| + const ComputedStyle& style) const {
|
| +#if DCHECK_IS_ON()
|
| + if (style.display() == EDisplay::Contents)
|
| + DCHECK(!layoutObject());
|
| +#endif
|
| +
|
| + return style.display() == EDisplay::Contents ||
|
| + isHTMLOptGroupElement(*this) || isHTMLOptionElement(*this);
|
| +}
|
| +
|
| +void Element::storeNonLayoutObjectComputedStyle(
|
| + PassRefPtr<ComputedStyle> style) {
|
| + DCHECK(style);
|
| + DCHECK(shouldStoreNonLayoutObjectComputedStyle(*style));
|
| + ensureElementRareData().setComputedStyle(std::move(style));
|
| +}
|
| +
|
| +void Element::clearNonLayoutObjectComputedStyle() {
|
| + DCHECK(nonLayoutObjectComputedStyle());
|
| + elementRareData()->clearComputedStyle();
|
| +}
|
| +
|
| AtomicString Element::computeInheritedLanguage() const {
|
| const Node* n = this;
|
| AtomicString value;
|
| @@ -3863,6 +3925,7 @@ void Element::inlineStyleChanged() {
|
| StyleChangeReason::Inline));
|
| DCHECK(elementData());
|
| elementData()->m_styleAttributeIsDirty = true;
|
| +
|
| InspectorInstrumentation::didInvalidateStyleAttr(this);
|
|
|
| if (MutationObserverInterestGroup* recipients =
|
|
|