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 @@ ...@@ -33,7 +33,6 @@
#include "core/dom/DocumentType.h" #include "core/dom/DocumentType.h"
#include "core/events/Event.h" #include "core/events/Event.h"
#include "core/frame/LocalDOMWindow.h" #include "core/frame/LocalDOMWindow.h"
#include "core/frame/FrameDestructionObserver.h"
#include "core/frame/FrameHost.h" #include "core/frame/FrameHost.h"
#include "core/frame/Settings.h" #include "core/frame/Settings.h"
#include "core/html/HTMLFrameElementBase.h" #include "core/html/HTMLFrameElementBase.h"
...@@ -90,20 +89,6 @@ Frame::~Frame() ...@@ -90,20 +89,6 @@ Frame::~Frame()
#ifndef NDEBUG #ifndef NDEBUG
frameCounter.decrement(); frameCounter.decrement();
#endif #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 FrameHost* Frame::host() const
...@@ -175,24 +160,6 @@ void Frame::setRemotePlatformLayer(blink::WebLayer* layer) ...@@ -175,24 +160,6 @@ void Frame::setRemotePlatformLayer(blink::WebLayer* layer)
renderer->layer()->updateSelfPaintingLayer(); 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 bool Frame::isMainFrame() const
{ {
Page* page = this->page(); Page* page = this->page();
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "core/page/FrameTree.h" #include "core/page/FrameTree.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "wtf/Forward.h" #include "wtf/Forward.h"
#include "wtf/HashSet.h"
#include "wtf/RefCounted.h" #include "wtf/RefCounted.h"
namespace blink { namespace blink {
...@@ -42,7 +41,6 @@ namespace blink { ...@@ -42,7 +41,6 @@ namespace blink {
class ChromeClient; class ChromeClient;
class FrameClient; class FrameClient;
class FrameDestructionObserver;
class FrameHost; class FrameHost;
class FrameOwner; class FrameOwner;
class HTMLFrameOwnerElement; class HTMLFrameOwnerElement;
...@@ -58,12 +56,6 @@ public: ...@@ -58,12 +56,6 @@ public:
virtual ~Frame(); virtual ~Frame();
void addDestructionObserver(FrameDestructionObserver*);
void removeDestructionObserver(FrameDestructionObserver*);
virtual void willDetachFrameHost();
virtual void detachFromFrameHost();
FrameClient* client() const; FrameClient* client() const;
void clearClient(); void clearClient();
...@@ -115,8 +107,6 @@ protected: ...@@ -115,8 +107,6 @@ protected:
private: private:
FrameClient* m_client; FrameClient* m_client;
HashSet<FrameDestructionObserver*> m_destructionObservers;
blink::WebLayer* m_remotePlatformLayer; blink::WebLayer* m_remotePlatformLayer;
}; };
......
...@@ -40,11 +40,12 @@ ...@@ -40,11 +40,12 @@
#include "core/editing/markup.h" #include "core/editing/markup.h"
#include "core/events/Event.h" #include "core/events/Event.h"
#include "core/fetch/ResourceFetcher.h" #include "core/fetch/ResourceFetcher.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/EventHandlerRegistry.h" #include "core/frame/EventHandlerRegistry.h"
#include "core/frame/FrameConsole.h" #include "core/frame/FrameConsole.h"
#include "core/frame/FrameDestructionObserver.h"
#include "core/frame/FrameHost.h" #include "core/frame/FrameHost.h"
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/Settings.h" #include "core/frame/Settings.h"
#include "core/html/HTMLFrameElementBase.h" #include "core/html/HTMLFrameElementBase.h"
#include "core/inspector/InspectorInstrumentation.h" #include "core/inspector/InspectorInstrumentation.h"
...@@ -116,6 +117,11 @@ LocalFrame::~LocalFrame() ...@@ -116,6 +117,11 @@ LocalFrame::~LocalFrame()
setView(nullptr); setView(nullptr);
loader().clear(); loader().clear();
setDOMWindow(nullptr); 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 bool LocalFrame::inScope(TreeScope* scope) const
...@@ -233,6 +239,16 @@ void LocalFrame::didChangeVisibilityState() ...@@ -233,6 +239,16 @@ void LocalFrame::didChangeVisibilityState()
childFrames[i]->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() void LocalFrame::willDetachFrameHost()
{ {
// We should never be detatching the page during a Layout. // We should never be detatching the page during a Layout.
...@@ -242,7 +258,15 @@ void LocalFrame::willDetachFrameHost() ...@@ -242,7 +258,15 @@ void LocalFrame::willDetachFrameHost()
if (parent && parent->isLocalFrame()) if (parent && parent->isLocalFrame())
toLocalFrame(parent)->loader().checkLoadComplete(); 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(); script().clearScriptObjects();
if (page() && page()->scrollingCoordinator() && m_view) if (page() && page()->scrollingCoordinator() && m_view)
...@@ -253,7 +277,7 @@ void LocalFrame::detachFromFrameHost() ...@@ -253,7 +277,7 @@ void LocalFrame::detachFromFrameHost()
{ {
// We should never be detatching the page during a Layout. // We should never be detatching the page during a Layout.
RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout());
Frame::detachFromFrameHost(); m_host = 0;
} }
String LocalFrame::documentTypeString() const String LocalFrame::documentTypeString() const
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "platform/Supplementable.h" #include "platform/Supplementable.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "platform/scroll/ScrollTypes.h" #include "platform/scroll/ScrollTypes.h"
#include "wtf/HashSet.h"
namespace blink { namespace blink {
...@@ -47,6 +48,7 @@ namespace blink { ...@@ -47,6 +48,7 @@ namespace blink {
class FloatSize; class FloatSize;
class FloatRect; class FloatRect;
class FrameConsole; class FrameConsole;
class FrameDestructionObserver;
class FrameSelection; class FrameSelection;
class FrameView; class FrameView;
class InputMethodController; class InputMethodController;
...@@ -75,8 +77,11 @@ namespace blink { ...@@ -75,8 +77,11 @@ namespace blink {
virtual ~LocalFrame(); virtual ~LocalFrame();
virtual void willDetachFrameHost() OVERRIDE; void addDestructionObserver(FrameDestructionObserver*);
virtual void detachFromFrameHost() OVERRIDE; void removeDestructionObserver(FrameDestructionObserver*);
void willDetachFrameHost();
void detachFromFrameHost();
virtual void disconnectOwnerElement() OVERRIDE; virtual void disconnectOwnerElement() OVERRIDE;
...@@ -150,6 +155,7 @@ namespace blink { ...@@ -150,6 +155,7 @@ namespace blink {
String localLayerTreeAsText(unsigned flags) const; String localLayerTreeAsText(unsigned flags) const;
HashSet<FrameDestructionObserver*> m_destructionObservers;
mutable FrameLoader m_loader; mutable FrameLoader m_loader;
mutable NavigationScheduler m_navigationScheduler; 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