Bug 137035 - Have DOMImplementation::document() and Element::attributes() return references
Summary: Have DOMImplementation::document() and Element::attributes() return references
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-23 11:46 PDT by Chris Dumez
Modified: 2014-09-23 12:53 PDT (History)
3 users (show)

See Also:


Attachments
Patch (5.78 KB, patch)
2014-09-23 12:00 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2014-09-23 11:46:10 PDT
Have DOMImplementation::document() and Element::attributes() return references instead of pointers as they can never return null.
Comment 1 Chris Dumez 2014-09-23 12:00:32 PDT
Created attachment 238556 [details]
Patch
Comment 2 Andreas Kling 2014-09-23 12:16:19 PDT
Comment on attachment 238556 [details]
Patch

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

Sweet! r=me

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2993
> -                $rootString  = "    Frame* root = js${interfaceName}->impl().frame();\n";
> +                $rootString  = "    Frame* root = WTF::getPtr(js${interfaceName}->impl().frame());\n";
>                  $rootString .= "    if (!root)\n";
>                  $rootString .= "        return false;\n";

It would be cool if we could avoid the null check if the root is a reference.
Although maybe the compiler takes care of that anyway.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2997
> -                $rootString  = "    Document* root = js${interfaceName}->impl().document();\n";
> +                $rootString  = "    Document* root = WTF::getPtr(js${interfaceName}->impl().document());\n";
>                  $rootString .= "    if (!root)\n";
>                  $rootString .= "        return false;\n";

Same comment.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3003
> -                $rootString  = "    Element* element = js${interfaceName}->impl().element();\n";
> +                $rootString  = "    Element* element = WTF::getPtr(js${interfaceName}->impl().element());\n";
>                  $rootString .= "    if (!element)\n";
>                  $rootString .= "        return false;\n";

Same comment.
Comment 3 Chris Dumez 2014-09-23 12:19:12 PDT
Comment on attachment 238556 [details]
Patch

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

>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2993
>>                  $rootString .= "        return false;\n";
> 
> It would be cool if we could avoid the null check if the root is a reference.
> Although maybe the compiler takes care of that anyway.

Yes, I thought about this as well. I am hoping the compiler is being smart here but I'll try and take a look soon.
Comment 4 WebKit Commit Bot 2014-09-23 12:53:16 PDT
Comment on attachment 238556 [details]
Patch

Clearing flags on attachment: 238556

Committed r173885: <http://trac.webkit.org/changeset/173885>
Comment 5 WebKit Commit Bot 2014-09-23 12:53:20 PDT
All reviewed patches have been landed.  Closing bug.