]> git.saurik.com Git - iphone-api.git/blob - WebCore/Page.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / Page.h
1 /*
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
4 *
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.
9 *
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.
14 *
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.
19 */
20
21 #ifndef Page_h
22 #define Page_h
23
24 #include "BackForwardList.h"
25 #include "Chrome.h"
26 #include "ContextMenuController.h"
27 #include "FrameLoaderTypes.h"
28 #include "LinkHash.h"
29 #include "PlatformString.h"
30 #include <wtf/HashSet.h>
31 #include <wtf/OwnPtr.h>
32
33 #if PLATFORM(MAC)
34 #include "SchedulePair.h"
35 #endif
36
37 #include "Settings.h"
38
39 #if PLATFORM(WIN) || (PLATFORM(WX) && PLATFORM(WIN_OS)) || (PLATFORM(QT) && defined(Q_WS_WIN))
40 typedef struct HINSTANCE__* HINSTANCE;
41 #endif
42
43 namespace JSC {
44 class Debugger;
45 }
46
47 namespace WebCore {
48
49 class Chrome;
50 class ChromeClient;
51 class ContextMenuClient;
52 class ContextMenuController;
53 class Document;
54 class DragClient;
55 class DragController;
56 class EditorClient;
57 class FocusController;
58 class Frame;
59 class InspectorClient;
60 class InspectorController;
61 class Node;
62 class PageGroup;
63 class PluginData;
64 class ProgressTracker;
65 class Selection;
66 class SelectionController;
67 #if ENABLE(DOM_STORAGE)
68 class SessionStorage;
69 #endif
70 class Settings;
71 #if ENABLE(WML)
72 class WMLPageState;
73 #endif
74
75 enum FindDirection { FindDirectionForward, FindDirectionBackward };
76
77 class Page : Noncopyable {
78 public:
79 static void setNeedsReapplyStyles();
80
81 Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*);
82 ~Page();
83
84 static void refreshPlugins(bool reload);
85 PluginData* pluginData() const;
86
87 EditorClient* editorClient() const { return m_editorClient; }
88
89 void setMainFrame(PassRefPtr<Frame>);
90 Frame* mainFrame() const { return m_mainFrame.get(); }
91
92 BackForwardList* backForwardList();
93
94 // FIXME: The following three methods don't fall under the responsibilities of the Page object
95 // They seem to fit a hypothetical Page-controller object that would be akin to the
96 // Frame-FrameLoader relationship. They have to live here now, but should move somewhere that
97 // makes more sense when that class exists.
98 bool goBack();
99 bool goForward();
100 void goToItem(HistoryItem*, FrameLoadType);
101
102 HistoryItem* globalHistoryItem() const { return m_globalHistoryItem.get(); }
103 void setGlobalHistoryItem(HistoryItem*);
104
105 void setGroupName(const String&);
106 const String& groupName() const;
107
108 PageGroup& group() { if (!m_group) initGroup(); return *m_group; }
109 PageGroup* groupPtr() { return m_group; } // can return 0
110
111 void incrementFrameCount() { ++m_frameCount; }
112 void decrementFrameCount() { --m_frameCount; }
113 int frameCount() const { return m_frameCount; }
114
115 Chrome* chrome() const { return m_chrome.get(); }
116 SelectionController* dragCaretController() const { return m_dragCaretController.get(); }
117 FocusController* focusController() const { return m_focusController.get(); }
118 Settings* settings() const { return m_settings.get(); }
119 ProgressTracker* progress() const { return m_progress.get(); }
120
121
122 void setTabKeyCyclesThroughElements(bool b) { m_tabKeyCyclesThroughElements = b; }
123 bool tabKeyCyclesThroughElements() const { return m_tabKeyCyclesThroughElements; }
124
125 bool findString(const String&, TextCaseSensitivity, FindDirection, bool shouldWrap);
126 unsigned int markAllMatchesForText(const String&, TextCaseSensitivity, bool shouldHighlight, unsigned);
127 void unmarkAllTextMatches();
128
129 #if PLATFORM(MAC)
130 void addSchedulePair(PassRefPtr<SchedulePair>);
131 void removeSchedulePair(PassRefPtr<SchedulePair>);
132 SchedulePairHashSet* scheduledRunLoopPairs() { return m_scheduledRunLoopPairs.get(); }
133
134 OwnPtr<SchedulePairHashSet> m_scheduledRunLoopPairs;
135 #endif
136
137 const Selection& selection() const;
138
139 void setDefersLoading(bool);
140 bool defersLoading() const { return m_defersLoading; }
141
142 void clearUndoRedoOperations();
143
144 bool inLowQualityImageInterpolationMode() const;
145 void setInLowQualityImageInterpolationMode(bool = true);
146
147 bool cookieEnabled() const { return m_cookieEnabled; }
148 void setCookieEnabled(bool enabled) { m_cookieEnabled = enabled; }
149
150 float mediaVolume() const { return m_mediaVolume; }
151 void setMediaVolume(float volume);
152
153 // Notifications when the Page starts and stops being presented via a native window.
154 void didMoveOnscreen();
155 void willMoveOffscreen();
156
157 void userStyleSheetLocationChanged();
158 const String& userStyleSheet() const;
159
160 void changePendingUnloadEventCount(int delta);
161 unsigned pendingUnloadEventCount();
162 void changePendingBeforeUnloadEventCount(int delta);
163 unsigned pendingBeforeUnloadEventCount();
164
165 static void setDebuggerForAllPages(JSC::Debugger*);
166 void setDebugger(JSC::Debugger*);
167 JSC::Debugger* debugger() const { return m_debugger; }
168
169 #if PLATFORM(WIN) || (PLATFORM(WX) && PLATFORM(WIN_OS)) || (PLATFORM(QT) && defined(Q_WS_WIN))
170 // The global DLL or application instance used for all windows.
171 static void setInstanceHandle(HINSTANCE instanceHandle) { s_instanceHandle = instanceHandle; }
172 static HINSTANCE instanceHandle() { return s_instanceHandle; }
173 #endif
174
175 static void removeAllVisitedLinks();
176
177 static void allVisitedStateChanged(PageGroup*);
178 static void visitedStateChanged(PageGroup*, LinkHash visitedHash);
179
180 #if ENABLE(DOM_STORAGE)
181 SessionStorage* sessionStorage(bool optionalCreate = true);
182 void setSessionStorage(PassRefPtr<SessionStorage>);
183 #endif
184
185 #if ENABLE(WML)
186 WMLPageState* wmlPageState();
187 #endif
188
189 void setCustomHTMLTokenizerTimeDelay(double);
190 bool hasCustomHTMLTokenizerTimeDelay() const { return true; }
191 double customHTMLTokenizerTimeDelay() const { return settings()->maxParseDuration(); }
192
193 void setCustomHTMLTokenizerChunkSize(int);
194 bool hasCustomHTMLTokenizerChunkSize() const { return m_customHTMLTokenizerChunkSize != -1; }
195 int customHTMLTokenizerChunkSize() const { ASSERT(m_customHTMLTokenizerChunkSize != -1); return m_customHTMLTokenizerChunkSize; }
196
197 void setMemoryCacheClientCallsEnabled(bool);
198 bool areMemoryCacheClientCallsEnabled() const { return m_areMemoryCacheClientCallsEnabled; }
199
200 void setJavaScriptURLsAreAllowed(bool);
201 bool javaScriptURLsAreAllowed() const;
202
203 private:
204 void initGroup();
205
206 OwnPtr<Chrome> m_chrome;
207 OwnPtr<SelectionController> m_dragCaretController;
208 OwnPtr<FocusController> m_focusController;
209 OwnPtr<Settings> m_settings;
210 OwnPtr<ProgressTracker> m_progress;
211
212 RefPtr<BackForwardList> m_backForwardList;
213 RefPtr<Frame> m_mainFrame;
214
215 RefPtr<HistoryItem> m_globalHistoryItem;
216
217 mutable RefPtr<PluginData> m_pluginData;
218
219 EditorClient* m_editorClient;
220
221 int m_frameCount;
222 String m_groupName;
223
224 bool m_tabKeyCyclesThroughElements;
225 bool m_defersLoading;
226
227 bool m_inLowQualityInterpolationMode;
228 bool m_cookieEnabled;
229 bool m_areMemoryCacheClientCallsEnabled;
230 float m_mediaVolume;
231
232 bool m_javaScriptURLsAreAllowed;
233
234
235 String m_userStyleSheetPath;
236 mutable String m_userStyleSheet;
237 mutable bool m_didLoadUserStyleSheet;
238 mutable time_t m_userStyleSheetModificationTime;
239
240 OwnPtr<PageGroup> m_singlePageGroup;
241 PageGroup* m_group;
242
243 JSC::Debugger* m_debugger;
244
245 unsigned m_pendingUnloadEventCount;
246 unsigned m_pendingBeforeUnloadEventCount;
247
248 double m_customHTMLTokenizerTimeDelay;
249 int m_customHTMLTokenizerChunkSize;
250
251 #if ENABLE(DOM_STORAGE)
252 RefPtr<SessionStorage> m_sessionStorage;
253 #endif
254
255 #if PLATFORM(WIN) || (PLATFORM(WX) && defined(__WXMSW__)) || (PLATFORM(QT) && defined(Q_WS_WIN))
256 static HINSTANCE s_instanceHandle;
257 #endif
258
259 #if ENABLE(WML)
260 OwnPtr<WMLPageState> m_wmlPageState;
261 #endif
262 };
263
264 } // namespace WebCore
265
266 #endif // Page_h