Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: Source/core/frame/LocalDOMWindow.h

Issue 683013002: Extract a DOMWindow interface from LocalDOMWindow and use it in the idl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: whee Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 11 matching lines...) Expand all
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef LocalDOMWindow_h 27 #ifndef LocalDOMWindow_h
28 #define LocalDOMWindow_h 28 #define LocalDOMWindow_h
29 29
30 #include "core/events/EventTarget.h" 30 #include "core/events/EventTarget.h"
31 #include "core/frame/DOMWindow.h" 31 #include "core/frame/DOMWindow.h"
32 #include "core/frame/DOMWindowBase64.h"
33 #include "core/frame/FrameDestructionObserver.h" 32 #include "core/frame/FrameDestructionObserver.h"
34 #include "core/frame/LocalFrame.h" 33 #include "core/frame/LocalFrame.h"
35 #include "platform/LifecycleContext.h" 34 #include "platform/LifecycleContext.h"
36 #include "platform/Supplementable.h" 35 #include "platform/Supplementable.h"
37 #include "platform/heap/Handle.h" 36 #include "platform/heap/Handle.h"
38 #include "platform/scroll/ScrollableArea.h"
39 37
38 #include "wtf/Assertions.h"
40 #include "wtf/Forward.h" 39 #include "wtf/Forward.h"
41 40
42 namespace blink { 41 namespace blink {
43 42
44 class CSSRuleList;
45 class CSSStyleDeclaration;
46 class Console;
47 class DOMSelection;
48 class DOMWindowCSS;
49 class DOMWindowEventQueue; 43 class DOMWindowEventQueue;
50 class DOMWindowLifecycleNotifier; 44 class DOMWindowLifecycleNotifier;
51 class DOMWindowProperty; 45 class DOMWindowProperty;
52 class DocumentInit; 46 class DocumentInit;
53 class Element;
54 class EventListener; 47 class EventListener;
55 class EventQueue; 48 class EventQueue;
56 class ExceptionState; 49 class ExceptionState;
57 class FloatRect; 50 class FloatRect;
58 class FrameConsole; 51 class FrameConsole;
59 class MediaQueryList;
60 class Page; 52 class Page;
61 class PostMessageTimer; 53 class PostMessageTimer;
62 class RequestAnimationFrameCallback;
63 class ScrollOptions;
64 class ScriptCallStack; 54 class ScriptCallStack;
65 class SecurityOrigin; 55 class SecurityOrigin;
66 class SerializedScriptValue;
67
68 typedef WillBeHeapVector<RefPtrWillBeMember<MessagePort>, 1> MessagePortArray;
69 56
70 enum PageshowEventPersistence { 57 enum PageshowEventPersistence {
71 PageshowEventNotPersisted = 0, 58 PageshowEventNotPersisted = 0,
72 PageshowEventPersisted = 1 59 PageshowEventPersisted = 1
73 }; 60 };
74 61
75 enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForw ardList }; 62 enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForw ardList };
76 63
77 // Note: if you're thinking of returning something DOM-related by reference, 64 // Note: if you're thinking of returning something DOM-related by reference,
78 // please ping dcheng@chromium.org first. You probably don't want to do that. 65 // please ping dcheng@chromium.org first. You probably don't want to do that.
79 class LocalDOMWindow final : public DOMWindow, public DOMWindowBase64, public Wi llBeHeapSupplementable<LocalDOMWindow>, public LifecycleContext<LocalDOMWindow> { 66 class LocalDOMWindow final : public DOMWindow, public WillBeHeapSupplementable<L ocalDOMWindow>, public LifecycleContext<LocalDOMWindow> {
80 DEFINE_WRAPPERTYPEINFO(); 67 DEFINE_WRAPPERTYPEINFO();
81 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LocalDOMWindow); 68 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LocalDOMWindow);
82 public: 69 public:
83 static PassRefPtrWillBeRawPtr<Document> createDocument(const String& mimeTyp e, const DocumentInit&, bool forceXHTML); 70 static PassRefPtrWillBeRawPtr<Document> createDocument(const String& mimeTyp e, const DocumentInit&, bool forceXHTML);
84 static PassRefPtrWillBeRawPtr<LocalDOMWindow> create(LocalFrame& frame) 71 static PassRefPtrWillBeRawPtr<LocalDOMWindow> create(LocalFrame& frame)
85 { 72 {
86 return adoptRefWillBeNoop(new LocalDOMWindow(frame)); 73 return adoptRefWillBeNoop(new LocalDOMWindow(frame));
87 } 74 }
88 virtual ~LocalDOMWindow(); 75 virtual ~LocalDOMWindow();
89 76
90 PassRefPtrWillBeRawPtr<Document> installNewDocument(const String& mimeType, const DocumentInit&, bool forceXHTML = false); 77 PassRefPtrWillBeRawPtr<Document> installNewDocument(const String& mimeType, const DocumentInit&, bool forceXHTML = false);
91 78
92 // EventTarget overrides: 79 // EventTarget overrides:
93 virtual const AtomicString& interfaceName() const override; 80 virtual const AtomicString& interfaceName() const override;
94 virtual ExecutionContext* executionContext() const override; 81 virtual ExecutionContext* executionContext() const override;
95 virtual LocalDOMWindow* toDOMWindow() override; 82 virtual LocalDOMWindow* toDOMWindow() override;
96 83
97 // DOMWindow overrides: 84 // DOMWindow overrides:
98 void trace(Visitor*) override; 85 void trace(Visitor*) override;
86 bool isLocalDOMWindow() const override { return true; }
99 virtual LocalFrame* frame() const override; 87 virtual LocalFrame* frame() const override;
100 Screen* screen() const override; 88 Screen* screen() const override;
101 History* history() const override; 89 History* history() const override;
102 BarProp* locationbar() const override; 90 BarProp* locationbar() const override;
103 BarProp* menubar() const override; 91 BarProp* menubar() const override;
104 BarProp* personalbar() const override; 92 BarProp* personalbar() const override;
105 BarProp* scrollbars() const override; 93 BarProp* scrollbars() const override;
106 BarProp* statusbar() const override; 94 BarProp* statusbar() const override;
107 BarProp* toolbar() const override; 95 BarProp* toolbar() const override;
108 Navigator* navigator() const override; 96 Navigator* navigator() const override;
(...skipping 22 matching lines...) Expand all
131 Document* document() const override; 119 Document* document() const override;
132 StyleMedia* styleMedia() const override; 120 StyleMedia* styleMedia() const override;
133 double devicePixelRatio() const override; 121 double devicePixelRatio() const override;
134 Storage* sessionStorage(ExceptionState&) const override; 122 Storage* sessionStorage(ExceptionState&) const override;
135 Storage* localStorage(ExceptionState&) const override; 123 Storage* localStorage(ExceptionState&) const override;
136 ApplicationCache* applicationCache() const override; 124 ApplicationCache* applicationCache() const override;
137 int orientation() const override; 125 int orientation() const override;
138 Console* console() const override; 126 Console* console() const override;
139 Performance* performance() const override; 127 Performance* performance() const override;
140 DOMWindowCSS* css() const override; 128 DOMWindowCSS* css() const override;
129 DOMSelection* getSelection() override;
130 void focus(ExecutionContext* = 0) override;
131 void blur() override;
132 void close(ExecutionContext* = 0) override;
133 void print() override;
134 void stop() override;
135 void alert(const String& message = String()) override;
136 bool confirm(const String& message) override;
137 String prompt(const String& message, const String& defaultValue) override;
138 bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const override;
139 void scrollBy(double x, double y, ScrollBehavior = ScrollBehaviorAuto) const override;
140 void scrollBy(double x, double y, const ScrollOptions&, ExceptionState&) con st override;
141 void scrollTo(double x, double y, ScrollBehavior = ScrollBehaviorAuto) const override;
142 void scrollTo(double x, double y, const ScrollOptions&, ExceptionState&) con st override;
143 void moveBy(float x, float y) const override;
144 void moveTo(float x, float y) const override;
145 void resizeBy(float x, float y) const override;
146 void resizeTo(float width, float height) const override;
147 PassRefPtrWillBeRawPtr<MediaQueryList> matchMedia(const String&) override;
148 PassRefPtrWillBeRawPtr<CSSStyleDeclaration> getComputedStyle(Element*, const String& pseudoElt) const override;
149 PassRefPtrWillBeRawPtr<CSSRuleList> getMatchedCSSRules(Element*, const Strin g& pseudoElt) const override;
150 int requestAnimationFrame(RequestAnimationFrameCallback*) override;
151 int webkitRequestAnimationFrame(RequestAnimationFrameCallback*) override;
152 void cancelAnimationFrame(int id) override;
153 LocalDOMWindow* anonymousIndexedGetter(uint32_t) override;
154 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor tArray*, const String& targetOrigin, LocalDOMWindow* source, ExceptionState&) ov erride;
141 155
142 void registerProperty(DOMWindowProperty*); 156 void registerProperty(DOMWindowProperty*);
143 void unregisterProperty(DOMWindowProperty*); 157 void unregisterProperty(DOMWindowProperty*);
144 158
145 void reset(); 159 void reset();
146 160
147 PassRefPtrWillBeRawPtr<MediaQueryList> matchMedia(const String&);
148
149 unsigned pendingUnloadEventListeners() const; 161 unsigned pendingUnloadEventListeners() const;
150 162
151 static FloatRect adjustWindowRect(LocalFrame&, const FloatRect& pendingChang es); 163 static FloatRect adjustWindowRect(LocalFrame&, const FloatRect& pendingChang es);
152 164
153 bool allowPopUp(); // Call on first window, not target window. 165 bool allowPopUp(); // Call on first window, not target window.
154 static bool allowPopUp(LocalFrame& firstFrame); 166 static bool allowPopUp(LocalFrame& firstFrame);
155 static bool canShowModalDialogNow(const LocalFrame*); 167 static bool canShowModalDialogNow(const LocalFrame*);
156 168
157 // DOM Level 0 169 // DOM Level 0
158 void setLocation(const String& location, LocalDOMWindow* callingWindow, Loca lDOMWindow* enteredWindow, 170 void setLocation(const String& location, LocalDOMWindow* callingWindow, Loca lDOMWindow* enteredWindow,
159 SetLocationLocking = LockHistoryBasedOnGestureState); 171 SetLocationLocking = LockHistoryBasedOnGestureState);
160 172
161 DOMSelection* getSelection();
162
163 Element* frameElement() const; 173 Element* frameElement() const;
164 174
165 void focus(ExecutionContext* = 0);
166 void blur();
167 void close(ExecutionContext* = 0);
168 void print();
169 void stop();
170
171 PassRefPtrWillBeRawPtr<LocalDOMWindow> open(const String& urlString, const A tomicString& frameName, const String& windowFeaturesString, 175 PassRefPtrWillBeRawPtr<LocalDOMWindow> open(const String& urlString, const A tomicString& frameName, const String& windowFeaturesString,
172 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow); 176 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow);
173 177
174 typedef void (*PrepareDialogFunction)(LocalDOMWindow*, void* context); 178 typedef void (*PrepareDialogFunction)(LocalDOMWindow*, void* context);
175 void showModalDialog(const String& urlString, const String& dialogFeaturesSt ring, 179 void showModalDialog(const String& urlString, const String& dialogFeaturesSt ring,
176 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, PrepareDia logFunction, void* functionContext); 180 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, PrepareDia logFunction, void* functionContext);
177 181
178 void alert(const String& message = String());
179 bool confirm(const String& message);
180 String prompt(const String& message, const String& defaultValue);
181
182 bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const;
183
184 // DOM Level 2 Style Interface
185
186 PassRefPtrWillBeRawPtr<CSSStyleDeclaration> getComputedStyle(Element*, const String& pseudoElt) const;
187
188 // WebKit extensions
189
190 PassRefPtrWillBeRawPtr<CSSRuleList> getMatchedCSSRules(Element*, const Strin g& pseudoElt) const;
191
192 FrameConsole* frameConsole() const; 182 FrameConsole* frameConsole() const;
193 183
194 void printErrorMessage(const String&); 184 void printErrorMessage(const String&);
195 String crossDomainAccessErrorMessage(LocalDOMWindow* callingWindow); 185 String crossDomainAccessErrorMessage(LocalDOMWindow* callingWindow);
196 String sanitizedCrossDomainAccessErrorMessage(LocalDOMWindow* callingWindow) ; 186 String sanitizedCrossDomainAccessErrorMessage(LocalDOMWindow* callingWindow) ;
197 187
198 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor tArray*, const String& targetOrigin, LocalDOMWindow* source, ExceptionState&);
199 void postMessageTimerFired(PostMessageTimer*); 188 void postMessageTimerFired(PostMessageTimer*);
200 void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigi n, PassRefPtrWillBeRawPtr<Event>, PassRefPtrWillBeRawPtr<ScriptCallStack>); 189 void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigi n, PassRefPtrWillBeRawPtr<Event>, PassRefPtrWillBeRawPtr<ScriptCallStack>);
201 190
202 void scrollBy(double x, double y, ScrollBehavior = ScrollBehaviorAuto) const ;
203 void scrollBy(double x, double y, const ScrollOptions&, ExceptionState&) con st;
204 void scrollTo(double x, double y, ScrollBehavior = ScrollBehaviorAuto) const ;
205 void scrollTo(double x, double y, const ScrollOptions&, ExceptionState&) con st;
206 void scroll(double x, double y) const { scrollTo(x, y); }
207 void scroll(double x, double y, const ScrollOptions& scrollOptions, Exceptio nState& exceptionState) const { scrollTo(x, y, scrollOptions, exceptionState); }
208
209 void moveBy(float x, float y) const;
210 void moveTo(float x, float y) const;
211
212 void resizeBy(float x, float y) const;
213 void resizeTo(float width, float height) const;
214
215 // WebKit animation extensions
216 int requestAnimationFrame(RequestAnimationFrameCallback*);
217 int webkitRequestAnimationFrame(RequestAnimationFrameCallback*);
218 void cancelAnimationFrame(int id);
219
220 // Events 191 // Events
221 // EventTarget API 192 // EventTarget API
222 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture = false) override; 193 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture = false) override;
223 virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr<E ventListener>, bool useCapture = false) override; 194 virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr<E ventListener>, bool useCapture = false) override;
224 virtual void removeAllEventListeners() override; 195 virtual void removeAllEventListeners() override;
225 196
226 using EventTarget::dispatchEvent; 197 using EventTarget::dispatchEvent;
227 bool dispatchEvent(PassRefPtrWillBeRawPtr<Event> prpEvent, PassRefPtrWillBeR awPtr<EventTarget> prpTarget); 198 bool dispatchEvent(PassRefPtrWillBeRawPtr<Event> prpEvent, PassRefPtrWillBeR awPtr<EventTarget> prpTarget);
228 199
229 void dispatchLoadEvent(); 200 void dispatchLoadEvent();
230 201
231 // FIXME: It's not clear how to move these to DOMWindow yet.
232 DEFINE_ATTRIBUTE_EVENT_LISTENER(animationend);
233 DEFINE_ATTRIBUTE_EVENT_LISTENER(animationiteration);
234 DEFINE_ATTRIBUTE_EVENT_LISTENER(animationstart);
235 DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
236 DEFINE_ATTRIBUTE_EVENT_LISTENER(transitionend);
237 DEFINE_ATTRIBUTE_EVENT_LISTENER(wheel);
238
239 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkitanimationstart, webkitAnimation Start);
240 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkitanimationiteration, webkitAnima tionIteration);
241 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkitanimationend, webkitAnimationEn d);
242 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkittransitionend, webkitTransition End);
243
244 void captureEvents() { }
245 void releaseEvents() { }
246
247 void finishedLoading(); 202 void finishedLoading();
248 203
249 // HTML 5 key/value storage 204 // HTML 5 key/value storage
250 Storage* optionalSessionStorage() const { return m_sessionStorage.get(); } 205 Storage* optionalSessionStorage() const { return m_sessionStorage.get(); }
251 Storage* optionalLocalStorage() const { return m_localStorage.get(); } 206 Storage* optionalLocalStorage() const { return m_localStorage.get(); }
252 ApplicationCache* optionalApplicationCache() const { return m_applicationCac he.get(); } 207 ApplicationCache* optionalApplicationCache() const { return m_applicationCac he.get(); }
253 208
254 // Dispatch the (deprecated) orientationchange event to this DOMWindow and 209 // Dispatch the (deprecated) orientationchange event to this DOMWindow and
255 // recurse on its child frames. 210 // recurse on its child frames.
256 void sendOrientationChangeEvent(); 211 void sendOrientationChangeEvent();
257 212
258 DEFINE_ATTRIBUTE_EVENT_LISTENER(orientationchange);
259 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
260 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
261 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
262 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
263
264 // FIXME: When this LocalDOMWindow is no longer the active LocalDOMWindow (i .e., 213 // FIXME: When this LocalDOMWindow is no longer the active LocalDOMWindow (i .e.,
265 // when its document is no longer the document that is displayed in its 214 // when its document is no longer the document that is displayed in its
266 // frame), we would like to zero out m_frame to avoid being confused 215 // frame), we would like to zero out m_frame to avoid being confused
267 // by the document that is currently active in m_frame. 216 // by the document that is currently active in m_frame.
268 bool isCurrentlyDisplayedInFrame() const; 217 bool isCurrentlyDisplayedInFrame() const;
269 218
270 void willDetachDocumentFromFrame(); 219 void willDetachDocumentFromFrame();
271 LocalDOMWindow* anonymousIndexedGetter(uint32_t);
272 220
273 bool isInsecureScriptAccess(LocalDOMWindow& callingWindow, const String& url String); 221 bool isInsecureScriptAccess(LocalDOMWindow& callingWindow, const String& url String);
274 222
275 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > createLifecycleNotifier(); 223 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > createLifecycleNotifier();
276 224
277 EventQueue* eventQueue() const; 225 EventQueue* eventQueue() const;
278 void enqueueWindowEvent(PassRefPtrWillBeRawPtr<Event>); 226 void enqueueWindowEvent(PassRefPtrWillBeRawPtr<Event>);
279 void enqueueDocumentEvent(PassRefPtrWillBeRawPtr<Event>); 227 void enqueueDocumentEvent(PassRefPtrWillBeRawPtr<Event>);
280 void enqueuePageshowEvent(PageshowEventPersistence); 228 void enqueuePageshowEvent(PageshowEventPersistence);
281 void enqueueHashchangeEvent(const String& oldURL, const String& newURL); 229 void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 mutable RefPtrWillBeMember<Performance> m_performance; 321 mutable RefPtrWillBeMember<Performance> m_performance;
374 322
375 mutable RefPtrWillBeMember<DOMWindowCSS> m_css; 323 mutable RefPtrWillBeMember<DOMWindowCSS> m_css;
376 324
377 RefPtrWillBeMember<DOMWindowEventQueue> m_eventQueue; 325 RefPtrWillBeMember<DOMWindowEventQueue> m_eventQueue;
378 RefPtr<SerializedScriptValue> m_pendingStateObject; 326 RefPtr<SerializedScriptValue> m_pendingStateObject;
379 327
380 HashSet<OwnPtr<PostMessageTimer> > m_postMessageTimers; 328 HashSet<OwnPtr<PostMessageTimer> > m_postMessageTimers;
381 }; 329 };
382 330
331 DEFINE_TYPE_CASTS(LocalDOMWindow, DOMWindow, x, x->isLocalDOMWindow(), x.isLocal DOMWindow());
332
383 inline String LocalDOMWindow::status() const 333 inline String LocalDOMWindow::status() const
384 { 334 {
385 return m_status; 335 return m_status;
386 } 336 }
387 337
388 inline String LocalDOMWindow::defaultStatus() const 338 inline String LocalDOMWindow::defaultStatus() const
389 { 339 {
390 return m_defaultStatus; 340 return m_defaultStatus;
391 } 341 }
392 342
393 } // namespace blink 343 } // namespace blink
394 344
395 #endif // LocalDOMWindow_h 345 #endif // LocalDOMWindow_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698