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

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: Fix incorrect assumption 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();
81 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LocalDOMWindow); 67 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LocalDOMWindow);
82 public: 68 public:
83 static PassRefPtrWillBeRawPtr<Document> createDocument(const String& mimeTyp e, const DocumentInit&, bool forceXHTML); 69 static PassRefPtrWillBeRawPtr<Document> createDocument(const String& mimeTyp e, const DocumentInit&, bool forceXHTML);
84 static PassRefPtrWillBeRawPtr<LocalDOMWindow> create(LocalFrame& frame) 70 static PassRefPtrWillBeRawPtr<LocalDOMWindow> create(LocalFrame& frame)
85 { 71 {
86 return adoptRefWillBeNoop(new LocalDOMWindow(frame)); 72 return adoptRefWillBeNoop(new LocalDOMWindow(frame));
87 } 73 }
88 virtual ~LocalDOMWindow(); 74 virtual ~LocalDOMWindow();
89 75
90 PassRefPtrWillBeRawPtr<Document> installNewDocument(const String& mimeType, const DocumentInit&, bool forceXHTML = false); 76 PassRefPtrWillBeRawPtr<Document> installNewDocument(const String& mimeType, const DocumentInit&, bool forceXHTML = false);
91 77
92 // EventTarget overrides: 78 // EventTarget overrides:
93 virtual const AtomicString& interfaceName() const override; 79 virtual const AtomicString& interfaceName() const override;
94 virtual ExecutionContext* executionContext() const override; 80 virtual ExecutionContext* executionContext() const override;
95 virtual LocalDOMWindow* toDOMWindow() override; 81 virtual LocalDOMWindow* toDOMWindow() override;
96 82
97 // DOMWindow overrides: 83 // DOMWindow overrides:
98 void trace(Visitor*) override; 84 void trace(Visitor*) override;
85 bool isLocalDOMWindow() const override { return true; }
99 virtual LocalFrame* frame() const override; 86 virtual LocalFrame* frame() const override;
100 Screen* screen() const override; 87 Screen* screen() const override;
101 History* history() const override; 88 History* history() const override;
102 BarProp* locationbar() const override; 89 BarProp* locationbar() const override;
103 BarProp* menubar() const override; 90 BarProp* menubar() const override;
104 BarProp* personalbar() const override; 91 BarProp* personalbar() const override;
105 BarProp* scrollbars() const override; 92 BarProp* scrollbars() const override;
106 BarProp* statusbar() const override; 93 BarProp* statusbar() const override;
107 BarProp* toolbar() const override; 94 BarProp* toolbar() const override;
108 Navigator* navigator() const override; 95 Navigator* navigator() const override;
(...skipping 22 matching lines...) Expand all
131 Document* document() const override; 118 Document* document() const override;
132 StyleMedia* styleMedia() const override; 119 StyleMedia* styleMedia() const override;
133 double devicePixelRatio() const override; 120 double devicePixelRatio() const override;
134 Storage* sessionStorage(ExceptionState&) const override; 121 Storage* sessionStorage(ExceptionState&) const override;
135 Storage* localStorage(ExceptionState&) const override; 122 Storage* localStorage(ExceptionState&) const override;
136 ApplicationCache* applicationCache() const override; 123 ApplicationCache* applicationCache() const override;
137 int orientation() const override; 124 int orientation() const override;
138 Console* console() const override; 125 Console* console() const override;
139 Performance* performance() const override; 126 Performance* performance() const override;
140 DOMWindowCSS* css() const override; 127 DOMWindowCSS* css() const override;
128 DOMSelection* getSelection() override;
129 void focus(ExecutionContext* = 0) override;
130 void blur() override;
131 void close(ExecutionContext* = 0) override;
132 void print() override;
133 void stop() override;
134 void alert(const String& message = String()) override;
135 bool confirm(const String& message) override;
136 String prompt(const String& message, const String& defaultValue) override;
137 bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const override;
138 void scrollBy(double x, double y, ScrollBehavior = ScrollBehaviorAuto) const override;
139 void scrollBy(double x, double y, const ScrollOptions&, ExceptionState&) con st override;
140 void scrollTo(double x, double y, ScrollBehavior = ScrollBehaviorAuto) const override;
141 void scrollTo(double x, double y, const ScrollOptions&, ExceptionState&) con st override;
142 void moveBy(float x, float y) const override;
143 void moveTo(float x, float y) const override;
144 void resizeBy(float x, float y) const override;
145 void resizeTo(float width, float height) const override;
146 PassRefPtrWillBeRawPtr<MediaQueryList> matchMedia(const String&) override;
147 PassRefPtrWillBeRawPtr<CSSStyleDeclaration> getComputedStyle(Element*, const String& pseudoElt) const override;
148 PassRefPtrWillBeRawPtr<CSSRuleList> getMatchedCSSRules(Element*, const Strin g& pseudoElt) const override;
149 int requestAnimationFrame(RequestAnimationFrameCallback*) override;
150 int webkitRequestAnimationFrame(RequestAnimationFrameCallback*) override;
151 void cancelAnimationFrame(int id) override;
152 LocalDOMWindow* anonymousIndexedGetter(uint32_t) override;
153 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor tArray*, const String& targetOrigin, LocalDOMWindow* source, ExceptionState&) ov erride;
141 154
142 void registerProperty(DOMWindowProperty*); 155 void registerProperty(DOMWindowProperty*);
143 void unregisterProperty(DOMWindowProperty*); 156 void unregisterProperty(DOMWindowProperty*);
144 157
145 void reset(); 158 void reset();
146 159
147 PassRefPtrWillBeRawPtr<MediaQueryList> matchMedia(const String&);
148
149 unsigned pendingUnloadEventListeners() const; 160 unsigned pendingUnloadEventListeners() const;
150 161
151 static FloatRect adjustWindowRect(LocalFrame&, const FloatRect& pendingChang es); 162 static FloatRect adjustWindowRect(LocalFrame&, const FloatRect& pendingChang es);
152 163
153 bool allowPopUp(); // Call on first window, not target window. 164 bool allowPopUp(); // Call on first window, not target window.
154 static bool allowPopUp(LocalFrame& firstFrame); 165 static bool allowPopUp(LocalFrame& firstFrame);
155 static bool canShowModalDialogNow(const LocalFrame*); 166 static bool canShowModalDialogNow(const LocalFrame*);
156 167
157 // DOM Level 0 168 // DOM Level 0
158 void setLocation(const String& location, LocalDOMWindow* callingWindow, Loca lDOMWindow* enteredWindow, 169 void setLocation(const String& location, LocalDOMWindow* callingWindow, Loca lDOMWindow* enteredWindow,
159 SetLocationLocking = LockHistoryBasedOnGestureState); 170 SetLocationLocking = LockHistoryBasedOnGestureState);
160 171
161 DOMSelection* getSelection();
162
163 Element* frameElement() const; 172 Element* frameElement() const;
164 173
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, 174 PassRefPtrWillBeRawPtr<LocalDOMWindow> open(const String& urlString, const A tomicString& frameName, const String& windowFeaturesString,
172 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow); 175 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow);
173 176
174 typedef void (*PrepareDialogFunction)(LocalDOMWindow*, void* context); 177 typedef void (*PrepareDialogFunction)(LocalDOMWindow*, void* context);
175 void showModalDialog(const String& urlString, const String& dialogFeaturesSt ring, 178 void showModalDialog(const String& urlString, const String& dialogFeaturesSt ring,
176 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, PrepareDia logFunction, void* functionContext); 179 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, PrepareDia logFunction, void* functionContext);
177 180
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; 181 FrameConsole* frameConsole() const;
193 182
194 void printErrorMessage(const String&); 183 void printErrorMessage(const String&);
195 String crossDomainAccessErrorMessage(LocalDOMWindow* callingWindow); 184 String crossDomainAccessErrorMessage(LocalDOMWindow* callingWindow);
196 String sanitizedCrossDomainAccessErrorMessage(LocalDOMWindow* callingWindow) ; 185 String sanitizedCrossDomainAccessErrorMessage(LocalDOMWindow* callingWindow) ;
197 186
198 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor tArray*, const String& targetOrigin, LocalDOMWindow* source, ExceptionState&);
199 void postMessageTimerFired(PostMessageTimer*); 187 void postMessageTimerFired(PostMessageTimer*);
200 void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigi n, PassRefPtrWillBeRawPtr<Event>, PassRefPtrWillBeRawPtr<ScriptCallStack>); 188 void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigi n, PassRefPtrWillBeRawPtr<Event>, PassRefPtrWillBeRawPtr<ScriptCallStack>);
201 189
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 190 // Events
221 // EventTarget API 191 // EventTarget API
222 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture = false) override; 192 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; 193 virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr<E ventListener>, bool useCapture = false) override;
224 virtual void removeAllEventListeners() override; 194 virtual void removeAllEventListeners() override;
225 195
226 using EventTarget::dispatchEvent; 196 using EventTarget::dispatchEvent;
227 bool dispatchEvent(PassRefPtrWillBeRawPtr<Event> prpEvent, PassRefPtrWillBeR awPtr<EventTarget> prpTarget); 197 bool dispatchEvent(PassRefPtrWillBeRawPtr<Event> prpEvent, PassRefPtrWillBeR awPtr<EventTarget> prpTarget);
228 198
229 void dispatchLoadEvent(); 199 void dispatchLoadEvent();
230 200
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(); 201 void finishedLoading();
248 202
249 // HTML 5 key/value storage 203 // HTML 5 key/value storage
250 Storage* optionalSessionStorage() const { return m_sessionStorage.get(); } 204 Storage* optionalSessionStorage() const { return m_sessionStorage.get(); }
251 Storage* optionalLocalStorage() const { return m_localStorage.get(); } 205 Storage* optionalLocalStorage() const { return m_localStorage.get(); }
252 ApplicationCache* optionalApplicationCache() const { return m_applicationCac he.get(); } 206 ApplicationCache* optionalApplicationCache() const { return m_applicationCac he.get(); }
253 207
254 // Dispatch the (deprecated) orientationchange event to this DOMWindow and 208 // Dispatch the (deprecated) orientationchange event to this DOMWindow and
255 // recurse on its child frames. 209 // recurse on its child frames.
256 void sendOrientationChangeEvent(); 210 void sendOrientationChangeEvent();
257 211
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., 212 // 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 213 // 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 214 // frame), we would like to zero out m_frame to avoid being confused
267 // by the document that is currently active in m_frame. 215 // by the document that is currently active in m_frame.
268 bool isCurrentlyDisplayedInFrame() const; 216 bool isCurrentlyDisplayedInFrame() const;
269 217
270 void willDetachDocumentFromFrame(); 218 void willDetachDocumentFromFrame();
271 LocalDOMWindow* anonymousIndexedGetter(uint32_t);
272 219
273 bool isInsecureScriptAccess(LocalDOMWindow& callingWindow, const String& url String); 220 bool isInsecureScriptAccess(LocalDOMWindow& callingWindow, const String& url String);
274 221
275 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > createLifecycleNotifier(); 222 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > createLifecycleNotifier();
276 223
277 EventQueue* eventQueue() const; 224 EventQueue* eventQueue() const;
278 void enqueueWindowEvent(PassRefPtrWillBeRawPtr<Event>); 225 void enqueueWindowEvent(PassRefPtrWillBeRawPtr<Event>);
279 void enqueueDocumentEvent(PassRefPtrWillBeRawPtr<Event>); 226 void enqueueDocumentEvent(PassRefPtrWillBeRawPtr<Event>);
280 void enqueuePageshowEvent(PageshowEventPersistence); 227 void enqueuePageshowEvent(PageshowEventPersistence);
281 void enqueueHashchangeEvent(const String& oldURL, const String& newURL); 228 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; 320 mutable RefPtrWillBeMember<Performance> m_performance;
374 321
375 mutable RefPtrWillBeMember<DOMWindowCSS> m_css; 322 mutable RefPtrWillBeMember<DOMWindowCSS> m_css;
376 323
377 RefPtrWillBeMember<DOMWindowEventQueue> m_eventQueue; 324 RefPtrWillBeMember<DOMWindowEventQueue> m_eventQueue;
378 RefPtr<SerializedScriptValue> m_pendingStateObject; 325 RefPtr<SerializedScriptValue> m_pendingStateObject;
379 326
380 HashSet<OwnPtr<PostMessageTimer> > m_postMessageTimers; 327 HashSet<OwnPtr<PostMessageTimer> > m_postMessageTimers;
381 }; 328 };
382 329
330 DEFINE_TYPE_CASTS(LocalDOMWindow, DOMWindow, x, x->isLocalDOMWindow(), x.isLocal DOMWindow());
331
383 inline String LocalDOMWindow::status() const 332 inline String LocalDOMWindow::status() const
384 { 333 {
385 return m_status; 334 return m_status;
386 } 335 }
387 336
388 inline String LocalDOMWindow::defaultStatus() const 337 inline String LocalDOMWindow::defaultStatus() const
389 { 338 {
390 return m_defaultStatus; 339 return m_defaultStatus;
391 } 340 }
392 341
393 } // namespace blink 342 } // namespace blink
394 343
395 #endif // LocalDOMWindow_h 344 #endif // LocalDOMWindow_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698