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 "AdjustViewSizeOrNot.h"
32 #include "AnimationController.h"
33 #include "DragImage.h"
35 #include "EventHandler.h"
36 #include "FrameLoader.h"
37 #include "FrameSelection.h"
38 #include "FrameTree.h"
39 #include "NavigationScheduler.h"
40 #include "ScriptController.h"
41 #include "UserScriptTypes.h"
47 #if USE(TILED_BACKING_STORE)
48 #include "TiledBackingStoreClient.h"
54 class NSMutableDictionary;
60 typedef struct HBITMAP__* HBITMAP;
67 class HTMLTableCellElement;
68 class RegularExpression;
70 class TiledBackingStore;
72 #if !USE(TILED_BACKING_STORE)
73 class TiledBackingStoreClient { };
76 class FrameDestructionObserver {
78 virtual ~FrameDestructionObserver() { }
80 virtual void frameDestroyed() = 0;
83 class Frame : public RefCounted<Frame>, public TiledBackingStoreClient {
85 static PassRefPtr<Frame> create(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*);
88 void setView(PassRefPtr<FrameView>);
89 void createView(const IntSize&, const Color&, bool, const IntSize&, bool,
90 ScrollbarMode = ScrollbarAuto, bool horizontalLock = false,
91 ScrollbarMode = ScrollbarAuto, bool verticalLock = false);
95 void addDestructionObserver(FrameDestructionObserver*);
96 void removeDestructionObserver(FrameDestructionObserver*);
98 void detachFromPage();
100 void disconnectOwnerElement();
103 HTMLFrameOwnerElement* ownerElement() const;
105 Document* document() const;
106 FrameView* view() const;
108 Editor* editor() const;
109 EventHandler* eventHandler() const;
110 FrameLoader* loader() const;
111 NavigationScheduler* navigationScheduler() const;
112 FrameSelection* selection() const;
113 FrameTree* tree() const;
114 AnimationController* animation() const;
115 ScriptController* script();
117 RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
118 RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame.
120 void transferChildFrameToNewDocument();
122 #if ENABLE(PAGE_VISIBILITY_API)
123 void dispatchVisibilityStateChangeEvent();
126 // ======== All public functions below this point are candidates to move out of Frame into another class. ========
128 bool isDisconnected() const;
129 void setIsDisconnected(bool);
130 bool excludeFromTextSearch() const;
131 void setExcludeFromTextSearch(bool);
133 void injectUserScripts(UserScriptInjectionTime);
135 String layerTreeAsText(bool showDebugInfo = false) const;
137 // Unlike most accessors in this class, domWindow() always creates a new DOMWindow if m_domWindow is null.
138 // Callers that don't need a new DOMWindow to be created should use existingDOMWindow().
139 DOMWindow* domWindow() const;
140 DOMWindow* existingDOMWindow() { return m_domWindow.get(); }
141 void setDOMWindow(DOMWindow*);
142 void clearFormerDOMWindow(DOMWindow*);
143 void clearDOMWindow();
144 #if ENABLE(TIZEN_JS_EXT_API)
145 bool IsScriptExecution();
147 static Frame* frameForWidget(const Widget*);
149 Settings* settings() const; // can be NULL
151 void setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio, AdjustViewSizeOrNot);
152 FloatSize resizePageRectsKeepingRatio(const FloatSize& originalSize, const FloatSize& expectedSize);
154 bool inViewSourceMode() const;
155 void setInViewSourceMode(bool = true);
157 void setDocument(PassRefPtr<Document>);
159 void setPageZoomFactor(float factor);
160 float pageZoomFactor() const { return m_pageZoomFactor; }
161 void setTextZoomFactor(float factor);
162 float textZoomFactor() const { return m_textZoomFactor; }
163 void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
165 // Scale factor of this frame with respect to the container.
166 float frameScaleFactor() const;
168 #if USE(ACCELERATED_COMPOSITING)
169 void deviceOrPageScaleFactorChanged();
172 #if ENABLE(ORIENTATION_EVENTS)
173 // Orientation is the interface orientation in degrees. Some examples are:
174 // 0 is straight up; -90 is when the device is rotated 90 clockwise;
175 // 90 is when rotated counter clockwise.
176 void sendOrientationChangeEvent(int orientation);
177 int orientation() const { return m_orientation; }
181 static void clearTimers(FrameView*, Document*);
183 String documentTypeString() const;
185 String displayStringModifiedByEncoding(const String&) const;
187 DragImageRef nodeImage(Node*);
188 DragImageRef dragImageForSelection();
190 #if ENABLE(TIZEN_TEXT_SELECTION)
191 VisiblePosition visiblePositionForPoint(const LayoutPoint& framePoint, bool ignoreClipping = false);
193 VisiblePosition visiblePositionForPoint(const LayoutPoint& framePoint);
195 Document* documentAtPoint(const LayoutPoint& windowPoint);
196 PassRefPtr<Range> rangeForPoint(const LayoutPoint& framePoint);
198 String searchForLabelsAboveCell(RegularExpression*, HTMLTableCellElement*, size_t* resultDistanceFromStartOfCell);
199 String searchForLabelsBeforeElement(const Vector<String>& labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove);
200 String matchLabelsAgainstElement(const Vector<String>& labels, Element*);
203 NSImage* selectionImage(bool forceBlackText = false) const;
204 NSImage* rangeImage(Range*, bool forceBlackText = false) const;
205 NSImage* snapshotDragImage(Node*, NSRect* imageRect, NSRect* elementRect) const;
206 NSImage* imageFromRect(NSRect) const;
209 // Should only be called on the main frame of a page.
210 void notifyChromeClientWheelEventHandlerCountChanged() const;
215 Frame(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*);
217 void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime);
219 HashSet<FrameDestructionObserver*> m_destructionObservers;
222 mutable FrameTree m_treeNode;
223 mutable FrameLoader m_loader;
224 mutable NavigationScheduler m_navigationScheduler;
226 mutable RefPtr<DOMWindow> m_domWindow;
227 HashSet<DOMWindow*> m_liveFormerWindows;
229 HTMLFrameOwnerElement* m_ownerElement;
230 RefPtr<FrameView> m_view;
231 RefPtr<Document> m_doc;
233 ScriptController m_script;
235 mutable Editor m_editor;
236 mutable FrameSelection m_selection;
237 mutable EventHandler m_eventHandler;
238 mutable AnimationController m_animationController;
240 float m_pageZoomFactor;
241 float m_textZoomFactor;
243 #if ENABLE(ORIENTATION_EVENTS)
247 bool m_inViewSourceMode;
248 bool m_isDisconnected;
249 bool m_excludeFromTextSearch;
251 #if USE(TILED_BACKING_STORE)
252 // FIXME: The tiled backing store belongs in FrameView, not Frame.
255 TiledBackingStore* tiledBackingStore() const { return m_tiledBackingStore.get(); }
256 void setTiledBackingStoreEnabled(bool);
259 // TiledBackingStoreClient interface
260 virtual void tiledBackingStorePaintBegin();
261 virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&);
262 virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea);
263 virtual IntRect tiledBackingStoreContentsRect();
264 virtual IntRect tiledBackingStoreVisibleRect();
265 virtual Color tiledBackingStoreBackgroundColor() const;
266 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
267 virtual void scheduleUpdateTileBuffersAsync() {}
269 #if ENABLE(TIZEN_RECORDING_SURFACE_SET)
270 virtual bool recordingSurfaceSetEnableGet() {}
272 OwnPtr<TiledBackingStore> m_tiledBackingStore;
277 inline void Frame::init()
282 inline FrameLoader* Frame::loader() const
287 inline NavigationScheduler* Frame::navigationScheduler() const
289 return &m_navigationScheduler;
292 inline FrameView* Frame::view() const
297 inline ScriptController* Frame::script()
302 inline Document* Frame::document() const
307 inline FrameSelection* Frame::selection() const
312 inline Editor* Frame::editor() const
317 inline AnimationController* Frame::animation() const
319 return &m_animationController;
322 inline HTMLFrameOwnerElement* Frame::ownerElement() const
324 return m_ownerElement;
327 inline bool Frame::isDisconnected() const
329 return m_isDisconnected;
332 inline void Frame::setIsDisconnected(bool isDisconnected)
334 m_isDisconnected = isDisconnected;
337 inline bool Frame::excludeFromTextSearch() const
339 return m_excludeFromTextSearch;
342 inline void Frame::setExcludeFromTextSearch(bool exclude)
344 m_excludeFromTextSearch = exclude;
347 inline bool Frame::inViewSourceMode() const
349 return m_inViewSourceMode;
352 inline void Frame::setInViewSourceMode(bool mode)
354 m_inViewSourceMode = mode;
357 inline FrameTree* Frame::tree() const
362 inline Page* Frame::page() const
367 inline void Frame::detachFromPage()
372 inline EventHandler* Frame::eventHandler() const
374 return &m_eventHandler;
377 } // namespace WebCore