Title: [160926] trunk/Source/WebCore
Revision
160926
Author
ander...@apple.com
Date
2013-12-20 14:15:13 -0800 (Fri, 20 Dec 2013)

Log Message

Node post attach callbacks should use references
https://bugs.webkit.org/show_bug.cgi?id=126081

Reviewed by Antti Koivisto.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::queuePostAttachCallback):
(WebCore::ContainerNode::dispatchPostAttachCallbacks):
(WebCore::needsStyleRecalcCallback):
(WebCore::ContainerNode::scheduleSetNeedsStyleRecalc):
* dom/ContainerNode.h:
* html/HTMLFormControlElement.cpp:
(WebCore::focusPostAttach):
(WebCore::HTMLFormControlElement::didAttachRenderers):
(WebCore::updateFromElementCallback):
(WebCore::HTMLFormControlElement::didRecalcStyle):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::didAttachRenderers):
(WebCore::HTMLPlugInImageElement::updateWidgetCallback):
(WebCore::HTMLPlugInImageElement::startLoadingImageCallback):
* html/HTMLPlugInImageElement.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (160925 => 160926)


--- trunk/Source/WebCore/ChangeLog	2013-12-20 22:04:31 UTC (rev 160925)
+++ trunk/Source/WebCore/ChangeLog	2013-12-20 22:15:13 UTC (rev 160926)
@@ -1,3 +1,27 @@
+2013-12-20  Anders Carlsson  <ander...@apple.com>
+
+        Node post attach callbacks should use references
+        https://bugs.webkit.org/show_bug.cgi?id=126081
+
+        Reviewed by Antti Koivisto.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::queuePostAttachCallback):
+        (WebCore::ContainerNode::dispatchPostAttachCallbacks):
+        (WebCore::needsStyleRecalcCallback):
+        (WebCore::ContainerNode::scheduleSetNeedsStyleRecalc):
+        * dom/ContainerNode.h:
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::focusPostAttach):
+        (WebCore::HTMLFormControlElement::didAttachRenderers):
+        (WebCore::updateFromElementCallback):
+        (WebCore::HTMLFormControlElement::didRecalcStyle):
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::didAttachRenderers):
+        (WebCore::HTMLPlugInImageElement::updateWidgetCallback):
+        (WebCore::HTMLPlugInImageElement::startLoadingImageCallback):
+        * html/HTMLPlugInImageElement.h:
+
 2013-12-20  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Extract CommandLineAPI into its own InjectedScriptModule

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (160925 => 160926)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2013-12-20 22:04:31 UTC (rev 160925)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2013-12-20 22:15:13 UTC (rev 160926)
@@ -797,12 +797,12 @@
     --s_attachDepth;
 }
 
-void ContainerNode::queuePostAttachCallback(NodeCallback callback, Node* node, unsigned callbackData)
+void ContainerNode::queuePostAttachCallback(NodeCallback callback, Node& node, unsigned callbackData)
 {
     if (!s_postAttachCallbackQueue)
         s_postAttachCallbackQueue = new NodeCallbackQueue;
     
-    s_postAttachCallbackQueue->append(CallbackInfo(callback, CallbackParameters(node, callbackData)));
+    s_postAttachCallbackQueue->append(CallbackInfo(callback, CallbackParameters(&node, callbackData)));
 }
 
 bool ContainerNode::postAttachCallbacksAreSuspended()
@@ -819,20 +819,20 @@
         NodeCallback callback = info.first;
         CallbackParameters params = info.second;
 
-        callback(params.first.get(), params.second);
+        callback(*params.first, params.second);
     }
     s_postAttachCallbackQueue->clear();
 }
 
-static void needsStyleRecalcCallback(Node* node, unsigned data)
+static void needsStyleRecalcCallback(Node& node, unsigned data)
 {
-    node->setNeedsStyleRecalc(static_cast<StyleChangeType>(data));
+    node.setNeedsStyleRecalc(static_cast<StyleChangeType>(data));
 }
 
 void ContainerNode::scheduleSetNeedsStyleRecalc(StyleChangeType changeType)
 {
     if (postAttachCallbacksAreSuspended())
-        queuePostAttachCallback(needsStyleRecalcCallback, this, static_cast<unsigned>(changeType));
+        queuePostAttachCallback(needsStyleRecalcCallback, *this, static_cast<unsigned>(changeType));
     else
         setNeedsStyleRecalc(changeType);
 }

Modified: trunk/Source/WebCore/dom/ContainerNode.h (160925 => 160926)


--- trunk/Source/WebCore/dom/ContainerNode.h	2013-12-20 22:04:31 UTC (rev 160925)
+++ trunk/Source/WebCore/dom/ContainerNode.h	2013-12-20 22:15:13 UTC (rev 160926)
@@ -35,7 +35,7 @@
 class FloatPoint;
 class RenderElement;
 
-typedef void (*NodeCallback)(Node*, unsigned);
+typedef void (*NodeCallback)(Node&, unsigned);
 
 namespace Private { 
     template<class GenericNode, class GenericNodeContainer>
@@ -141,7 +141,7 @@
 protected:
     explicit ContainerNode(Document*, ConstructionType = CreateContainer);
 
-    static void queuePostAttachCallback(NodeCallback, Node*, unsigned = 0);
+    static void queuePostAttachCallback(NodeCallback, Node&, unsigned = 0);
     static bool postAttachCallbacksAreSuspended();
 
     template<class GenericNode, class GenericNodeContainer>

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (160925 => 160926)


--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2013-12-20 22:04:31 UTC (rev 160925)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2013-12-20 22:15:13 UTC (rev 160926)
@@ -202,10 +202,10 @@
     return false;
 }
 
-static void focusPostAttach(Node* element, unsigned)
+static void focusPostAttach(Node& element, unsigned)
 { 
-    toElement(element)->focus(); 
-    element->deref(); 
+    toElement(element).focus();
+    element.deref();
 }
 
 void HTMLFormControlElement::didAttachRenderers()
@@ -219,7 +219,7 @@
     if (shouldAutofocus(this)) {
         setAutofocused();
         ref();
-        queuePostAttachCallback(focusPostAttach, this);
+        queuePostAttachCallback(focusPostAttach, *this);
     }
 }
 
@@ -287,9 +287,9 @@
     return m_isRequired;
 }
 
-static void updateFromElementCallback(Node* node, unsigned)
+static void updateFromElementCallback(Node& node, unsigned)
 {
-    if (auto renderer = toHTMLFormControlElement(node)->renderer())
+    if (auto renderer = toHTMLFormControlElement(node).renderer())
         renderer->updateFromElement();
 }
 
@@ -298,7 +298,7 @@
     // updateFromElement() can cause the selection to change, and in turn
     // trigger synchronous layout, so it must not be called during style recalc.
     if (renderer())
-        queuePostAttachCallback(updateFromElementCallback, this);
+        queuePostAttachCallback(updateFromElementCallback, *this);
 }
 
 bool HTMLFormControlElement::supportsFocus() const

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (160925 => 160926)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-12-20 22:04:31 UTC (rev 160925)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-12-20 22:15:13 UTC (rev 160926)
@@ -247,14 +247,14 @@
 void HTMLPlugInImageElement::didAttachRenderers()
 {
     if (!isImageType()) {
-        queuePostAttachCallback(&HTMLPlugInImageElement::updateWidgetCallback, this);
+        queuePostAttachCallback(&HTMLPlugInImageElement::updateWidgetCallback, *this);
         return;
     }
     if (!renderer() || useFallbackContent())
         return;
 
     // Image load might complete synchronously and cause us to re-enter attach.
-    queuePostAttachCallback(&HTMLPlugInImageElement::startLoadingImageCallback, this);
+    queuePostAttachCallback(&HTMLPlugInImageElement::startLoadingImageCallback, *this);
 }
 
 void HTMLPlugInImageElement::willDetachRenderers()
@@ -334,9 +334,9 @@
     return m_customStyleForPageCache;
 }
 
-void HTMLPlugInImageElement::updateWidgetCallback(Node* node, unsigned)
+void HTMLPlugInImageElement::updateWidgetCallback(Node& node, unsigned)
 {
-    toHTMLPlugInImageElement(node)->updateWidgetIfNecessary();
+    toHTMLPlugInImageElement(node).updateWidgetIfNecessary();
 }
 
 void HTMLPlugInImageElement::startLoadingImage()
@@ -346,9 +346,9 @@
     m_imageLoader->updateFromElement();
 }
 
-void HTMLPlugInImageElement::startLoadingImageCallback(Node* node, unsigned)
+void HTMLPlugInImageElement::startLoadingImageCallback(Node& node, unsigned)
 {
-    toHTMLPlugInImageElement(node)->startLoadingImage();
+    toHTMLPlugInImageElement(node).startLoadingImage();
 }
 
 void HTMLPlugInImageElement::updateSnapshot(PassRefPtr<Image> image)

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (160925 => 160926)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2013-12-20 22:04:31 UTC (rev 160925)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2013-12-20 22:15:13 UTC (rev 160926)
@@ -113,8 +113,8 @@
     String m_url;
     URL m_loadedUrl;
 
-    static void updateWidgetCallback(Node*, unsigned);
-    static void startLoadingImageCallback(Node*, unsigned);
+    static void updateWidgetCallback(Node&, unsigned);
+    static void startLoadingImageCallback(Node&, unsigned);
 
     virtual void didAttachRenderers() OVERRIDE;
     virtual void willDetachRenderers() OVERRIDE;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to