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/PageAnimator.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 "platform/heap/Handle.h"
34 #include "wtf/Forward.h"
35 #include "wtf/HashSet.h"
36 #include "wtf/Noncopyable.h"
37 #include "wtf/text/WTFString.h"
41 class AutoscrollController;
42 class BackForwardClient;
46 class ContextMenuClient;
47 class ContextMenuController;
49 class DragCaretController;
53 class FocusController;
57 class InspectorClient;
58 class InspectorController;
59 class PageLifecycleNotifier;
60 class PlatformMouseEvent;
62 class PointerLockController;
68 class VisibleSelection;
70 class ScrollingCoordinator;
72 class SpellCheckerClient;
73 class StorageNamespace;
75 class ValidationMessageClient;
77 typedef uint64_t LinkHash;
79 float deviceScaleFactor(LocalFrame*);
81 class Page FINAL : public NoBaseWillBeGarbageCollectedFinalized<Page>, public WillBeHeapSupplementable<Page>, public LifecycleContext<Page>, public SettingsDelegate {
82 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Page);
83 WTF_MAKE_NONCOPYABLE(Page);
84 friend class Settings;
86 static void scheduleForcedStyleRecalcForAllPages();
88 // It is up to the platform to ensure that non-null clients are provided where required.
90 WTF_MAKE_NONCOPYABLE(PageClients); WTF_MAKE_FAST_ALLOCATED;
95 ChromeClient* chromeClient;
96 ContextMenuClient* contextMenuClient;
97 EditorClient* editorClient;
98 DragClient* dragClient;
99 InspectorClient* inspectorClient;
100 BackForwardClient* backForwardClient;
101 SpellCheckerClient* spellCheckerClient;
102 StorageClient* storageClient;
105 explicit Page(PageClients&);
110 // This method returns all pages, incl. private ones associated with
111 // inspector overlay, popups, SVGImage, etc.
112 static HashSet<Page*>& allPages();
113 // This method returns all ordinary pages.
114 static HashSet<Page*>& ordinaryPages();
116 FrameHost& frameHost() const { return *m_frameHost; }
118 void setNeedsRecalcStyleInAllFrames();
119 void updateAcceleratedCompositingSettings();
121 ViewportDescription viewportDescription() const;
123 static void refreshPlugins(bool reload);
124 PluginData* pluginData() const;
126 EditorClient& editorClient() const { return *m_editorClient; }
127 SpellCheckerClient& spellCheckerClient() const { return *m_spellCheckerClient; }
128 UndoStack& undoStack() const { return *m_undoStack; }
130 void setMainFrame(PassRefPtr<LocalFrame>);
131 LocalFrame* mainFrame() const { return m_mainFrame.get(); }
133 void documentDetached(Document*);
135 bool openedByDOM() const;
136 void setOpenedByDOM();
138 void incrementSubframeCount() { ++m_subframeCount; }
139 void decrementSubframeCount() { ASSERT(m_subframeCount); --m_subframeCount; }
140 int subframeCount() const { checkSubframeCountConsistency(); return m_subframeCount; }
142 PageAnimator& animator() { return m_animator; }
143 Chrome& chrome() const { return *m_chrome; }
144 AutoscrollController& autoscrollController() const { return *m_autoscrollController; }
145 DragCaretController& dragCaretController() const { return *m_dragCaretController; }
146 DragController& dragController() const { return *m_dragController; }
147 FocusController& focusController() const { return *m_focusController; }
148 ContextMenuController& contextMenuController() const { return *m_contextMenuController; }
149 InspectorController& inspectorController() const { return *m_inspectorController; }
150 PointerLockController& pointerLockController() const { return *m_pointerLockController; }
151 ValidationMessageClient& validationMessageClient() const { return *m_validationMessageClient; }
152 void setValidationMessageClient(PassOwnPtr<ValidationMessageClient>);
154 ScrollingCoordinator* scrollingCoordinator();
156 String mainThreadScrollingReasonsAsText();
157 PassRefPtrWillBeRawPtr<ClientRectList> nonFastScrollableRects(const LocalFrame*);
159 Settings& settings() const { return *m_settings; }
160 BackForwardClient& backForward() const { return *m_backForwardClient; }
162 UseCounter& useCounter() { return m_useCounter; }
164 void setTabKeyCyclesThroughElements(bool b) { m_tabKeyCyclesThroughElements = b; }
165 bool tabKeyCyclesThroughElements() const { return m_tabKeyCyclesThroughElements; }
167 void unmarkAllTextMatches();
169 // DefersLoading is used to delay loads during modal dialogs.
170 // Modal dialogs are supposed to freeze all background processes
171 // in the page, including prevent additional loads from staring/continuing.
172 void setDefersLoading(bool);
173 bool defersLoading() const { return m_defersLoading; }
175 void setPageScaleFactor(float scale, const IntPoint& origin);
176 float pageScaleFactor() const;
178 float deviceScaleFactor() const { return m_deviceScaleFactor; }
179 void setDeviceScaleFactor(float);
181 static void allVisitedStateChanged();
182 static void visitedStateChanged(LinkHash visitedHash);
184 StorageNamespace* sessionStorage(bool optionalCreate = true);
185 StorageClient& storageClient() const { return *m_storageClient; }
187 // Don't allow more than a certain number of frames in a page.
188 // This seems like a reasonable upper bound, and otherwise mutually
189 // recursive frameset pages can quickly bring the program to its knees
190 // with exponential growth in the number of frames.
191 static const int maxNumberOfFrames = 1000;
193 PageVisibilityState visibilityState() const;
194 void setVisibilityState(PageVisibilityState, bool);
196 bool isCursorVisible() const;
197 void setIsCursorVisible(bool isVisible) { m_isCursorVisible = isVisible; }
200 void setIsPainting(bool painting) { m_isPainting = painting; }
201 bool isPainting() const { return m_isPainting; }
204 double timerAlignmentInterval() const;
206 class MultisamplingChangedObserver : public WillBeGarbageCollectedMixin {
208 virtual void multisamplingChanged(bool) = 0;
211 void addMultisamplingChangedObserver(MultisamplingChangedObserver*);
212 void removeMultisamplingChangedObserver(MultisamplingChangedObserver*);
214 void didCommitLoad(LocalFrame*);
216 static void networkStateChanged(bool online);
217 PassOwnPtr<LifecycleNotifier<Page> > createLifecycleNotifier();
219 void trace(Visitor*);
220 void willBeDestroyed();
223 PageLifecycleNotifier& lifecycleNotifier();
229 void checkSubframeCountConsistency() const { }
231 void checkSubframeCountConsistency() const;
234 void setTimerAlignmentInterval(double);
236 void setNeedsLayoutInAllFrames();
238 // SettingsDelegate overrides.
239 virtual void settingsChanged(SettingsDelegate::ChangeType) OVERRIDE;
241 PageAnimator m_animator;
242 const OwnPtr<AutoscrollController> m_autoscrollController;
243 const OwnPtr<Chrome> m_chrome;
244 const OwnPtr<DragCaretController> m_dragCaretController;
245 const OwnPtr<DragController> m_dragController;
246 const OwnPtr<FocusController> m_focusController;
247 const OwnPtr<ContextMenuController> m_contextMenuController;
248 const OwnPtr<InspectorController> m_inspectorController;
249 const OwnPtr<PointerLockController> m_pointerLockController;
250 OwnPtr<ScrollingCoordinator> m_scrollingCoordinator;
251 const OwnPtr<UndoStack> m_undoStack;
253 RefPtr<LocalFrame> m_mainFrame;
255 mutable RefPtr<PluginData> m_pluginData;
257 BackForwardClient* m_backForwardClient;
258 EditorClient* const m_editorClient;
259 SpellCheckerClient* const m_spellCheckerClient;
260 StorageClient* m_storageClient;
261 OwnPtr<ValidationMessageClient> m_validationMessageClient;
263 UseCounter m_useCounter;
268 bool m_tabKeyCyclesThroughElements;
269 bool m_defersLoading;
271 float m_deviceScaleFactor;
273 OwnPtr<StorageNamespace> m_sessionStorage;
275 double m_timerAlignmentInterval;
277 PageVisibilityState m_visibilityState;
279 bool m_isCursorVisible;
285 WillBeHeapHashSet<RawPtrWillBeWeakMember<MultisamplingChangedObserver> > m_multisamplingChangedObservers;
287 // A pointer to all the interfaces provided to in-process Frames for this Page.
288 // FIXME: Most of the members of Page should move onto FrameHost.
289 OwnPtrWillBeMember<FrameHost> m_frameHost;
292 } // namespace WebCore