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 "FeatureObserver.h"
25
#include "FrameLoaderTypes.h"
26
#include "FindOptions.h"
27
#include "LayoutMilestones.h"
28
#include "LayoutRect.h"
29
#include "PageVisibilityState.h"
30
#include "Pagination.h"
31
#include "PlatformScreen.h"
33
#include "Supplementable.h"
34
#include "ViewportArguments.h"
35
#include <wtf/Forward.h>
36
#include <wtf/HashMap.h>
37
#include <wtf/HashSet.h>
38
#include <wtf/Noncopyable.h>
39
#include <wtf/text/WTFString.h>
42
#include <sys/time.h> // For time_t structure.
46
#include "SchedulePair.h"
55
class AlternativeTextClient;
56
class BackForwardController;
57
class BackForwardList;
60
#if ENABLE(CONTEXT_MENUS)
61
class ContextMenuClient;
62
class ContextMenuController;
65
class DragCaretController;
69
class FocusController;
74
class InspectorClient;
75
class InspectorController;
76
class MediaCanStartListener;
81
class PointerLockController;
82
class ProgressTracker;
86
class VisibleSelection;
88
class ScrollingCoordinator;
90
class StorageNamespace;
91
class ValidationMessageClient;
93
typedef uint64_t LinkHash;
95
enum FindDirection { FindDirectionForward, FindDirectionBackward };
97
float deviceScaleFactor(Frame*);
100
ArenaSize(size_t treeSize, size_t allocated)
102
, allocated(allocated)
109
class Page : public Supplementable<Page> {
110
WTF_MAKE_NONCOPYABLE(Page);
111
friend class Settings;
113
static void scheduleForcedStyleRecalcForAllPages();
115
// It is up to the platform to ensure that non-null clients are provided where required.
117
WTF_MAKE_NONCOPYABLE(PageClients); WTF_MAKE_FAST_ALLOCATED;
122
AlternativeTextClient* alternativeTextClient;
123
ChromeClient* chromeClient;
124
#if ENABLE(CONTEXT_MENUS)
125
ContextMenuClient* contextMenuClient;
127
EditorClient* editorClient;
128
DragClient* dragClient;
129
InspectorClient* inspectorClient;
130
RefPtr<BackForwardList> backForwardClient;
131
ValidationMessageClient* validationMessageClient;
134
explicit Page(PageClients&);
137
ArenaSize renderTreeSize() const;
139
void setNeedsRecalcStyleInAllFrames();
141
RenderTheme* theme() const { return m_theme.get(); };
143
ViewportArguments viewportArguments() const;
145
static void refreshPlugins(bool reload);
146
PluginData* pluginData() const;
148
void setCanStartMedia(bool);
149
bool canStartMedia() const { return m_canStartMedia; }
151
EditorClient* editorClient() const { return m_editorClient; }
153
void setMainFrame(PassRefPtr<Frame>);
154
Frame* mainFrame() const { return m_mainFrame.get(); }
156
bool openedByDOM() const;
157
void setOpenedByDOM();
159
// DEPRECATED. Use backForward() instead of the following 6 functions.
160
BackForwardList* backForwardList() const;
163
bool canGoBackOrForward(int distance) const;
164
void goBackOrForward(int distance);
165
int getHistoryLength();
167
void goToItem(HistoryItem*, FrameLoadType);
169
void setGroupName(const String&);
170
const String& groupName() const;
172
PageGroup& group() { if (!m_group) initGroup(); return *m_group; }
173
PageGroup* groupPtr() { return m_group; } // can return 0
175
void incrementSubframeCount() { ++m_subframeCount; }
176
void decrementSubframeCount() { ASSERT(m_subframeCount); --m_subframeCount; }
177
int subframeCount() const { checkSubframeCountConsistency(); return m_subframeCount; }
179
Chrome* chrome() const { return m_chrome.get(); }
180
DragCaretController* dragCaretController() const { return m_dragCaretController.get(); }
181
#if ENABLE(DRAG_SUPPORT)
182
DragController* dragController() const { return m_dragController.get(); }
184
FocusController* focusController() const { return m_focusController.get(); }
185
#if ENABLE(CONTEXT_MENUS)
186
ContextMenuController* contextMenuController() const { return m_contextMenuController.get(); }
188
#if ENABLE(INSPECTOR)
189
InspectorController* inspectorController() const { return m_inspectorController.get(); }
191
#if ENABLE(POINTER_LOCK)
192
PointerLockController* pointerLockController() const { return m_pointerLockController.get(); }
194
ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient; }
196
ScrollingCoordinator* scrollingCoordinator();
198
String scrollingStateTreeAsText();
200
Settings* settings() const { return m_settings.get(); }
201
ProgressTracker* progress() const { return m_progress.get(); }
202
BackForwardController* backForward() const { return m_backForwardController.get(); }
204
FeatureObserver* featureObserver() { return &m_featureObserver; }
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
float mediaVolume() const { return m_mediaVolume; }
252
void setMediaVolume(float volume);
254
void setPageScaleFactor(float scale, const IntPoint& origin);
255
float pageScaleFactor() const { return m_pageScaleFactor; }
257
float deviceScaleFactor() const { return m_deviceScaleFactor; }
258
void setDeviceScaleFactor(float);
260
bool shouldSuppressScrollbarAnimations() const { return m_suppressScrollbarAnimations; }
261
void setShouldSuppressScrollbarAnimations(bool suppressAnimations);
263
// Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
264
// and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
265
// FrameViews in the page cache, but FrameView::pagination() only affects the current
267
const Pagination& pagination() const { return m_pagination; }
268
void setPagination(const Pagination&);
270
unsigned pageCount() const;
272
// Notifications when the Page starts and stops being presented via a native window.
273
void didMoveOnscreen();
274
void willMoveOffscreen();
275
bool isOnscreen() const { return m_isOnscreen; }
277
void windowScreenDidChange(PlatformDisplayID);
279
void suspendScriptedAnimations();
280
void resumeScriptedAnimations();
281
bool scriptedAnimationsSuspended() const { return m_scriptedAnimationsSuspended; }
283
void userStyleSheetLocationChanged();
284
const String& userStyleSheet() const;
286
void dnsPrefetchingStateChanged();
287
void storageBlockingStateChanged();
288
void privateBrowsingStateChanged();
290
static void setDebuggerForAllPages(JSC::Debugger*);
291
void setDebugger(JSC::Debugger*);
292
JSC::Debugger* debugger() const { return m_debugger; }
294
static void removeAllVisitedLinks();
296
static void allVisitedStateChanged(PageGroup*);
297
static void visitedStateChanged(PageGroup*, LinkHash visitedHash);
299
StorageNamespace* sessionStorage(bool optionalCreate = true);
300
void setSessionStorage(PassRefPtr<StorageNamespace>);
302
void setCustomHTMLTokenizerTimeDelay(double);
303
bool hasCustomHTMLTokenizerTimeDelay() const { return m_customHTMLTokenizerTimeDelay != -1; }
304
double customHTMLTokenizerTimeDelay() const { ASSERT(m_customHTMLTokenizerTimeDelay != -1); return m_customHTMLTokenizerTimeDelay; }
306
void setCustomHTMLTokenizerChunkSize(int);
307
bool hasCustomHTMLTokenizerChunkSize() const { return m_customHTMLTokenizerChunkSize != -1; }
308
int customHTMLTokenizerChunkSize() const { ASSERT(m_customHTMLTokenizerChunkSize != -1); return m_customHTMLTokenizerChunkSize; }
310
void setMemoryCacheClientCallsEnabled(bool);
311
bool areMemoryCacheClientCallsEnabled() const { return m_areMemoryCacheClientCallsEnabled; }
313
// Don't allow more than a certain number of frames in a page.
314
// This seems like a reasonable upper bound, and otherwise mutually
315
// recursive frameset pages can quickly bring the program to its knees
316
// with exponential growth in the number of frames.
317
static const int maxNumberOfFrames = 1000;
319
void setEditable(bool isEditable) { m_isEditable = isEditable; }
320
bool isEditable() { return m_isEditable; }
322
#if ENABLE(PAGE_VISIBILITY_API)
323
PageVisibilityState visibilityState() const;
325
#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
326
void setVisibilityState(PageVisibilityState, bool);
329
PlatformDisplayID displayID() const { return m_displayID; }
331
void addLayoutMilestones(LayoutMilestones);
332
LayoutMilestones layoutMilestones() const { return m_layoutMilestones; }
334
bool isCountingRelevantRepaintedObjects() const;
335
void startCountingRelevantRepaintedObjects();
336
void resetRelevantPaintedObjectCounter();
337
void addRelevantRepaintedObject(RenderObject*, const LayoutRect& objectPaintRect);
338
void addRelevantUnpaintedObject(RenderObject*, const LayoutRect& objectPaintRect);
340
void suspendActiveDOMObjectsAndAnimations();
341
void resumeActiveDOMObjectsAndAnimations();
343
void setIsPainting(bool painting) { m_isPainting = painting; }
344
bool isPainting() const { return m_isPainting; }
347
AlternativeTextClient* alternativeTextClient() const { return m_alternativeTextClient; }
349
bool hasSeenPlugin(const String& serviceType) const;
350
bool hasSeenAnyPlugin() const;
351
void sawPlugin(const String& serviceType);
352
void resetSeenPlugins();
354
bool hasSeenMediaEngine(const String& engineName) const;
355
bool hasSeenAnyMediaEngine() const;
356
void sawMediaEngine(const String& engineName);
357
void resetSeenMediaEngines();
359
void reportMemoryUsage(MemoryObjectInfo*) const;
365
void checkSubframeCountConsistency() const { }
367
void checkSubframeCountConsistency() const;
370
MediaCanStartListener* takeAnyMediaCanStartListener();
372
void setMinimumTimerInterval(double);
373
double minimumTimerInterval() const;
375
void setTimerAlignmentInterval(double);
376
double timerAlignmentInterval() const;
378
void collectPluginViews(Vector<RefPtr<PluginViewBase>, 32>& pluginViewBases);
380
OwnPtr<Chrome> m_chrome;
381
OwnPtr<DragCaretController> m_dragCaretController;
383
#if ENABLE(DRAG_SUPPORT)
384
OwnPtr<DragController> m_dragController;
386
OwnPtr<FocusController> m_focusController;
387
#if ENABLE(CONTEXT_MENUS)
388
OwnPtr<ContextMenuController> m_contextMenuController;
390
#if ENABLE(INSPECTOR)
391
OwnPtr<InspectorController> m_inspectorController;
393
#if ENABLE(POINTER_LOCK)
394
OwnPtr<PointerLockController> m_pointerLockController;
396
RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
398
OwnPtr<Settings> m_settings;
399
OwnPtr<ProgressTracker> m_progress;
401
OwnPtr<BackForwardController> m_backForwardController;
402
RefPtr<Frame> m_mainFrame;
404
mutable RefPtr<PluginData> m_pluginData;
406
RefPtr<RenderTheme> m_theme;
408
EditorClient* m_editorClient;
409
ValidationMessageClient* m_validationMessageClient;
411
FeatureObserver m_featureObserver;
417
bool m_tabKeyCyclesThroughElements;
418
bool m_defersLoading;
419
unsigned m_defersLoadingCallCount;
421
bool m_inLowQualityInterpolationMode;
422
bool m_cookieEnabled;
423
bool m_areMemoryCacheClientCallsEnabled;
426
float m_pageScaleFactor;
427
float m_deviceScaleFactor;
429
bool m_suppressScrollbarAnimations;
431
Pagination m_pagination;
433
String m_userStyleSheetPath;
434
mutable String m_userStyleSheet;
435
mutable bool m_didLoadUserStyleSheet;
436
mutable time_t m_userStyleSheetModificationTime;
438
OwnPtr<PageGroup> m_singlePageGroup;
441
JSC::Debugger* m_debugger;
443
double m_customHTMLTokenizerTimeDelay;
444
int m_customHTMLTokenizerChunkSize;
446
bool m_canStartMedia;
448
RefPtr<StorageNamespace> m_sessionStorage;
452
double m_minimumTimerInterval;
454
double m_timerAlignmentInterval;
459
#if ENABLE(PAGE_VISIBILITY_API)
460
PageVisibilityState m_visibilityState;
462
PlatformDisplayID m_displayID;
464
LayoutMilestones m_layoutMilestones;
466
HashSet<RenderObject*> m_relevantUnpaintedRenderObjects;
467
Region m_relevantPaintedRegion;
468
Region m_relevantUnpaintedRegion;
469
bool m_isCountingRelevantRepaintedObjects;
473
AlternativeTextClient* m_alternativeTextClient;
475
bool m_scriptedAnimationsSuspended;
477
HashSet<String> m_seenPlugins;
478
HashSet<String> m_seenMediaEngines;
481
} // namespace WebCore