Changeset 111836 in webkit
- Timestamp:
- Mar 23, 2012 1:04:25 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r111832 r111836 1 2012-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 1 36 2012-03-22 Adam Barth <abarth@webkit.org> 2 37 -
trunk/Source/WebCore/notifications/DOMWindowNotifications.cpp
r111832 r111836 38 38 namespace WebCore { 39 39 40 DOMWindowNotifications::DOMWindowNotifications() 40 DOMWindowNotifications::DOMWindowNotifications(DOMWindow* window) 41 : DOMWindowProperty(window->frame()) 42 , m_window(window) 41 43 { 42 44 } … … 48 50 DOMWindowNotifications* DOMWindowNotifications::from(DOMWindow* window) 49 51 { 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)); 51 54 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)); 54 57 } 55 58 return supplement; … … 58 61 NotificationCenter* DOMWindowNotifications::webkitNotifications(DOMWindow* window) 59 62 { 60 if (!window->isCurrentlyDisplayedInFrame()) 63 return DOMWindowNotifications::from(window)->webkitNotifications(); 64 } 65 66 void DOMWindowNotifications::disconnectFrame() 67 { 68 reset(); 69 DOMWindowProperty::disconnectFrame(); 70 } 71 72 void DOMWindowNotifications::willDetachPage() 73 { 74 reset(); 75 DOMWindowProperty::willDetachPage(); 76 } 77 78 NotificationCenter* DOMWindowNotifications::webkitNotifications() 79 { 80 if (!m_window->isCurrentlyDisplayedInFrame()) 61 81 return 0; 62 82 63 DOMWindowNotifications* supplement = DOMWindowNotifications::from(window); 83 if (m_notificationCenter) 84 return m_notificationCenter.get(); 64 85 65 if (supplement->m_notificationCenter) 66 return supplement->m_notificationCenter.get(); 67 68 Document* document = window->document(); 86 Document* document = m_window->document(); 69 87 if (!document) 70 88 return 0; … … 76 94 NotificationClient* provider = NotificationController::clientFrom(page); 77 95 if (provider) 78 supplement->m_notificationCenter = NotificationCenter::create(document, provider);96 m_notificationCenter = NotificationCenter::create(document, provider); 79 97 80 return supplement->m_notificationCenter.get();98 return m_notificationCenter.get(); 81 99 } 82 100 83 void DOMWindowNotifications::reset( DOMWindow* window)101 void DOMWindowNotifications::reset() 84 102 { 85 DOMWindowNotifications* supplement = static_cast<DOMWindowNotifications*>(Supplement<DOMWindow>::from(window, supplementName())); 86 if (!supplement) 103 if (!m_notificationCenter) 87 104 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; 98 107 } 99 108 -
trunk/Source/WebCore/notifications/DOMWindowNotifications.h
r111832 r111836 39 39 class NotificationCenter; 40 40 41 class DOMWindowNotifications : public Supplement<DOMWindow> {41 class DOMWindowNotifications : public Supplement<DOMWindow>, public DOMWindowProperty { 42 42 public: 43 43 virtual ~DOMWindowNotifications(); … … 46 46 static DOMWindowNotifications* from(DOMWindow*); 47 47 48 static void reset(DOMWindow*); 48 virtual void disconnectFrame() OVERRIDE; 49 // FIXME: Support reconnectFrame(). 50 virtual void willDetachPage() OVERRIDE; 49 51 50 52 private: 51 DOMWindowNotifications();53 explicit DOMWindowNotifications(DOMWindow*); 52 54 53 static const AtomicString& supplementName(); 55 NotificationCenter* webkitNotifications(); 56 void reset(); 54 57 58 DOMWindow* m_window; 55 59 RefPtr<NotificationCenter> m_notificationCenter; 56 60 }; -
trunk/Source/WebCore/page/DOMWindow.cpp
r111832 r111836 475 475 InspectorInstrumentation::frameWindowDiscarded(m_frame, this); 476 476 477 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)478 // Clearing Notifications requests involves accessing the client so it must be done479 // before the frame is detached.480 resetNotifications();481 #endif482 483 477 HashSet<DOMWindowProperty*>::iterator stop = m_properties.end(); 484 478 for (HashSet<DOMWindowProperty*>::iterator it = m_properties.begin(); it != stop; ++it) … … 524 518 for (HashSet<DOMWindowProperty*>::iterator it = m_properties.begin(); it != stop; ++it) 525 519 (*it)->disconnectFrame(); 526 527 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)528 // FIXME: Notifications shouldn't have different disconnection logic than529 // the rest of the DOMWindowProperties.530 // There is currently no way to reconnect them in resumeFromPageCache() so531 // 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=79636533 resetNotifications();534 #endif535 520 } 536 521 … … 568 553 m_localStorage = 0; 569 554 m_applicationCache = 0; 570 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)571 // FIXME: Notifications shouldn't have different disconnection logic than572 // the rest of the DOMWindowProperties.573 resetNotifications();574 #endif575 555 #if ENABLE(BLOB) 576 556 m_domURL = 0; … … 780 760 return m_localStorage.get(); 781 761 } 782 783 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)784 void DOMWindow::resetNotifications()785 {786 DOMWindowNotifications::reset(this);787 }788 #endif789 762 790 763 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec) -
trunk/Source/WebCore/page/DOMWindow.h
r111832 r111836 356 356 Storage* localStorage(ExceptionCode&) const; 357 357 358 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)359 void resetNotifications();360 #endif361 362 358 #if ENABLE(QUOTA) 363 359 StorageInfo* webkitStorageInfo() const; -
trunk/Source/WebCore/page/Frame.cpp
r111361 r111836 688 688 parent->loader()->checkLoadComplete(); 689 689 690 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)691 if (m_domWindow)692 m_domWindow->resetNotifications();693 #endif694 695 690 HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.end(); 696 691 for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it)
Note: See TracChangeset
for help on using the changeset viewer.