2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
24 #include "core/dom/ViewportDescription.h"
25 #include "core/frame/SettingsDelegate.h"
26 #include "core/frame/UseCounter.h"
27 #include "core/page/HistoryController.h"
28 #include "core/page/PageVisibilityState.h"
29 #include "platform/LifecycleContext.h"
30 #include "platform/Supplementable.h"
31 #include "platform/geometry/LayoutRect.h"
32 #include "platform/geometry/Region.h"
33 #include "wtf/Forward.h"
34 #include "wtf/HashSet.h"
35 #include "wtf/Noncopyable.h"
36 #include "wtf/text/WTFString.h"
40 class AutoscrollController;
41 class BackForwardClient;
45 class ContextMenuClient;
46 class ContextMenuController;
48 class DragCaretController;
52 class FocusController;
58 class InspectorClient;
59 class InspectorController;
62 class PageLifecycleNotifier;
63 class PlatformMouseEvent;
65 class PointerLockController;
66 class ProgressTracker;
72 class VisibleSelection;
74 class ScrollingCoordinator;
76 class SpellCheckerClient;
77 class StorageNamespace;
79 class ValidationMessageClient;
81 typedef uint64_t LinkHash;
83 float deviceScaleFactor(Frame*);
85 class Page FINAL : public Supplementable<Page>, public LifecycleContext<Page>, public SettingsDelegate {
86 WTF_MAKE_NONCOPYABLE(Page);
87 friend class Settings;
89 static void scheduleForcedStyleRecalcForAllPages();
91 // It is up to the platform to ensure that non-null clients are provided where required.
93 WTF_MAKE_NONCOPYABLE(PageClients); WTF_MAKE_FAST_ALLOCATED;
98 ChromeClient* chromeClient;
99 ContextMenuClient* contextMenuClient;
100 EditorClient* editorClient;
101 DragClient* dragClient;
102 InspectorClient* inspectorClient;
103 BackForwardClient* backForwardClient;
104 SpellCheckerClient* spellCheckerClient;
105 StorageClient* storageClient;
108 explicit Page(PageClients&);
111 // This method returns all pages, incl. private ones associated with
112 // inspector overlay, popups, SVGImage, etc.
113 static HashSet<Page*>& allPages();
115 FrameHost& frameHost() { return *m_frameHost; }
117 void setNeedsRecalcStyleInAllFrames();
119 ViewportDescription viewportDescription() const;
121 static void refreshPlugins(bool reload);
122 PluginData* pluginData() const;
124 EditorClient& editorClient() const { return *m_editorClient; }
125 SpellCheckerClient& spellCheckerClient() const { return *m_spellCheckerClient; }
126 UndoStack& undoStack() const { return *m_undoStack; }
128 HistoryController& historyController() const { return *m_historyController; }
130 void setMainFrame(PassRefPtr<Frame>);
131 Frame* mainFrame() const { return m_mainFrame.get(); }
133 void documentDetached(Document*);
135 bool openedByDOM() const;
136 void setOpenedByDOM();
138 // FIXME: PageGroup should probably just be removed, see comment in PageGroup.h
139 enum PageGroupType { PrivatePageGroup, SharedPageGroup };
140 void setGroupType(PageGroupType);
141 void clearPageGroup();
145 setGroupType(PrivatePageGroup);
149 void incrementSubframeCount() { ++m_subframeCount; }
150 void decrementSubframeCount() { ASSERT(m_subframeCount); --m_subframeCount; }
151 int subframeCount() const { checkSubframeCountConsistency(); return m_subframeCount; }
153 Chrome& chrome() const { return *m_chrome; }
154 AutoscrollController& autoscrollController() const { return *m_autoscrollController; }
155 DragCaretController& dragCaretController() const { return *m_dragCaretController; }
156 DragController& dragController() const { return *m_dragController; }
157 FocusController& focusController() const { return *m_focusController; }
158 ContextMenuController& contextMenuController() const { return *m_contextMenuController; }
159 InspectorController& inspectorController() const { return *m_inspectorController; }
160 PointerLockController& pointerLockController() const { return *m_pointerLockController; }
161 ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient; }
162 void setValidationMessageClient(ValidationMessageClient* client) { m_validationMessageClient = client; }
164 ScrollingCoordinator* scrollingCoordinator();
166 String mainThreadScrollingReasonsAsText();
167 PassRefPtr<ClientRectList> nonFastScrollableRects(const Frame*);
169 Settings& settings() const { return *m_settings; }
170 ProgressTracker& progress() const { return *m_progress; }
171 BackForwardClient& backForward() const { return *m_backForwardClient; }
173 UseCounter& useCounter() { return m_useCounter; }
175 void setTabKeyCyclesThroughElements(bool b) { m_tabKeyCyclesThroughElements = b; }
176 bool tabKeyCyclesThroughElements() const { return m_tabKeyCyclesThroughElements; }
178 void unmarkAllTextMatches();
180 // DefersLoading is used to delay loads during modal dialogs.
181 // Modal dialogs are supposed to freeze all background processes
182 // in the page, including prevent additional loads from staring/continuing.
183 void setDefersLoading(bool);
184 bool defersLoading() const { return m_defersLoading; }
186 void setPageScaleFactor(float scale, const IntPoint& origin);
187 float pageScaleFactor() const { return m_pageScaleFactor; }
189 float deviceScaleFactor() const { return m_deviceScaleFactor; }
190 void setDeviceScaleFactor(float);
192 static void allVisitedStateChanged();
193 static void visitedStateChanged(LinkHash visitedHash);
195 StorageNamespace* sessionStorage(bool optionalCreate = true);
196 StorageClient& storageClient() const { return *m_storageClient; }
198 // Don't allow more than a certain number of frames in a page.
199 // This seems like a reasonable upper bound, and otherwise mutually
200 // recursive frameset pages can quickly bring the program to its knees
201 // with exponential growth in the number of frames.
202 static const int maxNumberOfFrames = 1000;
204 PageVisibilityState visibilityState() const;
205 void setVisibilityState(PageVisibilityState, bool);
207 bool isCursorVisible() const { return m_isCursorVisible; }
208 void setIsCursorVisible(bool isVisible) { m_isCursorVisible = isVisible; }
211 void setIsPainting(bool painting) { m_isPainting = painting; }
212 bool isPainting() const { return m_isPainting; }
215 double timerAlignmentInterval() const;
217 class MultisamplingChangedObserver {
219 virtual void multisamplingChanged(bool) = 0;
222 void addMultisamplingChangedObserver(MultisamplingChangedObserver*);
223 void removeMultisamplingChangedObserver(MultisamplingChangedObserver*);
225 void didCommitLoad(Frame*);
227 static void networkStateChanged(bool online);
228 PassOwnPtr<LifecycleNotifier<Page> > createLifecycleNotifier();
231 PageLifecycleNotifier& lifecycleNotifier();
237 void checkSubframeCountConsistency() const { }
239 void checkSubframeCountConsistency() const;
242 void setTimerAlignmentInterval(double);
244 void setNeedsLayoutInAllFrames();
246 // SettingsDelegate overrides.
247 virtual void settingsChanged(SettingsDelegate::ChangeType) OVERRIDE;
249 const OwnPtr<AutoscrollController> m_autoscrollController;
250 const OwnPtr<Chrome> m_chrome;
251 const OwnPtr<DragCaretController> m_dragCaretController;
252 const OwnPtr<DragController> m_dragController;
253 const OwnPtr<FocusController> m_focusController;
254 const OwnPtr<ContextMenuController> m_contextMenuController;
255 const OwnPtr<InspectorController> m_inspectorController;
256 const OwnPtr<PointerLockController> m_pointerLockController;
257 OwnPtr<ScrollingCoordinator> m_scrollingCoordinator;
259 const OwnPtr<HistoryController> m_historyController;
260 const OwnPtr<ProgressTracker> m_progress;
261 const OwnPtr<UndoStack> m_undoStack;
263 RefPtr<Frame> m_mainFrame;
265 mutable RefPtr<PluginData> m_pluginData;
267 BackForwardClient* m_backForwardClient;
268 EditorClient* const m_editorClient;
269 ValidationMessageClient* m_validationMessageClient;
270 SpellCheckerClient* const m_spellCheckerClient;
271 StorageClient* m_storageClient;
273 UseCounter m_useCounter;
278 bool m_tabKeyCyclesThroughElements;
279 bool m_defersLoading;
281 float m_pageScaleFactor;
282 float m_deviceScaleFactor;
284 RefPtr<PageGroup> m_group;
286 OwnPtr<StorageNamespace> m_sessionStorage;
288 double m_timerAlignmentInterval;
290 PageVisibilityState m_visibilityState;
292 bool m_isCursorVisible;
298 HashSet<MultisamplingChangedObserver*> m_multisamplingChangedObservers;
300 // A pointer to all the interfaces provided to in-process Frames for this Page.
301 // FIXME: Most of the members of Page should move onto FrameHost.
302 OwnPtr<FrameHost> m_frameHost;
305 } // namespace WebCore