OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
3 * 1999-2001 Lars Knoll <knoll@kde.org> | 3 * 1999-2001 Lars Knoll <knoll@kde.org> |
4 * 1999-2001 Antti Koivisto <koivisto@kde.org> | 4 * 1999-2001 Antti Koivisto <koivisto@kde.org> |
5 * 2000-2001 Simon Hausmann <hausmann@kde.org> | 5 * 2000-2001 Simon Hausmann <hausmann@kde.org> |
6 * 2000-2001 Dirk Mueller <mueller@kde.org> | 6 * 2000-2001 Dirk Mueller <mueller@kde.org> |
7 * 2000 Stefan Schimanski <1Stein@gmx.de> | 7 * 2000 Stefan Schimanski <1Stein@gmx.de> |
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 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) | 9 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 10 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
(...skipping 10 matching lines...) Expand all Loading... |
21 * | 21 * |
22 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 * Boston, MA 02110-1301, USA. | 25 * Boston, MA 02110-1301, USA. |
26 */ | 26 */ |
27 | 27 |
28 #ifndef LocalFrame_h | 28 #ifndef LocalFrame_h |
29 #define LocalFrame_h | 29 #define LocalFrame_h |
30 | 30 |
| 31 #include "core/frame/Frame.h" |
31 #include "core/loader/FrameLoader.h" | 32 #include "core/loader/FrameLoader.h" |
32 #include "core/loader/NavigationScheduler.h" | 33 #include "core/loader/NavigationScheduler.h" |
33 #include "core/page/FrameTree.h" | 34 #include "core/page/FrameTree.h" |
34 #include "platform/geometry/IntSize.h" | |
35 #include "platform/scroll/ScrollTypes.h" | 35 #include "platform/scroll/ScrollTypes.h" |
36 #include "wtf/Forward.h" | |
37 #include "wtf/RefCounted.h" | |
38 | |
39 namespace blink { | |
40 class WebLayer; | |
41 } | |
42 | 36 |
43 namespace WebCore { | 37 namespace WebCore { |
44 | 38 |
45 class ChromeClient; | |
46 class Color; | 39 class Color; |
47 class DOMWindow; | |
48 class Document; | |
49 class DragImage; | 40 class DragImage; |
50 class Editor; | 41 class Editor; |
51 class Element; | |
52 class EventHandler; | 42 class EventHandler; |
53 class FetchContext; | 43 class FetchContext; |
54 class FloatSize; | 44 class FloatSize; |
55 class FrameDestructionObserver; | |
56 class FrameHost; | |
57 class FrameSelection; | 45 class FrameSelection; |
58 class FrameView; | 46 class FrameView; |
59 class HTMLFrameOwnerElement; | |
60 class HTMLTableCellElement; | |
61 class InputMethodController; | 47 class InputMethodController; |
62 class IntPoint; | 48 class IntPoint; |
| 49 class IntSize; |
63 class Node; | 50 class Node; |
64 class Page; | |
65 class Range; | 51 class Range; |
66 class RenderPart; | 52 class RenderPart; |
67 class RenderView; | |
68 class TreeScope; | 53 class TreeScope; |
69 class ScriptController; | 54 class ScriptController; |
70 class Settings; | |
71 class SpellChecker; | 55 class SpellChecker; |
72 class TreeScope; | 56 class TreeScope; |
73 class VisiblePosition; | 57 class VisiblePosition; |
74 class Widget; | |
75 | 58 |
76 class FrameInit : public RefCounted<FrameInit> { | 59 class LocalFrame : public Frame { |
77 public: | |
78 // For creating a dummy LocalFrame | |
79 static PassRefPtr<FrameInit> create(FrameHost* host, FrameLoaderClient*
client) | |
80 { | |
81 return adoptRef(new FrameInit(host, client)); | |
82 } | |
83 | |
84 void setFrameHost(FrameHost* host) { m_frameHost = host; } | |
85 FrameHost* frameHost() const { return m_frameHost; } | |
86 | |
87 void setFrameLoaderClient(FrameLoaderClient* client) { m_client = client
; } | |
88 FrameLoaderClient* frameLoaderClient() const { return m_client; } | |
89 | |
90 void setOwnerElement(HTMLFrameOwnerElement* ownerElement) { m_ownerEleme
nt = ownerElement; } | |
91 HTMLFrameOwnerElement* ownerElement() const { return m_ownerElement; } | |
92 | |
93 protected: | |
94 FrameInit(FrameHost* host = 0, FrameLoaderClient* client = 0) | |
95 : m_client(client) | |
96 , m_frameHost(host) | |
97 , m_ownerElement(0) | |
98 { | |
99 } | |
100 | |
101 private: | |
102 FrameLoaderClient* m_client; | |
103 FrameHost* m_frameHost; | |
104 HTMLFrameOwnerElement* m_ownerElement; | |
105 }; | |
106 | |
107 class LocalFrame : public RefCounted<LocalFrame> { | |
108 public: | 60 public: |
109 static PassRefPtr<LocalFrame> create(PassRefPtr<FrameInit>); | 61 static PassRefPtr<LocalFrame> create(PassRefPtr<FrameInit>); |
110 | 62 |
| 63 virtual bool isLocalFrame() const OVERRIDE { return true; } |
| 64 |
111 void init(); | 65 void init(); |
112 void setView(PassRefPtr<FrameView>); | 66 void setView(PassRefPtr<FrameView>); |
113 void createView(const IntSize&, const Color&, bool, | 67 void createView(const IntSize&, const Color&, bool, |
114 ScrollbarMode = ScrollbarAuto, bool horizontalLock = false, | 68 ScrollbarMode = ScrollbarAuto, bool horizontalLock = false, |
115 ScrollbarMode = ScrollbarAuto, bool verticalLock = false); | 69 ScrollbarMode = ScrollbarAuto, bool verticalLock = false); |
116 | 70 |
117 ~LocalFrame(); | 71 virtual ~LocalFrame(); |
118 | 72 |
119 void addDestructionObserver(FrameDestructionObserver*); | 73 virtual void willDetachFrameHost() OVERRIDE; |
120 void removeDestructionObserver(FrameDestructionObserver*); | 74 virtual void detachFromFrameHost() OVERRIDE; |
121 | |
122 void willDetachFrameHost(); | |
123 void detachFromFrameHost(); | |
124 void disconnectOwnerElement(); | 75 void disconnectOwnerElement(); |
125 | 76 |
126 // NOTE: Page is moving out of Blink up into the browser process as | 77 HTMLFrameOwnerElement* ownerElement() const; |
127 // part of the site-isolation (out of process iframes) work. | |
128 // FrameHost should be used instead where possible. | |
129 Page* page() const; | |
130 FrameHost* host() const; // Null when the frame is detached. | |
131 | 78 |
132 HTMLFrameOwnerElement* ownerElement() const; | 79 virtual void setDOMWindow(PassRefPtr<DOMWindow>) OVERRIDE; |
133 bool isMainFrame() const; | |
134 | |
135 void setDOMWindow(PassRefPtr<DOMWindow>); | |
136 DOMWindow* domWindow() const; | |
137 Document* document() const; | |
138 FrameView* view() const; | 80 FrameView* view() const; |
139 | 81 |
140 ChromeClient& chromeClient() const; | |
141 Editor& editor() const; | 82 Editor& editor() const; |
142 EventHandler& eventHandler() const; | 83 EventHandler& eventHandler() const; |
143 FrameLoader& loader() const; | 84 FrameLoader& loader() const; |
| 85 FrameTree& tree() const; |
144 NavigationScheduler& navigationScheduler() const; | 86 NavigationScheduler& navigationScheduler() const; |
145 FrameSelection& selection() const; | 87 FrameSelection& selection() const; |
146 FrameTree& tree() const; | |
147 InputMethodController& inputMethodController() const; | 88 InputMethodController& inputMethodController() const; |
148 FetchContext& fetchContext() const { return loader().fetchContext(); } | 89 FetchContext& fetchContext() const { return loader().fetchContext(); } |
149 ScriptController& script(); | 90 ScriptController& script(); |
150 SpellChecker& spellChecker() const; | 91 SpellChecker& spellChecker() const; |
151 | 92 |
152 RenderView* contentRenderer() const; // Root of the render tree for the
document contained in this frame. | |
153 RenderPart* ownerRenderer() const; // Renderer for the element that cont
ains this frame. | 93 RenderPart* ownerRenderer() const; // Renderer for the element that cont
ains this frame. |
154 | 94 |
155 void didChangeVisibilityState(); | 95 void didChangeVisibilityState(); |
156 | 96 |
157 int64_t frameID() const { return m_frameID; } | |
158 | |
159 // FIXME: These should move to RemoteFrame once that exists. | |
160 // RemotePlatformLayer is only ever set for Frames which exist in anothe
r process. | |
161 void setRemotePlatformLayer(blink::WebLayer* remotePlatformLayer) { m_re
motePlatformLayer = remotePlatformLayer; } | |
162 blink::WebLayer* remotePlatformLayer() const { return m_remotePlatformLa
yer; } | |
163 | |
164 // ======== All public functions below this point are candidates to move out
of LocalFrame into another class. ======== | 97 // ======== All public functions below this point are candidates to move out
of LocalFrame into another class. ======== |
165 | 98 |
166 bool inScope(TreeScope*) const; | 99 bool inScope(TreeScope*) const; |
167 | 100 |
168 void countObjectsNeedingLayout(unsigned& needsLayoutObjects, unsigned& t
otalObjects, bool& isPartial); | 101 void countObjectsNeedingLayout(unsigned& needsLayoutObjects, unsigned& t
otalObjects, bool& isPartial); |
169 | 102 |
170 // See GraphicsLayerClient.h for accepted flags. | 103 // See GraphicsLayerClient.h for accepted flags. |
171 String layerTreeAsText(unsigned flags = 0) const; | 104 String layerTreeAsText(unsigned flags = 0) const; |
172 String trackedRepaintRectsAsText() const; | 105 String trackedRepaintRectsAsText() const; |
173 | 106 |
174 Settings* settings() const; // can be NULL | |
175 | |
176 void setPrinting(bool printing, const FloatSize& pageSize, const FloatSi
ze& originalPageSize, float maximumShrinkRatio); | 107 void setPrinting(bool printing, const FloatSize& pageSize, const FloatSi
ze& originalPageSize, float maximumShrinkRatio); |
177 bool shouldUsePrintingLayout() const; | 108 bool shouldUsePrintingLayout() const; |
178 FloatSize resizePageRectsKeepingRatio(const FloatSize& originalSize, con
st FloatSize& expectedSize); | 109 FloatSize resizePageRectsKeepingRatio(const FloatSize& originalSize, con
st FloatSize& expectedSize); |
179 | 110 |
180 bool inViewSourceMode() const; | 111 bool inViewSourceMode() const; |
181 void setInViewSourceMode(bool = true); | 112 void setInViewSourceMode(bool = true); |
182 | 113 |
183 void setPageZoomFactor(float factor); | 114 void setPageZoomFactor(float factor); |
184 float pageZoomFactor() const { return m_pageZoomFactor; } | 115 float pageZoomFactor() const { return m_pageZoomFactor; } |
185 void setTextZoomFactor(float factor); | 116 void setTextZoomFactor(float factor); |
(...skipping 24 matching lines...) Expand all Loading... |
210 // Should only be called on the main frame of a page. | 141 // Should only be called on the main frame of a page. |
211 void notifyChromeClientWheelEventHandlerCountChanged() const; | 142 void notifyChromeClientWheelEventHandlerCountChanged() const; |
212 | 143 |
213 bool isURLAllowed(const KURL&) const; | 144 bool isURLAllowed(const KURL&) const; |
214 | 145 |
215 // ======== | 146 // ======== |
216 | 147 |
217 private: | 148 private: |
218 LocalFrame(PassRefPtr<FrameInit>); | 149 LocalFrame(PassRefPtr<FrameInit>); |
219 | 150 |
220 HashSet<FrameDestructionObserver*> m_destructionObservers; | |
221 | |
222 // Temporary hack for history. | |
223 int64_t m_frameID; | |
224 FrameHost* m_host; | |
225 mutable FrameTree m_treeNode; | 151 mutable FrameTree m_treeNode; |
226 mutable FrameLoader m_loader; | 152 mutable FrameLoader m_loader; |
227 mutable NavigationScheduler m_navigationScheduler; | 153 mutable NavigationScheduler m_navigationScheduler; |
228 | 154 |
229 RefPtr<FrameView> m_view; | 155 RefPtr<FrameView> m_view; |
230 RefPtr<DOMWindow> m_domWindow; | |
231 | 156 |
232 OwnPtr<ScriptController> m_script; | 157 OwnPtr<ScriptController> m_script; |
233 const OwnPtr<Editor> m_editor; | 158 const OwnPtr<Editor> m_editor; |
234 const OwnPtr<SpellChecker> m_spellChecker; | 159 const OwnPtr<SpellChecker> m_spellChecker; |
235 const OwnPtr<FrameSelection> m_selection; | 160 const OwnPtr<FrameSelection> m_selection; |
236 const OwnPtr<EventHandler> m_eventHandler; | 161 const OwnPtr<EventHandler> m_eventHandler; |
237 OwnPtr<InputMethodController> m_inputMethodController; | 162 OwnPtr<InputMethodController> m_inputMethodController; |
238 | 163 |
239 RefPtr<FrameInit> m_frameInit; | |
240 | |
241 float m_pageZoomFactor; | 164 float m_pageZoomFactor; |
242 float m_textZoomFactor; | 165 float m_textZoomFactor; |
243 | 166 |
244 int m_orientation; | 167 int m_orientation; |
245 | 168 |
246 bool m_inViewSourceMode; | 169 bool m_inViewSourceMode; |
247 | |
248 blink::WebLayer* m_remotePlatformLayer; | |
249 }; | 170 }; |
250 | 171 |
251 inline void LocalFrame::init() | 172 inline void LocalFrame::init() |
252 { | 173 { |
253 m_loader.init(); | 174 m_loader.init(); |
254 } | 175 } |
255 | 176 |
256 inline FrameLoader& LocalFrame::loader() const | 177 inline FrameLoader& LocalFrame::loader() const |
257 { | 178 { |
258 return m_loader; | 179 return m_loader; |
259 } | 180 } |
260 | 181 |
261 inline NavigationScheduler& LocalFrame::navigationScheduler() const | 182 inline NavigationScheduler& LocalFrame::navigationScheduler() const |
262 { | 183 { |
263 return m_navigationScheduler; | 184 return m_navigationScheduler; |
264 } | 185 } |
265 | 186 |
266 inline FrameView* LocalFrame::view() const | 187 inline FrameView* LocalFrame::view() const |
267 { | 188 { |
268 return m_view.get(); | 189 return m_view.get(); |
269 } | 190 } |
270 | 191 |
271 inline ScriptController& LocalFrame::script() | 192 inline ScriptController& LocalFrame::script() |
272 { | 193 { |
273 return *m_script; | 194 return *m_script; |
274 } | 195 } |
275 | 196 |
276 inline DOMWindow* LocalFrame::domWindow() const | |
277 { | |
278 return m_domWindow.get(); | |
279 } | |
280 | |
281 inline FrameSelection& LocalFrame::selection() const | 197 inline FrameSelection& LocalFrame::selection() const |
282 { | 198 { |
283 return *m_selection; | 199 return *m_selection; |
284 } | 200 } |
285 | 201 |
286 inline Editor& LocalFrame::editor() const | 202 inline Editor& LocalFrame::editor() const |
287 { | 203 { |
288 return *m_editor; | 204 return *m_editor; |
289 } | 205 } |
290 | 206 |
(...skipping 26 matching lines...) Expand all Loading... |
317 { | 233 { |
318 return m_treeNode; | 234 return m_treeNode; |
319 } | 235 } |
320 | 236 |
321 inline EventHandler& LocalFrame::eventHandler() const | 237 inline EventHandler& LocalFrame::eventHandler() const |
322 { | 238 { |
323 ASSERT(m_eventHandler); | 239 ASSERT(m_eventHandler); |
324 return *m_eventHandler; | 240 return *m_eventHandler; |
325 } | 241 } |
326 | 242 |
| 243 DEFINE_TYPE_CASTS(LocalFrame, Frame, localFrame, localFrame->isLocalFrame(),
localFrame.isLocalFrame()); |
| 244 |
327 } // namespace WebCore | 245 } // namespace WebCore |
328 | 246 |
329 #endif // LocalFrame_h | 247 #endif // LocalFrame_h |
OLD | NEW |