]>
git.saurik.com Git - iphone-api.git/blob - WebCore/DOMWindow.h
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "PlatformString.h"
31 #include "SecurityOrigin.h"
32 #include <wtf/Forward.h>
33 #include <wtf/RefCounted.h>
34 #include <wtf/RefPtr.h>
40 class CSSStyleDeclaration
;
53 class PostMessageTimer
;
58 #if ENABLE(DOM_STORAGE)
63 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
64 class DOMApplicationCache
;
67 typedef int ExceptionCode
;
69 class DOMWindow
: public RefCounted
<DOMWindow
> {
71 static PassRefPtr
<DOMWindow
> create(Frame
* frame
) { return adoptRef(new DOMWindow(frame
)); }
74 Frame
* frame() { return m_frame
; }
75 void disconnectFrame();
79 int orientation() const;
81 void setSecurityOrigin(SecurityOrigin
* securityOrigin
) { m_securityOrigin
= securityOrigin
; }
82 SecurityOrigin
* securityOrigin() const { return m_securityOrigin
.get(); }
84 void setURL(const KURL
& url
) { m_url
= url
; }
85 KURL
url() const { return m_url
; }
87 static void adjustWindowRect(const FloatRect
& screen
, FloatRect
& window
, const FloatRect
& pendingChanges
);
90 Screen
* screen() const;
91 History
* history() const;
92 BarInfo
* locationbar() const;
93 BarInfo
* menubar() const;
94 BarInfo
* personalbar() const;
95 BarInfo
* scrollbars() const;
96 BarInfo
* statusbar() const;
97 BarInfo
* toolbar() const;
98 Navigator
* navigator() const;
99 Navigator
* clientInformation() const { return navigator(); }
100 Location
* location() const;
102 DOMSelection
* getSelection();
104 Element
* frameElement() const;
112 void alert(const String
& message
);
113 bool confirm(const String
& message
);
114 String
prompt(const String
& message
, const String
& defaultValue
);
116 bool find(const String
&, bool caseSensitive
, bool backwards
, bool wrap
, bool wholeWord
, bool searchInFrames
, bool showDialog
) const;
118 bool offscreenBuffering() const;
120 int outerHeight() const;
121 int outerWidth() const;
122 int innerHeight() const;
123 int innerWidth() const;
126 int screenLeft() const { return screenX(); }
127 int screenTop() const { return screenY(); }
130 int pageXOffset() const { return scrollX(); }
131 int pageYOffset() const { return scrollY(); }
135 unsigned length() const;
138 void setName(const String
&);
140 String
status() const;
141 void setStatus(const String
&);
142 String
defaultStatus() const;
143 void setDefaultStatus(const String
&);
144 // This attribute is an alias of defaultStatus and is necessary for legacy uses.
145 String
defaultstatus() const { return defaultStatus(); }
146 void setDefaultstatus(const String
& status
) { setDefaultStatus(status
); }
148 // Self referential attributes
149 DOMWindow
* self() const;
150 DOMWindow
* window() const { return self(); }
151 DOMWindow
* frames() const { return self(); }
153 DOMWindow
* opener() const;
154 DOMWindow
* parent() const;
155 DOMWindow
* top() const;
157 // DOM Level 2 AbstractView Interface
158 Document
* document() const;
160 // DOM Level 2 Style Interface
161 PassRefPtr
<CSSStyleDeclaration
> getComputedStyle(Element
*, const String
& pseudoElt
) const;
164 PassRefPtr
<CSSRuleList
> getMatchedCSSRules(Element
*, const String
& pseudoElt
, bool authorOnly
= true) const;
165 double devicePixelRatio() const;
167 PassRefPtr
<WebKitPoint
> webkitConvertPointFromPageToNode(Node
* node
, const WebKitPoint
* p
) const;
168 PassRefPtr
<WebKitPoint
> webkitConvertPointFromNodeToPage(Node
* node
, const WebKitPoint
* p
) const;
171 // HTML 5 client-side database
172 PassRefPtr
<Database
> openDatabase(const String
& name
, const String
& version
, const String
& displayName
, unsigned long estimatedSize
, ExceptionCode
&);
175 #if ENABLE(DOM_STORAGE)
176 // HTML 5 key/value storage
177 Storage
* sessionStorage() const;
178 Storage
* localStorage() const;
181 Console
* console() const;
183 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
184 DOMApplicationCache
* applicationCache() const;
187 void postMessage(const String
& message
, MessagePort
*, const String
& targetOrigin
, DOMWindow
* source
, ExceptionCode
&);
188 void postMessageTimerFired(PostMessageTimer
*);
190 void scrollBy(int x
, int y
) const;
191 void scrollTo(int x
, int y
) const;
192 void scroll(int x
, int y
) const { scrollTo(x
, y
); }
194 void moveBy(float x
, float y
) const;
195 void moveTo(float x
, float y
) const;
197 void resizeBy(float x
, float y
) const;
198 void resizeTo(float width
, float height
) const;
200 EventListener
* onabort() const;
201 void setOnabort(PassRefPtr
<EventListener
>);
202 EventListener
* onblur() const;
203 void setOnblur(PassRefPtr
<EventListener
>);
204 EventListener
* onchange() const;
205 void setOnchange(PassRefPtr
<EventListener
>);
206 EventListener
* onclick() const;
207 void setOnclick(PassRefPtr
<EventListener
>);
208 EventListener
* ondblclick() const;
209 void setOndblclick(PassRefPtr
<EventListener
>);
210 EventListener
* onerror() const;
211 void setOnerror(PassRefPtr
<EventListener
>);
212 EventListener
* onfocus() const;
213 void setOnfocus(PassRefPtr
<EventListener
>);
214 EventListener
* onkeydown() const;
215 void setOnkeydown(PassRefPtr
<EventListener
>);
216 EventListener
* onkeypress() const;
217 void setOnkeypress(PassRefPtr
<EventListener
>);
218 EventListener
* onkeyup() const;
219 void setOnkeyup(PassRefPtr
<EventListener
>);
220 EventListener
* onload() const;
221 void setOnload(PassRefPtr
<EventListener
>);
222 EventListener
* onmousedown() const;
223 void setOnmousedown(PassRefPtr
<EventListener
>);
224 EventListener
* onmousemove() const;
225 void setOnmousemove(PassRefPtr
<EventListener
>);
226 EventListener
* onmouseout() const;
227 void setOnmouseout(PassRefPtr
<EventListener
>);
228 EventListener
* onmouseover() const;
229 void setOnmouseover(PassRefPtr
<EventListener
>);
230 EventListener
* onmouseup() const;
231 void setOnmouseup(PassRefPtr
<EventListener
>);
232 EventListener
* onmousewheel() const;
233 void setOnmousewheel(PassRefPtr
<EventListener
>);
234 EventListener
* onreset() const;
235 void setOnreset(PassRefPtr
<EventListener
>);
236 EventListener
* onresize() const;
237 void setOnresize(PassRefPtr
<EventListener
>);
238 EventListener
* onscroll() const;
239 void setOnscroll(PassRefPtr
<EventListener
>);
240 EventListener
* onsearch() const;
241 void setOnsearch(PassRefPtr
<EventListener
>);
242 EventListener
* onselect() const;
243 void setOnselect(PassRefPtr
<EventListener
>);
244 EventListener
* onsubmit() const;
245 void setOnsubmit(PassRefPtr
<EventListener
>);
246 EventListener
* onunload() const;
247 void setOnunload(PassRefPtr
<EventListener
>);
248 EventListener
* onbeforeunload() const;
249 void setOnbeforeunload(PassRefPtr
<EventListener
>);
250 EventListener
* onwebkitanimationstart() const;
251 void setOnwebkitanimationstart(PassRefPtr
<EventListener
>);
252 EventListener
* onwebkitanimationiteration() const;
253 void setOnwebkitanimationiteration(PassRefPtr
<EventListener
>);
254 EventListener
* onwebkitanimationend() const;
255 void setOnwebkitanimationend(PassRefPtr
<EventListener
>);
256 EventListener
* onwebkittransitionend() const;
257 void setOnwebkittransitionend(PassRefPtr
<EventListener
>);
258 EventListener
* onorientationchange() const;
259 void setOnorientationchange(PassRefPtr
<EventListener
>);
260 #if ENABLE(TOUCH_EVENTS)
261 EventListener
* ontouchstart() const;
262 void setOntouchstart(PassRefPtr
<EventListener
>);
263 EventListener
* ontouchmove() const;
264 void setOntouchmove(PassRefPtr
<EventListener
>);
265 EventListener
* ontouchend() const;
266 void setOntouchend(PassRefPtr
<EventListener
>);
267 EventListener
* ontouchcancel() const;
268 void setOntouchcancel(PassRefPtr
<EventListener
>);
269 EventListener
* ongesturestart() const;
270 void setOngesturestart(PassRefPtr
<EventListener
>);
271 EventListener
* ongesturechange() const;
272 void setOngesturechange(PassRefPtr
<EventListener
>);
273 EventListener
* ongestureend() const;
274 void setOngestureend(PassRefPtr
<EventListener
>);
277 // These methods are used for GC marking. See JSDOMWindow::mark() in
278 // JSDOMWindowCustom.cpp.
279 Screen
* optionalScreen() const { return m_screen
.get(); }
280 DOMSelection
* optionalSelection() const { return m_selection
.get(); }
281 History
* optionalHistory() const { return m_history
.get(); }
282 BarInfo
* optionalLocationbar() const { return m_locationbar
.get(); }
283 BarInfo
* optionalMenubar() const { return m_menubar
.get(); }
284 BarInfo
* optionalPersonalbar() const { return m_personalbar
.get(); }
285 BarInfo
* optionalScrollbars() const { return m_scrollbars
.get(); }
286 BarInfo
* optionalStatusbar() const { return m_statusbar
.get(); }
287 BarInfo
* optionalToolbar() const { return m_toolbar
.get(); }
288 Console
* optionalConsole() const { return m_console
.get(); }
289 Navigator
* optionalNavigator() const { return m_navigator
.get(); }
290 Location
* optionalLocation() const { return m_location
.get(); }
291 #if ENABLE(DOM_STORAGE)
292 Storage
* optionalSessionStorage() const { return m_sessionStorage
.get(); }
293 Storage
* optionalLocalStorage() const { return m_localStorage
.get(); }
295 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
296 DOMApplicationCache
* optionalApplicationCache() const { return m_applicationCache
.get(); }
302 void setInlineEventListenerForType(const AtomicString
& eventType
, PassRefPtr
<EventListener
>);
303 EventListener
* inlineEventListenerForType(const AtomicString
& eventType
) const;
305 RefPtr
<SecurityOrigin
> m_securityOrigin
;
309 mutable RefPtr
<Screen
> m_screen
;
310 mutable RefPtr
<DOMSelection
> m_selection
;
311 mutable RefPtr
<History
> m_history
;
312 mutable RefPtr
<BarInfo
> m_locationbar
;
313 mutable RefPtr
<BarInfo
> m_menubar
;
314 mutable RefPtr
<BarInfo
> m_personalbar
;
315 mutable RefPtr
<BarInfo
> m_scrollbars
;
316 mutable RefPtr
<BarInfo
> m_statusbar
;
317 mutable RefPtr
<BarInfo
> m_toolbar
;
318 mutable RefPtr
<Console
> m_console
;
319 mutable RefPtr
<Navigator
> m_navigator
;
320 mutable RefPtr
<Location
> m_location
;
321 #if ENABLE(DOM_STORAGE)
322 mutable RefPtr
<Storage
> m_sessionStorage
;
323 mutable RefPtr
<Storage
> m_localStorage
;
325 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
326 mutable RefPtr
<DOMApplicationCache
> m_applicationCache
;
330 } // namespace WebCore