Changeset 111836 in webkit


Ignore:
Timestamp:
Mar 23, 2012 1:04:25 AM (12 years ago)
Author:
abarth@webkit.org
Message:

Move Notifications APIs from DOMWindow.idl to DOMWindowNotifications.idl (Part 2)
https://bugs.webkit.org/show_bug.cgi?id=82026

Reviewed by Kentaro Hara.

This patch removes DOMWindow::resetNotifications, which was unneeded
special-case logic for clearing the notifications center. The previous
patch that tried to accomplish the same thing did not override
willDetachPage, which is why it caused crashes.

There's actually a cleaner way to handle these cases, which will let us
implement reconnectFrame, but that will need to wait for the next
patch.

  • notifications/DOMWindowNotifications.cpp:

(WebCore::DOMWindowNotifications::DOMWindowNotifications):
(WebCore::DOMWindowNotifications::from):
(WebCore::DOMWindowNotifications::webkitNotifications):
(WebCore):
(WebCore::DOMWindowNotifications::disconnectFrame):
(WebCore::DOMWindowNotifications::willDetachPage):
(WebCore::DOMWindowNotifications::reset):

  • notifications/DOMWindowNotifications.h:

(DOMWindowNotifications):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::willDetachPage):
(WebCore::DOMWindow::disconnectDOMWindowProperties):
(WebCore::DOMWindow::clearDOMWindowProperties):

  • page/DOMWindow.h:

(DOMWindow):

  • page/Frame.cpp:

(WebCore::Frame::willDetachPage):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r111832 r111836  
     12012-03-23  Adam Barth  <abarth@webkit.org>
     2
     3        Move Notifications APIs from DOMWindow.idl to DOMWindowNotifications.idl (Part 2)
     4        https://bugs.webkit.org/show_bug.cgi?id=82026
     5
     6        Reviewed by Kentaro Hara.
     7
     8        This patch removes DOMWindow::resetNotifications, which was unneeded
     9        special-case logic for clearing the notifications center.  The previous
     10        patch that tried to accomplish the same thing did not override
     11        willDetachPage, which is why it caused crashes.
     12
     13        There's actually a cleaner way to handle these cases, which will let us
     14        implement reconnectFrame, but that will need to wait for the next
     15        patch.
     16
     17        * notifications/DOMWindowNotifications.cpp:
     18        (WebCore::DOMWindowNotifications::DOMWindowNotifications):
     19        (WebCore::DOMWindowNotifications::from):
     20        (WebCore::DOMWindowNotifications::webkitNotifications):
     21        (WebCore):
     22        (WebCore::DOMWindowNotifications::disconnectFrame):
     23        (WebCore::DOMWindowNotifications::willDetachPage):
     24        (WebCore::DOMWindowNotifications::reset):
     25        * notifications/DOMWindowNotifications.h:
     26        (DOMWindowNotifications):
     27        * page/DOMWindow.cpp:
     28        (WebCore::DOMWindow::willDetachPage):
     29        (WebCore::DOMWindow::disconnectDOMWindowProperties):
     30        (WebCore::DOMWindow::clearDOMWindowProperties):
     31        * page/DOMWindow.h:
     32        (DOMWindow):
     33        * page/Frame.cpp:
     34        (WebCore::Frame::willDetachPage):
     35
    1362012-03-22  Adam Barth  <abarth@webkit.org>
    237
  • trunk/Source/WebCore/notifications/DOMWindowNotifications.cpp

    r111832 r111836  
    3838namespace WebCore {
    3939
    40 DOMWindowNotifications::DOMWindowNotifications()
     40DOMWindowNotifications::DOMWindowNotifications(DOMWindow* window)
     41    : DOMWindowProperty(window->frame())
     42    , m_window(window)
    4143{
    4244}
     
    4850DOMWindowNotifications* DOMWindowNotifications::from(DOMWindow* window)
    4951{
    50     DOMWindowNotifications* supplement = static_cast<DOMWindowNotifications*>(Supplement<DOMWindow>::from(window, supplementName()));
     52    DEFINE_STATIC_LOCAL(AtomicString, supplementName, ("DOMWindowNotifications"));
     53    DOMWindowNotifications* supplement = static_cast<DOMWindowNotifications*>(Supplement<DOMWindow>::from(window, supplementName));
    5154    if (!supplement) {
    52         supplement = new DOMWindowNotifications();
    53         Supplement<DOMWindow>::provideTo(window, supplementName(), adoptPtr(supplement));
     55        supplement = new DOMWindowNotifications(window);
     56        Supplement<DOMWindow>::provideTo(window, supplementName, adoptPtr(supplement));
    5457    }
    5558    return supplement;
     
    5861NotificationCenter* DOMWindowNotifications::webkitNotifications(DOMWindow* window)
    5962{
    60     if (!window->isCurrentlyDisplayedInFrame())
     63    return DOMWindowNotifications::from(window)->webkitNotifications();
     64}
     65
     66void DOMWindowNotifications::disconnectFrame()
     67{
     68    reset();
     69    DOMWindowProperty::disconnectFrame();
     70}
     71
     72void DOMWindowNotifications::willDetachPage()
     73{
     74    reset();
     75    DOMWindowProperty::willDetachPage();
     76}
     77
     78NotificationCenter* DOMWindowNotifications::webkitNotifications()
     79{
     80    if (!m_window->isCurrentlyDisplayedInFrame())
    6181        return 0;
    6282
    63     DOMWindowNotifications* supplement = DOMWindowNotifications::from(window);
     83    if (m_notificationCenter)
     84        return m_notificationCenter.get();
    6485
    65     if (supplement->m_notificationCenter)
    66         return supplement->m_notificationCenter.get();
    67 
    68     Document* document = window->document();
     86    Document* document = m_window->document();
    6987    if (!document)
    7088        return 0;
     
    7694    NotificationClient* provider = NotificationController::clientFrom(page);
    7795    if (provider)
    78         supplement->m_notificationCenter = NotificationCenter::create(document, provider);   
     96        m_notificationCenter = NotificationCenter::create(document, provider);   
    7997
    80     return supplement->m_notificationCenter.get();
     98    return m_notificationCenter.get();
    8199}
    82100
    83 void DOMWindowNotifications::reset(DOMWindow* window)
     101void DOMWindowNotifications::reset()
    84102{
    85     DOMWindowNotifications* supplement = static_cast<DOMWindowNotifications*>(Supplement<DOMWindow>::from(window, supplementName()));
    86     if (!supplement)
     103    if (!m_notificationCenter)
    87104        return;
    88     if (!supplement->m_notificationCenter)
    89         return;
    90     supplement->m_notificationCenter->disconnectFrame();
    91     supplement->m_notificationCenter = 0;
    92 }
    93 
    94 const AtomicString& DOMWindowNotifications::supplementName()
    95 {
    96     DEFINE_STATIC_LOCAL(AtomicString, supplementName, ("DOMWindowNotifications"));
    97     return supplementName;
     105    m_notificationCenter->disconnectFrame();
     106    m_notificationCenter = 0;
    98107}
    99108
  • trunk/Source/WebCore/notifications/DOMWindowNotifications.h

    r111832 r111836  
    3939class NotificationCenter;
    4040
    41 class DOMWindowNotifications : public Supplement<DOMWindow> {
     41class DOMWindowNotifications : public Supplement<DOMWindow>, public DOMWindowProperty {
    4242public:
    4343    virtual ~DOMWindowNotifications();
     
    4646    static DOMWindowNotifications* from(DOMWindow*);
    4747
    48     static void reset(DOMWindow*);
     48    virtual void disconnectFrame() OVERRIDE;
     49    // FIXME: Support reconnectFrame().
     50    virtual void willDetachPage() OVERRIDE;
    4951
    5052private:
    51     DOMWindowNotifications();
     53    explicit DOMWindowNotifications(DOMWindow*);
    5254
    53     static const AtomicString& supplementName();
     55    NotificationCenter* webkitNotifications();
     56    void reset();
    5457
     58    DOMWindow* m_window;
    5559    RefPtr<NotificationCenter> m_notificationCenter;
    5660};
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r111832 r111836  
    475475    InspectorInstrumentation::frameWindowDiscarded(m_frame, this);
    476476
    477 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    478     // Clearing Notifications requests involves accessing the client so it must be done
    479     // before the frame is detached.
    480     resetNotifications();
    481 #endif
    482 
    483477    HashSet<DOMWindowProperty*>::iterator stop = m_properties.end();
    484478    for (HashSet<DOMWindowProperty*>::iterator it = m_properties.begin(); it != stop; ++it)
     
    524518    for (HashSet<DOMWindowProperty*>::iterator it = m_properties.begin(); it != stop; ++it)
    525519        (*it)->disconnectFrame();
    526 
    527 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    528     // FIXME: Notifications shouldn't have different disconnection logic than
    529     // the rest of the DOMWindowProperties.
    530     // There is currently no way to reconnect them in resumeFromPageCache() so
    531     // they will be broken after returning to a cached page.
    532     // This should be fixed as part of https://bugs.webkit.org/show_bug.cgi?id=79636
    533     resetNotifications();
    534 #endif
    535520}
    536521
     
    568553    m_localStorage = 0;
    569554    m_applicationCache = 0;
    570 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    571     // FIXME: Notifications shouldn't have different disconnection logic than
    572     // the rest of the DOMWindowProperties.
    573     resetNotifications();
    574 #endif
    575555#if ENABLE(BLOB)
    576556    m_domURL = 0;
     
    780760    return m_localStorage.get();
    781761}
    782 
    783 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    784 void DOMWindow::resetNotifications()
    785 {
    786     DOMWindowNotifications::reset(this);
    787 }
    788 #endif
    789762
    790763void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec)
  • trunk/Source/WebCore/page/DOMWindow.h

    r111832 r111836  
    356356        Storage* localStorage(ExceptionCode&) const;
    357357
    358 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    359         void resetNotifications();
    360 #endif
    361 
    362358#if ENABLE(QUOTA)
    363359        StorageInfo* webkitStorageInfo() const;
  • trunk/Source/WebCore/page/Frame.cpp

    r111361 r111836  
    688688        parent->loader()->checkLoadComplete();
    689689
    690 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    691     if (m_domWindow)
    692         m_domWindow->resetNotifications();
    693 #endif
    694 
    695690    HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.end();
    696691    for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it)
Note: See TracChangeset for help on using the changeset viewer.