OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 24 matching lines...) Expand all Loading... | |
35 #include "bindings/core/v8/ScopedPersistent.h" | 35 #include "bindings/core/v8/ScopedPersistent.h" |
36 #include "core/CoreExport.h" | 36 #include "core/CoreExport.h" |
37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
38 #include "v8/include/v8.h" | 38 #include "v8/include/v8.h" |
39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 class DOMWindow; | 43 class DOMWindow; |
44 class Frame; | 44 class Frame; |
45 class ScriptController; | |
46 | 45 |
47 // WindowProxy implements the split window model of a window for a frame. In the | 46 // WindowProxy implements the split window model of a window for a frame. In the |
48 // HTML standard, the split window model is composed of the Window interface | 47 // HTML standard, the split window model is composed of the Window interface |
49 // (the inner global object) and the WindowProxy interface (the outer global | 48 // (the inner global object) and the WindowProxy interface (the outer global |
50 // proxy). | 49 // proxy). |
51 // | 50 // |
52 // The Window interface is backed by the Blink DOMWindow C++ implementation. | 51 // The Window interface is backed by the Blink DOMWindow C++ implementation. |
53 // In contrast, the WindowProxy interface does not have a corresponding | 52 // In contrast, the WindowProxy interface does not have a corresponding |
54 // C++ implementation in Blink: the WindowProxy class defined here only manages | 53 // C++ implementation in Blink: the WindowProxy class defined here only manages |
55 // context initialization and detach. Instead, the behavior of the WindowProxy | 54 // context initialization and detach. Instead, the behavior of the WindowProxy |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 v8::Local<v8::Object> releaseGlobal(); | 155 v8::Local<v8::Object> releaseGlobal(); |
157 void setGlobal(v8::Local<v8::Object>); | 156 void setGlobal(v8::Local<v8::Object>); |
158 | 157 |
159 // TODO(dcheng): Temporarily exposed to avoid include cycles. Remove the need | 158 // TODO(dcheng): Temporarily exposed to avoid include cycles. Remove the need |
160 // for this and remove this getter. | 159 // for this and remove this getter. |
161 DOMWrapperWorld& world() { return *m_world; } | 160 DOMWrapperWorld& world() { return *m_world; } |
162 | 161 |
163 virtual bool isLocal() const { return false; } | 162 virtual bool isLocal() const { return false; } |
164 | 163 |
165 protected: | 164 protected: |
166 // TODO(dcheng): Remove this friend declaration once LocalWindowProxyManager | 165 // Lifecycle represents the following four states. |
167 // and ScriptController are merged. | 166 // |
168 friend class ScriptController; | 167 // * ContextUninitialized |
169 | 168 // We lazily initialize WindowProxies for performance reasons, and this state |
170 // A valid transition is from ContextUninitialized to ContextInitialized, | 169 // is "to be initialized on demand". WindowProxy basically behaves the same as |
171 // and then ContextDetached. Other transitions are forbidden. | 170 // |ContextInitialized| from a point of view of call sites. |
171 // - Possible next states: ContextInitialized | |
172 // It's possible to detach the context from a frame or navigate to a new page | |
173 // without initializing the WindowProxy, however, there is no transition to | |
174 // |ContextDetachedFromFrame| or |GlobalObjectDetached| because | |
175 // |disposeContext| does not change the state if the state is | |
176 // |ContextUninitialized|. In either case of a) the browsing context is | |
177 // detached from a frame or b) the page is navigated away, there must be no | |
178 // way for author script to access the context of |ContextUninitialized| | |
179 // because |ContextUninitialized| means that author script has never accessed | |
180 // the context, hence there must exist no reference to the context. | |
181 // | |
182 // * ContextInitialized | |
183 // The context is initialized and still attached to a frame. | |
184 // - Possible next states: ContextDetachedFromFrame, GlobalObjectDetached | |
185 // | |
186 // * ContextDetachedFromFrame | |
187 // The context is initialized, once attached to a frame and now detached. Note | |
dcheng
2017/03/28 21:25:42
Hmm... maybe be more explicit that it's the frame
Yuki
2017/03/30 14:48:37
Done.
| |
188 // that the context is still alive and author script may have references to | |
189 // the context and hence author script may run in the context. | |
190 // The spec does not support some of web features such as setTimeout, etc. on | |
191 // a detached window. Blink supports less things than the spec. | |
192 // V8PerContextData is cut off from the context. | |
193 // - Possible next states: n/a | |
194 // | |
195 // * GlobalObjectDetached | |
196 // The context is initialized, attached to a frame, and now navigated away. | |
197 // The global object (inner global) is detached from the global proxy (outer | |
198 // global), but the (detached) global object and context are still alive, and | |
199 // author script may have references to the context. | |
dcheng
2017/03/28 21:25:42
May be worth noting that this state is also used w
Yuki
2017/03/30 14:48:37
Good to know.
When swapping frames, currently we
dcheng
2017/03/30 21:03:01
We actually do =)
See https://cs.chromium.org/chro
Yuki
2017/03/31 07:32:09
Oops, thank you for pointing it out.
I've added a
| |
200 // The spec does not support full web features in this state. Blink supports | |
201 // less things than the spec. | |
202 // - Possible next states: ContextInitialized | |
203 // This state is in the middle of navigation. Once it's completed and the | |
204 // context gets accessed, the WindowProxy is lazily re-initialized for a new | |
dcheng
2017/03/28 21:25:42
It might be more accurate to say that the context
Yuki
2017/03/30 14:48:38
Done.
| |
205 // window and document, and then the state becomes |ContextInitialized|. | |
172 enum class Lifecycle { | 206 enum class Lifecycle { |
207 // v8::Context is not yet initialized. | |
173 ContextUninitialized, | 208 ContextUninitialized, |
209 // v8::Context is initialized. | |
174 ContextInitialized, | 210 ContextInitialized, |
175 ContextDetached, | 211 // A context is detached from a frame. |
212 ContextDetachedFromFrame, | |
dcheng
2017/03/28 21:25:42
Nit: I think it would be more accurate to call thi
haraken
2017/03/29 08:54:53
ContextIsNotInitialized, ContextIsInitialized, Glo
Yuki
2017/03/30 14:48:38
Good points. Updated to:
ContextIsNotInitialized
| |
213 // The global object (inner global) is detached from the global proxy. | |
214 GlobalObjectDetached, | |
176 }; | 215 }; |
177 | 216 |
178 WindowProxy(v8::Isolate*, Frame&, RefPtr<DOMWrapperWorld>); | 217 WindowProxy(v8::Isolate*, Frame&, RefPtr<DOMWrapperWorld>); |
179 | 218 |
180 virtual void initialize() = 0; | 219 virtual void initialize() = 0; |
181 | 220 |
182 enum GlobalDetachmentBehavior { DoNotDetachGlobal, DetachGlobal }; | 221 enum GlobalDetachmentBehavior { DoNotDetachGlobal, DetachGlobal }; |
183 virtual void disposeContext(GlobalDetachmentBehavior) = 0; | 222 virtual void disposeContext(GlobalDetachmentBehavior) = 0; |
184 | 223 |
185 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( | 224 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( |
(...skipping 19 matching lines...) Expand all Loading... | |
205 protected: | 244 protected: |
206 // TODO(dcheng): Consider making these private and using getters. | 245 // TODO(dcheng): Consider making these private and using getters. |
207 const RefPtr<DOMWrapperWorld> m_world; | 246 const RefPtr<DOMWrapperWorld> m_world; |
208 ScopedPersistent<v8::Object> m_globalProxy; | 247 ScopedPersistent<v8::Object> m_globalProxy; |
209 Lifecycle m_lifecycle; | 248 Lifecycle m_lifecycle; |
210 }; | 249 }; |
211 | 250 |
212 } // namespace blink | 251 } // namespace blink |
213 | 252 |
214 #endif // WindowProxy_h | 253 #endif // WindowProxy_h |
OLD | NEW |