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 24b75742fc9986422bbe76bbeb7380fefc21829f..87984872d478602c209f900a75c6850d94ead313 100644 |
--- a/third_party/WebKit/Source/core/dom/Element.cpp |
+++ b/third_party/WebKit/Source/core/dom/Element.cpp |
@@ -1527,7 +1527,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) { |
@@ -1665,9 +1666,20 @@ void Element::attachLayoutTree(const AttachContext& context) { |
data->clearComputedStyle(); |
} |
- if (!isSlotOrActiveInsertionPoint()) |
- LayoutTreeBuilderForElement(*this, context.resolvedStyle) |
- .createLayoutObjectIfNeeded(); |
+ if (!isSlotOrActiveInsertionPoint()) { |
+ LayoutTreeBuilderForElement builder(*this, context.resolvedStyle); |
+ builder.createLayoutObjectIfNeeded(); |
+ |
+ // Persist the resolved style if we got to the point we needed to compute |
+ // the style, and it was a display: contents style, since we need it for our |
+ // children. |
+ if (ComputedStyle* style = builder.resolvedStyle()) { |
+ if (style->display() == EDisplay::Contents) { |
+ DCHECK(!layoutObject()); |
+ storeDisplayContentsStyle(*style); |
+ } |
+ } |
+ } |
addCallbackSelectors(); |
@@ -2003,7 +2015,7 @@ StyleRecalcChange Element::rebuildLayoutTree() { |
// sub-trees. At this point no child should need reattaching. |
DCHECK(!childNeedsReattachLayoutTree()); |
- if (layoutObjectWillChange || layoutObject()) { |
+ if (layoutObjectWillChange || layoutObject() || displayContentsStyle()) { |
// nextTextSibling is passed on to recalcStyle from recalcDescendantStyles |
// we can either traverse the current subtree from this node onwards |
// or store it. |
@@ -3133,6 +3145,22 @@ const ComputedStyle* Element::ensureComputedStyle( |
return elementStyle->addCachedPseudoStyle(result.release()); |
} |
+const ComputedStyle* Element::displayContentsStyle() const { |
+ if (layoutObject() || !hasRareData()) |
+ return nullptr; |
+ |
+ ComputedStyle* style = elementRareData()->computedStyle(); |
+ if (!style || style->display() != EDisplay::Contents) |
+ return nullptr; |
+ |
+ return style; |
+} |
+ |
+void Element::storeDisplayContentsStyle(ComputedStyle& style) { |
+ DCHECK_EQ(style.display(), EDisplay::Contents); |
+ ensureElementRareData().setComputedStyle(&style); |
+} |
+ |
AtomicString Element::computeInheritedLanguage() const { |
const Node* n = this; |
AtomicString value; |