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 d5ea539ee3527b4a3f90bb8e3b32abb76b499bdf..f6ce013105253907f7f4c35ed0cbb0bf29ca6068 100644 |
--- a/third_party/WebKit/Source/core/dom/Element.cpp |
+++ b/third_party/WebKit/Source/core/dom/Element.cpp |
@@ -1570,7 +1570,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) { |
@@ -1708,9 +1709,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(); |
@@ -1886,7 +1893,7 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) { |
if (change >= IndependentInherit || needsStyleRecalc()) { |
if (hasRareData()) { |
ElementRareData* data = elementRareData(); |
- if (change != IndependentInherit) |
+ if (change != IndependentInherit && !nonLayoutObjectComputedStyle()) |
data->clearComputedStyle(); |
if (change >= IndependentInherit) { |
@@ -2009,6 +2016,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) |
@@ -3160,15 +3170,49 @@ const ComputedStyle* Element::ensureComputedStyle( |
elementStyle->getCachedPseudoStyle(pseudoElementSpecifier)) |
return pseudoElementStyle; |
+ // TODO(ecobos): Passing two times elementStyle may be wrong, though we don't |
+ // support display: contents elements' pseudo-elements yet, so this is not a |
+ // problem for now. |
RefPtr<ComputedStyle> result = |
document().ensureStyleResolver().pseudoStyleForElement( |
this, PseudoStyleRequest(pseudoElementSpecifier, |
PseudoStyleRequest::ForComputedStyle), |
- elementStyle); |
+ elementStyle, elementStyle); |
DCHECK(result); |
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)); |
+} |
+ |
AtomicString Element::computeInheritedLanguage() const { |
const Node* n = this; |
AtomicString value; |
@@ -3909,6 +3953,7 @@ void Element::inlineStyleChanged() { |
StyleChangeReason::Inline)); |
DCHECK(elementData()); |
elementData()->m_styleAttributeIsDirty = true; |
+ |
rune
2017/01/27 13:09:23
Stray newline?
|
InspectorInstrumentation::didInvalidateStyleAttr(this); |
if (MutationObserverInterestGroup* recipients = |