2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 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 "FrameLoaderTypes.h"
25 #include "FindOptions.h"
26 #include "LayoutTypes.h"
27 #include "PageVisibilityState.h"
28 #include "PlatformScreen.h"
29 #include "PlatformString.h"
30 #include "ViewportArguments.h"
31 #include <wtf/Forward.h>
32 #include <wtf/HashSet.h>
33 #include <wtf/Noncopyable.h>
36 #include <sys/time.h> // For time_t structure.
40 #include "SchedulePair.h"
43 #if ENABLE(TIZEN_JS_PERMISSION_CHECKER)
44 #include "PageGroupLoadDeferrer.h"
53 class BackForwardController;
54 class BackForwardList;
57 class ContextMenuClient;
58 class ContextMenuController;
59 class DeviceMotionClient;
60 class DeviceMotionController;
61 class DeviceOrientationClient;
62 class DeviceOrientationController;
64 class DragCaretController;
68 class FocusController;
71 class GeolocationClient;
72 class GeolocationController;
75 class InspectorClient;
76 class InspectorController;
77 class MediaCanStartListener;
79 class NotificationController;
80 class NotificationPresenter;
83 class ProgressTracker;
86 class VisibleSelection;
90 class SpeechInputClient;
91 class UserMediaClient;
92 class StorageNamespace;
93 #if ENABLE(NOTIFICATIONS)
94 class NotificationPresenter;
97 typedef uint64_t LinkHash;
99 enum FindDirection { FindDirectionForward, FindDirectionBackward };
101 float deviceScaleFactor(Frame*);
104 WTF_MAKE_NONCOPYABLE(Page);
105 friend class Settings;
107 static void scheduleForcedStyleRecalcForAllPages();
109 // It is up to the platform to ensure that non-null clients are provided where required.
111 WTF_MAKE_NONCOPYABLE(PageClients); WTF_MAKE_FAST_ALLOCATED;
116 ChromeClient* chromeClient;
117 ContextMenuClient* contextMenuClient;
118 EditorClient* editorClient;
119 DragClient* dragClient;
120 InspectorClient* inspectorClient;
121 GeolocationClient* geolocationClient;
122 DeviceMotionClient* deviceMotionClient;
123 DeviceOrientationClient* deviceOrientationClient;
124 RefPtr<BackForwardList> backForwardClient;
125 SpeechInputClient* speechInputClient;
126 NotificationPresenter* notificationClient;
127 UserMediaClient* userMediaClient;
133 void setNeedsRecalcStyleInAllFrames();
135 RenderTheme* theme() const { return m_theme.get(); };
137 ViewportArguments viewportArguments() const { return m_viewportArguments; }
138 void updateViewportArguments();
140 static void refreshPlugins(bool reload);
141 PluginData* pluginData() const;
143 void setCanStartMedia(bool);
144 bool canStartMedia() const { return m_canStartMedia; }
146 EditorClient* editorClient() const { return m_editorClient; }
148 void setMainFrame(PassRefPtr<Frame>);
149 Frame* mainFrame() const { return m_mainFrame.get(); }
151 bool openedByDOM() const;
152 void setOpenedByDOM();
154 // DEPRECATED. Use backForward() instead of the following 6 functions.
155 BackForwardList* backForwardList() const;
158 bool canGoBackOrForward(int distance) const;
159 void goBackOrForward(int distance);
160 int getHistoryLength();
162 void goToItem(HistoryItem*, FrameLoadType);
164 void setGroupName(const String&);
165 const String& groupName() const;
167 PageGroup& group() { if (!m_group) initGroup(); return *m_group; }
168 PageGroup* groupPtr() { return m_group; } // can return 0
170 void incrementFrameCount() { ++m_frameCount; }
171 void decrementFrameCount() { ASSERT(m_frameCount); --m_frameCount; }
172 int frameCount() const { checkFrameCountConsistency(); return m_frameCount; }
174 Chrome* chrome() const { return m_chrome.get(); }
175 DragCaretController* dragCaretController() const { return m_dragCaretController.get(); }
176 #if ENABLE(DRAG_SUPPORT)
177 DragController* dragController() const { return m_dragController.get(); }
179 FocusController* focusController() const { return m_focusController.get(); }
180 #if ENABLE(CONTEXT_MENUS)
181 ContextMenuController* contextMenuController() const { return m_contextMenuController.get(); }
183 #if ENABLE(INSPECTOR)
184 InspectorController* inspectorController() const { return m_inspectorController.get(); }
186 #if ENABLE(CLIENT_BASED_GEOLOCATION)
187 GeolocationController* geolocationController() const { return m_geolocationController.get(); }
189 #if ENABLE(DEVICE_ORIENTATION)
190 DeviceMotionController* deviceMotionController() const { return m_deviceMotionController.get(); }
191 DeviceOrientationController* deviceOrientationController() const { return m_deviceOrientationController.get(); }
193 #if ENABLE(NOTIFICATIONS)
194 NotificationController* notificationController() const { return m_notificationController.get(); }
196 #if ENABLE(INPUT_SPEECH)
197 SpeechInput* speechInput();
199 #if ENABLE(MEDIA_STREAM)
200 UserMediaClient* userMediaClient() const { return m_userMediaClient; }
202 Settings* settings() const { return m_settings.get(); }
203 ProgressTracker* progress() const { return m_progress.get(); }
204 BackForwardController* backForward() const { return m_backForwardController.get(); }
214 static ViewMode stringToViewMode(const String&);
216 ViewMode viewMode() const { return m_viewMode; }
217 void setViewMode(ViewMode);
219 void setTabKeyCyclesThroughElements(bool b) { m_tabKeyCyclesThroughElements = b; }
220 bool tabKeyCyclesThroughElements() const { return m_tabKeyCyclesThroughElements; }
222 bool findString(const String&, FindOptions);
223 // FIXME: Switch callers over to the FindOptions version and retire this one.
224 bool findString(const String&, TextCaseSensitivity, FindDirection, bool shouldWrap);
226 PassRefPtr<Range> rangeOfString(const String&, Range*, FindOptions);
228 unsigned markAllMatchesForText(const String&, FindOptions, bool shouldHighlight, unsigned);
229 // FIXME: Switch callers over to the FindOptions version and retire this one.
230 unsigned markAllMatchesForText(const String&, TextCaseSensitivity, bool shouldHighlight, unsigned);
231 void unmarkAllTextMatches();
234 void addSchedulePair(PassRefPtr<SchedulePair>);
235 void removeSchedulePair(PassRefPtr<SchedulePair>);
236 SchedulePairHashSet* scheduledRunLoopPairs() { return m_scheduledRunLoopPairs.get(); }
238 OwnPtr<SchedulePairHashSet> m_scheduledRunLoopPairs;
241 const VisibleSelection& selection() const;
243 void setDefersLoading(bool);
244 bool defersLoading() const { return m_defersLoading; }
246 void clearUndoRedoOperations();
248 bool inLowQualityImageInterpolationMode() const;
249 void setInLowQualityImageInterpolationMode(bool = true);
251 bool cookieEnabled() const { return m_cookieEnabled; }
252 void setCookieEnabled(bool enabled) { m_cookieEnabled = enabled; }
254 float mediaVolume() const { return m_mediaVolume; }
255 void setMediaVolume(float volume);
257 void setPageScaleFactor(float scale, const IntPoint& origin);
258 float pageScaleFactor() const { return m_pageScaleFactor; }
260 float deviceScaleFactor() const { return m_deviceScaleFactor; }
261 void setDeviceScaleFactor(float);
264 enum Mode { Unpaginated, HorizontallyPaginated, VerticallyPaginated };
276 const Pagination& pagination() const { return m_pagination; }
277 void setPagination(const Pagination&);
279 unsigned pageCount() const;
281 // Notifications when the Page starts and stops being presented via a native window.
282 void didMoveOnscreen();
283 void willMoveOffscreen();
285 void windowScreenDidChange(PlatformDisplayID);
287 void suspendScriptedAnimations();
288 void resumeScriptedAnimations();
290 void userStyleSheetLocationChanged();
291 const String& userStyleSheet() const;
293 void dnsPrefetchingStateChanged();
294 void privateBrowsingStateChanged();
296 static void setDebuggerForAllPages(JSC::Debugger*);
297 void setDebugger(JSC::Debugger*);
298 JSC::Debugger* debugger() const { return m_debugger; }
300 static void removeAllVisitedLinks();
302 static void allVisitedStateChanged(PageGroup*);
303 static void visitedStateChanged(PageGroup*, LinkHash visitedHash);
305 StorageNamespace* sessionStorage(bool optionalCreate = true);
306 void setSessionStorage(PassRefPtr<StorageNamespace>);
308 void setCustomHTMLTokenizerTimeDelay(double);
309 bool hasCustomHTMLTokenizerTimeDelay() const { return m_customHTMLTokenizerTimeDelay != -1; }
310 double customHTMLTokenizerTimeDelay() const { ASSERT(m_customHTMLTokenizerTimeDelay != -1); return m_customHTMLTokenizerTimeDelay; }
312 void setCustomHTMLTokenizerChunkSize(int);
313 bool hasCustomHTMLTokenizerChunkSize() const { return m_customHTMLTokenizerChunkSize != -1; }
314 int customHTMLTokenizerChunkSize() const { ASSERT(m_customHTMLTokenizerChunkSize != -1); return m_customHTMLTokenizerChunkSize; }
316 void setMemoryCacheClientCallsEnabled(bool);
317 bool areMemoryCacheClientCallsEnabled() const { return m_areMemoryCacheClientCallsEnabled; }
319 void setJavaScriptURLsAreAllowed(bool);
320 bool javaScriptURLsAreAllowed() const;
322 typedef HashSet<ScrollableArea*> ScrollableAreaSet;
323 void addScrollableArea(ScrollableArea*);
324 void removeScrollableArea(ScrollableArea*);
325 bool containsScrollableArea(ScrollableArea*) const;
326 const ScrollableAreaSet* scrollableAreaSet() const { return m_scrollableAreaSet.get(); }
328 // Don't allow more than a certain number of frames in a page.
329 // This seems like a reasonable upper bound, and otherwise mutually
330 // recursive frameset pages can quickly bring the program to its knees
331 // with exponential growth in the number of frames.
332 static const int maxNumberOfFrames = 1000;
334 #if ENABLE(TIZEN_JS_PERMISSION_CHECKER)
335 void suspendJavaScript();
336 void resumeJavaScript();
338 void setEditable(bool isEditable) { m_isEditable = isEditable; }
339 bool isEditable() { return m_isEditable; }
341 #if ENABLE(PAGE_VISIBILITY_API)
342 PageVisibilityState visibilityState() const;
343 void setVisibilityState(PageVisibilityState, bool);
346 PlatformDisplayID displayID() const { return m_displayID; }
352 void checkFrameCountConsistency() const { }
354 void checkFrameCountConsistency() const;
357 MediaCanStartListener* takeAnyMediaCanStartListener();
359 void setMinimumTimerInterval(double);
360 double minimumTimerInterval() const;
362 OwnPtr<Chrome> m_chrome;
363 OwnPtr<DragCaretController> m_dragCaretController;
365 #if ENABLE(DRAG_SUPPORT)
366 OwnPtr<DragController> m_dragController;
368 OwnPtr<FocusController> m_focusController;
369 #if ENABLE(CONTEXT_MENUS)
370 OwnPtr<ContextMenuController> m_contextMenuController;
372 #if ENABLE(INSPECTOR)
373 OwnPtr<InspectorController> m_inspectorController;
375 #if ENABLE(CLIENT_BASED_GEOLOCATION)
376 OwnPtr<GeolocationController> m_geolocationController;
378 #if ENABLE(DEVICE_ORIENTATION)
379 OwnPtr<DeviceMotionController> m_deviceMotionController;
380 OwnPtr<DeviceOrientationController> m_deviceOrientationController;
382 #if ENABLE(NOTIFICATIONS)
383 OwnPtr<NotificationController> m_notificationController;
385 #if ENABLE(INPUT_SPEECH)
386 SpeechInputClient* m_speechInputClient;
387 OwnPtr<SpeechInput> m_speechInput;
389 #if ENABLE(MEDIA_STREAM)
390 UserMediaClient* m_userMediaClient;
392 OwnPtr<Settings> m_settings;
393 OwnPtr<ProgressTracker> m_progress;
395 OwnPtr<BackForwardController> m_backForwardController;
396 RefPtr<Frame> m_mainFrame;
398 mutable RefPtr<PluginData> m_pluginData;
400 RefPtr<RenderTheme> m_theme;
402 EditorClient* m_editorClient;
408 bool m_tabKeyCyclesThroughElements;
409 bool m_defersLoading;
411 bool m_inLowQualityInterpolationMode;
412 bool m_cookieEnabled;
413 bool m_areMemoryCacheClientCallsEnabled;
416 float m_pageScaleFactor;
417 float m_deviceScaleFactor;
419 Pagination m_pagination;
421 bool m_javaScriptURLsAreAllowed;
423 String m_userStyleSheetPath;
424 mutable String m_userStyleSheet;
425 mutable bool m_didLoadUserStyleSheet;
426 mutable time_t m_userStyleSheetModificationTime;
428 OwnPtr<PageGroup> m_singlePageGroup;
431 JSC::Debugger* m_debugger;
433 double m_customHTMLTokenizerTimeDelay;
434 int m_customHTMLTokenizerChunkSize;
436 bool m_canStartMedia;
438 RefPtr<StorageNamespace> m_sessionStorage;
440 #if ENABLE(NOTIFICATIONS)
441 NotificationPresenter* m_notificationPresenter;
446 ViewportArguments m_viewportArguments;
448 double m_minimumTimerInterval;
450 #if ENABLE(TIZEN_JS_PERMISSION_CHECKER)
457 typedef enum _DeferStatus DeferStatus;
459 DeferStatus m_deferStatus;
460 PageGroupLoadDeferrer* m_deferrer;
462 OwnPtr<ScrollableAreaSet> m_scrollableAreaSet;
466 #if ENABLE(PAGE_VISIBILITY_API)
467 PageVisibilityState m_visibilityState;
469 PlatformDisplayID m_displayID;
472 } // namespace WebCore