Chromium Code Reviews| 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 fd79b779eabf4799b7ba977e3148225b61db4544..df3c499d00da4d3568c72f7686518dbac2cff4b6 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(); |
| @@ -1968,6 +1975,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) |
| @@ -3120,15 +3130,49 @@ const ComputedStyle* Element::ensureComputedStyle( |
| elementStyle->getCachedPseudoStyle(pseudoElementSpecifier)) |
| return pseudoElementStyle; |
| + // FIXME(ecobos): Passing two times elementStyle may be wrong, though we don't |
| + // support display: contents pseudo-elements yet, so this is not a problem for |
| + // now. |
|
rune
2016/12/01 15:28:53
FIXME -> TODO.
It is wrong, but it's not about di
emilio
2016/12/01 17:32:56
Right, should've clarified.
|
| 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; |
| @@ -3862,6 +3906,7 @@ void Element::inlineStyleChanged() { |
| StyleChangeReason::Inline)); |
| DCHECK(elementData()); |
| elementData()->m_styleAttributeIsDirty = true; |
| + |
| InspectorInstrumentation::didInvalidateStyleAttr(this); |
| if (MutationObserverInterestGroup* recipients = |