<https://webkit.org/b/119982> Make Element::attach non-virtual
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Aug 2013 20:01:20 +0000 (20:01 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Aug 2013 20:01:20 +0000 (20:01 +0000)
Reviewed by Andreas Kling.

This will give us more future refactoring options.

* dom/Element.cpp:
(WebCore::Element::attach):
(WebCore::Element::detach):

    Make non-virtual. Call element type specific custom functions as needed.

(WebCore::Element::styleForRenderer):
(WebCore::Element::willRecalcStyle):
(WebCore::Element::didRecalcStyle):
(WebCore::Element::willAttachRenderers):
(WebCore::Element::didAttachRenderers):
(WebCore::Element::willDetachRenderers):
(WebCore::Element::didDetachRenderers):

    Add virtual custom callbacks.

(WebCore::Element::customStyleForRenderer):
* dom/Element.h:
* dom/Node.h:
(WebCore::Node::pseudoId):
(WebCore::Node::hasCustomStyleResolveCallbacks):
(WebCore::Node::setHasCustomStyleResolveCallbacks):

    Use the existing bit as it largely overlaps. Rename for clarity.

(WebCore::Node::customPseudoId):
* dom/PseudoElement.cpp:
(WebCore::PseudoElement::PseudoElement):
(WebCore::PseudoElement::didAttachRenderers):
* dom/PseudoElement.h:
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::HTMLCanvasElement):
(WebCore::HTMLCanvasElement::willAttachRenderers):
* html/HTMLCanvasElement.h:
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::HTMLFormControlElement):
(WebCore::HTMLFormControlElement::didAttachRenderers):
* html/HTMLFormControlElement.h:
* html/HTMLFrameElement.cpp:
(WebCore::HTMLFrameElement::HTMLFrameElement):
(WebCore::HTMLFrameElement::didAttachRenderers):
* html/HTMLFrameElement.h:
* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::HTMLFrameElementBase):
(WebCore::HTMLFrameElementBase::didAttachRenderers):
* html/HTMLFrameElementBase.h:
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::HTMLFrameSetElement):
(WebCore::HTMLFrameSetElement::willAttachRenderers):
* html/HTMLFrameSetElement.h:
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::HTMLIFrameElement):
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::HTMLImageElement):
(WebCore::HTMLImageElement::didAttachRenderers):
* html/HTMLImageElement.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::HTMLInputElement):
(WebCore::HTMLInputElement::willAttachRenderers):
(WebCore::HTMLInputElement::didAttachRenderers):
(WebCore::HTMLInputElement::didDetachRenderers):
* html/HTMLInputElement.h:
* html/HTMLLIElement.cpp:
(WebCore::HTMLLIElement::HTMLLIElement):
(WebCore::HTMLLIElement::didAttachRenderers):
* html/HTMLLIElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::willAttachRenderers):
(WebCore::HTMLMediaElement::didAttachRenderers):
* html/HTMLMediaElement.h:
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::HTMLOptGroupElement):
(WebCore::HTMLOptGroupElement::didAttachRenderers):
(WebCore::HTMLOptGroupElement::willDetachRenderers):
* html/HTMLOptGroupElement.h:
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::HTMLOptionElement):
(WebCore::HTMLOptionElement::didAttachRenderers):
(WebCore::HTMLOptionElement::willDetachRenderers):
* html/HTMLOptionElement.h:
* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::HTMLPlugInElement):
(WebCore::HTMLPlugInElement::willDetachRenderers):
* html/HTMLPlugInElement.h:
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement):
(WebCore::HTMLPlugInImageElement::didAttachRenderers):
(WebCore::HTMLPlugInImageElement::willDetachRenderers):
* html/HTMLPlugInImageElement.h:
* html/HTMLProgressElement.cpp:
(WebCore::HTMLProgressElement::HTMLProgressElement):
(WebCore::HTMLProgressElement::didAttachRenderers):
* html/HTMLProgressElement.h:
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::HTMLTextAreaElement):
(WebCore::HTMLTextAreaElement::didAttachRenderers):
* html/HTMLTextAreaElement.h:
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::HTMLVideoElement):
(WebCore::HTMLVideoElement::didAttachRenderers):
* html/HTMLVideoElement.h:
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::InsertionPoint):
(WebCore::InsertionPoint::willAttachRenderers):
(WebCore::InsertionPoint::willDetachRenderers):
* html/shadow/InsertionPoint.h:
* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::SliderThumbElement):
(WebCore::SliderThumbElement::willDetachRenderers):
* html/shadow/SliderThumbElement.h:
* html/shadow/SpinButtonElement.cpp:
(WebCore::SpinButtonElement::SpinButtonElement):
(WebCore::SpinButtonElement::willDetachRenderers):
* html/shadow/SpinButtonElement.h:
* html/shadow/TextControlInnerElements.cpp:
(WebCore::TextControlInnerElement::TextControlInnerElement):
(WebCore::TextControlInnerTextElement::TextControlInnerTextElement):
(WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement):
(WebCore::SearchFieldCancelButtonElement::willDetachRenderers):
(WebCore::InputFieldSpeechButtonElement::InputFieldSpeechButtonElement):
(WebCore::InputFieldSpeechButtonElement::willAttachRenderers):
(WebCore::InputFieldSpeechButtonElement::willDetachRenderers):
* html/shadow/TextControlInnerElements.h:
* style/StyleResolveTree.cpp:
(WebCore::Style::resolveTree):
* svg/SVGElement.cpp:
(WebCore::SVGElement::SVGElement):
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::SVGImageElement):
(WebCore::SVGImageElement::didAttachRenderers):
* svg/SVGImageElement.h:
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::SVGUseElement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154254 268f45cc-cd09-0410-ab3c-d52691b4dbfc

52 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Node.h
Source/WebCore/dom/PseudoElement.cpp
Source/WebCore/dom/PseudoElement.h
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLCanvasElement.h
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLFormControlElement.h
Source/WebCore/html/HTMLFrameElement.cpp
Source/WebCore/html/HTMLFrameElement.h
Source/WebCore/html/HTMLFrameElementBase.cpp
Source/WebCore/html/HTMLFrameElementBase.h
Source/WebCore/html/HTMLFrameSetElement.cpp
Source/WebCore/html/HTMLFrameSetElement.h
Source/WebCore/html/HTMLIFrameElement.cpp
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLImageElement.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLLIElement.cpp
Source/WebCore/html/HTMLLIElement.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLOptGroupElement.cpp
Source/WebCore/html/HTMLOptGroupElement.h
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLOptionElement.h
Source/WebCore/html/HTMLPlugInElement.cpp
Source/WebCore/html/HTMLPlugInElement.h
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.h
Source/WebCore/html/HTMLProgressElement.cpp
Source/WebCore/html/HTMLProgressElement.h
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/HTMLTextAreaElement.h
Source/WebCore/html/HTMLVideoElement.cpp
Source/WebCore/html/HTMLVideoElement.h
Source/WebCore/html/shadow/InsertionPoint.cpp
Source/WebCore/html/shadow/InsertionPoint.h
Source/WebCore/html/shadow/SliderThumbElement.cpp
Source/WebCore/html/shadow/SliderThumbElement.h
Source/WebCore/html/shadow/SpinButtonElement.cpp
Source/WebCore/html/shadow/SpinButtonElement.h
Source/WebCore/html/shadow/TextControlInnerElements.cpp
Source/WebCore/html/shadow/TextControlInnerElements.h
Source/WebCore/style/StyleResolveTree.cpp
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/svg/SVGImageElement.cpp
Source/WebCore/svg/SVGImageElement.h
Source/WebCore/svg/SVGUseElement.cpp

index 58a00b9..b4bffda 100644 (file)
@@ -1,3 +1,146 @@
+2013-08-18  Antti Koivisto  <antti@apple.com>
+
+        <https://webkit.org/b/119982> Make Element::attach non-virtual
+
+        Reviewed by Andreas Kling.
+
+        This will give us more future refactoring options.
+
+        * dom/Element.cpp:
+        (WebCore::Element::attach):
+        (WebCore::Element::detach):
+        
+            Make non-virtual. Call element type specific custom functions as needed.
+
+        (WebCore::Element::styleForRenderer):
+        (WebCore::Element::willRecalcStyle):
+        (WebCore::Element::didRecalcStyle):
+        (WebCore::Element::willAttachRenderers):
+        (WebCore::Element::didAttachRenderers):
+        (WebCore::Element::willDetachRenderers):
+        (WebCore::Element::didDetachRenderers):
+        
+            Add virtual custom callbacks.
+
+        (WebCore::Element::customStyleForRenderer):
+        * dom/Element.h:
+        * dom/Node.h:
+        (WebCore::Node::pseudoId):
+        (WebCore::Node::hasCustomStyleResolveCallbacks):
+        (WebCore::Node::setHasCustomStyleResolveCallbacks):
+        
+            Use the existing bit as it largely overlaps. Rename for clarity.
+
+        (WebCore::Node::customPseudoId):
+        * dom/PseudoElement.cpp:
+        (WebCore::PseudoElement::PseudoElement):
+        (WebCore::PseudoElement::didAttachRenderers):
+        * dom/PseudoElement.h:
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::HTMLCanvasElement):
+        (WebCore::HTMLCanvasElement::willAttachRenderers):
+        * html/HTMLCanvasElement.h:
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::HTMLFormControlElement):
+        (WebCore::HTMLFormControlElement::didAttachRenderers):
+        * html/HTMLFormControlElement.h:
+        * html/HTMLFrameElement.cpp:
+        (WebCore::HTMLFrameElement::HTMLFrameElement):
+        (WebCore::HTMLFrameElement::didAttachRenderers):
+        * html/HTMLFrameElement.h:
+        * html/HTMLFrameElementBase.cpp:
+        (WebCore::HTMLFrameElementBase::HTMLFrameElementBase):
+        (WebCore::HTMLFrameElementBase::didAttachRenderers):
+        * html/HTMLFrameElementBase.h:
+        * html/HTMLFrameSetElement.cpp:
+        (WebCore::HTMLFrameSetElement::HTMLFrameSetElement):
+        (WebCore::HTMLFrameSetElement::willAttachRenderers):
+        * html/HTMLFrameSetElement.h:
+        * html/HTMLIFrameElement.cpp:
+        (WebCore::HTMLIFrameElement::HTMLIFrameElement):
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::HTMLImageElement):
+        (WebCore::HTMLImageElement::didAttachRenderers):
+        * html/HTMLImageElement.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::HTMLInputElement):
+        (WebCore::HTMLInputElement::willAttachRenderers):
+        (WebCore::HTMLInputElement::didAttachRenderers):
+        (WebCore::HTMLInputElement::didDetachRenderers):
+        * html/HTMLInputElement.h:
+        * html/HTMLLIElement.cpp:
+        (WebCore::HTMLLIElement::HTMLLIElement):
+        (WebCore::HTMLLIElement::didAttachRenderers):
+        * html/HTMLLIElement.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement):
+        (WebCore::HTMLMediaElement::willAttachRenderers):
+        (WebCore::HTMLMediaElement::didAttachRenderers):
+        * html/HTMLMediaElement.h:
+        * html/HTMLOptGroupElement.cpp:
+        (WebCore::HTMLOptGroupElement::HTMLOptGroupElement):
+        (WebCore::HTMLOptGroupElement::didAttachRenderers):
+        (WebCore::HTMLOptGroupElement::willDetachRenderers):
+        * html/HTMLOptGroupElement.h:
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::HTMLOptionElement):
+        (WebCore::HTMLOptionElement::didAttachRenderers):
+        (WebCore::HTMLOptionElement::willDetachRenderers):
+        * html/HTMLOptionElement.h:
+        * html/HTMLPlugInElement.cpp:
+        (WebCore::HTMLPlugInElement::HTMLPlugInElement):
+        (WebCore::HTMLPlugInElement::willDetachRenderers):
+        * html/HTMLPlugInElement.h:
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement):
+        (WebCore::HTMLPlugInImageElement::didAttachRenderers):
+        (WebCore::HTMLPlugInImageElement::willDetachRenderers):
+        * html/HTMLPlugInImageElement.h:
+        * html/HTMLProgressElement.cpp:
+        (WebCore::HTMLProgressElement::HTMLProgressElement):
+        (WebCore::HTMLProgressElement::didAttachRenderers):
+        * html/HTMLProgressElement.h:
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::HTMLTextAreaElement):
+        (WebCore::HTMLTextAreaElement::didAttachRenderers):
+        * html/HTMLTextAreaElement.h:
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::HTMLVideoElement):
+        (WebCore::HTMLVideoElement::didAttachRenderers):
+        * html/HTMLVideoElement.h:
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::InsertionPoint::InsertionPoint):
+        (WebCore::InsertionPoint::willAttachRenderers):
+        (WebCore::InsertionPoint::willDetachRenderers):
+        * html/shadow/InsertionPoint.h:
+        * html/shadow/SliderThumbElement.cpp:
+        (WebCore::SliderThumbElement::SliderThumbElement):
+        (WebCore::SliderThumbElement::willDetachRenderers):
+        * html/shadow/SliderThumbElement.h:
+        * html/shadow/SpinButtonElement.cpp:
+        (WebCore::SpinButtonElement::SpinButtonElement):
+        (WebCore::SpinButtonElement::willDetachRenderers):
+        * html/shadow/SpinButtonElement.h:
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::TextControlInnerElement::TextControlInnerElement):
+        (WebCore::TextControlInnerTextElement::TextControlInnerTextElement):
+        (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement):
+        (WebCore::SearchFieldCancelButtonElement::willDetachRenderers):
+        (WebCore::InputFieldSpeechButtonElement::InputFieldSpeechButtonElement):
+        (WebCore::InputFieldSpeechButtonElement::willAttachRenderers):
+        (WebCore::InputFieldSpeechButtonElement::willDetachRenderers):
+        * html/shadow/TextControlInnerElements.h:
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::resolveTree):
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::SVGElement):
+        * svg/SVGImageElement.cpp:
+        (WebCore::SVGImageElement::SVGImageElement):
+        (WebCore::SVGImageElement::didAttachRenderers):
+        * svg/SVGImageElement.h:
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::SVGUseElement):
+
 2013-08-18  Gavin Barraclough  <barraclough@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=119972
index dc0d841..fdb64de 100644 (file)
@@ -1416,9 +1416,11 @@ void Element::attachChildren(const AttachContext& context)
 void Element::attach(const AttachContext& context)
 {
     PostAttachCallbackDisabler callbackDisabler(this);
-    StyleResolverParentPusher parentPusher(this);
     WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
 
+    if (hasCustomStyleResolveCallbacks())
+        willAttachRenderers();
+
     createRendererIfNeeded(context);
 
     if (parentElement() && parentElement()->isInCanvasSubtree())
@@ -1426,6 +1428,8 @@ void Element::attach(const AttachContext& context)
 
     updatePseudoElement(BEFORE);
 
+    StyleResolverParentPusher parentPusher(this);
+
     // When a shadow root exists, it does the work of attaching the children.
     if (ShadowRoot* shadowRoot = this->shadowRoot()) {
         parentPusher.push();
@@ -1457,6 +1461,9 @@ void Element::attach(const AttachContext& context)
             data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
         }
     }
+
+    if (hasCustomStyleResolveCallbacks())
+        didAttachRenderers();
 }
 
 void Element::unregisterNamedFlowContentNode()
@@ -1484,6 +1491,10 @@ void Element::detachChildren(const AttachContext& context)
 void Element::detach(const AttachContext& context)
 {
     WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
+
+    if (hasCustomStyleResolveCallbacks())
+        willDetachRenderers();
+
     unregisterNamedFlowContentNode();
     cancelFocusAppearanceUpdate();
     if (hasRareData()) {
@@ -1518,6 +1529,9 @@ void Element::detach(const AttachContext& context)
     setRenderer(0);
 
     setAttached(false);
+
+    if (hasCustomStyleResolveCallbacks())
+        didDetachRenderers();
 }
 
 void Element::reattach(const AttachContext& context)
@@ -1563,7 +1577,7 @@ void Element::lazyAttach(ShouldSetAttached shouldSetAttached)
 
 PassRefPtr<RenderStyle> Element::styleForRenderer()
 {
-    if (hasCustomStyleCallbacks()) {
+    if (hasCustomStyleResolveCallbacks()) {
         if (RefPtr<RenderStyle> style = customStyleForRenderer())
             return style.release();
     }
@@ -3100,18 +3114,38 @@ void Element::resetComputedStyle()
 
 bool Element::willRecalcStyle(Style::Change)
 {
-    ASSERT(hasCustomStyleCallbacks());
+    ASSERT(hasCustomStyleResolveCallbacks());
     return true;
 }
 
 void Element::didRecalcStyle(Style::Change)
 {
-    ASSERT(hasCustomStyleCallbacks());
+    ASSERT(hasCustomStyleResolveCallbacks());
+}
+
+void Element::willAttachRenderers()
+{
+    ASSERT(hasCustomStyleResolveCallbacks());
+}
+
+void Element::didAttachRenderers()
+{
+    ASSERT(hasCustomStyleResolveCallbacks());
+}
+
+void Element::willDetachRenderers()
+{
+    ASSERT(hasCustomStyleResolveCallbacks());
+}
+
+void Element::didDetachRenderers()
+{
+    ASSERT(hasCustomStyleResolveCallbacks());
 }
 
 PassRefPtr<RenderStyle> Element::customStyleForRenderer()
 {
-    ASSERT(hasCustomStyleCallbacks());
+    ASSERT(hasCustomStyleResolveCallbacks());
     return 0;
 }
 
index da3e5f4..6327c2c 100644 (file)
@@ -299,8 +299,8 @@ public:
 
         AttachContext() : resolvedStyle(0), performingReattach(false) { }
     };
-    virtual void attach(const AttachContext& = AttachContext());
-    virtual void detach(const AttachContext& = AttachContext());
+    void attach(const AttachContext& = AttachContext());
+    void detach(const AttachContext& = AttachContext());
     void reattach(const AttachContext& = AttachContext());
     void reattachIfAttached(const AttachContext& = AttachContext());
     enum ShouldSetAttached {
@@ -555,6 +555,7 @@ public:
 
     virtual bool willRecalcStyle(Style::Change);
     virtual void didRecalcStyle(Style::Change);
+
     void updatePseudoElement(PseudoId, Style::Change = Style::NoChange);
     void resetComputedStyle();
 
@@ -673,6 +674,11 @@ private:
     void attachChildren(const AttachContext&);
     void detachChildren(const AttachContext&);
 
+    virtual void willAttachRenderers();
+    virtual void didAttachRenderers();
+    virtual void willDetachRenderers();
+    virtual void didDetachRenderers();
+
     void createRendererIfNeeded(const AttachContext&);
 
     bool isJavaScriptURLAttribute(const Attribute&) const;
index a490036..38984a1 100644 (file)
@@ -238,7 +238,7 @@ public:
     bool isPseudoElement() const { return pseudoId() != NOPSEUDO; }
     bool isBeforePseudoElement() const { return pseudoId() == BEFORE; }
     bool isAfterPseudoElement() const { return pseudoId() == AFTER; }
-    PseudoId pseudoId() const { return (isElementNode() && hasCustomStyleCallbacks()) ? customPseudoId() : NOPSEUDO; }
+    PseudoId pseudoId() const { return (isElementNode() && hasCustomStyleResolveCallbacks()) ? customPseudoId() : NOPSEUDO; }
 
     virtual bool isMediaControlElement() const { return false; }
     virtual bool isMediaControls() const { return false; }
@@ -266,7 +266,7 @@ public:
     void resetNeedsShadowTreeWalker() { setFlag(needsShadowTreeWalkerSlow(), NeedsShadowTreeWalkerFlag); }
 
     bool inNamedFlow() const { return getFlag(InNamedFlowFlag); }
-    bool hasCustomStyleCallbacks() const { return getFlag(HasCustomStyleCallbacksFlag); }
+    bool hasCustomStyleResolveCallbacks() const { return getFlag(HasCustomStyleResolveCallbacksFlag); }
 
     bool isRegisteredWithNamedFlow() const;
 
@@ -635,7 +635,7 @@ private:
 
         InNamedFlowFlag = 1 << 19,
         HasSyntheticAttrChildNodesFlag = 1 << 20,
-        HasCustomStyleCallbacksFlag = 1 << 21,
+        HasCustomStyleResolveCallbacksFlag = 1 << 21,
         HasScopedHTMLStyleChildFlag = 1 << 22,
         HasEventTargetDataFlag = 1 << 23,
         NeedsShadowTreeWalkerFlag = 1 << 25,
@@ -681,7 +681,7 @@ protected:
 
     void clearEventTargetData();
 
-    void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFlag); }
+    void setHasCustomStyleResolveCallbacks() { setFlag(true, HasCustomStyleResolveCallbacksFlag); }
 
     Document* documentInternal() const { return treeScope()->documentScope(); }
     void setTreeScope(TreeScope* scope) { m_treeScope = scope; }
@@ -693,7 +693,7 @@ private:
 
     virtual PseudoId customPseudoId() const
     {
-        ASSERT(hasCustomStyleCallbacks());
+        ASSERT(hasCustomStyleResolveCallbacks());
         return NOPSEUDO;
     }
 
index aa1a545..0059947 100644 (file)
@@ -61,7 +61,7 @@ PseudoElement::PseudoElement(Element* host, PseudoId pseudoId)
     , m_pseudoId(pseudoId)
 {
     ASSERT(pseudoId == BEFORE || pseudoId == AFTER);
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 PseudoElement::~PseudoElement()
@@ -77,12 +77,8 @@ PassRefPtr<RenderStyle> PseudoElement::customStyleForRenderer()
     return m_hostElement->renderer()->getCachedPseudoStyle(m_pseudoId);
 }
 
-void PseudoElement::attach(const AttachContext& context)
+void PseudoElement::didAttachRenderers()
 {
-    ASSERT(!renderer());
-
-    Element::attach(context);
-
     RenderObject* renderer = this->renderer();
     if (!renderer || !renderer->style()->regionThread().isEmpty())
         return;
index 8a6bc84..7b55e53 100644 (file)
@@ -46,7 +46,7 @@ public:
     void clearHostElement() { m_hostElement = 0; }
 
     virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
     virtual bool rendererIsNeeded(const NodeRenderingContext&) OVERRIDE;
 
     // As per http://dev.w3.org/csswg/css3-regions/#flow-into, pseudo-elements such as ::first-line, ::first-letter, ::before or ::after
index 32267eb..eaa4478 100644 (file)
@@ -80,6 +80,7 @@ HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document* doc
     , m_didClearImageBuffer(false)
 {
     ASSERT(hasTagName(canvasTag));
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<HTMLCanvasElement> HTMLCanvasElement::create(Document* document)
@@ -120,10 +121,9 @@ RenderObject* HTMLCanvasElement::createRenderer(RenderArena* arena, RenderStyle*
     return HTMLElement::createRenderer(arena, style);
 }
 
-void HTMLCanvasElement::attach(const AttachContext& context)
+void HTMLCanvasElement::willAttachRenderers()
 {
     setIsInCanvasSubtree(true);
-    HTMLElement::attach(context);
 }
 
 bool HTMLCanvasElement::areAuthorShadowsAllowed() const
index c430262..658109d 100644 (file)
@@ -147,7 +147,7 @@ private:
 
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willAttachRenderers() OVERRIDE;
     virtual bool areAuthorShadowsAllowed() const OVERRIDE;
 
     virtual bool canContainRangeEndPoint() const OVERRIDE;
index e657d10..7f7dd47 100644 (file)
@@ -63,7 +63,7 @@ HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc
     , m_hasAutofocused(false)
 {
     setForm(form ? form : findFormAncestor());
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 HTMLFormControlElement::~HTMLFormControlElement()
@@ -208,12 +208,8 @@ static void focusPostAttach(Node* element, unsigned)
     element->deref(); 
 }
 
-void HTMLFormControlElement::attach(const AttachContext& context)
+void HTMLFormControlElement::didAttachRenderers()
 {
-    PostAttachCallbackDisabler disabler(this);
-
-    HTMLElement::attach(context);
-
     // The call to updateFromElement() needs to go after the call through
     // to the base class's attach() because that can sometimes do a close
     // on the renderer.
index 31199aa..5f512fe 100644 (file)
@@ -111,7 +111,7 @@ protected:
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual void requiredAttributeChanged();
     virtual void disabledAttributeChanged();
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
     virtual void removedFrom(ContainerNode*) OVERRIDE;
     virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE;
index ed5b9b8..c5ef297 100644 (file)
@@ -40,6 +40,7 @@ inline HTMLFrameElement::HTMLFrameElement(const QualifiedName& tagName, Document
     , m_frameBorderSet(false)
 {
     ASSERT(hasTagName(frameTag));
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<HTMLFrameElement> HTMLFrameElement::create(const QualifiedName& tagName, Document* document)
@@ -72,10 +73,9 @@ bool HTMLFrameElement::noResize() const
     return hasAttribute(noresizeAttr);
 }
 
-void HTMLFrameElement::attach(const AttachContext& context)
+void HTMLFrameElement::didAttachRenderers()
 {
-    HTMLFrameElementBase::attach(context);
-    
+    HTMLFrameElementBase::didAttachRenderers();
     if (HTMLFrameSetElement* frameSetElement = containingFrameSetElement(this)) {
         if (!m_frameBorderSet)
             m_frameBorder = frameSetElement->hasFrameBorder();
index 928429b..39d58bb 100644 (file)
@@ -39,7 +39,7 @@ public:
 private:
     HTMLFrameElement(const QualifiedName&, Document*);
 
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
 
     virtual bool rendererIsNeeded(const NodeRenderingContext&);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
index d8c4c82..4f0cb2e 100644 (file)
@@ -51,6 +51,7 @@ HTMLFrameElementBase::HTMLFrameElementBase(const QualifiedName& tagName, Documen
     , m_marginHeight(-1)
     , m_viewSource(false)
 {
+    setHasCustomStyleResolveCallbacks();
 }
 
 bool HTMLFrameElementBase::isURLAllowed() const
@@ -172,10 +173,8 @@ void HTMLFrameElementBase::didNotifySubtreeInsertions(ContainerNode*)
     setNameAndOpenURL();
 }
 
-void HTMLFrameElementBase::attach(const AttachContext& context)
+void HTMLFrameElementBase::didAttachRenderers()
 {
-    HTMLFrameOwnerElement::attach(context);
-
     if (RenderPart* part = renderPart()) {
         if (Frame* frame = contentFrame())
             part->setWidget(frame->view());
index c094f12..499f2bd 100644 (file)
@@ -52,7 +52,7 @@ protected:
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
     virtual void didNotifySubtreeInsertions(ContainerNode*) OVERRIDE;
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
 
 private:
     virtual bool supportsFocus() const OVERRIDE;
index 686c2d2..d8d0283 100644 (file)
@@ -56,8 +56,7 @@ HTMLFrameSetElement::HTMLFrameSetElement(const QualifiedName& tagName, Document*
     , m_noresize(false)
 {
     ASSERT(hasTagName(framesetTag));
-    
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<HTMLFrameSetElement> HTMLFrameSetElement::create(const QualifiedName& tagName, Document* document)
@@ -165,28 +164,25 @@ RenderObject *HTMLFrameSetElement::createRenderer(RenderArena *arena, RenderStyl
     return new (arena) RenderFrameSet(this);
 }
 
-void HTMLFrameSetElement::attach(const AttachContext& context)
+void HTMLFrameSetElement::willAttachRenderers()
 {
     // Inherit default settings from parent frameset
     // FIXME: This is not dynamic.
     for (ContainerNode* node = parentNode(); node; node = node->parentNode()) {
-        if (node->hasTagName(framesetTag)) {
-            HTMLFrameSetElement* frameset = static_cast<HTMLFrameSetElement*>(node);
-            if (!m_frameborderSet)
-                m_frameborder = frameset->hasFrameBorder();
-            if (m_frameborder) {
-                if (!m_borderSet)
-                    m_border = frameset->border();
-                if (!m_borderColorSet)
-                    m_borderColorSet = frameset->hasBorderColor();
-            }
-            if (!m_noresize)
-                m_noresize = frameset->noResize();
-            break;
+        if (!node->hasTagName(framesetTag))
+            continue;
+        HTMLFrameSetElement* frameset = static_cast<HTMLFrameSetElement*>(node);
+        if (!m_frameborderSet)
+            m_frameborder = frameset->hasFrameBorder();
+        if (m_frameborder) {
+            if (!m_borderSet)
+                m_border = frameset->border();
+            if (!m_borderColorSet)
+                m_borderColorSet = frameset->hasBorderColor();
         }
+        if (!m_noresize)
+            m_noresize = frameset->noResize();
     }
-
-    HTMLElement::attach(context);
 }
 
 void HTMLFrameSetElement::defaultEventHandler(Event* evt)
index 0a770bb..2756362 100644 (file)
@@ -71,7 +71,7 @@ private:
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
 
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willAttachRenderers() OVERRIDE;
     virtual bool rendererIsNeeded(const NodeRenderingContext&);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     
index f4dfa56..6af3213 100644 (file)
@@ -42,7 +42,7 @@ inline HTMLIFrameElement::HTMLIFrameElement(const QualifiedName& tagName, Docume
     : HTMLFrameElementBase(tagName, document)
 {
     ASSERT(hasTagName(iframeTag));
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<HTMLIFrameElement> HTMLIFrameElement::create(const QualifiedName& tagName, Document* document)
index 34b42c6..0bfaf00 100644 (file)
@@ -52,6 +52,7 @@ HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document* docum
     , m_compositeOperator(CompositeSourceOver)
 {
     ASSERT(hasTagName(imgTag));
+    setHasCustomStyleResolveCallbacks();
     if (form)
         form->registerImgElement(this);
 }
@@ -184,22 +185,22 @@ bool HTMLImageElement::canStartSelection() const
     return false;
 }
 
-void HTMLImageElement::attach(const AttachContext& context)
+void HTMLImageElement::didAttachRenderers()
 {
-    HTMLElement::attach(context);
+    if (!renderer() || !renderer()->isImage())
+        return;
+    if (m_imageLoader.hasPendingBeforeLoadEvent())
+        return;
+    RenderImage* renderImage = toRenderImage(renderer());
+    RenderImageResource* renderImageResource = renderImage->imageResource();
+    if (renderImageResource->hasImage())
+        return;
+    renderImageResource->setCachedImage(m_imageLoader.image());
 
-    if (renderer() && renderer()->isImage() && !m_imageLoader.hasPendingBeforeLoadEvent()) {
-        RenderImage* renderImage = toRenderImage(renderer());
-        RenderImageResource* renderImageResource = renderImage->imageResource();
-        if (renderImageResource->hasImage())
-            return;
-        renderImageResource->setCachedImage(m_imageLoader.image());
-
-        // If we have no image at all because we have no src attribute, set
-        // image height and width for the alt text instead.
-        if (!m_imageLoader.image() && !renderImageResource->cachedImage())
-            renderImage->setImageSizeForAltText();
-    }
+    // If we have no image at all because we have no src attribute, set
+    // image height and width for the alt text instead.
+    if (!m_imageLoader.image() && !renderImageResource->cachedImage())
+        renderImage->setImageSizeForAltText();
 }
 
 Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode* insertionPoint)
index f4e31da..625ccb2 100644 (file)
@@ -90,7 +90,7 @@ private:
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
 
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
 
     virtual bool canStartSelection() const;
index b345b62..4bf1eb1 100644 (file)
@@ -135,6 +135,7 @@ HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document* docum
     , m_inputType(InputType::createText(this))
 {
     ASSERT(hasTagName(inputTag) || hasTagName(isindexTag));
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<HTMLInputElement> HTMLInputElement::create(const QualifiedName& tagName, Document* document, HTMLFormElement* form, bool createdByParser)
@@ -795,14 +796,15 @@ RenderObject* HTMLInputElement::createRenderer(RenderArena* arena, RenderStyle*
     return m_inputType->createRenderer(arena, style);
 }
 
-void HTMLInputElement::attach(const AttachContext& context)
+void HTMLInputElement::willAttachRenderers()
 {
-    PostAttachCallbackDisabler disabler(this);
-
     if (!m_hasType)
         updateType();
+}
 
-    HTMLTextFormControlElement::attach(context);
+void HTMLInputElement::didAttachRenderers()
+{
+    HTMLTextFormControlElement::didAttachRenderers();
 
     m_inputType->attach();
 
@@ -810,9 +812,8 @@ void HTMLInputElement::attach(const AttachContext& context)
         document()->updateFocusAppearanceSoon(true /* restore selection */);
 }
 
-void HTMLInputElement::detach(const AttachContext& context)
+void HTMLInputElement::didDetachRenderers()
 {
-    HTMLTextFormControlElement::detach(context);
     setFormControlValueMatchesRenderer(false);
     m_inputType->detach();
 }
index d2e8cdd..12745fb 100644 (file)
@@ -189,7 +189,9 @@ public:
 
     virtual bool rendererIsNeeded(const NodeRenderingContext&);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
-    virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willAttachRenderers() OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
+    virtual void didDetachRenderers() OVERRIDE;
 
     // FIXME: For isActivatedSubmit and setActivatedSubmit, we should use the NVI-idiom here by making
     // it private virtual in all classes and expose a public method in HTMLFormControlElement to call
@@ -352,8 +354,6 @@ private:
 
     virtual void copyNonAttributePropertiesFromElement(const Element&);
 
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
-
     virtual bool appendFormData(FormDataList&, bool);
 
     virtual bool isSuccessfulSubmitButton() const;
index f41183c..b439a9e 100644 (file)
@@ -38,6 +38,7 @@ HTMLLIElement::HTMLLIElement(const QualifiedName& tagName, Document* document)
     : HTMLElement(tagName, document)
 {
     ASSERT(hasTagName(liTag));
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<HTMLLIElement> HTMLLIElement::create(Document* document)
@@ -85,33 +86,29 @@ void HTMLLIElement::parseAttribute(const QualifiedName& name, const AtomicString
         HTMLElement::parseAttribute(name, value);
 }
 
-void HTMLLIElement::attach(const AttachContext& context)
+void HTMLLIElement::didAttachRenderers()
 {
-    ASSERT(!attached());
-
-    HTMLElement::attach(context);
-
-    if (renderer() && renderer()->isListItem()) {
-        RenderListItem* listItemRenderer = toRenderListItem(renderer());
-
-        // Find the enclosing list node.
-        Element* listNode = 0;
-        Element* current = this;
-        while (!listNode) {
-            current = current->parentElement();
-            if (!current)
-                break;
-            if (current->hasTagName(ulTag) || current->hasTagName(olTag))
-                listNode = current;
-        }
-
-        // If we are not in a list, tell the renderer so it can position us inside.
-        // We don't want to change our style to say "inside" since that would affect nested nodes.
-        if (!listNode)
-            listItemRenderer->setNotInList(true);
-
-        parseValue(fastGetAttribute(valueAttr));
+    if (!renderer() || !renderer()->isListItem())
+        return;
+    RenderListItem* listItemRenderer = toRenderListItem(renderer());
+
+    // Find the enclosing list node.
+    Element* listNode = 0;
+    Element* current = this;
+    while (!listNode) {
+        current = current->parentElement();
+        if (!current)
+            break;
+        if (current->hasTagName(ulTag) || current->hasTagName(olTag))
+            listNode = current;
     }
+
+    // If we are not in a list, tell the renderer so it can position us inside.
+    // We don't want to change our style to say "inside" since that would affect nested nodes.
+    if (!listNode)
+        listItemRenderer->setNotInList(true);
+
+    parseValue(fastGetAttribute(valueAttr));
 }
 
 inline void HTMLLIElement::parseValue(const AtomicString& value)
index 2e645c4..5161fb5 100644 (file)
@@ -39,7 +39,7 @@ private:
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
 
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
 
     void parseValue(const AtomicString&);
 };
index 1b41fb9..28001d1 100644 (file)
@@ -327,6 +327,8 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
     , m_reportedExtraMemoryCost(0)
 {
     LOG(Media, "HTMLMediaElement::HTMLMediaElement");
+    setHasCustomStyleResolveCallbacks();
+
     document->registerForMediaVolumeCallbacks(this);
     document->registerForPrivateBrowsingStateChangedCallbacks(this);
 
@@ -335,7 +337,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
         addBehaviorRestriction(RequireUserGestureForLoadRestriction);
     }
 
-    setHasCustomStyleCallbacks();
     addElementToDocumentMap(this, document);
 
 #if ENABLE(VIDEO_TRACK)
@@ -631,16 +632,17 @@ void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint)
     HTMLElement::removedFrom(insertionPoint);
 }
 
-void HTMLMediaElement::attach(const AttachContext& context)
+void HTMLMediaElement::willAttachRenderers()
 {
     ASSERT(!attached());
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     m_needWidgetUpdate = true;
 #endif
+}
 
-    HTMLElement::attach(context);
-
+void HTMLMediaElement::didAttachRenderers()
+{
     if (renderer())
         renderer()->updateFromElement();
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
index 299380f..fae51ad 100644 (file)
@@ -386,7 +386,8 @@ protected:
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual void finishParsingChildren();
     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willAttachRenderers() OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
 
     virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE;
 
index 49b4db9..e470cc9 100644 (file)
@@ -42,7 +42,7 @@ inline HTMLOptGroupElement::HTMLOptGroupElement(const QualifiedName& tagName, Do
     : HTMLElement(tagName, document)
 {
     ASSERT(hasTagName(optgroupTag));
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<HTMLOptGroupElement> HTMLOptGroupElement::create(const QualifiedName& tagName, Document* document)
@@ -91,9 +91,8 @@ void HTMLOptGroupElement::recalcSelectOptions()
         toHTMLSelectElement(select)->setRecalcListItems();
 }
 
-void HTMLOptGroupElement::attach(const AttachContext& context)
+void HTMLOptGroupElement::didAttachRenderers()
 {
-    HTMLElement::attach(context);
     // If after attaching nothing called styleForRenderer() on this node we
     // manually cache the value. This happens if our parent doesn't have a
     // renderer like <optgroup> or if it doesn't allow children like <select>.
@@ -101,10 +100,9 @@ void HTMLOptGroupElement::attach(const AttachContext& context)
         updateNonRenderStyle();
 }
 
-void HTMLOptGroupElement::detach(const AttachContext& context)
+void HTMLOptGroupElement::willDetachRenderers()
 {
     m_style.clear();
-    HTMLElement::detach(context);
 }
 
 void HTMLOptGroupElement::updateNonRenderStyle()
index cc62e90..5efba0d 100644 (file)
@@ -46,8 +46,8 @@ private:
     virtual bool isFocusable() const OVERRIDE;
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
-    virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
+    virtual void willDetachRenderers() OVERRIDE;
 
     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
 
index 0f351e8..dc6a93c 100644 (file)
@@ -56,7 +56,7 @@ HTMLOptionElement::HTMLOptionElement(const QualifiedName& tagName, Document* doc
     , m_isSelected(false)
 {
     ASSERT(hasTagName(optionTag));
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<HTMLOptionElement> HTMLOptionElement::create(Document* document)
@@ -90,9 +90,8 @@ PassRefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document
     return element.release();
 }
 
-void HTMLOptionElement::attach(const AttachContext& context)
+void HTMLOptionElement::didAttachRenderers()
 {
-    HTMLElement::attach(context);
     // If after attaching nothing called styleForRenderer() on this node we
     // manually cache the value. This happens if our parent doesn't have a
     // renderer like <optgroup> or if it doesn't allow children like <select>.
@@ -100,10 +99,9 @@ void HTMLOptionElement::attach(const AttachContext& context)
         updateNonRenderStyle();
 }
 
-void HTMLOptionElement::detach(const AttachContext& context)
+void HTMLOptionElement::willDetachRenderers()
 {
     m_style.clear();
-    HTMLElement::detach(context);
 }
 
 bool HTMLOptionElement::isFocusable() const
index 5acfa8d..00d1ee9 100644 (file)
@@ -71,8 +71,8 @@ private:
 
     virtual bool isFocusable() const OVERRIDE;
     virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
-    virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
+    virtual void willDetachRenderers() OVERRIDE;
 
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
 
index b740125..4ed60d4 100644 (file)
@@ -61,6 +61,7 @@ HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document* doc
     , m_isCapturingMouseEvents(false)
     , m_displayState(Playing)
 {
+    setHasCustomStyleResolveCallbacks();
 }
 
 HTMLPlugInElement::~HTMLPlugInElement()
@@ -93,7 +94,7 @@ bool HTMLPlugInElement::willRespondToMouseClickEvents()
     return true;
 }
 
-void HTMLPlugInElement::detach(const AttachContext& context)
+void HTMLPlugInElement::willDetachRenderers()
 {
     m_instance.clear();
 
@@ -109,8 +110,6 @@ void HTMLPlugInElement::detach(const AttachContext& context)
         m_NPObject = 0;
     }
 #endif
-
-    HTMLFrameOwnerElement::detach(context);
 }
 
 void HTMLPlugInElement::resetInstance()
index 83b9e6c..634e5c6 100644 (file)
@@ -83,7 +83,7 @@ public:
 protected:
     HTMLPlugInElement(const QualifiedName& tagName, Document*);
 
-    virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willDetachRenderers() OVERRIDE;
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
 
index 57afc63..5dba8dc 100644 (file)
@@ -115,7 +115,7 @@ HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Doc
     , m_deferredPromotionToPrimaryPlugIn(false)
     , m_snapshotDecision(SnapshotNotYetDecided)
 {
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 HTMLPlugInImageElement::~HTMLPlugInImageElement()
@@ -231,33 +231,32 @@ bool HTMLPlugInImageElement::willRecalcStyle(Style::Change)
     return true;
 }
 
-void HTMLPlugInImageElement::attach(const AttachContext& context)
+void HTMLPlugInImageElement::didAttachRenderers()
 {
-    PostAttachCallbackDisabler disabler(this);
-
-    bool isImage = isImageType();
-
-    if (!isImage)
+    if (!isImageType()) {
         queuePostAttachCallback(&HTMLPlugInImageElement::updateWidgetCallback, this);
-
-    HTMLPlugInElement::attach(context);
-
-    if (isImage && renderer() && !useFallbackContent()) {
-        if (!m_imageLoader)
-            m_imageLoader = adoptPtr(new HTMLImageLoader(this));
-        m_imageLoader->updateFromElement();
+        return;
     }
+    if (!renderer() || useFallbackContent())
+        return;
+    if (!m_imageLoader)
+        m_imageLoader = adoptPtr(new HTMLImageLoader(this));
+    m_imageLoader->updateFromElement();
 }
 
-void HTMLPlugInImageElement::detach(const AttachContext& context)
+void HTMLPlugInImageElement::willDetachRenderers()
 {
-    // FIXME: Because of the insanity that is HTMLPlugInImageElement::recalcStyle,
+    // FIXME: Because of the insanity that is HTMLPlugInImageElement::willRecalcStyle,
     // we can end up detaching during an attach() call, before we even have a
     // renderer.  In that case, don't mark the widget for update.
-    if (attached() && renderer() && !useFallbackContent())
-        // Update the widget the next time we attach (detaching destroys the plugin).
-        setNeedsWidgetUpdate(true);
-    HTMLPlugInElement::detach(context);
+    if (!attached() || !renderer())
+        return;
+    if (useFallbackContent())
+        return;
+    // Update the widget the next time we attach (detaching destroys the plugin).
+    setNeedsWidgetUpdate(true);
+
+    HTMLPlugInElement::willDetachRenderers();
 }
 
 void HTMLPlugInImageElement::updateWidgetIfNecessary()
index e577ddd..eee0db0 100644 (file)
@@ -109,8 +109,8 @@ protected:
     KURL m_loadedUrl;
 
     static void updateWidgetCallback(Node*, unsigned = 0);
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
-    virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
+    virtual void willDetachRenderers() OVERRIDE;
 
     bool allowedToLoadFrameURL(const String& url);
     bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType);
index 3d791c4..87902b7 100644 (file)
@@ -45,6 +45,7 @@ HTMLProgressElement::HTMLProgressElement(const QualifiedName& tagName, Document*
     , m_value(0)
 {
     ASSERT(hasTagName(progressTag));
+    setHasCustomStyleResolveCallbacks();
 }
 
 HTMLProgressElement::~HTMLProgressElement()
@@ -91,9 +92,8 @@ void HTMLProgressElement::parseAttribute(const QualifiedName& name, const Atomic
         LabelableElement::parseAttribute(name, value);
 }
 
-void HTMLProgressElement::attach(const AttachContext& context)
+void HTMLProgressElement::didAttachRenderers()
 {
-    LabelableElement::attach(context);
     if (RenderProgress* render = renderProgress())
         render->updateFromElement();
 }
index 4617d6b..dfb3dea 100644 (file)
@@ -60,7 +60,7 @@ private:
 
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
 
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
 
     void didElementStateChange();
     virtual void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE;
index 3acfd73..34f7dff 100644 (file)
@@ -97,6 +97,7 @@ HTMLTextAreaElement::HTMLTextAreaElement(const QualifiedName& tagName, Document*
 {
     ASSERT(hasTagName(textareaTag));
     setFormControlValueMatchesRenderer(true);
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<HTMLTextAreaElement> HTMLTextAreaElement::create(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
@@ -515,9 +516,9 @@ HTMLElement* HTMLTextAreaElement::placeholderElement() const
     return m_placeholder;
 }
 
-void HTMLTextAreaElement::attach(const AttachContext& context)
+void HTMLTextAreaElement::didAttachRenderers()
 {
-    HTMLTextFormControlElement::attach(context);
+    HTMLTextFormControlElement::didAttachRenderers();
     fixPlaceholderRenderer(m_placeholder, innerTextElement());
 }
 
index d9785c9..9764b1b 100644 (file)
@@ -111,7 +111,7 @@ private:
     virtual void accessKeyAction(bool sendMouseEvents);
 
     virtual bool shouldUseInputMethod() OVERRIDE;
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
     virtual bool matchesReadOnlyPseudoClass() const OVERRIDE;
     virtual bool matchesReadWritePseudoClass() const OVERRIDE;
 
index a64e59e..b6b5e22 100644 (file)
@@ -51,6 +51,7 @@ inline HTMLVideoElement::HTMLVideoElement(const QualifiedName& tagName, Document
     : HTMLMediaElement(tagName, document, createdByParser)
 {
     ASSERT(hasTagName(videoTag));
+    setHasCustomStyleResolveCallbacks();
     if (document->settings())
         m_defaultPosterURL = document->settings()->defaultVideoPosterURL();
 }
@@ -74,9 +75,9 @@ RenderObject* HTMLVideoElement::createRenderer(RenderArena* arena, RenderStyle*)
 }
 #endif
 
-void HTMLVideoElement::attach(const AttachContext& context)
+void HTMLVideoElement::didAttachRenderers()
 {
-    HTMLMediaElement::attach(context);
+    HTMLMediaElement::didAttachRenderers();
 
 #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     updateDisplayState();
index 8f5017a..2e6997b 100644 (file)
@@ -78,7 +78,7 @@ private:
 #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
 #endif
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
index 85d148d..ec00490 100644 (file)
@@ -45,13 +45,14 @@ InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document)
     : HTMLElement(tagName, document, CreateInsertionPoint)
     , m_hasDistribution(false)
 {
+    setHasCustomStyleResolveCallbacks();
 }
 
 InsertionPoint::~InsertionPoint()
 {
 }
 
-void InsertionPoint::attach(const AttachContext& context)
+void InsertionPoint::willAttachRenderers()
 {
     if (ShadowRoot* shadowRoot = containingShadowRoot())
         ContentDistributor::ensureDistribution(shadowRoot);
@@ -63,12 +64,11 @@ void InsertionPoint::attach(const AttachContext& context)
             continue;
         }
         if (current->isElementNode())
-            toElement(current)->attach(context);
+            toElement(current)->attach();
     }
-    HTMLElement::attach(context);
 }
 
-void InsertionPoint::detach(const AttachContext& context)
+void InsertionPoint::willDetachRenderers()
 {
     if (ShadowRoot* shadowRoot = containingShadowRoot())
         ContentDistributor::ensureDistribution(shadowRoot);
@@ -79,9 +79,8 @@ void InsertionPoint::detach(const AttachContext& context)
             continue;
         }
         if (current->isElementNode())
-            toElement(current)->detach(context);
+            toElement(current)->detach();
     }
-    HTMLElement::detach(context);
 }
 
 bool InsertionPoint::shouldUseFallbackElements() const
index 8b4ab51..b670135 100644 (file)
@@ -65,8 +65,8 @@ public:
     bool resetStyleInheritance() const;
     void setResetStyleInheritance(bool);
 
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
-    virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willAttachRenderers() OVERRIDE;
+    virtual void willDetachRenderers() OVERRIDE;
 
     bool shouldUseFallbackElements() const;
 
index b27f293..b68929a 100644 (file)
@@ -206,6 +206,13 @@ void RenderSliderContainer::layout()
 
 // --------------------------------
 
+SliderThumbElement::SliderThumbElement(Document* document)
+    : HTMLDivElement(HTMLNames::divTag, document)
+    , m_inDragMode(false)
+{
+    setHasCustomStyleResolveCallbacks();
+}
+
 void SliderThumbElement::setPositionFromValue()
 {
     // Since the code to calculate position is in the RenderSliderThumb layout
@@ -385,13 +392,12 @@ bool SliderThumbElement::willRespondToMouseClickEvents()
     return HTMLDivElement::willRespondToMouseClickEvents();
 }
 
-void SliderThumbElement::detach(const AttachContext& context)
+void SliderThumbElement::willDetachRenderers()
 {
     if (m_inDragMode) {
         if (Frame* frame = document()->frame())
             frame->eventHandler().setCapturingMouseEventsNode(0);
     }
-    HTMLDivElement::detach(context);
 }
 
 HTMLInputElement* SliderThumbElement::hostInput() const
index 5236683..f5cd0c6 100644 (file)
@@ -54,7 +54,7 @@ public:
     virtual void defaultEventHandler(Event*);
     virtual bool willRespondToMouseMoveEvents() OVERRIDE;
     virtual bool willRespondToMouseClickEvents() OVERRIDE;
-    virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willDetachRenderers() OVERRIDE;
     virtual const AtomicString& shadowPseudoId() const;
     HTMLInputElement* hostInput() const;
     void setPositionFromPoint(const LayoutPoint&);
@@ -73,12 +73,6 @@ private:
     bool m_inDragMode;
 };
 
-inline SliderThumbElement::SliderThumbElement(Document* document)
-    : HTMLDivElement(HTMLNames::divTag, document)
-    , m_inDragMode(false)
-{
-}
-
 inline PassRefPtr<SliderThumbElement> SliderThumbElement::create(Document* document)
 {
     return adoptRef(new SliderThumbElement(document));
index 47aa330..613cca2 100644 (file)
@@ -50,6 +50,7 @@ inline SpinButtonElement::SpinButtonElement(Document* document, SpinButtonOwner&
     , m_pressStartingState(Indeterminate)
     , m_repeatingTimer(this, &SpinButtonElement::repeatingTimerFired)
 {
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<SpinButtonElement> SpinButtonElement::create(Document* document, SpinButtonOwner& spinButtonOwner)
@@ -63,10 +64,9 @@ const AtomicString& SpinButtonElement::shadowPseudoId() const
     return innerPseudoId;
 }
 
-void SpinButtonElement::detach(const AttachContext& context)
+void SpinButtonElement::willDetachRenderers()
 {
     releaseCapture();
-    HTMLDivElement::detach(context);
 }
 
 void SpinButtonElement::defaultEventHandler(Event* event)
index ba41c32..a6d3238 100644 (file)
@@ -70,7 +70,7 @@ private:
     SpinButtonElement(Document*, SpinButtonOwner&);
 
     virtual const AtomicString& shadowPseudoId() const;
-    virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willDetachRenderers() OVERRIDE;
     virtual bool isSpinButtonElement() const { return true; }
     virtual bool isDisabledFormControl() const OVERRIDE { return shadowHost() && shadowHost()->isDisabledFormControl(); }
     virtual bool matchesReadOnlyPseudoClass() const OVERRIDE;
index 3672f34..8ccb452 100644 (file)
@@ -65,7 +65,7 @@ RenderObject* TextControlInnerContainer::createRenderer(RenderArena* arena, Rend
 TextControlInnerElement::TextControlInnerElement(Document* document)
     : HTMLDivElement(divTag, document)
 {
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<TextControlInnerElement> TextControlInnerElement::create(Document* document)
@@ -84,7 +84,7 @@ PassRefPtr<RenderStyle> TextControlInnerElement::customStyleForRenderer()
 inline TextControlInnerTextElement::TextControlInnerTextElement(Document* document)
     : HTMLDivElement(divTag, document)
 {
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<TextControlInnerTextElement> TextControlInnerTextElement::create(Document* document)
@@ -182,6 +182,7 @@ inline SearchFieldCancelButtonElement::SearchFieldCancelButtonElement(Document*
     : HTMLDivElement(divTag, document)
     , m_capturing(false)
 {
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<SearchFieldCancelButtonElement> SearchFieldCancelButtonElement::create(Document* document)
@@ -195,16 +196,14 @@ const AtomicString& SearchFieldCancelButtonElement::shadowPseudoId() const
     return pseudoId;
 }
 
-void SearchFieldCancelButtonElement::detach(const AttachContext& context)
+void SearchFieldCancelButtonElement::willDetachRenderers()
 {
     if (m_capturing) {
         if (Frame* frame = document()->frame())
             frame->eventHandler().setCapturingMouseEventsNode(0);
     }
-    HTMLDivElement::detach(context);
 }
 
-
 void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
 {
     // If the element is visible, on mouseup, clear the value, and set selection
@@ -264,6 +263,7 @@ inline InputFieldSpeechButtonElement::InputFieldSpeechButtonElement(Document* do
     , m_state(Idle)
     , m_listenerId(0)
 {
+    setHasCustomStyleResolveCallbacks();
 }
 
 InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement()
@@ -404,15 +404,14 @@ void InputFieldSpeechButtonElement::setRecognitionResult(int, const SpeechInputR
         renderer()->repaint();
 }
 
-void InputFieldSpeechButtonElement::attach(const AttachContext& context)
+void InputFieldSpeechButtonElement::willAttachRenderers()
 {
     ASSERT(!m_listenerId);
     if (SpeechInput* input = SpeechInput::from(document()->page()))
         m_listenerId = input->registerListener(this);
-    HTMLDivElement::attach(context);
 }
 
-void InputFieldSpeechButtonElement::detach(const AttachContext& context)
+void InputFieldSpeechButtonElement::willDetachRenderers()
 {
     if (m_capturing) {
         if (Frame* frame = document()->frame())
@@ -425,8 +424,6 @@ void InputFieldSpeechButtonElement::detach(const AttachContext& context)
         speechInput()->unregisterListener(m_listenerId);
         m_listenerId = 0;
     }
-
-    HTMLDivElement::detach(context);
 }
 
 void InputFieldSpeechButtonElement::startSpeechInput()
index f6f5d6b..519a733 100644 (file)
@@ -91,7 +91,7 @@ public:
 private:
     SearchFieldCancelButtonElement(Document*);
     virtual const AtomicString& shadowPseudoId() const;
-    virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willDetachRenderers() OVERRIDE;
     virtual bool isMouseFocusable() const OVERRIDE { return false; }
 
     bool m_capturing;
@@ -112,7 +112,6 @@ public:
     static PassRefPtr<InputFieldSpeechButtonElement> create(Document*);
     virtual ~InputFieldSpeechButtonElement();
 
-    virtual void detach();
     virtual void defaultEventHandler(Event*);
     virtual bool willRespondToMouseClickEvents();
     virtual bool isInputFieldSpeechButtonElement() const { return true; }
@@ -131,7 +130,9 @@ private:
     void setState(SpeechInputState state);
     virtual const AtomicString& shadowPseudoId() const;
     virtual bool isMouseFocusable() const OVERRIDE { return false; }
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void willAttachRenderers() OVERRIDE;
+    virtual void willDetachRenderera) OVERRIDE;
+
 
     bool m_capturing;
     SpeechInputState m_state;
index 66e040a..58ef4df 100644 (file)
@@ -220,7 +220,7 @@ void resolveTree(Element* current, Change change)
 {
     ASSERT(change != Detach);
 
-    if (current->hasCustomStyleCallbacks()) {
+    if (current->hasCustomStyleResolveCallbacks()) {
         if (!current->willRecalcStyle(change))
             return;
     }
@@ -279,7 +279,7 @@ void resolveTree(Element* current, Change change)
     current->clearNeedsStyleRecalc();
     current->clearChildNeedsStyleRecalc();
     
-    if (current->hasCustomStyleCallbacks())
+    if (current->hasCustomStyleResolveCallbacks())
         current->didRecalcStyle(change);
 }
 
index f7f44f4..b0947b0 100644 (file)
@@ -53,7 +53,7 @@ using namespace HTMLNames;
 SVGElement::SVGElement(const QualifiedName& tagName, Document* document, ConstructionType constructionType)
     : StyledElement(tagName, document, constructionType)
 {
-    setHasCustomStyleCallbacks();
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<SVGElement> SVGElement::create(const QualifiedName& tagName, Document* document)
index 27e7274..9bd6d9f 100644 (file)
@@ -66,6 +66,7 @@ inline SVGImageElement::SVGImageElement(const QualifiedName& tagName, Document*
 {
     ASSERT(isSVGImageElement(this));
     registerAnimatedPropertiesForSVGImageElement();
+    setHasCustomStyleResolveCallbacks();
 }
 
 PassRefPtr<SVGImageElement> SVGImageElement::create(const QualifiedName& tagName, Document* document)
@@ -193,10 +194,8 @@ bool SVGImageElement::haveLoadedRequiredResources()
     return !externalResourcesRequiredBaseValue() || !m_imageLoader.hasPendingActivity();
 }
 
-void SVGImageElement::attach(const AttachContext& context)
+void SVGImageElement::didAttachRenderers()
 {
-    SVGGraphicsElement::attach(context);
-
     if (RenderSVGImage* imageObj = toRenderSVGImage(renderer())) {
         if (imageObj->imageResource()->hasImage())
             return;
index 6e5e732..9cd5793 100644 (file)
@@ -51,7 +51,7 @@ private:
     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
     virtual void svgAttributeChanged(const QualifiedName&);
 
-    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+    virtual void didAttachRenderers() OVERRIDE;
     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
 
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
index 55cfb4e..d0cbe70 100644 (file)
@@ -92,7 +92,7 @@ inline SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document* docu
     , m_needsShadowTreeRecreation(false)
     , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
 {
-    ASSERT(hasCustomStyleCallbacks());
+    ASSERT(hasCustomStyleResolveCallbacks());
     ASSERT(hasTagName(SVGNames::useTag));
     registerAnimatedPropertiesForSVGUseElement();
 }