Bug 119435 - FrameView should have an isMainFrameView()
Summary: FrameView should have an isMainFrameView()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords:
Depends on: 119861
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-02 01:11 PDT by Tim Horton
Modified: 2013-08-15 13:53 PDT (History)
5 users (show)

See Also:


Attachments
patch (6.77 KB, patch)
2013-08-02 01:13 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
more places (10.79 KB, patch)
2013-08-02 03:26 PDT, Tim Horton
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Horton 2013-08-02 01:11:22 PDT
There's a lot of "m_frame && m_frame->page() && m_frame->page()->mainFrame() == m_frame".

Also I have already (maybe twice) made the mistake of not doing the requisite null-checks.
Comment 1 Tim Horton 2013-08-02 01:13:28 PDT
Created attachment 207992 [details]
patch

Maybe there's some compelling reason that we haven't done this before? I don't know, but I'd love to!
Comment 2 zalan 2013-08-02 02:11:47 PDT
Yay. I wanted to do this for such a long time :) (I was a bit hesitant though, whether WebCore::Frame should have an isMainFrame() function instead (copy what WK2 already has) and use that in FrameView (and in other classes))

Anyway there are a few more places where you check for isMainFrameView()

FrameView::setFrameRect()
FrameView::performPostLayoutTasks()
FrameView::pagination()
FrameView::paintOverhangAreas()
Comment 3 Tim Horton 2013-08-02 03:22:18 PDT
(In reply to comment #2)
> Yay. I wanted to do this for such a long time :) (I was a bit hesitant though, whether WebCore::Frame should have an isMainFrame() function instead (copy what WK2 already has) and use that in FrameView (and in other classes))
> 
> Anyway there are a few more places where you check for isMainFrameView()
> 
> FrameView::setFrameRect()
> FrameView::performPostLayoutTasks()
> FrameView::pagination()
> FrameView::paintOverhangAreas()

There are even more than that! I will post a new patch in a moment.
Comment 4 Tim Horton 2013-08-02 03:26:42 PDT
Created attachment 207997 [details]
more places
Comment 5 Simon Fraser (smfr) 2013-08-02 10:59:19 PDT
Comment on attachment 207997 [details]
more places

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

> Source/WebCore/page/FrameView.cpp:427
> +bool FrameView::isMainFrameView() const
> +{
> +    return m_frame && m_frame->page() && m_frame->page()->mainFrame() == m_frame;
> +}
> +

Does this do the right thing for a page in the page cache? What is the right thing?
Comment 6 Brady Eidson 2013-08-02 12:29:49 PDT
(In reply to comment #5)
> (From update of attachment 207997 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207997&action=review
> 
> > Source/WebCore/page/FrameView.cpp:427
> > +bool FrameView::isMainFrameView() const
> > +{
> > +    return m_frame && m_frame->page() && m_frame->page()->mainFrame() == m_frame;
> > +}
> > +
> 
> Does this do the right thing for a page in the page cache? What is the right thing?

A "web page" in the page cache is a much different concept than a WebCore::Page

WebCore::Page represents the browser tab.  And that WebCore::Page has a single WebCore::Frame that is ALWAYS the main frame of that tab, even across navigations.

I think this check is fine.
Comment 7 Darin Adler 2013-08-02 14:13:17 PDT
(In reply to comment #1)
> Maybe there's some compelling reason that we haven't done this before? I don't know, but I'd love to!

Generally it’s hard to know how much to replicate across the core classes. Should Document have isMainFrameDocument in it? Should Frame have isMainFrame or only FrameTree, etc.?
Comment 8 Tim Horton 2013-08-15 12:07:51 PDT
http://trac.webkit.org/changeset/154116
Comment 9 Ryosuke Niwa 2013-08-15 13:53:59 PDT
Qt build fixed in http://trac.webkit.org/changeset/154128.