diff --git a/engine/core/dom/Element.cpp b/engine/core/dom/Element.cpp index 7cb85c47be1..8cee479481d 100644 --- a/engine/core/dom/Element.cpp +++ b/engine/core/dom/Element.cpp @@ -801,6 +801,9 @@ void Element::attach(const AttachContext& context) { ASSERT(document().inStyleRecalc()); + if (isInsertionPoint()) + toInsertionPoint(this)->attachDistribution(context); + // We've already been through detach when doing an attach, but we might // need to clear any state that's been added since then. if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { @@ -826,6 +829,9 @@ void Element::attach(const AttachContext& context) void Element::detach(const AttachContext& context) { + if (isInsertionPoint()) + toInsertionPoint(this)->detachDistribution(context); + if (hasRareData()) { ElementRareData* data = elementRareData(); diff --git a/engine/core/dom/Element.h b/engine/core/dom/Element.h index 4f5a234c1a1..2771a576bae 100644 --- a/engine/core/dom/Element.h +++ b/engine/core/dom/Element.h @@ -196,8 +196,9 @@ public: bool hasEquivalentAttributes(const Element* other) const; - virtual void attach(const AttachContext& = AttachContext()) override; - virtual void detach(const AttachContext& = AttachContext()) override; + void attach(const AttachContext& = AttachContext()) final; + void detach(const AttachContext& = AttachContext()) final; + virtual RenderObject* createRenderer(RenderStyle*); void recalcStyle(StyleRecalcChange, Text* nextTextSibling = 0); void setAnimationStyleChange(bool); diff --git a/engine/core/dom/shadow/InsertionPoint.cpp b/engine/core/dom/shadow/InsertionPoint.cpp index 98ec9d2b2a8..1ac84d70647 100644 --- a/engine/core/dom/shadow/InsertionPoint.cpp +++ b/engine/core/dom/shadow/InsertionPoint.cpp @@ -92,7 +92,7 @@ void InsertionPoint::setDistribution(ContentDistribution& distribution) m_distribution.shrinkToFit(); } -void InsertionPoint::attach(const AttachContext& context) +void InsertionPoint::attachDistribution(const AttachContext& context) { // We need to attach the distribution here so that they're inserted in the right order // otherwise the n^2 protection inside RenderTreeBuilder will cause them to be @@ -102,16 +102,12 @@ void InsertionPoint::attach(const AttachContext& context) if (m_distribution.at(i)->needsAttach()) m_distribution.at(i)->attach(context); } - - HTMLElement::attach(context); } -void InsertionPoint::detach(const AttachContext& context) +void InsertionPoint::detachDistribution(const AttachContext& context) { for (size_t i = 0; i < m_distribution.size(); ++i) m_distribution.at(i)->lazyReattachIfAttached(); - - HTMLElement::detach(context); } void InsertionPoint::willRecalcStyle(StyleRecalcChange change) diff --git a/engine/core/dom/shadow/InsertionPoint.h b/engine/core/dom/shadow/InsertionPoint.h index 82ade6bb884..6b86d710b49 100644 --- a/engine/core/dom/shadow/InsertionPoint.h +++ b/engine/core/dom/shadow/InsertionPoint.h @@ -54,8 +54,8 @@ public: virtual bool canAffectSelector() const { return false; } - virtual void attach(const AttachContext& = AttachContext()) override; - virtual void detach(const AttachContext& = AttachContext()) override; + void attachDistribution(const AttachContext&); + void detachDistribution(const AttachContext&); bool shouldUseFallbackElements() const;