Bug 127812 - Simplify WebFrame::isMainFrame
Summary: Simplify WebFrame::isMainFrame
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-28 15:51 PST by Anders Carlsson
Modified: 2014-01-29 10:06 PST (History)
0 users

See Also:


Attachments
Patch (1.32 KB, patch)
2014-01-28 15:51 PST, Anders Carlsson
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Carlsson 2014-01-28 15:51:03 PST
Simplify WebFrame::isMainFrame
Comment 1 Anders Carlsson 2014-01-28 15:51:30 PST
Created attachment 222520 [details]
Patch
Comment 2 Sergio Correia (qrwteyrutiyoup) 2014-01-28 16:05:27 PST
Comment on attachment 222520 [details]
Patch

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

> Source/WebKit2/WebProcess/WebPage/WebFrame.cpp:372
> +    return m_coreFrame->isMainFrame();

maybe a ternary here would be cleaner?
return m_coreFrame ? m_coreFrame->isMainFrame() : false;
Comment 3 Anders Carlsson 2014-01-28 16:08:07 PST
(In reply to comment #2)
> (From update of attachment 222520 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=222520&action=review
> 
> > Source/WebKit2/WebProcess/WebPage/WebFrame.cpp:372
> > +    return m_coreFrame->isMainFrame();
> 
> maybe a ternary here would be cleaner?
> return m_coreFrame ? m_coreFrame->isMainFrame() : false;

I think the explicit null check is easier to follow.
Comment 4 Anders Carlsson 2014-01-28 16:11:27 PST
Committed r162980: <http://trac.webkit.org/changeset/162980>
Comment 5 Darin Adler 2014-01-29 10:06:49 PST
Comment on attachment 222520 [details]
Patch

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

>>> Source/WebKit2/WebProcess/WebPage/WebFrame.cpp:372
>>> +    return m_coreFrame->isMainFrame();
>> 
>> maybe a ternary here would be cleaner?
>> return m_coreFrame ? m_coreFrame->isMainFrame() : false;
> 
> I think the explicit null check is easier to follow.

I think that && is easier to follow than the if statement or the ternary.

    return m_coreFrame && m_coreFrame->isMainFrame();

But tastes may differ, I suppose.