Bug 118219

Summary: Calling WKBundlePageSetFooterBanner() API to set a banner to null does not actually hide the banner
Product: WebKit Reporter: Ada Chan <adachan>
Component: Layout and RenderingAssignee: Ada Chan <adachan>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, eflews.bot, gyuyoung.kim, jeffm, rego+ews, sam, webkit-ews, xan.lopez
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
eflews.bot: commit-queue-
Patch
webkit-ews: commit-queue-
Patch
none
Patch bdakin: review+

Description Ada Chan 2013-06-30 08:53:41 PDT
Calling WKBundlePageSetFooterBanner() API to set a banner to null does not actually hide the banner.  

Looks like we need to call Page::addFooterWithHeight(0) in that case to properly remove the parent layer that hosts the banner.  Ditto for the header banner.

Patch coming soon.

This is needed for <rdar://problem/13917901>.
Comment 1 Ada Chan 2013-06-30 09:12:01 PDT
Created attachment 205775 [details]
Patch
Comment 2 EFL EWS Bot 2013-06-30 09:16:55 PDT
Comment on attachment 205775 [details]
Patch

Attachment 205775 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/995956
Comment 3 Early Warning System Bot 2013-06-30 09:17:27 PDT
Comment on attachment 205775 [details]
Patch

Attachment 205775 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/927397
Comment 4 Ada Chan 2013-06-30 09:29:15 PDT
Created attachment 205776 [details]
Patch

Replaced m_page with corePage().
Comment 5 Early Warning System Bot 2013-06-30 09:37:15 PDT
Comment on attachment 205776 [details]
Patch

Attachment 205776 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/919584
Comment 6 EFL EWS Bot 2013-06-30 09:38:06 PDT
Comment on attachment 205776 [details]
Patch

Attachment 205776 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/943800
Comment 7 Ada Chan 2013-06-30 10:16:15 PDT
Created attachment 205777 [details]
Patch

Wrap the calls with #if ENABLE(RUBBER_BANDING).
Comment 8 Sam Weinig 2013-06-30 14:28:01 PDT
Ideally this would all be in the PageBanner class.  Any reason we can't do this in PageBanner::detachFromPage()?
Comment 9 Ada Chan 2013-06-30 22:28:06 PDT
(In reply to comment #8)
> Ideally this would all be in the PageBanner class.  Any reason we can't do this in PageBanner::detachFromPage()?

PageBanner::detachFromPage() is also called on the header and footer banners in WebPage's destructor. I don't know if it's necessary to hide the banners also for that case, and if there would be issues trying to hide the banners at that point.

Another thing I can do is this:

void WebPage::setHeaderPageBanner(PassRefPtr<PageBanner> pageBanner)
{
    if (m_headerBanner) {
        m_headerBanner->hide();
        m_headerBanner->detachFromPage();
    }

    m_headerBanner = pageBanner;

    if (m_headerBanner)
        m_headerBanner->addToPage(PageBanner::Header, this);
}

In the common case where we are setting the page banner to another instance, the above code would remove the parent layer that hosts the banner and then recreate it again when we add in the new banner. What I had earlier in my patch would avoid that. I'm not sure if that optimization is worth the trouble though. If it's really worth not removing the parent layer that hosts the banner unless it's necessary, I could do this:

void WebPage::setHeaderPageBanner(PassRefPtr<PageBanner> pageBanner)
{
    if (m_headerBanner) {
        if (!pageBanner)
            m_headerBanner->hide();
        m_headerBanner->detachFromPage();
    }

    m_headerBanner = pageBanner;

    if (m_headerBanner)
        m_headerBanner->addToPage(PageBanner::Header, this);
}

Please let me know what you think.  By the way, should we add a check in the beginning of the method to see if pageBanner is the same as m_headerBanner and bail early if it is?
Comment 10 Ada Chan 2013-07-01 13:09:21 PDT
Created attachment 205831 [details]
Patch

Fix this in PageBanner::detachFromPage() as suggested by Sam.
Comment 11 Ada Chan 2013-07-01 14:58:59 PDT
Committed:
https://trac.webkit.org/changeset/152249