Title: [196474] trunk/Source/WebCore
Revision
196474
Author
[email protected]
Date
2016-02-12 08:37:13 -0800 (Fri, 12 Feb 2016)

Log Message

[GTK] Properly handle classes inheriting from EventTarget
https://bugs.webkit.org/show_bug.cgi?id=154158

Reviewed by Michael Catanzaro.

Instead of removing its parent we now handle the case of classes
having EventTarget as parent to make them implement the interface
instead.

* bindings/scripts/CodeGeneratorGObject.pm:
(ShouldBeExposedAsInterface): Whether the parent given class
should be exposed as an interface instead of a parent class.
(GetParentClassName): Return Object as parent for classes having
a parent that should be exposed as an interface.
(GetParentImplClassName): Ditto.
(GetBaseClass): Ditto.
(GetParentGObjType): Ditto.
(SkipFunction): Add FIXME comment.
(ImplementsInterface): Helper function to check if a class
implements the given interface.
(GenerateCFile): Check whether the class implements EventTarget to
generate the interface implementation.
(GenerateInterface): Do not remove the parent class when it's EventTarget.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (196473 => 196474)


--- trunk/Source/WebCore/ChangeLog	2016-02-12 15:49:24 UTC (rev 196473)
+++ trunk/Source/WebCore/ChangeLog	2016-02-12 16:37:13 UTC (rev 196474)
@@ -1,3 +1,29 @@
+2016-02-12  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Properly handle classes inheriting from EventTarget
+        https://bugs.webkit.org/show_bug.cgi?id=154158
+
+        Reviewed by Michael Catanzaro.
+
+        Instead of removing its parent we now handle the case of classes
+        having EventTarget as parent to make them implement the interface
+        instead.
+
+        * bindings/scripts/CodeGeneratorGObject.pm:
+        (ShouldBeExposedAsInterface): Whether the parent given class
+        should be exposed as an interface instead of a parent class.
+        (GetParentClassName): Return Object as parent for classes having
+        a parent that should be exposed as an interface.
+        (GetParentImplClassName): Ditto.
+        (GetBaseClass): Ditto.
+        (GetParentGObjType): Ditto.
+        (SkipFunction): Add FIXME comment.
+        (ImplementsInterface): Helper function to check if a class
+        implements the given interface.
+        (GenerateCFile): Check whether the class implements EventTarget to
+        generate the interface implementation.
+        (GenerateInterface): Do not remove the parent class when it's EventTarget.
+
 2016-02-12  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r196470.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm (196473 => 196474)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm	2016-02-12 15:49:24 UTC (rev 196473)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm	2016-02-12 16:37:13 UTC (rev 196474)
@@ -119,18 +119,26 @@
  */
 EOF
 
+sub ShouldBeExposedAsInterface {
+    my $interface = shift;
+
+    return $interface eq "EventTarget";
+}
+
 sub GetParentClassName {
     my $interface = shift;
+    my $parent = $interface->parent;
 
-    return "WebKitDOMObject" unless $interface->parent;
-    return "WebKitDOM" . $interface->parent;
+    return "WebKitDOMObject" unless $parent and !ShouldBeExposedAsInterface($parent);
+    return "WebKitDOM" . $parent;
 }
 
 sub GetParentImplClassName {
     my $interface = shift;
+    my $parent = $interface->parent;
 
-    return "Object" unless $interface->parent;
-    return $interface->parent;
+    return "Object" unless $parent and !ShouldBeExposedAsInterface($parent);
+    return $parent;
 }
 
 sub IsBaseType
@@ -147,6 +155,7 @@
     $interface = shift;
 
     return $parent if $parent eq "Object" or IsBaseType($parent);
+    return "Object" if ShouldBeExposedAsInterface($parent);
     return "Event" if $codeGenerator->InheritsInterface($interface, "Event");
     return "CSSValue" if $parent eq "SVGColor" or $parent eq "CSSValueList";
     return "Node";
@@ -208,9 +217,10 @@
 
 sub GetParentGObjType {
     my $interface = shift;
+    my $parent = $interface->parent;
 
-    return "WEBKIT_DOM_TYPE_OBJECT" unless $interface->parent;
-    return "WEBKIT_DOM_TYPE_" . uc(decamelize(($interface->parent)));
+    return "WEBKIT_DOM_TYPE_OBJECT" unless $parent and !ShouldBeExposedAsInterface($parent);
+    return "WEBKIT_DOM_TYPE_" . uc(decamelize(($parent)));
 }
 
 sub GetClassName {
@@ -326,6 +336,7 @@
     }
 
     # Skip dispatch_event methods.
+    # FIXME: This can be removed once all classes implementing EventTarget inherit from it instead.
     if ($parentNode->extendedAttributes->{"EventTarget"} && $function->signature->name eq "dispatchEvent") {
         return 1;
     }
@@ -1490,10 +1501,20 @@
     }
 }
 
+sub ImplementsInterface {
+    my $interface = shift;
+    my $implementInterface = shift;
+
+    # FIXME: Check only the parent class once all classes implementing EventTarget inherit from it instead.
+    return 1 if $interface->parent and $interface->parent eq implementInterface and ShouldBeExposedAsInterface($interface->parent);
+    return 1 if $interface->extendedAttributes->{$implementInterface};
+    return 0;
+}
+
 sub GenerateCFile {
     my ($object, $interfaceName, $parentClassName, $parentGObjType, $interface) = @_;
 
-    if ($interface->extendedAttributes->{"EventTarget"}) {
+    if (ImplementsInterface($interface, "EventTarget")) {
         $object->GenerateEventTargetIface($interface);
     }
 
@@ -1921,9 +1942,6 @@
 sub GenerateInterface {
     my ($object, $interface, $defines) = @_;
 
-    # FIXME: GObject bindings do not support EventTarget as base class.
-    $interface->parent(undef) if $interface->parent && $interface->parent eq "EventTarget";
-
     # Set up some global variables
     $className = GetClassName($interface->name);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to