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

Side by Side Diff: third_party/WebKit/Source/core/frame/DOMWindow.h

Issue 2668753006: Special-case LocalDOMWindow for same-origin access in bindings. (Closed)
Patch Set: Rebase and address comments. Created 3 years, 10 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DOMWindow_h 5 #ifndef DOMWindow_h
6 #define DOMWindow_h 6 #define DOMWindow_h
7 7
8 #include "bindings/core/v8/Transferables.h" 8 #include "bindings/core/v8/Transferables.h"
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "core/events/EventTarget.h" 10 #include "core/events/EventTarget.h"
11 #include "core/frame/DOMWindowBase64.h" 11 #include "core/frame/DOMWindowBase64.h"
12 #include "core/frame/Frame.h" 12 #include "core/frame/Frame.h"
13 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
14 #include "platform/scroll/ScrollableArea.h"
15 #include "wtf/Assertions.h" 14 #include "wtf/Assertions.h"
16 #include "wtf/Forward.h" 15 #include "wtf/Forward.h"
17 16
18 namespace blink { 17 namespace blink {
19 18
20 class ApplicationCache;
21 class BarProp;
22 class CSSRuleList;
23 class CSSStyleDeclaration;
24 class CustomElementRegistry;
25 class DOMSelection;
26 class DOMVisualViewport;
27 class Document; 19 class Document;
28 class Element;
29 class External;
30 class FrameRequestCallback;
31 class History;
32 class IdleRequestCallback;
33 class IdleRequestOptions;
34 class Location; 20 class Location;
35 class LocalDOMWindow; 21 class LocalDOMWindow;
36 class MessageEvent; 22 class MessageEvent;
37 class MediaQueryList;
38 class Navigator;
39 class Screen;
40 class ScriptState;
41 class ScrollToOptions;
42 class SerializedScriptValue; 23 class SerializedScriptValue;
43 class StyleMedia;
44 24
45 class CORE_EXPORT DOMWindow : public EventTargetWithInlineData, 25 class CORE_EXPORT DOMWindow : public EventTargetWithInlineData,
46 public DOMWindowBase64 { 26 public DOMWindowBase64 {
47 DEFINE_WRAPPERTYPEINFO(); 27 DEFINE_WRAPPERTYPEINFO();
48 28
49 public: 29 public:
50 ~DOMWindow() override; 30 ~DOMWindow() override;
51 31
52 Frame* frame() const { 32 Frame* frame() const {
53 // If the DOMWindow still has a frame reference, that frame must point 33 // If the DOMWindow still has a frame reference, that frame must point
(...skipping 14 matching lines...) Expand all
68 v8::Local<v8::Object> creationContext) final; 48 v8::Local<v8::Object> creationContext) final;
69 v8::Local<v8::Object> associateWithWrapper( 49 v8::Local<v8::Object> associateWithWrapper(
70 v8::Isolate*, 50 v8::Isolate*,
71 const WrapperTypeInfo*, 51 const WrapperTypeInfo*,
72 v8::Local<v8::Object> wrapper) final; 52 v8::Local<v8::Object> wrapper) final;
73 53
74 // EventTarget overrides: 54 // EventTarget overrides:
75 const AtomicString& interfaceName() const override; 55 const AtomicString& interfaceName() const override;
76 const DOMWindow* toDOMWindow() const override; 56 const DOMWindow* toDOMWindow() const override;
77 57
78 // DOM Level 0 58 // Cross-origin DOM Level 0
79 virtual Screen* screen() const = 0;
80 virtual History* history() const = 0;
81 virtual BarProp* locationbar() const = 0;
82 virtual BarProp* menubar() const = 0;
83 virtual BarProp* personalbar() const = 0;
84 virtual BarProp* scrollbars() const = 0;
85 virtual BarProp* statusbar() const = 0;
86 virtual BarProp* toolbar() const = 0;
87 virtual Navigator* navigator() const = 0;
88 Navigator* clientInformation() const { return navigator(); }
89 Location* location() const; 59 Location* location() const;
90
91 virtual bool offscreenBuffering() const = 0;
92
93 virtual int outerHeight() const = 0;
94 virtual int outerWidth() const = 0;
95 virtual int innerHeight() const = 0;
96 virtual int innerWidth() const = 0;
97 virtual int screenX() const = 0;
98 virtual int screenY() const = 0;
99 int screenLeft() const { return screenX(); }
100 int screenTop() const { return screenY(); }
101 virtual double scrollX() const = 0;
102 virtual double scrollY() const = 0;
103 double pageXOffset() const { return scrollX(); }
104 double pageYOffset() const { return scrollY(); }
105
106 virtual DOMVisualViewport* visualViewport() { return nullptr; }
107
108 bool closed() const; 60 bool closed() const;
109
110 unsigned length() const; 61 unsigned length() const;
111 62
112 virtual const AtomicString& name() const = 0;
113 virtual void setName(const AtomicString&) = 0;
114
115 virtual String status() const = 0;
116 virtual void setStatus(const String&) = 0;
117 virtual String defaultStatus() const = 0;
118 virtual void setDefaultStatus(const String&) = 0;
119
120 // Self-referential attributes 63 // Self-referential attributes
121 DOMWindow* self() const; 64 DOMWindow* self() const;
122 DOMWindow* window() const { return self(); } 65 DOMWindow* window() const { return self(); }
123 DOMWindow* frames() const { return self(); } 66 DOMWindow* frames() const { return self(); }
124 67
125 DOMWindow* opener() const; 68 DOMWindow* opener() const;
126 DOMWindow* parent() const; 69 DOMWindow* parent() const;
127 DOMWindow* top() const; 70 DOMWindow* top() const;
128 71
129 // DOM Level 2 AbstractView Interface
130 virtual Document* document() const = 0;
131
132 // CSSOM View Module
133 virtual StyleMedia* styleMedia() const = 0;
134
135 // WebKit extensions
136 virtual double devicePixelRatio() const = 0;
137
138 virtual ApplicationCache* applicationCache() const = 0;
139
140 // This is the interface orientation in degrees. Some examples are:
141 // 0 is straight up; -90 is when the device is rotated 90 clockwise;
142 // 90 is when rotated counter clockwise.
143 virtual int orientation() const = 0;
144
145 virtual DOMSelection* getSelection() = 0;
146
147 void focus(ExecutionContext*); 72 void focus(ExecutionContext*);
148 virtual void blur() = 0; 73 virtual void blur() = 0;
149 void close(ExecutionContext*); 74 void close(ExecutionContext*);
150 virtual void print(ScriptState*) = 0;
151 virtual void stop() = 0;
152
153 virtual void alert(ScriptState*, const String& message = String()) = 0;
154 virtual bool confirm(ScriptState*, const String& message) = 0;
155 virtual String prompt(ScriptState*,
156 const String& message,
157 const String& defaultValue) = 0;
158
159 virtual bool find(const String&,
160 bool caseSensitive,
161 bool backwards,
162 bool wrap,
163 bool wholeWord,
164 bool searchInFrames,
165 bool showDialog) const = 0;
166
167 virtual void scrollBy(double x,
168 double y,
169 ScrollBehavior = ScrollBehaviorAuto) const = 0;
170 virtual void scrollBy(const ScrollToOptions&) const = 0;
171 virtual void scrollTo(double x, double y) const = 0;
172 virtual void scrollTo(const ScrollToOptions&) const = 0;
173 void scroll(double x, double y) const { scrollTo(x, y); }
174 void scroll(const ScrollToOptions& scrollToOptions) const {
175 scrollTo(scrollToOptions);
176 }
177 virtual void moveBy(int x, int y) const = 0;
178 virtual void moveTo(int x, int y) const = 0;
179
180 virtual void resizeBy(int x, int y) const = 0;
181 virtual void resizeTo(int width, int height) const = 0;
182
183 virtual MediaQueryList* matchMedia(const String&) = 0;
184
185 // DOM Level 2 Style Interface
186 virtual CSSStyleDeclaration* getComputedStyle(
187 Element*,
188 const String& pseudoElt) const = 0;
189
190 // WebKit extensions
191 virtual CSSRuleList* getMatchedCSSRules(Element*,
192 const String& pseudoElt) const = 0;
193
194 // WebKit animation extensions
195 virtual int requestAnimationFrame(FrameRequestCallback*) = 0;
196 virtual int webkitRequestAnimationFrame(FrameRequestCallback*) = 0;
197 virtual void cancelAnimationFrame(int id) = 0;
198
199 // Idle callback extensions
200 virtual int requestIdleCallback(IdleRequestCallback*,
201 const IdleRequestOptions&) = 0;
202 virtual void cancelIdleCallback(int id) = 0;
203
204 // Custom elements
205 virtual CustomElementRegistry* customElements(ScriptState*) const = 0;
206
207 // Obsolete APIs
208 void captureEvents() {}
209 void releaseEvents() {}
210 External* external();
211 75
212 // FIXME: This handles both window[index] and window.frames[index]. However, 76 // FIXME: This handles both window[index] and window.frames[index]. However,
213 // the spec exposes window.frames[index] across origins but not 77 // the spec exposes window.frames[index] across origins but not
214 // window[index]... 78 // window[index]...
215 DOMWindow* anonymousIndexedGetter(uint32_t) const; 79 DOMWindow* anonymousIndexedGetter(uint32_t) const;
216 80
217 void postMessage(PassRefPtr<SerializedScriptValue> message, 81 void postMessage(PassRefPtr<SerializedScriptValue> message,
218 const MessagePortArray&, 82 const MessagePortArray&,
219 const String& targetOrigin, 83 const String& targetOrigin,
220 LocalDOMWindow* source, 84 LocalDOMWindow* source,
221 ExceptionState&); 85 ExceptionState&);
222 86
223 String sanitizedCrossDomainAccessErrorMessage( 87 String sanitizedCrossDomainAccessErrorMessage(
224 const LocalDOMWindow* callingWindow) const; 88 const LocalDOMWindow* callingWindow) const;
225 String crossDomainAccessErrorMessage( 89 String crossDomainAccessErrorMessage(
226 const LocalDOMWindow* callingWindow) const; 90 const LocalDOMWindow* callingWindow) const;
227 bool isInsecureScriptAccess(LocalDOMWindow& callingWindow, const KURL&); 91 bool isInsecureScriptAccess(LocalDOMWindow& callingWindow, const KURL&);
228 92
229 // FIXME: When this DOMWindow is no longer the active DOMWindow (i.e., 93 // FIXME: When this DOMWindow is no longer the active DOMWindow (i.e.,
230 // when its document is no longer the document that is displayed in its 94 // when its document is no longer the document that is displayed in its
231 // frame), we would like to zero out m_frame to avoid being confused 95 // frame), we would like to zero out m_frame to avoid being confused
232 // by the document that is currently active in m_frame. 96 // by the document that is currently active in m_frame.
233 // See https://bugs.webkit.org/show_bug.cgi?id=62054 97 // See https://bugs.webkit.org/show_bug.cgi?id=62054
234 bool isCurrentlyDisplayedInFrame() const; 98 bool isCurrentlyDisplayedInFrame() const;
235 99
236 void resetLocation(); 100 void resetLocation();
237 101
238 bool isSecureContext() const; 102 bool isSecureContext() const;
239 103
240 DEFINE_ATTRIBUTE_EVENT_LISTENER(animationend);
241 DEFINE_ATTRIBUTE_EVENT_LISTENER(animationiteration);
242 DEFINE_ATTRIBUTE_EVENT_LISTENER(animationstart);
243 DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
244 DEFINE_ATTRIBUTE_EVENT_LISTENER(transitionend);
245 DEFINE_ATTRIBUTE_EVENT_LISTENER(wheel);
246
247 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkitanimationstart,
248 webkitAnimationStart);
249 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkitanimationiteration,
250 webkitAnimationIteration);
251 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkitanimationend,
252 webkitAnimationEnd);
253 DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkittransitionend,
254 webkitTransitionEnd);
255
256 DEFINE_ATTRIBUTE_EVENT_LISTENER(orientationchange);
257
258 protected: 104 protected:
259 explicit DOMWindow(Frame&); 105 explicit DOMWindow(Frame&);
260 106
261 virtual void schedulePostMessage(MessageEvent*, 107 virtual void schedulePostMessage(MessageEvent*,
262 PassRefPtr<SecurityOrigin> target, 108 PassRefPtr<SecurityOrigin> target,
263 Document* source) = 0; 109 Document* source) = 0;
264 110
265 void disconnectFromFrame() { m_frame = nullptr; } 111 void disconnectFromFrame() { m_frame = nullptr; }
266 112
267 private: 113 private:
268 Member<Frame> m_frame; 114 Member<Frame> m_frame;
269 mutable Member<Location> m_location; 115 mutable Member<Location> m_location;
270 Member<External> m_external;
271 116
272 // Set to true when close() has been called. Needed for 117 // Set to true when close() has been called. Needed for
273 // |window.closed| determinism; having it return 'true' 118 // |window.closed| determinism; having it return 'true'
274 // only after the layout widget's deferred window close 119 // only after the layout widget's deferred window close
275 // operation has been performed, exposes (confusing) 120 // operation has been performed, exposes (confusing)
276 // implementation details to scripts. 121 // implementation details to scripts.
277 bool m_windowIsClosing; 122 bool m_windowIsClosing;
278 123
279 }; 124 };
280 125
281 } // namespace blink 126 } // namespace blink
282 127
283 #endif // DOMWindow_h 128 #endif // DOMWindow_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl ('k') | third_party/WebKit/Source/core/frame/DOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698