Changeset 71892 in webkit


Ignore:
Timestamp:
Nov 11, 2010 10:51:46 PM (13 years ago)
Author:
hamaji@chromium.org
Message:

2010-11-11 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

REGRESSION: window.print in onload doesn't fire if there's an img
https://bugs.webkit.org/show_bug.cgi?id=48195

This issue was introduced in
https://bugs.webkit.org/show_bug.cgi?id=43658
This happens because FrameLoader::isLoading() is false while an
image is still loading. Now, window.print() happens after all
resources are loaded.

Also changed the name of a member variable as Darin suggested in Bug 43658.

Added a manual test as DRT doesn't support window.print() yet.

  • loader/DocumentLoader.cpp: (WebCore::DocumentLoader::DocumentLoader): (WebCore::DocumentLoader::updateLoading):
  • loader/DocumentLoader.h:
  • page/DOMWindow.cpp: (WebCore::DOMWindow::DOMWindow): (WebCore::DOMWindow::print): (WebCore::DOMWindow::finishedLoading):
  • page/DOMWindow.h:
Location:
trunk/WebCore
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r71887 r71892  
     12010-11-11  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        REGRESSION: window.print in onload doesn't fire if there's an img
     6        https://bugs.webkit.org/show_bug.cgi?id=48195
     7
     8        This issue was introduced in
     9        https://bugs.webkit.org/show_bug.cgi?id=43658
     10        This happens because FrameLoader::isLoading() is false while an
     11        image is still loading. Now, window.print() happens after all
     12        resources are loaded.
     13
     14        Also changed the name of a member variable as Darin suggested in Bug 43658.
     15
     16        Added a manual test as DRT doesn't support window.print() yet.
     17
     18        * loader/DocumentLoader.cpp:
     19        (WebCore::DocumentLoader::DocumentLoader):
     20        (WebCore::DocumentLoader::updateLoading):
     21        * loader/DocumentLoader.h:
     22        * page/DOMWindow.cpp:
     23        (WebCore::DOMWindow::DOMWindow):
     24        (WebCore::DOMWindow::print):
     25        (WebCore::DOMWindow::finishedLoading):
     26        * page/DOMWindow.h:
     27
    1282010-11-11  James Simonsen  <simonjam@chromium.org>
    229
  • trunk/WebCore/loader/DocumentLoader.cpp

    r71625 r71892  
    3535#include "CachedPage.h"
    3636#include "CachedResourceLoader.h"
     37#include "DOMWindow.h"
    3738#include "Document.h"
    3839#include "DocumentParser.h"
     
    357358    }
    358359    ASSERT(this == frameLoader()->activeDocumentLoader());
     360    bool wasLoading = m_loading;
    359361    setLoading(frameLoader()->isLoading());
     362
     363    if (wasLoading && !m_loading) {
     364        if (DOMWindow* window = m_frame->existingDOMWindow())
     365            window->finishedLoading();
     366    }
    360367}
    361368
  • trunk/WebCore/loader/FrameLoader.cpp

    r71625 r71892  
    21772177    m_client->dispatchDidLoadMainResource(dl.get());
    21782178    checkLoadComplete();
    2179 
    2180     DOMWindow* window = m_frame->existingDOMWindow();
    2181     if (window && window->printDeferred())
    2182         window->print();
    21832179}
    21842180
  • trunk/WebCore/page/DOMWindow.cpp

    r71219 r71892  
    393393
    394394DOMWindow::DOMWindow(Frame* frame)
    395     : m_printDeferred(false),
    396       m_frame(frame)
     395    : m_shouldPrintWhenFinishedLoading(false)
     396    , m_frame(frame)
    397397{
    398398}
     
    893893        return;
    894894
    895     if (m_frame->loader()->isLoading()) {
    896         m_printDeferred = true;
    897         return;
    898     }
    899     m_printDeferred = false;
     895    if (m_frame->loader()->activeDocumentLoader()->isLoading()) {
     896        m_shouldPrintWhenFinishedLoading = true;
     897        return;
     898    }
     899    m_shouldPrintWhenFinishedLoading = false;
    900900    page->chrome()->print(m_frame);
    901901}
     
    15681568}
    15691569
     1570void DOMWindow::finishedLoading()
     1571{
     1572    if (m_shouldPrintWhenFinishedLoading) {
     1573        m_shouldPrintWhenFinishedLoading = false;
     1574        print();
     1575    }
     1576}
     1577
    15701578EventTargetData* DOMWindow::eventTargetData()
    15711579{
  • trunk/WebCore/page/DOMWindow.h

    r70102 r71892  
    9292        virtual ScriptExecutionContext* scriptExecutionContext() const;
    9393
    94         bool printDeferred() const { return m_printDeferred; }
    9594        Frame* frame() const { return m_frame; }
    9695        void disconnectFrame();
     
    367366        void releaseEvents();
    368367
     368        void finishedLoading();
     369
    369370        // These methods are used for GC marking. See JSDOMWindow::markChildren(MarkStack&) in
    370371        // JSDOMWindowCustom.cpp.
     
    411412        KURL m_url;
    412413
    413         bool m_printDeferred;
     414        bool m_shouldPrintWhenFinishedLoading;
    414415        Frame* m_frame;
    415416        mutable RefPtr<Screen> m_screen;
Note: See TracChangeset for help on using the changeset viewer.