Commit 3a497e63 authored by dcheng@chromium.org's avatar dcheng@chromium.org

Move FrameDestructionObserver into LocalFrame.

Prepratory cleanup for making recursive frame detach work for all
frames. FrameDestructionObserver can only observe a LocalFrame.
Similarly willDetachFrameHost() and detachFromFrameHost() can only be
called on LocalFrames, since these methods are only called by
FrameLoader.

BUG=none

Review URL: https://codereview.chromium.org/427673008

git-svn-id: svn://svn.chromium.org/blink/trunk@179178 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0e4d62e4
......@@ -33,7 +33,6 @@
#include "core/dom/DocumentType.h"
#include "core/events/Event.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/FrameDestructionObserver.h"
#include "core/frame/FrameHost.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLFrameElementBase.h"
......@@ -90,20 +89,6 @@ Frame::~Frame()
#ifndef NDEBUG
frameCounter.decrement();
#endif
HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.end();
for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it)
(*it)->frameDestroyed();
}
void Frame::addDestructionObserver(FrameDestructionObserver* observer)
{
m_destructionObservers.add(observer);
}
void Frame::removeDestructionObserver(FrameDestructionObserver* observer)
{
m_destructionObservers.remove(observer);
}
FrameHost* Frame::host() const
......@@ -175,24 +160,6 @@ void Frame::setRemotePlatformLayer(blink::WebLayer* layer)
renderer->layer()->updateSelfPaintingLayer();
}
void Frame::willDetachFrameHost()
{
HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.end();
for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it)
(*it)->willDetachFrameHost();
// FIXME: Page should take care of updating focus/scrolling instead of Frame.
// FIXME: It's unclear as to why this is called more than once, but it is,
// so page() could be null.
if (page() && page()->focusController().focusedFrame() == this)
page()->focusController().setFocusedFrame(nullptr);
}
void Frame::detachFromFrameHost()
{
m_host = 0;
}
bool Frame::isMainFrame() const
{
Page* page = this->page();
......
......@@ -31,7 +31,6 @@
#include "core/page/FrameTree.h"
#include "platform/heap/Handle.h"
#include "wtf/Forward.h"
#include "wtf/HashSet.h"
#include "wtf/RefCounted.h"
namespace blink {
......@@ -42,7 +41,6 @@ namespace blink {
class ChromeClient;
class FrameClient;
class FrameDestructionObserver;
class FrameHost;
class FrameOwner;
class HTMLFrameOwnerElement;
......@@ -58,12 +56,6 @@ public:
virtual ~Frame();
void addDestructionObserver(FrameDestructionObserver*);
void removeDestructionObserver(FrameDestructionObserver*);
virtual void willDetachFrameHost();
virtual void detachFromFrameHost();
FrameClient* client() const;
void clearClient();
......@@ -115,8 +107,6 @@ protected:
private:
FrameClient* m_client;
HashSet<FrameDestructionObserver*> m_destructionObservers;
blink::WebLayer* m_remotePlatformLayer;
};
......
......@@ -40,11 +40,12 @@
#include "core/editing/markup.h"
#include "core/events/Event.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/EventHandlerRegistry.h"
#include "core/frame/FrameConsole.h"
#include "core/frame/FrameDestructionObserver.h"
#include "core/frame/FrameHost.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLFrameElementBase.h"
#include "core/inspector/InspectorInstrumentation.h"
......@@ -116,6 +117,11 @@ LocalFrame::~LocalFrame()
setView(nullptr);
loader().clear();
setDOMWindow(nullptr);
// FIXME: What to do here... some of this is redundant with ~Frame.
HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.end();
for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it)
(*it)->frameDestroyed();
}
bool LocalFrame::inScope(TreeScope* scope) const
......@@ -233,6 +239,16 @@ void LocalFrame::didChangeVisibilityState()
childFrames[i]->didChangeVisibilityState();
}
void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer)
{
m_destructionObservers.add(observer);
}
void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer)
{
m_destructionObservers.remove(observer);
}
void LocalFrame::willDetachFrameHost()
{
// We should never be detatching the page during a Layout.
......@@ -242,7 +258,15 @@ void LocalFrame::willDetachFrameHost()
if (parent && parent->isLocalFrame())
toLocalFrame(parent)->loader().checkLoadComplete();
Frame::willDetachFrameHost();
HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.end();
for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it)
(*it)->willDetachFrameHost();
// FIXME: Page should take care of updating focus/scrolling instead of Frame.
// FIXME: It's unclear as to why this is called more than once, but it is,
// so page() could be null.
if (page() && page()->focusController().focusedFrame() == this)
page()->focusController().setFocusedFrame(nullptr);
script().clearScriptObjects();
if (page() && page()->scrollingCoordinator() && m_view)
......@@ -253,7 +277,7 @@ void LocalFrame::detachFromFrameHost()
{
// We should never be detatching the page during a Layout.
RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout());
Frame::detachFromFrameHost();
m_host = 0;
}
String LocalFrame::documentTypeString() const
......
......@@ -35,6 +35,7 @@
#include "platform/Supplementable.h"
#include "platform/heap/Handle.h"
#include "platform/scroll/ScrollTypes.h"
#include "wtf/HashSet.h"
namespace blink {
......@@ -47,6 +48,7 @@ namespace blink {
class FloatSize;
class FloatRect;
class FrameConsole;
class FrameDestructionObserver;
class FrameSelection;
class FrameView;
class InputMethodController;
......@@ -75,8 +77,11 @@ namespace blink {
virtual ~LocalFrame();
virtual void willDetachFrameHost() OVERRIDE;
virtual void detachFromFrameHost() OVERRIDE;
void addDestructionObserver(FrameDestructionObserver*);
void removeDestructionObserver(FrameDestructionObserver*);
void willDetachFrameHost();
void detachFromFrameHost();
virtual void disconnectOwnerElement() OVERRIDE;
......@@ -150,6 +155,7 @@ namespace blink {
String localLayerTreeAsText(unsigned flags) const;
HashSet<FrameDestructionObserver*> m_destructionObservers;
mutable FrameLoader m_loader;
mutable NavigationScheduler m_navigationScheduler;
......
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