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"
38 #include "wtf/HashSet.h"
51 class FrameDestructionObserver;
54 class InputMethodController;
61 class ScriptController;
64 class VisiblePosition;
66 class LocalFrame : public Frame, public WillBeHeapSupplementable<LocalFrame> {
68 static PassRefPtrWillBeRawPtr<LocalFrame> create(FrameLoaderClient*, FrameHost*, FrameOwner*);
70 virtual bool isLocalFrame() const OVERRIDE { return true; }
73 void setView(PassRefPtr<FrameView>);
74 void createView(const IntSize&, const Color&, bool,
75 ScrollbarMode = ScrollbarAuto, bool horizontalLock = false,
76 ScrollbarMode = ScrollbarAuto, bool verticalLock = false);
78 virtual ~LocalFrame();
79 virtual void trace(Visitor*) OVERRIDE;
81 virtual void detach() OVERRIDE;
83 void addDestructionObserver(FrameDestructionObserver*);
84 void removeDestructionObserver(FrameDestructionObserver*);
86 void willDetachFrameHost();
87 void detachFromFrameHost();
89 virtual void disconnectOwnerElement() OVERRIDE;
91 virtual void setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow>) OVERRIDE;
92 FrameView* view() const;
93 Document* document() const;
94 void setPagePopupOwner(Element&);
95 Element* pagePopupOwner() const { return m_pagePopupOwner.get(); }
97 RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
99 Editor& editor() const;
100 EventHandler& eventHandler() const;
101 FrameLoader& loader() const;
102 NavigationScheduler& navigationScheduler() const;
103 FrameSelection& selection() const;
104 InputMethodController& inputMethodController() const;
105 FetchContext& fetchContext() const { return loader().fetchContext(); }
106 ScriptController& script();
107 SpellChecker& spellChecker() const;
108 FrameConsole& console() const;
110 void didChangeVisibilityState();
112 // FIXME: This method is only used by EventHandler to get the highest level
113 // LocalFrame in this frame's in-process subtree. When user gesture tokens
114 // are synchronized across processes this method should be removed.
115 LocalFrame* localFrameRoot();
117 // ======== All public functions below this point are candidates to move out of LocalFrame into another class. ========
119 bool inScope(TreeScope*) const;
121 void countObjectsNeedingLayout(unsigned& needsLayoutObjects, unsigned& totalObjects, bool& isPartial);
123 // See GraphicsLayerClient.h for accepted flags.
124 String layerTreeAsText(unsigned flags = 0) const;
126 void setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio);
127 bool shouldUsePrintingLayout() const;
128 FloatSize resizePageRectsKeepingRatio(const FloatSize& originalSize, const FloatSize& expectedSize);
130 bool inViewSourceMode() const;
131 void setInViewSourceMode(bool = true);
133 void setPageZoomFactor(float factor);
134 float pageZoomFactor() const { return m_pageZoomFactor; }
135 void setTextZoomFactor(float factor);
136 float textZoomFactor() const { return m_textZoomFactor; }
137 void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
139 void deviceOrPageScaleFactorChanged();
140 double devicePixelRatio() const;
142 String documentTypeString() const;
144 PassOwnPtr<DragImage> nodeImage(Node&);
145 PassOwnPtr<DragImage> dragImageForSelection();
147 String selectedText() const;
148 String selectedTextForClipboard() const;
150 VisiblePosition visiblePositionForPoint(const IntPoint& framePoint);
151 Document* documentAtPoint(const IntPoint& windowPoint);
152 PassRefPtrWillBeRawPtr<Range> rangeForPoint(const IntPoint& framePoint);
154 bool isURLAllowed(const KURL&) const;
155 bool shouldReuseDefaultView(const KURL&) const;
156 void removeSpellingMarkersUnderWords(const Vector<String>& words);
161 LocalFrame(FrameLoaderClient*, FrameHost*, FrameOwner*);
163 String localLayerTreeAsText(unsigned flags) const;
167 WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> > m_destructionObservers;
168 mutable FrameLoader m_loader;
169 mutable NavigationScheduler m_navigationScheduler;
171 RefPtr<FrameView> m_view;
172 // Usually 0. Non-null if this is the top frame of PagePopup.
173 RefPtrWillBeMember<Element> m_pagePopupOwner;
175 OwnPtr<ScriptController> m_script;
176 const OwnPtrWillBeMember<Editor> m_editor;
177 const OwnPtrWillBeMember<SpellChecker> m_spellChecker;
178 const OwnPtrWillBeMember<FrameSelection> m_selection;
179 const OwnPtrWillBeMember<EventHandler> m_eventHandler;
180 const OwnPtrWillBeMember<FrameConsole> m_console;
181 OwnPtrWillBeMember<InputMethodController> m_inputMethodController;
183 float m_pageZoomFactor;
184 float m_textZoomFactor;
186 bool m_inViewSourceMode;
189 inline void LocalFrame::init()
194 inline FrameLoader& LocalFrame::loader() const
199 inline NavigationScheduler& LocalFrame::navigationScheduler() const
201 return m_navigationScheduler;
204 inline FrameView* LocalFrame::view() const
209 inline ScriptController& LocalFrame::script()
214 inline FrameSelection& LocalFrame::selection() const
219 inline Editor& LocalFrame::editor() const
224 inline SpellChecker& LocalFrame::spellChecker() const
226 return *m_spellChecker;
229 inline FrameConsole& LocalFrame::console() const
234 inline InputMethodController& LocalFrame::inputMethodController() const
236 return *m_inputMethodController;
239 inline bool LocalFrame::inViewSourceMode() const
241 return m_inViewSourceMode;
244 inline void LocalFrame::setInViewSourceMode(bool mode)
246 m_inViewSourceMode = mode;
249 inline EventHandler& LocalFrame::eventHandler() const
251 ASSERT(m_eventHandler);
252 return *m_eventHandler;
255 DEFINE_TYPE_CASTS(LocalFrame, Frame, localFrame, localFrame->isLocalFrame(), localFrame.isLocalFrame());
259 // During refactoring, there are some places where we need to do type conversions that
260 // will not be needed once all instances of LocalFrame and RemoteFrame are sorted out.
261 // At that time this #define will be removed and all the uses of it will need to be corrected.
262 #define toLocalFrameTemporary toLocalFrame
264 #endif // LocalFrame_h