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