Commit 3766b020 authored by abarth@webkit.org's avatar abarth@webkit.org

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:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104372 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3e7472be
2012-01-06 Adam Barth <abarth@webkit.org>
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 <pecoraro@apple.com>
Web Inspector: Missing Implementation of Public InspectorDOMAgent Function
......@@ -397,16 +397,13 @@ bool DOMWindow::canShowModalDialogNow(const Frame* frame)
}
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 @@ void DOMWindow::setSecurityOrigin(SecurityOrigin* securityOrigin)
m_securityOrigin = securityOrigin;
}
void DOMWindow::disconnectFrame()
void DOMWindow::frameDestroyed()
{
m_frame = 0;
FrameDestructionObserver::frameDestroyed();
clear();
}
......
......@@ -28,6 +28,7 @@
#define DOMWindow_h
#include "EventTarget.h"
#include "FrameDestructionObserver.h"
#include "KURL.h"
namespace WebCore {
......@@ -80,7 +81,7 @@ namespace WebCore {
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 @@ namespace WebCore {
virtual DOMWindow* toDOMWindow();
Frame* frame() const { return m_frame; }
void disconnectFrame();
virtual void frameDestroyed() OVERRIDE;
void clear();
......@@ -415,7 +415,7 @@ namespace WebCore {
#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 @@ namespace WebCore {
KURL m_url;
bool m_shouldPrintWhenFinishedLoading;
Frame* m_frame;
mutable RefPtr<Screen> m_screen;
mutable RefPtr<DOMSelection> m_selection;
mutable RefPtr<History> m_history;
......
......@@ -219,13 +219,6 @@ Frame::~Frame()
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::injectUserScriptsForWorld(DOMWrapperWorld* world, const UserScriptVe
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::clearTimers()
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 @@ DOMWindow* Frame::domWindow() const
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.
......
......@@ -133,7 +133,6 @@ namespace WebCore {
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 @@ namespace WebCore {
mutable NavigationScheduler m_navigationScheduler;
mutable RefPtr<DOMWindow> m_domWindow;
HashSet<DOMWindow*> m_liveFormerWindows;
HTMLFrameOwnerElement* m_ownerElement;
RefPtr<FrameView> m_view;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment