Bug 129145 - [GTK] webkit_dom_range_compare_boundary_points fails when 0 is passed as how parameter
Summary: [GTK] webkit_dom_range_compare_boundary_points fails when 0 is passed as how ...
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2014-02-21 01:57 PST by Tomas Popela
Modified: 2014-03-03 02:11 PST (History)
3 users (show)

See Also:

Proposed patch (2.43 KB, patch)
2014-02-21 02:06 PST, Tomas Popela
cgarcia: review-
cgarcia: commit-queue-
Details | Formatted Diff | Diff
Proposed patch v2 (2.88 KB, patch)
2014-03-03 01:23 PST, Tomas Popela
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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

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.