Title: [181643] trunk/Source/WebCore
Revision
181643
Author
[email protected]
Date
2015-03-17 05:22:06 -0700 (Tue, 17 Mar 2015)

Log Message

[GTK] Wrong transfer annotations used in GObject DOM bindings
https://bugs.webkit.org/show_bug.cgi?id=142780

Reviewed by Gustavo Noronha Silva.

We are using transfer none for all methods returning a GObject DOM
Object. That's not true. Only objects derived from Node are
automatically released by the DOM object cache and can be transfer
none. All other objects are added to the cache only to avoid
creating the same wrapper twice for the same core object, but
caller should release the returned reference.

* bindings/gobject/WebKitDOMCustomUnstable.h:
* bindings/scripts/CodeGeneratorGObject.pm:
(GetTransferTypeForReturnType):
(GenerateFunction):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (181642 => 181643)


--- trunk/Source/WebCore/ChangeLog	2015-03-17 12:18:18 UTC (rev 181642)
+++ trunk/Source/WebCore/ChangeLog	2015-03-17 12:22:06 UTC (rev 181643)
@@ -1,5 +1,24 @@
 2015-03-17  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Wrong transfer annotations used in GObject DOM bindings
+        https://bugs.webkit.org/show_bug.cgi?id=142780
+
+        Reviewed by Gustavo Noronha Silva.
+
+        We are using transfer none for all methods returning a GObject DOM
+        Object. That's not true. Only objects derived from Node are
+        automatically released by the DOM object cache and can be transfer
+        none. All other objects are added to the cache only to avoid
+        creating the same wrapper twice for the same core object, but
+        caller should release the returned reference.
+
+        * bindings/gobject/WebKitDOMCustomUnstable.h:
+        * bindings/scripts/CodeGeneratorGObject.pm:
+        (GetTransferTypeForReturnType):
+        (GenerateFunction):
+
+2015-03-17  Carlos Garcia Campos  <[email protected]>
+
         [GTK] WebKitDOM objects leaking
         https://bugs.webkit.org/show_bug.cgi?id=118788
 

Modified: trunk/Source/WebCore/bindings/gobject/WebKitDOMCustomUnstable.h (181642 => 181643)


--- trunk/Source/WebCore/bindings/gobject/WebKitDOMCustomUnstable.h	2015-03-17 12:18:18 UTC (rev 181642)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMCustomUnstable.h	2015-03-17 12:22:06 UTC (rev 181643)
@@ -29,7 +29,7 @@
  * webkit_dom_dom_window_get_webkit_namespace:
  * @self: A #WebKitDOMDOMWindow
  *
- * Returns: (transfer none): A #WebKitDOMWebKitNamespace
+ * Returns: (transfer full): A #WebKitDOMWebKitNamespace
  *
  * Stability: Unstable
  * Since: 2.8
@@ -42,7 +42,7 @@
  * @self: A #WebKitDOMUserMessageHandlersNamespace
  * @name: a #gchar
  *
- * Returns: (transfer none): A #WebKitDOMUserMessageHandler
+ * Returns: (transfer full): A #WebKitDOMUserMessageHandler
  *
  * Stability: Unstable
  * Since: 2.8

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm (181642 => 181643)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm	2015-03-17 12:18:18 UTC (rev 181642)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm	2015-03-17 12:22:06 UTC (rev 181643)
@@ -49,6 +49,29 @@
                     "NodeIterator" => 1, "TreeWalker" => 1, "AbstractView" => 1, "Blob" => 1, "DOMTokenList" => 1,
                     "HTMLCollection" => 1, "TextTrackCue" => 1);
 
+# Only objects derived from Node are released by the DOM object cache and can be
+# transfer none. Ideally we could use GetBaseClass with the parent type to check
+# whether it's Node, but unfortunately we only have the name of the return type,
+# and we can't know its parent base class. Since there are fewer classes in the
+# API that are not derived from Node, we will list them here to decide the
+# transfer type.
+my %transferFullTypeHash = ("AudioTrack" => 1, "AudioTrackList" => 1, "BarProp" => 1, "BatteryManager" => 1,
+    "CSSRuleList" => 1, "CSSStyleDeclaration" => 1, "CSSStyleSheet" => 1,
+    "DOMApplicationCache" => 1, "DOMMimeType" => 1, "DOMMimeTypeArray" => 1, "DOMNamedFlowCollection" => 1,
+    "DOMPlugin" => 1, "DOMPluginArray" => 1, "DOMSecurityPolicy" => 1,
+    "DOMSelection" => 1, "DOMSettableTokenList" => 1, "DOMStringList" => 1,
+    "DOMWindow" => 1, "DOMWindowCSS" => 1, "EventTarget" => 1,
+    "File" => 1, "FileList" => 1, "Gamepad" => 1, "GamepadList" => 1,
+    "Geolocation" => 1, "HTMLOptionsCollection" => 1, "History" => 1,
+    "KeyboardEvent" => 1, "MediaError" => 1, "MediaController" => 1,
+    "MouseEvent" => 1, "MediaQueryList" => 1, "Navigator" => 1, "NodeFilter" => 1,
+    "Performance" => 1, "PerformanceEntry" => 1, "PerformanceEntryList" => 1, "PerformanceNavigation" => 1, "PerformanceTiming" => 1,
+    "Range" => 1, "Screen" => 1, "SpeechSynthesis" => 1, "SpeechSynthesisVoice" => 1,
+    "Storage" => 1, "StyleMedia" => 1, "TextTrack" => 1, "TextTrackCueList" => 1,
+    "TimeRanges" => 1, "Touch" => 1, "UIEvent" => 1, "UserMessageHandler" => 1, "UserMessageHandlersNamespace" => 1,
+    "ValidityState" => 1, "VideoTrack" => 1, "WebKitNamedFlow" => 1,
+    "WebKitNamespace" => 1, "WebKitPoint" => 1, "WheelEvent" => 1, "XPathNSResolver" => 1);
+
 # List of function parameters that are allowed to be NULL
 my $canBeNullParams = {
     'webkit_dom_document_create_attribute_ns' => ['namespaceURI'],
@@ -945,6 +968,20 @@
     return "${name}_type";
 }
 
+sub GetTransferTypeForReturnType {
+    my $returnType = shift;
+
+    # Node is always transfer none.
+    return "none" if $returnType eq "Node";
+
+    # Any base class but Node is transfer full.
+    return "full" if IsBaseType($returnType);
+
+    # Any other class not derived from Node is transfer full.
+    return "full" if $transferFullTypeHash{$returnType};
+    return "none";
+}
+
 sub GenerateFunction {
     my ($object, $interfaceName, $function, $prefix, $parentNode) = @_;
 
@@ -1042,7 +1079,8 @@
     my $hasReturnTag = 0;
     $returnTypeName =~ s/\*$//;
     if ($returnValueIsGDOMType) {
-        push(@functionHeader, " * Returns: (transfer none): A #${returnTypeName}");
+        my $transferType = GetTransferTypeForReturnType($functionSigType);
+        push(@functionHeader, " * Returns: (transfer $transferType): A #${returnTypeName}");
         $hasReturnTag = 1;
     } elsif ($returnType ne "void") {
         push(@functionHeader, " * Returns: A #${returnTypeName}");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to