• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3  *                     1999-2001 Lars Knoll <knoll@kde.org>
4  *                     1999-2001 Antti Koivisto <koivisto@kde.org>
5  *                     2000-2001 Simon Hausmann <hausmann@kde.org>
6  *                     2000-2001 Dirk Mueller <mueller@kde.org>
7  *                     2000 Stefan Schimanski <1Stein@gmx.de>
8  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
9  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
10  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public License
23  * along with this library; see the file COPYING.LIB.  If not, write to
24  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25  * Boston, MA 02110-1301, USA.
26  */
27 
28 #ifndef Frame_h
29 #define Frame_h
30 
31 #include "core/page/FrameTree.h"
32 #include "platform/heap/Handle.h"
33 #include "wtf/Forward.h"
34 #include "wtf/HashSet.h"
35 #include "wtf/RefCounted.h"
36 
37 namespace blink {
38 class WebLayer;
39 }
40 
41 namespace WebCore {
42 
43 class ChromeClient;
44 class FrameClient;
45 class FrameDestructionObserver;
46 class FrameHost;
47 class FrameOwner;
48 class HTMLFrameOwnerElement;
49 class LocalDOMWindow;
50 class Page;
51 class RenderPart;
52 class Settings;
53 
54 class Frame : public RefCounted<Frame> {
55 public:
isLocalFrame()56     virtual bool isLocalFrame() const { return false; }
isRemoteFrame()57     virtual bool isRemoteFrame() const { return false; }
58 
59     virtual ~Frame();
60 
61     void addDestructionObserver(FrameDestructionObserver*);
62     void removeDestructionObserver(FrameDestructionObserver*);
63 
64     virtual void willDetachFrameHost();
65     virtual void detachFromFrameHost();
66 
67     FrameClient* client() const;
68     void clearClient();
69 
70     // NOTE: Page is moving out of Blink up into the browser process as
71     // part of the site-isolation (out of process iframes) work.
72     // FrameHost should be used instead where possible.
73     Page* page() const;
74     FrameHost* host() const; // Null when the frame is detached.
75 
76     bool isMainFrame() const;
77 
78     virtual void disconnectOwnerElement();
79 
80     FrameOwner* owner() const;
81     HTMLFrameOwnerElement* deprecatedLocalOwner() const;
82 
83     // FIXME: LocalDOMWindow and Document should both be moved to LocalFrame
84     // after RemoteFrame is complete enough to exist without them.
85     virtual void setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow>);
86     LocalDOMWindow* domWindow() const;
87 
88     FrameTree& tree() const;
89     ChromeClient& chromeClient() const;
90 
91     RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame.
92 
93     // FIXME: These should move to RemoteFrame when that is instantiated.
setRemotePlatformLayer(blink::WebLayer * remotePlatformLayer)94     void setRemotePlatformLayer(blink::WebLayer* remotePlatformLayer) { m_remotePlatformLayer = remotePlatformLayer; }
remotePlatformLayer()95     blink::WebLayer* remotePlatformLayer() const { return m_remotePlatformLayer; }
96 
97     Settings* settings() const; // can be null
98 
99     // FIXME: This method identifies a LocalFrame that is acting as a RemoteFrame.
100     // It is necessary only until we can instantiate a RemoteFrame, at which point
101     // it can be removed and its callers can be converted to use the isRemoteFrame()
102     // method.
isRemoteFrameTemporary()103     bool isRemoteFrameTemporary() const { return m_remotePlatformLayer; }
104 
105 protected:
106     Frame(FrameClient*, FrameHost*, FrameOwner*);
107 
108     mutable FrameTree m_treeNode;
109 
110     FrameHost* m_host;
111     FrameOwner* m_owner;
112 
113     RefPtrWillBePersistent<LocalDOMWindow> m_domWindow;
114 
115 private:
116     FrameClient* m_client;
117     HashSet<FrameDestructionObserver*> m_destructionObservers;
118 
119     blink::WebLayer* m_remotePlatformLayer;
120 };
121 
client()122 inline FrameClient* Frame::client() const
123 {
124     return m_client;
125 }
126 
clearClient()127 inline void Frame::clearClient()
128 {
129     m_client = 0;
130 }
131 
domWindow()132 inline LocalDOMWindow* Frame::domWindow() const
133 {
134     return m_domWindow.get();
135 }
136 
owner()137 inline FrameOwner* Frame::owner() const
138 {
139     return m_owner;
140 }
141 
tree()142 inline FrameTree& Frame::tree() const
143 {
144     return m_treeNode;
145 }
146 
147 // Allow equality comparisons of Frames by reference or pointer, interchangeably.
148 DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES_REFCOUNTED(Frame)
149 
150 } // namespace WebCore
151 
152 #endif // Frame_h
153