2 * Copyright (C) 2006, 2008 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 "BackForwardList.h"
26 #include "ContextMenuController.h"
27 #include "FrameLoaderTypes.h"
29 #include "PlatformString.h"
30 #include <wtf/HashSet.h>
31 #include <wtf/OwnPtr.h>
34 #include "SchedulePair.h"
39 #if PLATFORM(WIN) || (PLATFORM(WX) && PLATFORM(WIN_OS)) || (PLATFORM(QT) && defined(Q_WS_WIN))
40 typedef struct HINSTANCE__
* HINSTANCE
;
51 class ContextMenuClient
;
52 class ContextMenuController
;
57 class FocusController
;
59 class InspectorClient
;
60 class InspectorController
;
64 class ProgressTracker
;
66 class SelectionController
;
67 #if ENABLE(DOM_STORAGE)
75 enum FindDirection
{ FindDirectionForward
, FindDirectionBackward
};
77 class Page
: Noncopyable
{
79 static void setNeedsReapplyStyles();
81 Page(ChromeClient
*, ContextMenuClient
*, EditorClient
*, DragClient
*, InspectorClient
*);
84 static void refreshPlugins(bool reload
);
85 PluginData
* pluginData() const;
87 EditorClient
* editorClient() const { return m_editorClient
; }
89 void setMainFrame(PassRefPtr
<Frame
>);
90 Frame
* mainFrame() const { return m_mainFrame
.get(); }
92 BackForwardList
* backForwardList();
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.
100 void goToItem(HistoryItem
*, FrameLoadType
);
102 HistoryItem
* globalHistoryItem() const { return m_globalHistoryItem
.get(); }
103 void setGlobalHistoryItem(HistoryItem
*);
105 void setGroupName(const String
&);
106 const String
& groupName() const;
108 PageGroup
& group() { if (!m_group
) initGroup(); return *m_group
; }
109 PageGroup
* groupPtr() { return m_group
; } // can return 0
111 void incrementFrameCount() { ++m_frameCount
; }
112 void decrementFrameCount() { --m_frameCount
; }
113 int frameCount() const { return m_frameCount
; }
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(); }
122 void setTabKeyCyclesThroughElements(bool b
) { m_tabKeyCyclesThroughElements
= b
; }
123 bool tabKeyCyclesThroughElements() const { return m_tabKeyCyclesThroughElements
; }
125 bool findString(const String
&, TextCaseSensitivity
, FindDirection
, bool shouldWrap
);
126 unsigned int markAllMatchesForText(const String
&, TextCaseSensitivity
, bool shouldHighlight
, unsigned);
127 void unmarkAllTextMatches();
130 void addSchedulePair(PassRefPtr
<SchedulePair
>);
131 void removeSchedulePair(PassRefPtr
<SchedulePair
>);
132 SchedulePairHashSet
* scheduledRunLoopPairs() { return m_scheduledRunLoopPairs
.get(); }
134 OwnPtr
<SchedulePairHashSet
> m_scheduledRunLoopPairs
;
137 const Selection
& selection() const;
139 void setDefersLoading(bool);
140 bool defersLoading() const { return m_defersLoading
; }
142 void clearUndoRedoOperations();
144 bool inLowQualityImageInterpolationMode() const;
145 void setInLowQualityImageInterpolationMode(bool = true);
147 bool cookieEnabled() const { return m_cookieEnabled
; }
148 void setCookieEnabled(bool enabled
) { m_cookieEnabled
= enabled
; }
150 float mediaVolume() const { return m_mediaVolume
; }
151 void setMediaVolume(float volume
);
153 // Notifications when the Page starts and stops being presented via a native window.
154 void didMoveOnscreen();
155 void willMoveOffscreen();
157 void userStyleSheetLocationChanged();
158 const String
& userStyleSheet() const;
160 void changePendingUnloadEventCount(int delta
);
161 unsigned pendingUnloadEventCount();
162 void changePendingBeforeUnloadEventCount(int delta
);
163 unsigned pendingBeforeUnloadEventCount();
165 static void setDebuggerForAllPages(JSC::Debugger
*);
166 void setDebugger(JSC::Debugger
*);
167 JSC::Debugger
* debugger() const { return m_debugger
; }
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
; }
175 static void removeAllVisitedLinks();
177 static void allVisitedStateChanged(PageGroup
*);
178 static void visitedStateChanged(PageGroup
*, LinkHash visitedHash
);
180 #if ENABLE(DOM_STORAGE)
181 SessionStorage
* sessionStorage(bool optionalCreate
= true);
182 void setSessionStorage(PassRefPtr
<SessionStorage
>);
186 WMLPageState
* wmlPageState();
189 void setCustomHTMLTokenizerTimeDelay(double);
190 bool hasCustomHTMLTokenizerTimeDelay() const { return true; }
191 double customHTMLTokenizerTimeDelay() const { return settings()->maxParseDuration(); }
193 void setCustomHTMLTokenizerChunkSize(int);
194 bool hasCustomHTMLTokenizerChunkSize() const { return m_customHTMLTokenizerChunkSize
!= -1; }
195 int customHTMLTokenizerChunkSize() const { ASSERT(m_customHTMLTokenizerChunkSize
!= -1); return m_customHTMLTokenizerChunkSize
; }
197 void setMemoryCacheClientCallsEnabled(bool);
198 bool areMemoryCacheClientCallsEnabled() const { return m_areMemoryCacheClientCallsEnabled
; }
200 void setJavaScriptURLsAreAllowed(bool);
201 bool javaScriptURLsAreAllowed() const;
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
;
212 RefPtr
<BackForwardList
> m_backForwardList
;
213 RefPtr
<Frame
> m_mainFrame
;
215 RefPtr
<HistoryItem
> m_globalHistoryItem
;
217 mutable RefPtr
<PluginData
> m_pluginData
;
219 EditorClient
* m_editorClient
;
224 bool m_tabKeyCyclesThroughElements
;
225 bool m_defersLoading
;
227 bool m_inLowQualityInterpolationMode
;
228 bool m_cookieEnabled
;
229 bool m_areMemoryCacheClientCallsEnabled
;
232 bool m_javaScriptURLsAreAllowed
;
235 String m_userStyleSheetPath
;
236 mutable String m_userStyleSheet
;
237 mutable bool m_didLoadUserStyleSheet
;
238 mutable time_t m_userStyleSheetModificationTime
;
240 OwnPtr
<PageGroup
> m_singlePageGroup
;
243 JSC::Debugger
* m_debugger
;
245 unsigned m_pendingUnloadEventCount
;
246 unsigned m_pendingBeforeUnloadEventCount
;
248 double m_customHTMLTokenizerTimeDelay
;
249 int m_customHTMLTokenizerChunkSize
;
251 #if ENABLE(DOM_STORAGE)
252 RefPtr
<SessionStorage
> m_sessionStorage
;
255 #if PLATFORM(WIN) || (PLATFORM(WX) && defined(__WXMSW__)) || (PLATFORM(QT) && defined(Q_WS_WIN))
256 static HINSTANCE s_instanceHandle
;
260 OwnPtr
<WMLPageState
> m_wmlPageState
;
264 } // namespace WebCore