Bug 137035

Summary: Have DOMImplementation::document() and Element::attributes() return references
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, kling, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

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.