Bug 129145

Summary: [GTK] webkit_dom_range_compare_boundary_points fails when 0 is passed as how parameter
Product: WebKit Reporter: Tomas Popela <tpopela>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, cgarcia, commit-queue
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch
cgarcia: review-, cgarcia: commit-queue-
Proposed patch v2 none

Description Tomas Popela 2014-02-21 01:57:16 PST
In GObject DOM API there is a webkit_dom_range_compare_boundary_points function ( https://developer.mozilla.org/en-US/docs/Web/API/Range.compareBoundaryPoints ) that takes second argument "how" that's type is CompareHow (in GObject DOM API it is defined as gushort). CompareHow is enum defined in http://trac.webkit.org/browser/trunk/Source/WebCore/dom/Range.h#L87 . The problem is that START_TO_START is defined first so it has value 0, but the generator is not counting with it and it generates g_return_val_if_fail (how, 0) in WebKitDOMRange.cpp. Thus we will get a nice runtime warning: CRITICAL **: gshort webkit_dom_range_compare_boundary_points(WebKitDOMRange*, gushort, WebKitDOMRange*, GError**): assertion 'how' failed . So the generator should be aware of CompareHow while generating the g_return_* macros.
Comment 1 Tomas Popela 2014-02-21 02:06:56 PST
Created attachment 224845 [details]
Proposed patch
Comment 2 Carlos Garcia Campos 2014-02-21 02:27:44 PST
Comment on attachment 224845 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=224845&action=review

Thanks for the patch. I think we should add a test case for this.

> Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm:897
> +        if ($paramIDLType eq "CompareHow") {
> +           return "";
> +        }

This is not correct, this method should not be called for non pointer types. We are currently checking whether the param type is primitve or not, but we should actually check that is a pointer type.

my $paramTypeIsPrimitive = $codeGenerator->IsPrimitiveType($paramIDLType);
my $paramIsGDOMType = IsGDOMClassType($paramIDLType);
if (!$paramTypeIsPrimitive) {
    $gReturnMacro = GetGReturnMacro($paramName, $paramIDLType, $returnType, $functionName);
    push(@cBody, $gReturnMacro);
}

We should use 

my $paramTypeIsPointer = !$codeGenerator->IsNonPointerType($paramIDLType);

You can also remove the paramIsGDOMType that is unused :-)
Comment 3 Tomas Popela 2014-03-03 01:23:37 PST
Created attachment 225638 [details]
Proposed patch v2
Comment 4 Carlos Garcia Campos 2014-03-03 01:32:23 PST
Comment on attachment 225638 [details]
Proposed patch v2

Thanks!
Comment 5 WebKit Commit Bot 2014-03-03 02:11:18 PST
Comment on attachment 225638 [details]
Proposed patch v2

Clearing flags on attachment: 225638

Committed r164980: <http://trac.webkit.org/changeset/164980>
Comment 6 WebKit Commit Bot 2014-03-03 02:11:21 PST
All reviewed patches have been landed.  Closing bug.