OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 V8_PROXY_H__ | 5 #ifndef V8_PROXY_H__ |
6 #define V8_PROXY_H__ | 6 #define V8_PROXY_H__ |
7 | 7 |
8 #include <v8.h> | 8 #include <v8.h> |
9 #include "v8_index.h" | 9 #include "v8_index.h" |
10 #include "v8_custom.h" | 10 #include "v8_custom.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 static V8Proxy* retrieve(Frame* frame); | 276 static V8Proxy* retrieve(Frame* frame); |
277 // Returns V8Proxy object associated with a script execution context. | 277 // Returns V8Proxy object associated with a script execution context. |
278 static V8Proxy* retrieve(ScriptExecutionContext* context); | 278 static V8Proxy* retrieve(ScriptExecutionContext* context); |
279 | 279 |
280 // Returns the frame object of the window object associated | 280 // Returns the frame object of the window object associated |
281 // with the currently executing context. | 281 // with the currently executing context. |
282 static Frame* retrieveFrame(); | 282 static Frame* retrieveFrame(); |
283 // Returns the frame object of the window object associated with | 283 // Returns the frame object of the window object associated with |
284 // a context. | 284 // a context. |
285 static Frame* retrieveFrame(v8::Handle<v8::Context> context); | 285 static Frame* retrieveFrame(v8::Handle<v8::Context> context); |
286 // Returns the frame that started JS execution. | 286 |
287 // NOTE: cannot declare retrieveActiveFrame as inline function, | 287 |
288 // VS complains at linking time. | 288 // The two functions below retrieve WebFrame instances relating the currently |
289 static Frame* retrieveActiveFrame(); | 289 // executing JavaScript. Since JavaScript can make function calls across |
| 290 // frames, though, we need to be more precise. |
| 291 // |
| 292 // For example, imagine that a JS function in frame A calls a function in |
| 293 // frame B, which calls native code, which wants to know what the 'active' |
| 294 // frame is. |
| 295 // |
| 296 // The 'entered context' is the context where execution first entered the |
| 297 // script engine; the context that is at the bottom of the JS function stack. |
| 298 // RetrieveFrameForEnteredContext() would return Frame A in our example. |
| 299 // |
| 300 // The 'current context' is the context the JS engine is currently inside of; |
| 301 // the context that is at the top of the JS function stack. |
| 302 // RetrieveFrameForCurrentContext() would return Frame B in our example. |
| 303 // |
| 304 // NOTE: These cannot be declared as inline function, because VS complains at |
| 305 // linking time. |
| 306 static Frame* retrieveFrameForEnteredContext(); |
| 307 static Frame* retrieveFrameForCurrentContext(); |
290 | 308 |
291 // Returns V8 Context of a frame. If none exists, creates | 309 // Returns V8 Context of a frame. If none exists, creates |
292 // a new context. It is potentially slow and consumes memory. | 310 // a new context. It is potentially slow and consumes memory. |
293 static v8::Local<v8::Context> GetContext(Frame* frame); | 311 static v8::Local<v8::Context> GetContext(Frame* frame); |
294 static v8::Local<v8::Context> GetCurrentContext(); | 312 static v8::Local<v8::Context> GetCurrentContext(); |
295 | 313 |
296 // If the current context causes out of memory, JavaScript setting | 314 // If the current context causes out of memory, JavaScript setting |
297 // is disabled and it returns true. | 315 // is disabled and it returns true. |
298 static bool HandleOutOfMemory(); | 316 static bool HandleOutOfMemory(); |
299 | 317 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 V8Proxy::SetDOMWrapper(args.Holder(), tag, obj.get()); | 617 V8Proxy::SetDOMWrapper(args.Holder(), tag, obj.get()); |
600 obj->ref(); | 618 obj->ref(); |
601 V8Proxy::SetJSWrapperForDOMObject( | 619 V8Proxy::SetJSWrapperForDOMObject( |
602 obj.get(), v8::Persistent<v8::Object>::New(args.Holder())); | 620 obj.get(), v8::Persistent<v8::Object>::New(args.Holder())); |
603 return args.Holder(); | 621 return args.Holder(); |
604 } | 622 } |
605 | 623 |
606 } // namespace WebCore | 624 } // namespace WebCore |
607 | 625 |
608 #endif // V8_PROXY_H__ | 626 #endif // V8_PROXY_H__ |
OLD | NEW |