WebCore:
authorxan@webkit.org <xan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Nov 2010 19:15:04 +0000 (19:15 +0000)
committerxan@webkit.org <xan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Nov 2010 19:15:04 +0000 (19:15 +0000)
2010-11-24  Xan Lopez  <xlopez@igalia.com>

        Reviewed by Martin Robinson.

        [GTK] Make kit() methods return the proper type instead of gpointer
        https://bugs.webkit.org/show_bug.cgi?id=50034

        Change kit() methods to return proper type pointer.

        * bindings/gobject/WebKitDOMBinding.cpp: change implementions of
        kit methods.
        * bindings/gobject/WebKitDOMBinding.h: change their declarations.
        * bindings/scripts/CodeGeneratorGObject.pm: change the generated
        kit() methods.

WebKit/gtk:

2010-11-24  Xan Lopez  <xlopez@igalia.com>

        Reviewed by Martin Robinson.

        [GTK] Make kit() methods return the proper type instead of gpointer
        https://bugs.webkit.org/show_bug.cgi?id=50034

        * WebCoreSupport/EditorClientGtk.cpp:
        (WebKit::EditorClient::shouldDeleteRange): get rid of unneeded cast.
        (WebKit::EditorClient::shouldShowDeleteInterface): ditto.
        (WebKit::EditorClient::shouldBeginEditing): ditto.
        (WebKit::EditorClient::shouldEndEditing): ditto.
        (WebKit::EditorClient::shouldInsertText): ditto.
        (WebKit::EditorClient::shouldChangeSelectedRange): ditto.
        (WebKit::EditorClient::shouldApplyStyle): ditto.
        (WebKit::EditorClient::shouldInsertNode): ditto.
        * webkit/webkitprivate.cpp:
        (WebKit::kit): ditto.
        * webkit/webkitwebview.cpp:
        (webkit_web_view_get_dom_document): ditto.

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

WebCore/ChangeLog
WebCore/bindings/gobject/WebKitDOMBinding.cpp
WebCore/bindings/gobject/WebKitDOMBinding.h
WebCore/bindings/scripts/CodeGeneratorGObject.pm
WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
WebKit/gtk/webkit/webkitprivate.cpp
WebKit/gtk/webkit/webkitwebview.cpp

index 32d2f7c..b739402 100644 (file)
@@ -1,3 +1,18 @@
+2010-11-24  Xan Lopez  <xlopez@igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Make kit() methods return the proper type instead of gpointer
+        https://bugs.webkit.org/show_bug.cgi?id=50034
+
+        Change kit() methods to return proper type pointer.
+
+        * bindings/gobject/WebKitDOMBinding.cpp: change implementions of
+        kit methods.
+        * bindings/gobject/WebKitDOMBinding.h: change their declarations.
+        * bindings/scripts/CodeGeneratorGObject.pm: change the generated
+        kit() methods.
+
 2010-11-24  Martin Robinson  <mrobinson@igalia.com>
 
         Reviewed by Xan Lopez.
index a8a8956..a9b0897 100644 (file)
@@ -69,26 +69,26 @@ static gpointer createWrapper(Node* node)
     return DOMObjectCache::put(node, wrappedNode);
 }
 
-gpointer kit(Node* node)
+WebKitDOMNode* kit(Node* node)
 {
     if (!node)
         return 0;
 
     gpointer kitNode = DOMObjectCache::get(node);
     if (kitNode)
-        return kitNode;
+        return static_cast<WebKitDOMNode*>(kitNode);
 
-    return createWrapper(node);
+    return static_cast<WebKitDOMNode*>(createWrapper(node));
 }
 
-gpointer kit(Element* element)
+WebKitDOMElement* kit(Element* element)
 {
     if (!element)
         return 0;
 
     gpointer kitElement = DOMObjectCache::get(element);
     if (kitElement)
-        return kitElement;
+        return static_cast<WebKitDOMElement*>(kitElement);
 
     gpointer wrappedElement;
 
@@ -97,17 +97,17 @@ gpointer kit(Element* element)
     else
         wrappedElement = wrapElement(element);
 
-    return DOMObjectCache::put(element, wrappedElement);
+    return static_cast<WebKitDOMElement*>(DOMObjectCache::put(element, wrappedElement));
 }
 
-gpointer kit(Event* event)
+WebKitDOMEvent* kit(Event* event)
 {
     if (!event)
         return 0;
 
     gpointer kitEvent = DOMObjectCache::get(event);
     if (kitEvent)
-        return kitEvent;
+        return static_cast<WebKitDOMEvent*>(kitEvent);
 
     gpointer wrappedEvent;
 
@@ -118,7 +118,7 @@ gpointer kit(Event* event)
     else
         wrappedEvent = wrapEvent(event);
 
-    return DOMObjectCache::put(event, wrappedEvent);
+    return static_cast<WebKitDOMEvent*>(DOMObjectCache::put(event, wrappedEvent));
 }
 
 static gpointer wrapEventTarget(EventTarget* target)
@@ -138,14 +138,14 @@ static gpointer wrapEventTarget(EventTarget* target)
     return DOMObjectCache::put(target, wrappedTarget);
 }
 
-gpointer kit(WebCore::EventTarget* obj)
+WebKitDOMEventTarget* kit(WebCore::EventTarget* obj)
 {
     g_return_val_if_fail(obj, 0);
 
     if (gpointer ret = DOMObjectCache::get(obj))
-        return ret;
+        return static_cast<WebKitDOMEventTarget*>(ret);
 
-    return DOMObjectCache::put(obj, WebKit::wrapEventTarget(obj));
+    return static_cast<WebKitDOMEventTarget*>(DOMObjectCache::put(obj, WebKit::wrapEventTarget(obj)));
 }
 
 } // namespace WebKit
index 47594a6..fde47af 100644 (file)
@@ -25,6 +25,7 @@
 #define WebKitDOMBinding_h
 
 #include <glib.h>
+#include "webkit/webkitdomdefines.h"
 
 namespace WebCore {
 class Node;
@@ -34,10 +35,10 @@ class EventTarget;
 } // namespace WebCore
 
 namespace WebKit {
-gpointer kit(WebCore::Node* node);
-gpointer kit(WebCore::Element* element);
-gpointer kit(WebCore::Event* event);
-gpointer kit(WebCore::EventTarget* target);
+WebKitDOMNode* kit(WebCore::Node* node);
+WebKitDOMElement* kit(WebCore::Element* element);
+WebKitDOMEvent* kit(WebCore::Event* event);
+WebKitDOMEventTarget* kit(WebCore::EventTarget* target);
 } // namespace WebKit
 
 #endif // WebKitDOMBinding_h
index 4c93899..e2773b8 100644 (file)
@@ -985,7 +985,7 @@ sub GenerateFunction {
     bool ok = item->${functionSigName}(${callImplParams}${exceptions});
     if (ok)
     {
-        ${returnType} res = static_cast<${returnType}>(WebKit::kit($returnParamName));
+        ${returnType} res = WebKit::kit($returnParamName);
         return res;
     }
 EOF
@@ -1040,7 +1040,7 @@ EOF
     if ($returnType ne "void" && !$functionHasCustomReturn) {
         if ($functionSigType ne "DOMObject") {
             if ($returnValueIsGDOMType) {
-                push(@cBody, "    ${returnType} res = static_cast<${returnType}>(WebKit::kit(g_res.get()));\n");
+                push(@cBody, "    ${returnType} res = WebKit::kit(g_res.get());\n");
             }
         }
         if ($functionSigType eq "DOMObject") {
@@ -1252,7 +1252,7 @@ EOF
 
     if ($className ne "WebKitDOMNode") {
         $text = << "EOF";
-    gpointer
+    ${className}*
     kit(WebCore::${interfaceName}* node);
 
 EOF
@@ -1350,14 +1350,14 @@ sub Generate {
         my $converter = << "EOF";
 namespace WebKit {
     
-gpointer kit(WebCore::$interfaceName* obj)
+${className}* kit(WebCore::$interfaceName* obj)
 {
     g_return_val_if_fail(obj, 0);
 
     if (gpointer ret = DOMObjectCache::get(obj))
-        return ret;
+        return static_cast<${className}*>(ret);
 
-    return DOMObjectCache::put(obj, WebKit::wrap${interfaceName}(obj));
+    return static_cast<${className}*>(DOMObjectCache::put(obj, WebKit::wrap${interfaceName}(obj)));
 }
     
 } // namespace WebKit //
index b1d112b..d608e77 100644 (file)
@@ -2,6 +2,27 @@
 
         Reviewed by Martin Robinson.
 
+        [GTK] Make kit() methods return the proper type instead of gpointer
+        https://bugs.webkit.org/show_bug.cgi?id=50034
+
+        * WebCoreSupport/EditorClientGtk.cpp:
+        (WebKit::EditorClient::shouldDeleteRange): get rid of unneeded cast.
+        (WebKit::EditorClient::shouldShowDeleteInterface): ditto.
+        (WebKit::EditorClient::shouldBeginEditing): ditto.
+        (WebKit::EditorClient::shouldEndEditing): ditto.
+        (WebKit::EditorClient::shouldInsertText): ditto.
+        (WebKit::EditorClient::shouldChangeSelectedRange): ditto.
+        (WebKit::EditorClient::shouldApplyStyle): ditto.
+        (WebKit::EditorClient::shouldInsertNode): ditto.
+        * webkit/webkitprivate.cpp:
+        (WebKit::kit): ditto.
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_get_dom_document): ditto.
+
+2010-11-24  Xan Lopez  <xlopez@igalia.com>
+
+        Reviewed by Martin Robinson.
+
         Fix crashes in GTK+ bots. Use kit() instead of wrapFoo, otherwise
         the DOM objects won't be in the cache and we'll ASSERT when
         unreffing them.
index 2357c44..bd88480 100644 (file)
@@ -275,7 +275,7 @@ void EditorClient::setInputMethodState(bool active)
 bool EditorClient::shouldDeleteRange(Range* range)
 {
     gboolean accept = TRUE;
-    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(static_cast<WebKitDOMRange*>(kit(range))));
+    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(kit(range)));
     g_signal_emit_by_name(m_webView, "should-delete-range", kitRange.get(), &accept);
     return accept;
 }
@@ -283,7 +283,7 @@ bool EditorClient::shouldDeleteRange(Range* range)
 bool EditorClient::shouldShowDeleteInterface(HTMLElement* element)
 {
     gboolean accept = TRUE;
-    PlatformRefPtr<WebKitDOMHTMLElement> kitElement(adoptPlatformRef(static_cast<WebKitDOMHTMLElement*>(kit(element))));
+    PlatformRefPtr<WebKitDOMHTMLElement> kitElement(adoptPlatformRef(kit(element)));
     g_signal_emit_by_name(m_webView, "should-show-delete-interface-for-element", kitElement.get(), &accept);
     return accept;
 }
@@ -315,7 +315,7 @@ bool EditorClient::shouldBeginEditing(WebCore::Range* range)
     clearPendingComposition();
 
     gboolean accept = TRUE;
-    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(static_cast<WebKitDOMRange*>(kit(range))));
+    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(kit(range)));
     g_signal_emit_by_name(m_webView, "should-begin-editing", kitRange.get(), &accept);
     return accept;
 }
@@ -325,7 +325,7 @@ bool EditorClient::shouldEndEditing(WebCore::Range* range)
     clearPendingComposition();
 
     gboolean accept = TRUE;
-    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(static_cast<WebKitDOMRange*>(kit(range))));
+    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(kit(range)));
     g_signal_emit_by_name(m_webView, "should-end-editing", kitRange.get(), &accept);
     return accept;
 }
@@ -347,7 +347,7 @@ static WebKitInsertAction kit(EditorInsertAction action)
 bool EditorClient::shouldInsertText(const String& string, Range* range, EditorInsertAction action)
 {
     gboolean accept = TRUE;
-    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(static_cast<WebKitDOMRange*>(kit(range))));
+    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(kit(range)));
     g_signal_emit_by_name(m_webView, "should-insert-text", string.utf8().data(), kitRange.get(), kit(action), &accept);
     return accept;
 }
@@ -367,8 +367,8 @@ static WebKitSelectionAffinity kit(EAffinity affinity)
 bool EditorClient::shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity affinity, bool stillSelecting)
 {
     gboolean accept = TRUE;
-    PlatformRefPtr<WebKitDOMRange> kitFromRange(fromRange ? adoptPlatformRef(static_cast<WebKitDOMRange*>(kit(fromRange))) : 0);
-    PlatformRefPtr<WebKitDOMRange> kitToRange(toRange ? adoptPlatformRef(static_cast<WebKitDOMRange*>(kit(toRange))) : 0);
+    PlatformRefPtr<WebKitDOMRange> kitFromRange(fromRange ? adoptPlatformRef(kit(fromRange)) : 0);
+    PlatformRefPtr<WebKitDOMRange> kitToRange(toRange ? adoptPlatformRef(kit(toRange)) : 0);
     g_signal_emit_by_name(m_webView, "should-change-selected-range", kitFromRange.get(), kitToRange.get(),
                           kit(affinity), stillSelecting, &accept);
     return accept;
@@ -377,8 +377,8 @@ bool EditorClient::shouldChangeSelectedRange(Range* fromRange, Range* toRange, E
 bool EditorClient::shouldApplyStyle(WebCore::CSSStyleDeclaration* declaration, WebCore::Range* range)
 {
     gboolean accept = TRUE;
-    PlatformRefPtr<WebKitDOMCSSStyleDeclaration> kitDeclaration(static_cast<WebKitDOMCSSStyleDeclaration*>(static_cast<WebKitDOMCSSStyleDeclaration*>(kit(declaration))));
-    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(static_cast<WebKitDOMRange*>(static_cast<WebKitDOMRange*>(kit(range)))));
+    PlatformRefPtr<WebKitDOMCSSStyleDeclaration> kitDeclaration(kit(declaration));
+    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(kit(range)));
     g_signal_emit_by_name(m_webView, "should-apply-style", kitDeclaration.get(), kitRange.get(), &accept);
     return accept;
 }
@@ -548,8 +548,8 @@ void EditorClient::redo()
 bool EditorClient::shouldInsertNode(Node* node, Range* range, EditorInsertAction action)
 {
     gboolean accept = TRUE;
-    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(static_cast<WebKitDOMRange*>(kit(range))));
-    PlatformRefPtr<WebKitDOMNode> kitNode(adoptPlatformRef(static_cast<WebKitDOMNode*>(kit(node))));
+    PlatformRefPtr<WebKitDOMRange> kitRange(adoptPlatformRef(kit(range)));
+    PlatformRefPtr<WebKitDOMNode> kitNode(adoptPlatformRef(kit(node)));
     g_signal_emit_by_name(m_webView, "should-insert-node", kitNode.get(), kitRange.get(), kit(action), &accept);
     return accept;
 }
index aa3d3da..b359cb1 100644 (file)
@@ -173,7 +173,7 @@ WebKitHitTestResult* kit(const WebCore::HitTestResult& result)
         context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
 
     if (result.innerNonSharedNode())
-        node = static_cast<WebKitDOMNode*>(kit(result.innerNonSharedNode()));
+        node = kit(result.innerNonSharedNode());
 
     return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT,
                                                "link-uri", linkURI.get(),
index 8e4a202..0c6b20c 100644 (file)
@@ -4877,7 +4877,7 @@ webkit_web_view_get_dom_document(WebKitWebView* webView)
     if (!doc)
         return 0;
 
-    return static_cast<WebKitDOMDocument*>(kit(doc));
+    return kit(doc);
 }
 
 /**