- Revision
- 104372
- Author
- [email protected]
- Date
- 2012-01-06 19:12:01 -0800 (Fri, 06 Jan 2012)
Log Message
DOMWindow should be a FrameDestructionObserver
https://bugs.webkit.org/show_bug.cgi?id=75697
Reviewed by Alexey Proskuryakov.
DOMWindow plays exactly the role of a FrameDestructionObserver, just
with special-case code. It should just use the general-case code.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::DOMWindow):
(WebCore::DOMWindow::~DOMWindow):
(WebCore::DOMWindow::frameDestroyed):
* page/DOMWindow.h:
* page/Frame.cpp:
(WebCore::Frame::~Frame):
(WebCore::Frame::clearDOMWindow):
(WebCore::Frame::setDOMWindow):
* page/Frame.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (104371 => 104372)
--- trunk/Source/WebCore/ChangeLog 2012-01-07 03:10:44 UTC (rev 104371)
+++ trunk/Source/WebCore/ChangeLog 2012-01-07 03:12:01 UTC (rev 104372)
@@ -1,3 +1,24 @@
+2012-01-06 Adam Barth <[email protected]>
+
+ DOMWindow should be a FrameDestructionObserver
+ https://bugs.webkit.org/show_bug.cgi?id=75697
+
+ Reviewed by Alexey Proskuryakov.
+
+ DOMWindow plays exactly the role of a FrameDestructionObserver, just
+ with special-case code. It should just use the general-case code.
+
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::DOMWindow):
+ (WebCore::DOMWindow::~DOMWindow):
+ (WebCore::DOMWindow::frameDestroyed):
+ * page/DOMWindow.h:
+ * page/Frame.cpp:
+ (WebCore::Frame::~Frame):
+ (WebCore::Frame::clearDOMWindow):
+ (WebCore::Frame::setDOMWindow):
+ * page/Frame.h:
+
2012-01-06 Joseph Pecoraro <[email protected]>
Web Inspector: Missing Implementation of Public InspectorDOMAgent Function
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (104371 => 104372)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2012-01-07 03:10:44 UTC (rev 104371)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2012-01-07 03:12:01 UTC (rev 104372)
@@ -397,16 +397,13 @@
}
DOMWindow::DOMWindow(Frame* frame)
- : m_shouldPrintWhenFinishedLoading(false)
- , m_frame(frame)
+ : FrameDestructionObserver(frame)
+ , m_shouldPrintWhenFinishedLoading(false)
{
}
DOMWindow::~DOMWindow()
{
- if (m_frame)
- m_frame->clearFormerDOMWindow(this);
-
ASSERT(!m_screen);
ASSERT(!m_selection);
ASSERT(!m_history);
@@ -473,9 +470,9 @@
m_securityOrigin = securityOrigin;
}
-void DOMWindow::disconnectFrame()
+void DOMWindow::frameDestroyed()
{
- m_frame = 0;
+ FrameDestructionObserver::frameDestroyed();
clear();
}
Modified: trunk/Source/WebCore/page/DOMWindow.h (104371 => 104372)
--- trunk/Source/WebCore/page/DOMWindow.h 2012-01-07 03:10:44 UTC (rev 104371)
+++ trunk/Source/WebCore/page/DOMWindow.h 2012-01-07 03:12:01 UTC (rev 104372)
@@ -28,6 +28,7 @@
#define DOMWindow_h
#include "EventTarget.h"
+#include "FrameDestructionObserver.h"
#include "KURL.h"
namespace WebCore {
@@ -80,7 +81,7 @@
enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForwardList };
- class DOMWindow : public RefCounted<DOMWindow>, public EventTarget {
+ class DOMWindow : public RefCounted<DOMWindow>, public EventTarget, public FrameDestructionObserver {
public:
static PassRefPtr<DOMWindow> create(Frame* frame) { return adoptRef(new DOMWindow(frame)); }
virtual ~DOMWindow();
@@ -90,8 +91,7 @@
virtual DOMWindow* toDOMWindow();
- Frame* frame() const { return m_frame; }
- void disconnectFrame();
+ virtual void frameDestroyed() OVERRIDE;
void clear();
@@ -415,7 +415,7 @@
#endif
private:
- DOMWindow(Frame*);
+ explicit DOMWindow(Frame*);
// FIXME: When this DOMWindow is no longer the active DOMWindow (i.e.,
// when its document is no longer the document that is displayed in its
@@ -437,7 +437,6 @@
KURL m_url;
bool m_shouldPrintWhenFinishedLoading;
- Frame* m_frame;
mutable RefPtr<Screen> m_screen;
mutable RefPtr<DOMSelection> m_selection;
mutable RefPtr<History> m_history;
Modified: trunk/Source/WebCore/page/Frame.cpp (104371 => 104372)
--- trunk/Source/WebCore/page/Frame.cpp 2012-01-07 03:10:44 UTC (rev 104371)
+++ trunk/Source/WebCore/page/Frame.cpp 2012-01-07 03:12:01 UTC (rev 104372)
@@ -219,13 +219,6 @@
disconnectOwnerElement();
- if (m_domWindow)
- m_domWindow->disconnectFrame();
-
- HashSet<DOMWindow*>::iterator end = m_liveFormerWindows.end();
- for (HashSet<DOMWindow*>::iterator it = m_liveFormerWindows.begin(); it != end; ++it)
- (*it)->disconnectFrame();
-
HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.end();
for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it)
(*it)->frameDestroyed();
@@ -576,10 +569,8 @@
void Frame::clearDOMWindow()
{
- if (m_domWindow) {
- m_liveFormerWindows.add(m_domWindow.get());
+ if (m_domWindow)
m_domWindow->clear();
- }
m_domWindow = 0;
}
@@ -644,10 +635,8 @@
void Frame::setDOMWindow(DOMWindow* domWindow)
{
- if (m_domWindow) {
- m_liveFormerWindows.add(m_domWindow.get());
+ if (m_domWindow)
m_domWindow->clear();
- }
m_domWindow = domWindow;
}
@@ -669,11 +658,6 @@
return m_domWindow.get();
}
-void Frame::clearFormerDOMWindow(DOMWindow* window)
-{
- m_liveFormerWindows.remove(window);
-}
-
void Frame::pageDestroyed()
{
// FIXME: Rename this function, since it's called not only from Page destructor, but in several other cases.
Modified: trunk/Source/WebCore/page/Frame.h (104371 => 104372)
--- trunk/Source/WebCore/page/Frame.h 2012-01-07 03:10:44 UTC (rev 104371)
+++ trunk/Source/WebCore/page/Frame.h 2012-01-07 03:12:01 UTC (rev 104372)
@@ -133,7 +133,6 @@
DOMWindow* domWindow() const;
DOMWindow* existingDOMWindow() { return m_domWindow.get(); }
void setDOMWindow(DOMWindow*);
- void clearFormerDOMWindow(DOMWindow*);
void clearDOMWindow();
static Frame* frameForWidget(const Widget*);
@@ -212,7 +211,6 @@
mutable NavigationScheduler m_navigationScheduler;
mutable RefPtr<DOMWindow> m_domWindow;
- HashSet<DOMWindow*> m_liveFormerWindows;
HTMLFrameOwnerElement* m_ownerElement;
RefPtr<FrameView> m_view;