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>
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.
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.
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.
31 #include "core/frame/Frame.h"
32 #include "core/loader/FrameLoader.h"
33 #include "core/loader/NavigationScheduler.h"
34 #include "core/page/FrameTree.h"
35 #include "platform/Supplementable.h"
36 #include "platform/heap/Handle.h"
37 #include "platform/scroll/ScrollTypes.h"
51 class InputMethodController;
58 class ScriptController;
61 class VisiblePosition;
63 class LocalFrame : public Frame, public Supplementable<LocalFrame> {
65 static PassRefPtr<LocalFrame> create(FrameLoaderClient*, FrameHost*, HTMLFrameOwnerElement*);
67 virtual bool isLocalFrame() const OVERRIDE { return true; }
70 void setView(PassRefPtr<FrameView>);
71 void createView(const IntSize&, const Color&, bool,
72 ScrollbarMode = ScrollbarAuto, bool horizontalLock = false,
73 ScrollbarMode = ScrollbarAuto, bool verticalLock = false);
75 virtual ~LocalFrame();
77 virtual void willDetachFrameHost() OVERRIDE;
78 virtual void detachFromFrameHost() OVERRIDE;
80 virtual void disconnectOwnerElement() OVERRIDE;
82 virtual void setDOMWindow(PassRefPtrWillBeRawPtr<DOMWindow>) OVERRIDE;
83 FrameView* view() const;
84 Document* document() const;
86 RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
88 Editor& editor() const;
89 EventHandler& eventHandler() const;
90 FrameLoader& loader() const;
91 FrameTree& tree() const;
92 NavigationScheduler& navigationScheduler() const;
93 FrameSelection& selection() const;
94 InputMethodController& inputMethodController() const;
95 FetchContext& fetchContext() const { return loader().fetchContext(); }
96 ScriptController& script();
97 SpellChecker& spellChecker() const;
98 FrameConsole& console() const;
100 void didChangeVisibilityState();
102 // FIXME: This method is only used by EventHandler to get the highest level
103 // LocalFrame in this frame's in-process subtree. When user gesture tokens
104 // are synchronized across processes this method should be removed.
105 LocalFrame* localFrameRoot();
107 // ======== All public functions below this point are candidates to move out of LocalFrame into another class. ========
109 bool inScope(TreeScope*) const;
111 void countObjectsNeedingLayout(unsigned& needsLayoutObjects, unsigned& totalObjects, bool& isPartial);
113 // See GraphicsLayerClient.h for accepted flags.
114 String layerTreeAsText(unsigned flags = 0) const;
115 String trackedRepaintRectsAsText() const;
117 void setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio);
118 bool shouldUsePrintingLayout() const;
119 FloatSize resizePageRectsKeepingRatio(const FloatSize& originalSize, const FloatSize& expectedSize);
121 bool inViewSourceMode() const;
122 void setInViewSourceMode(bool = true);
124 void setPageZoomFactor(float factor);
125 float pageZoomFactor() const { return m_pageZoomFactor; }
126 void setTextZoomFactor(float factor);
127 float textZoomFactor() const { return m_textZoomFactor; }
128 void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
130 void deviceOrPageScaleFactorChanged();
131 double devicePixelRatio() const;
133 void sendOrientationChangeEvent();
135 String documentTypeString() const;
137 PassOwnPtr<DragImage> nodeImage(Node&);
138 PassOwnPtr<DragImage> dragImageForSelection();
140 String selectedText() const;
141 String selectedTextForClipboard() const;
143 VisiblePosition visiblePositionForPoint(const IntPoint& framePoint);
144 Document* documentAtPoint(const IntPoint& windowPoint);
145 PassRefPtrWillBeRawPtr<Range> rangeForPoint(const IntPoint& framePoint);
147 // Should only be called on the main frame of a page.
148 void notifyChromeClientWheelEventHandlerCountChanged() const;
150 bool isURLAllowed(const KURL&) const;
155 LocalFrame(FrameLoaderClient*, FrameHost*, HTMLFrameOwnerElement*);
157 mutable FrameTree m_treeNode;
158 mutable FrameLoader m_loader;
159 mutable NavigationScheduler m_navigationScheduler;
161 RefPtr<FrameView> m_view;
163 OwnPtr<ScriptController> m_script;
164 const OwnPtr<Editor> m_editor;
165 const OwnPtr<SpellChecker> m_spellChecker;
166 const OwnPtr<FrameSelection> m_selection;
167 const OwnPtr<EventHandler> m_eventHandler;
168 const OwnPtr<FrameConsole> m_console;
169 OwnPtr<InputMethodController> m_inputMethodController;
171 float m_pageZoomFactor;
172 float m_textZoomFactor;
174 bool m_inViewSourceMode;
177 inline void LocalFrame::init()
182 inline FrameLoader& LocalFrame::loader() const
187 inline NavigationScheduler& LocalFrame::navigationScheduler() const
189 return m_navigationScheduler;
192 inline FrameView* LocalFrame::view() const
197 inline ScriptController& LocalFrame::script()
202 inline FrameSelection& LocalFrame::selection() const
207 inline Editor& LocalFrame::editor() const
212 inline SpellChecker& LocalFrame::spellChecker() const
214 return *m_spellChecker;
217 inline FrameConsole& LocalFrame::console() const
222 inline InputMethodController& LocalFrame::inputMethodController() const
224 return *m_inputMethodController;
227 inline bool LocalFrame::inViewSourceMode() const
229 return m_inViewSourceMode;
232 inline void LocalFrame::setInViewSourceMode(bool mode)
234 m_inViewSourceMode = mode;
237 inline FrameTree& LocalFrame::tree() const
242 inline EventHandler& LocalFrame::eventHandler() const
244 ASSERT(m_eventHandler);
245 return *m_eventHandler;
248 DEFINE_TYPE_CASTS(LocalFrame, Frame, localFrame, localFrame->isLocalFrame(), localFrame.isLocalFrame());
250 } // namespace WebCore
252 // During refactoring, there are some places where we need to do type conversions that
253 // will not be needed once all instances of LocalFrame and RemoteFrame are sorted out.
254 // At that time this #define will be removed and all the uses of it will need to be corrected.
255 #define toLocalFrameTemporary toLocalFrame
257 #endif // LocalFrame_h