Commit c4cf2227 authored by kenrb@chromium.org's avatar kenrb@chromium.org

Add Frame and RemoteFrame classes.

Creates RemoteFrame, which will represent in WebCore frames
that are rendered outside of Blink, and Frame, a base class
for both LocalFrame and RemoteFrame. The current division of
members and methods between Frame and LocalFrame is not
final, but provides a starting point for us to start
converting LocalFrame to Frame in some parts of Blink.

BUG=346764
R=eseidel@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@168501 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 705234df
...@@ -1062,6 +1062,8 @@ ...@@ -1062,6 +1062,8 @@
'frame/DeprecatedScheduleStyleRecalcDuringCompositingUpdate.h', 'frame/DeprecatedScheduleStyleRecalcDuringCompositingUpdate.h',
'frame/DeprecatedScheduleStyleRecalcDuringLayout.cpp', 'frame/DeprecatedScheduleStyleRecalcDuringLayout.cpp',
'frame/DeprecatedScheduleStyleRecalcDuringLayout.h', 'frame/DeprecatedScheduleStyleRecalcDuringLayout.h',
'frame/Frame.cpp',
'frame/Frame.h',
'frame/FrameDestructionObserver.cpp', 'frame/FrameDestructionObserver.cpp',
'frame/FrameDestructionObserver.h', 'frame/FrameDestructionObserver.h',
'frame/FrameHost.cpp', 'frame/FrameHost.cpp',
...@@ -1082,6 +1084,8 @@ ...@@ -1082,6 +1084,8 @@
'frame/NavigatorID.h', 'frame/NavigatorID.h',
'frame/NavigatorOnLine.h', 'frame/NavigatorOnLine.h',
'frame/PageConsole.cpp', 'frame/PageConsole.cpp',
'frame/RemoteFrame.cpp',
'frame/RemoteFrame.h',
'frame/Screen.cpp', 'frame/Screen.cpp',
'frame/Screen.h', 'frame/Screen.h',
'frame/Settings.cpp', 'frame/Settings.cpp',
......
/*
* Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
* 1999 Lars Knoll <knoll@kde.org>
* 1999 Antti Koivisto <koivisto@kde.org>
* 2000 Simon Hausmann <hausmann@kde.org>
* 2000 Stefan Schimanski <1Stein@gmx.de>
* 2001 George Staikos <staikos@kde.org>
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008 Eric Seidel <eric@webkit.org>
* Copyright (C) 2008 Google Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "core/frame/Frame.h"
#include "core/dom/DocumentType.h"
#include "core/events/Event.h"
#include "core/frame/DOMWindow.h"
#include "core/frame/FrameDestructionObserver.h"
#include "core/frame/FrameHost.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLFrameElementBase.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/loader/EmptyClients.h"
#include "core/loader/FrameLoaderClient.h"
#include "core/page/Chrome.h"
#include "core/page/ChromeClient.h"
#include "core/page/EventHandler.h"
#include "core/page/FocusController.h"
#include "core/page/Page.h"
#include "core/rendering/RenderView.h"
#include "public/platform/WebLayer.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefCountedLeakCounter.h"
namespace WebCore {
using namespace HTMLNames;
namespace {
int64_t generateFrameID()
{
// Initialize to the current time to reduce the likelihood of generating
// identifiers that overlap with those from past/future browser sessions.
static int64_t next = static_cast<int64_t>(currentTime() * 1000000.0);
return ++next;
}
} // namespace
DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, frameCounter, ("Frame"));
Frame::Frame(PassRefPtr<FrameInit> frameInit)
: m_frameInit(frameInit)
, m_host(m_frameInit->frameHost())
, m_frameID(generateFrameID())
, m_remotePlatformLayer(0)
{
ASSERT(page());
#ifndef NDEBUG
frameCounter.increment();
#endif
}
Frame::~Frame()
{
setDOMWindow(nullptr);
// FIXME: We should not be doing all this work inside the destructor
#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
{
return m_host;
}
Page* Frame::page() const
{
if (m_host)
return &m_host->page();
return 0;
}
Settings* Frame::settings() const
{
if (m_host)
return &m_host->settings();
return 0;
}
void Frame::setDOMWindow(PassRefPtr<DOMWindow> domWindow)
{
if (m_domWindow)
m_domWindow->reset();
m_domWindow = domWindow;
}
static ChromeClient& emptyChromeClient()
{
DEFINE_STATIC_LOCAL(EmptyChromeClient, client, ());
return client;
}
ChromeClient& Frame::chromeClient() const
{
if (Page* page = this->page())
return page->chrome().client();
return emptyChromeClient();
}
Document* Frame::document() const
{
return m_domWindow ? m_domWindow->document() : 0;
}
RenderView* Frame::contentRenderer() const
{
return document() ? document()->renderView() : 0;
}
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();
return page && this == page->mainFrame();
}
} // namespace WebCore
/*
* Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
* 1999-2001 Lars Knoll <knoll@kde.org>
* 1999-2001 Antti Koivisto <koivisto@kde.org>
* 2000-2001 Simon Hausmann <hausmann@kde.org>
* 2000-2001 Dirk Mueller <mueller@kde.org>
* 2000 Stefan Schimanski <1Stein@gmx.de>
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008 Eric Seidel <eric@webkit.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef Frame_h
#define Frame_h
#include "wtf/Forward.h"
#include "wtf/HashSet.h"
#include "wtf/RefCounted.h"
namespace blink {
class WebLayer;
}
namespace WebCore {
class Document;
class DOMWindow;
class ChromeClient;
class FrameDestructionObserver;
class FrameHost;
class FrameLoaderClient;
class HTMLFrameOwnerElement;
class Page;
class RenderView;
class Settings;
class FrameInit : public RefCounted<FrameInit> {
public:
// For creating a dummy Frame
static PassRefPtr<FrameInit> create(FrameHost* host, FrameLoaderClient* client)
{
return adoptRef(new FrameInit(host, client));
}
void setFrameHost(FrameHost* host) { m_frameHost = host; }
FrameHost* frameHost() const { return m_frameHost; }
void setFrameLoaderClient(FrameLoaderClient* client) { m_client = client; }
FrameLoaderClient* frameLoaderClient() const { return m_client; }
void setOwnerElement(HTMLFrameOwnerElement* ownerElement) { m_ownerElement = ownerElement; }
HTMLFrameOwnerElement* ownerElement() const { return m_ownerElement; }
protected:
FrameInit(FrameHost* host = 0, FrameLoaderClient* client = 0)
: m_client(client)
, m_frameHost(host)
, m_ownerElement(0)
{
}
private:
FrameLoaderClient* m_client;
FrameHost* m_frameHost;
HTMLFrameOwnerElement* m_ownerElement;
};
class Frame : public RefCounted<Frame> {
public:
virtual bool isLocalFrame() const { return false; }
virtual bool isRemoteFrame() const { return false; }
virtual ~Frame();
void addDestructionObserver(FrameDestructionObserver*);
void removeDestructionObserver(FrameDestructionObserver*);
virtual void willDetachFrameHost();
virtual void detachFromFrameHost();
// NOTE: Page is moving out of Blink up into the browser process as
// part of the site-isolation (out of process iframes) work.
// FrameHost should be used instead where possible.
Page* page() const;
FrameHost* host() const; // Null when the frame is detached.
bool isMainFrame() const;
// FIXME: DOMWindow and Document should both be moved to LocalFrame
// after RemoteFrame is complete enough to exist without them.
virtual void setDOMWindow(PassRefPtr<DOMWindow>);
DOMWindow* domWindow() const;
Document* document() const;
ChromeClient& chromeClient() const;
RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
int64_t frameID() const { return m_frameID; }
// FIXME: These should move to RemoteFrame when that is instantiated.
void setRemotePlatformLayer(blink::WebLayer* remotePlatformLayer) { m_remotePlatformLayer = remotePlatformLayer; }
blink::WebLayer* remotePlatformLayer() const { return m_remotePlatformLayer; }
Settings* settings() const; // can be null
protected:
Frame(PassRefPtr<FrameInit>);
RefPtr<FrameInit> m_frameInit;
FrameHost* m_host;
RefPtr<DOMWindow> m_domWindow;
private:
HashSet<FrameDestructionObserver*> m_destructionObservers;
// Temporary hack for history.
int64_t m_frameID;
blink::WebLayer* m_remotePlatformLayer;
};
inline DOMWindow* Frame::domWindow() const
{
return m_domWindow.get();
}
} // namespace WebCore
#endif // Frame_h
...@@ -43,19 +43,15 @@ ...@@ -43,19 +43,15 @@
#include "core/events/Event.h" #include "core/events/Event.h"
#include "core/fetch/ResourceFetcher.h" #include "core/fetch/ResourceFetcher.h"
#include "core/frame/DOMWindow.h" #include "core/frame/DOMWindow.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/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"
#include "core/loader/EmptyClients.h"
#include "core/loader/FrameLoaderClient.h" #include "core/loader/FrameLoaderClient.h"
#include "core/page/Chrome.h" #include "core/page/Chrome.h"
#include "core/page/ChromeClient.h"
#include "core/page/EventHandler.h" #include "core/page/EventHandler.h"
#include "core/page/FocusController.h" #include "core/page/FocusController.h"
#include "core/page/Page.h"
#include "core/page/scrolling/ScrollingCoordinator.h" #include "core/page/scrolling/ScrollingCoordinator.h"
#include "core/rendering/HitTestResult.h" #include "core/rendering/HitTestResult.h"
#include "core/rendering/RenderLayer.h" #include "core/rendering/RenderLayer.h"
...@@ -66,9 +62,7 @@ ...@@ -66,9 +62,7 @@
#include "platform/DragImage.h" #include "platform/DragImage.h"
#include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/ImageBuffer.h" #include "platform/graphics/ImageBuffer.h"
#include "public/platform/WebLayer.h"
#include "wtf/PassOwnPtr.h" #include "wtf/PassOwnPtr.h"
#include "wtf/RefCountedLeakCounter.h"
#include "wtf/StdLibExtras.h" #include "wtf/StdLibExtras.h"
using namespace std; using namespace std;
...@@ -77,20 +71,6 @@ namespace WebCore { ...@@ -77,20 +71,6 @@ namespace WebCore {
using namespace HTMLNames; using namespace HTMLNames;
namespace {
int64_t generateFrameID()
{
// Initialize to the current time to reduce the likelihood of generating
// identifiers that overlap with those from past/future browser sessions.
static int64_t next = static_cast<int64_t>(currentTime() * 1000000.0);
return ++next;
}
} // namespace
DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, frameCounter, ("LocalFrame"));
static inline float parentPageZoomFactor(LocalFrame* frame) static inline float parentPageZoomFactor(LocalFrame* frame)
{ {
LocalFrame* parent = frame->tree().parent(); LocalFrame* parent = frame->tree().parent();
...@@ -108,10 +88,9 @@ static inline float parentTextZoomFactor(LocalFrame* frame) ...@@ -108,10 +88,9 @@ static inline float parentTextZoomFactor(LocalFrame* frame)
} }
inline LocalFrame::LocalFrame(PassRefPtr<FrameInit> frameInit) inline LocalFrame::LocalFrame(PassRefPtr<FrameInit> frameInit)
: m_frameID(generateFrameID()) : Frame(frameInit)
, m_host(frameInit->frameHost())
, m_treeNode(this) , m_treeNode(this)
, m_loader(this, frameInit->frameLoaderClient()) , m_loader(this, m_frameInit->frameLoaderClient())
, m_navigationScheduler(this) , m_navigationScheduler(this)
, m_script(adoptPtr(new ScriptController(this))) , m_script(adoptPtr(new ScriptController(this)))
, m_editor(Editor::create(*this)) , m_editor(Editor::create(*this))
...@@ -119,23 +98,15 @@ inline LocalFrame::LocalFrame(PassRefPtr<FrameInit> frameInit) ...@@ -119,23 +98,15 @@ inline LocalFrame::LocalFrame(PassRefPtr<FrameInit> frameInit)
, m_selection(adoptPtr(new FrameSelection(this))) , m_selection(adoptPtr(new FrameSelection(this)))
, m_eventHandler(adoptPtr(new EventHandler(this))) , m_eventHandler(adoptPtr(new EventHandler(this)))
, m_inputMethodController(InputMethodController::create(*this)) , m_inputMethodController(InputMethodController::create(*this))
, m_frameInit(frameInit)
, m_pageZoomFactor(parentPageZoomFactor(this)) , m_pageZoomFactor(parentPageZoomFactor(this))
, m_textZoomFactor(parentTextZoomFactor(this)) , m_textZoomFactor(parentTextZoomFactor(this))
, m_orientation(0) , m_orientation(0)
, m_inViewSourceMode(false) , m_inViewSourceMode(false)
, m_remotePlatformLayer(0)
{ {
ASSERT(page());
if (ownerElement()) { if (ownerElement()) {
page()->incrementSubframeCount(); page()->incrementSubframeCount();
ownerElement()->setContentFrame(*this); ownerElement()->setContentFrame(*this);
} }
#ifndef NDEBUG
frameCounter.increment();
#endif
} }
PassRefPtr<LocalFrame> LocalFrame::create(PassRefPtr<FrameInit> frameInit) PassRefPtr<LocalFrame> LocalFrame::create(PassRefPtr<FrameInit> frameInit)
...@@ -153,17 +124,7 @@ LocalFrame::~LocalFrame() ...@@ -153,17 +124,7 @@ LocalFrame::~LocalFrame()
loader().clear(); loader().clear();
setDOMWindow(nullptr); setDOMWindow(nullptr);
// FIXME: We should not be doing all this work inside the destructor
#ifndef NDEBUG
frameCounter.decrement();
#endif
disconnectOwnerElement(); disconnectOwnerElement();
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
...@@ -178,16 +139,6 @@ bool LocalFrame::inScope(TreeScope* scope) const ...@@ -178,16 +139,6 @@ bool LocalFrame::inScope(TreeScope* scope) const
return owner->treeScope() == scope; return owner->treeScope() == scope;
} }
void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer)
{
m_destructionObservers.add(observer);
}
void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer)
{
m_destructionObservers.remove(observer);
}
void LocalFrame::setView(PassRefPtr<FrameView> view) void LocalFrame::setView(PassRefPtr<FrameView> view)
{ {
// We the custom scroll bars as early as possible to prevent m_doc->detach() // We the custom scroll bars as early as possible to prevent m_doc->detach()
...@@ -222,25 +173,6 @@ void LocalFrame::sendOrientationChangeEvent(int orientation) ...@@ -222,25 +173,6 @@ void LocalFrame::sendOrientationChangeEvent(int orientation)
window->dispatchEvent(Event::create(EventTypeNames::orientationchange)); window->dispatchEvent(Event::create(EventTypeNames::orientationchange));
} }
FrameHost* LocalFrame::host() const
{
return m_host;
}
Page* LocalFrame::page() const
{
if (m_host)
return &m_host->page();
return 0;
}
Settings* LocalFrame::settings() const
{
if (m_host)
return &m_host->settings();
return 0;
}
void LocalFrame::setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio) void LocalFrame::setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio)
{ {
// In setting printing, we should not validate resources already cached for the document. // In setting printing, we should not validate resources already cached for the document.
...@@ -293,34 +225,9 @@ FloatSize LocalFrame::resizePageRectsKeepingRatio(const FloatSize& originalSize, ...@@ -293,34 +225,9 @@ FloatSize LocalFrame::resizePageRectsKeepingRatio(const FloatSize& originalSize,
void LocalFrame::setDOMWindow(PassRefPtr<DOMWindow> domWindow) void LocalFrame::setDOMWindow(PassRefPtr<DOMWindow> domWindow)
{ {
InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get()); InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get());
if (m_domWindow)
m_domWindow->reset();
if (domWindow) if (domWindow)
script().clearWindowShell(); script().clearWindowShell();
m_domWindow = domWindow; Frame::setDOMWindow(domWindow);
}
static ChromeClient& emptyChromeClient()
{
DEFINE_STATIC_LOCAL(EmptyChromeClient, client, ());
return client;
}
ChromeClient& LocalFrame::chromeClient() const
{
if (Page* page = this->page())
return page->chrome().client();
return emptyChromeClient();
}
Document* LocalFrame::document() const
{
return m_domWindow ? m_domWindow->document() : 0;
}
RenderView* LocalFrame::contentRenderer() const
{
return document() ? document()->renderView() : 0;
} }
RenderPart* LocalFrame::ownerRenderer() const RenderPart* LocalFrame::ownerRenderer() const
...@@ -360,27 +267,18 @@ void LocalFrame::willDetachFrameHost() ...@@ -360,27 +267,18 @@ void LocalFrame::willDetachFrameHost()
if (LocalFrame* parent = tree().parent()) if (LocalFrame* parent = tree().parent())
parent->loader().checkLoadComplete(); parent->loader().checkLoadComplete();
HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.end(); Frame::willDetachFrameHost();
for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it) script().clearScriptObjects();
(*it)->willDetachFrameHost();
// FIXME: Page should take care of updating focus/scrolling instead of LocalFrame.
// 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);
if (page() && page()->scrollingCoordinator() && m_view) if (page() && page()->scrollingCoordinator() && m_view)
page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get());
script().clearScriptObjects();
} }
void LocalFrame::detachFromFrameHost() 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());
m_host = 0; Frame::detachFromFrameHost();
} }
void LocalFrame::disconnectOwnerElement() void LocalFrame::disconnectOwnerElement()
...@@ -395,12 +293,6 @@ void LocalFrame::disconnectOwnerElement() ...@@ -395,12 +293,6 @@ void LocalFrame::disconnectOwnerElement()
m_frameInit->setOwnerElement(0); m_frameInit->setOwnerElement(0);
} }
bool LocalFrame::isMainFrame() const
{
Page* page = this->page();
return page && this == page->mainFrame();
}
String LocalFrame::documentTypeString() const String LocalFrame::documentTypeString() const
{ {
if (DocumentType* doctype = document()->doctype()) if (DocumentType* doctype = document()->doctype())
......
...@@ -28,139 +28,72 @@ ...@@ -28,139 +28,72 @@
#ifndef LocalFrame_h #ifndef LocalFrame_h
#define LocalFrame_h #define LocalFrame_h
#include "core/frame/Frame.h"
#include "core/loader/FrameLoader.h" #include "core/loader/FrameLoader.h"
#include "core/loader/NavigationScheduler.h" #include "core/loader/NavigationScheduler.h"
#include "core/page/FrameTree.h" #include "core/page/FrameTree.h"
#include "platform/geometry/IntSize.h"
#include "platform/scroll/ScrollTypes.h" #include "platform/scroll/ScrollTypes.h"
#include "wtf/Forward.h"
#include "wtf/RefCounted.h"
namespace blink {
class WebLayer;
}
namespace WebCore { namespace WebCore {
class ChromeClient;
class Color; class Color;
class DOMWindow;
class Document;
class DragImage; class DragImage;
class Editor; class Editor;
class Element;
class EventHandler; class EventHandler;
class FetchContext; class FetchContext;
class FloatSize; class FloatSize;
class FrameDestructionObserver;
class FrameHost;
class FrameSelection; class FrameSelection;
class FrameView; class FrameView;
class HTMLFrameOwnerElement;
class HTMLTableCellElement;
class InputMethodController; class InputMethodController;
class IntPoint; class IntPoint;
class IntSize;
class Node; class Node;
class Page;
class Range; class Range;
class RenderPart; class RenderPart;
class RenderView;
class TreeScope; class TreeScope;
class ScriptController; class ScriptController;
class Settings;
class SpellChecker; class SpellChecker;
class TreeScope; class TreeScope;
class VisiblePosition; class VisiblePosition;
class Widget;
class FrameInit : public RefCounted<FrameInit> { class LocalFrame : public Frame {
public:
// For creating a dummy LocalFrame
static PassRefPtr<FrameInit> create(FrameHost* host, FrameLoaderClient* client)
{
return adoptRef(new FrameInit(host, client));
}
void setFrameHost(FrameHost* host) { m_frameHost = host; }
FrameHost* frameHost() const { return m_frameHost; }
void setFrameLoaderClient(FrameLoaderClient* client) { m_client = client; }
FrameLoaderClient* frameLoaderClient() const { return m_client; }
void setOwnerElement(HTMLFrameOwnerElement* ownerElement) { m_ownerElement = ownerElement; }
HTMLFrameOwnerElement* ownerElement() const { return m_ownerElement; }
protected:
FrameInit(FrameHost* host = 0, FrameLoaderClient* client = 0)
: m_client(client)
, m_frameHost(host)
, m_ownerElement(0)
{
}
private:
FrameLoaderClient* m_client;
FrameHost* m_frameHost;
HTMLFrameOwnerElement* m_ownerElement;
};
class LocalFrame : public RefCounted<LocalFrame> {
public: public:
static PassRefPtr<LocalFrame> create(PassRefPtr<FrameInit>); static PassRefPtr<LocalFrame> create(PassRefPtr<FrameInit>);
virtual bool isLocalFrame() const OVERRIDE { return true; }
void init(); void init();
void setView(PassRefPtr<FrameView>); void setView(PassRefPtr<FrameView>);
void createView(const IntSize&, const Color&, bool, void createView(const IntSize&, const Color&, bool,
ScrollbarMode = ScrollbarAuto, bool horizontalLock = false, ScrollbarMode = ScrollbarAuto, bool horizontalLock = false,
ScrollbarMode = ScrollbarAuto, bool verticalLock = false); ScrollbarMode = ScrollbarAuto, bool verticalLock = false);
~LocalFrame(); virtual ~LocalFrame();
void addDestructionObserver(FrameDestructionObserver*);
void removeDestructionObserver(FrameDestructionObserver*);
void willDetachFrameHost(); virtual void willDetachFrameHost() OVERRIDE;
void detachFromFrameHost(); virtual void detachFromFrameHost() OVERRIDE;
void disconnectOwnerElement(); void disconnectOwnerElement();
// NOTE: Page is moving out of Blink up into the browser process as
// part of the site-isolation (out of process iframes) work.
// FrameHost should be used instead where possible.
Page* page() const;
FrameHost* host() const; // Null when the frame is detached.
HTMLFrameOwnerElement* ownerElement() const; HTMLFrameOwnerElement* ownerElement() const;
bool isMainFrame() const;
void setDOMWindow(PassRefPtr<DOMWindow>); virtual void setDOMWindow(PassRefPtr<DOMWindow>) OVERRIDE;
DOMWindow* domWindow() const;
Document* document() const;
FrameView* view() const; FrameView* view() const;
ChromeClient& chromeClient() const;
Editor& editor() const; Editor& editor() const;
EventHandler& eventHandler() const; EventHandler& eventHandler() const;
FrameLoader& loader() const; FrameLoader& loader() const;
FrameTree& tree() const;
NavigationScheduler& navigationScheduler() const; NavigationScheduler& navigationScheduler() const;
FrameSelection& selection() const; FrameSelection& selection() const;
FrameTree& tree() const;
InputMethodController& inputMethodController() const; InputMethodController& inputMethodController() const;
FetchContext& fetchContext() const { return loader().fetchContext(); } FetchContext& fetchContext() const { return loader().fetchContext(); }
ScriptController& script(); ScriptController& script();
SpellChecker& spellChecker() const; SpellChecker& spellChecker() const;
RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame. RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame.
void didChangeVisibilityState(); void didChangeVisibilityState();
int64_t frameID() const { return m_frameID; }
// FIXME: These should move to RemoteFrame once that exists.
// RemotePlatformLayer is only ever set for Frames which exist in another process.
void setRemotePlatformLayer(blink::WebLayer* remotePlatformLayer) { m_remotePlatformLayer = remotePlatformLayer; }
blink::WebLayer* remotePlatformLayer() const { return m_remotePlatformLayer; }
// ======== All public functions below this point are candidates to move out of LocalFrame into another class. ======== // ======== All public functions below this point are candidates to move out of LocalFrame into another class. ========
bool inScope(TreeScope*) const; bool inScope(TreeScope*) const;
...@@ -171,8 +104,6 @@ namespace WebCore { ...@@ -171,8 +104,6 @@ namespace WebCore {
String layerTreeAsText(unsigned flags = 0) const; String layerTreeAsText(unsigned flags = 0) const;
String trackedRepaintRectsAsText() const; String trackedRepaintRectsAsText() const;
Settings* settings() const; // can be NULL
void setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio); void setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio);
bool shouldUsePrintingLayout() const; bool shouldUsePrintingLayout() const;
FloatSize resizePageRectsKeepingRatio(const FloatSize& originalSize, const FloatSize& expectedSize); FloatSize resizePageRectsKeepingRatio(const FloatSize& originalSize, const FloatSize& expectedSize);
...@@ -217,17 +148,11 @@ namespace WebCore { ...@@ -217,17 +148,11 @@ namespace WebCore {
private: private:
LocalFrame(PassRefPtr<FrameInit>); LocalFrame(PassRefPtr<FrameInit>);
HashSet<FrameDestructionObserver*> m_destructionObservers;
// Temporary hack for history.
int64_t m_frameID;
FrameHost* m_host;
mutable FrameTree m_treeNode; mutable FrameTree m_treeNode;
mutable FrameLoader m_loader; mutable FrameLoader m_loader;
mutable NavigationScheduler m_navigationScheduler; mutable NavigationScheduler m_navigationScheduler;
RefPtr<FrameView> m_view; RefPtr<FrameView> m_view;
RefPtr<DOMWindow> m_domWindow;
OwnPtr<ScriptController> m_script; OwnPtr<ScriptController> m_script;
const OwnPtr<Editor> m_editor; const OwnPtr<Editor> m_editor;
...@@ -236,16 +161,12 @@ namespace WebCore { ...@@ -236,16 +161,12 @@ namespace WebCore {
const OwnPtr<EventHandler> m_eventHandler; const OwnPtr<EventHandler> m_eventHandler;
OwnPtr<InputMethodController> m_inputMethodController; OwnPtr<InputMethodController> m_inputMethodController;
RefPtr<FrameInit> m_frameInit;
float m_pageZoomFactor; float m_pageZoomFactor;
float m_textZoomFactor; float m_textZoomFactor;
int m_orientation; int m_orientation;
bool m_inViewSourceMode; bool m_inViewSourceMode;
blink::WebLayer* m_remotePlatformLayer;
}; };
inline void LocalFrame::init() inline void LocalFrame::init()
...@@ -273,11 +194,6 @@ namespace WebCore { ...@@ -273,11 +194,6 @@ namespace WebCore {
return *m_script; return *m_script;
} }
inline DOMWindow* LocalFrame::domWindow() const
{
return m_domWindow.get();
}
inline FrameSelection& LocalFrame::selection() const inline FrameSelection& LocalFrame::selection() const
{ {
return *m_selection; return *m_selection;
...@@ -324,6 +240,8 @@ namespace WebCore { ...@@ -324,6 +240,8 @@ namespace WebCore {
return *m_eventHandler; return *m_eventHandler;
} }
DEFINE_TYPE_CASTS(LocalFrame, Frame, localFrame, localFrame->isLocalFrame(), localFrame.isLocalFrame());
} // namespace WebCore } // namespace WebCore
#endif // LocalFrame_h #endif // LocalFrame_h
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "core/frame/RemoteFrame.h"
namespace WebCore {
inline RemoteFrame::RemoteFrame(PassRefPtr<FrameInit> frameInit)
: Frame(frameInit)
{
}
PassRefPtr<RemoteFrame> RemoteFrame::create(PassRefPtr<FrameInit> frameInit)
{
RefPtr<RemoteFrame> frame = adoptRef(new RemoteFrame(frameInit));
return frame.release();
}
RemoteFrame::~RemoteFrame()
{
}
} // namespace WebCore
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef RemoteFrame_h
#define RemoteFrame_h
#include "core/frame/Frame.h"
namespace WebCore {
class RemoteFrame: public Frame {
public:
static PassRefPtr<RemoteFrame> create(PassRefPtr<FrameInit>);
virtual bool isRemoteFrame() const OVERRIDE { return true; }
virtual ~RemoteFrame();
private:
RemoteFrame(PassRefPtr<FrameInit>);
};
DEFINE_TYPE_CASTS(RemoteFrame, Frame, remoteFrame, remoteFrame->isRemoteFrame(), remoteFrame.isRemoteFrame());
} // namespace WebCore
#endif // RemoteFrame_h
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