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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ToV8.h

Issue 2690943002: Revert of binding: Changes the association among global-proxy/global/window-instance. (Closed)
Patch Set: 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 ToV8_h 5 #ifndef ToV8_h
6 #define ToV8_h 6 #define ToV8_h
7 7
8 // ToV8() provides C++ -> V8 conversion. Note that ToV8() can return an empty 8 // ToV8() provides C++ -> V8 conversion. Note that ToV8() can return an empty
9 // handle. Call sites must check IsEmpty() before using return value. 9 // handle. Call sites must check IsEmpty() before using return value.
10 10
11 #include "bindings/core/v8/DOMDataStore.h" 11 #include "bindings/core/v8/DOMDataStore.h"
12 #include "bindings/core/v8/IDLDictionaryBase.h" 12 #include "bindings/core/v8/IDLDictionaryBase.h"
13 #include "bindings/core/v8/ScriptState.h" 13 #include "bindings/core/v8/ScriptState.h"
14 #include "bindings/core/v8/ScriptValue.h" 14 #include "bindings/core/v8/ScriptValue.h"
15 #include "bindings/core/v8/ScriptWrappable.h" 15 #include "bindings/core/v8/ScriptWrappable.h"
16 #include "bindings/core/v8/V8Binding.h" 16 #include "bindings/core/v8/V8Binding.h"
17 #include "core/CoreExport.h" 17 #include "core/CoreExport.h"
18 #include "platform/heap/Handle.h" 18 #include "platform/heap/Handle.h"
19 #include "wtf/Forward.h" 19 #include "wtf/Forward.h"
20 #include <utility> 20 #include <utility>
21 #include <v8.h> 21 #include <v8.h>
22 22
23 namespace blink { 23 namespace blink {
24 24
25 class DOMWindow;
25 class Dictionary; 26 class Dictionary;
27 class EventTarget;
26 28
27 // ScriptWrappable 29 // ScriptWrappable
28 30
29 inline v8::Local<v8::Value> ToV8(ScriptWrappable* impl, 31 inline v8::Local<v8::Value> ToV8(ScriptWrappable* impl,
30 v8::Local<v8::Object> creationContext, 32 v8::Local<v8::Object> creationContext,
31 v8::Isolate* isolate) { 33 v8::Isolate* isolate) {
32 if (UNLIKELY(!impl)) 34 if (UNLIKELY(!impl))
33 return v8::Null(isolate); 35 return v8::Null(isolate);
34 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); 36 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
35 if (!wrapper.IsEmpty()) 37 if (!wrapper.IsEmpty())
(...skipping 11 matching lines...) Expand all
47 return v8::Null(isolate); 49 return v8::Null(isolate);
48 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); 50 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
49 if (!wrapper.IsEmpty()) 51 if (!wrapper.IsEmpty())
50 return wrapper; 52 return wrapper;
51 53
52 wrapper = ScriptWrappable::fromNode(impl)->wrap(isolate, creationContext); 54 wrapper = ScriptWrappable::fromNode(impl)->wrap(isolate, creationContext);
53 DCHECK(!wrapper.IsEmpty()); 55 DCHECK(!wrapper.IsEmpty());
54 return wrapper; 56 return wrapper;
55 } 57 }
56 58
59 // Special versions for DOMWindow and EventTarget
60
61 CORE_EXPORT v8::Local<v8::Value> ToV8(DOMWindow*,
62 v8::Local<v8::Object> creationContext,
63 v8::Isolate*);
64 CORE_EXPORT v8::Local<v8::Value> ToV8(EventTarget*,
65 v8::Local<v8::Object> creationContext,
66 v8::Isolate*);
67
57 // Primitives 68 // Primitives
58 69
59 inline v8::Local<v8::Value> ToV8(const String& value, 70 inline v8::Local<v8::Value> ToV8(const String& value,
60 v8::Local<v8::Object> creationContext, 71 v8::Local<v8::Object> creationContext,
61 v8::Isolate* isolate) { 72 v8::Isolate* isolate) {
62 return v8String(isolate, value); 73 return v8String(isolate, value);
63 } 74 }
64 75
65 inline v8::Local<v8::Value> ToV8(const char* value, 76 inline v8::Local<v8::Value> ToV8(const char* value,
66 v8::Local<v8::Object> creationContext, 77 v8::Local<v8::Object> creationContext,
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // Cannot define in ScriptValue because of the circular dependency between toV8 307 // Cannot define in ScriptValue because of the circular dependency between toV8
297 // and ScriptValue 308 // and ScriptValue
298 template <typename T> 309 template <typename T>
299 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { 310 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) {
300 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState)); 311 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState));
301 } 312 }
302 313
303 } // namespace blink 314 } // namespace blink
304 315
305 #endif // ToV8_h 316 #endif // ToV8_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptWrappable.h ('k') | third_party/WebKit/Source/bindings/core/v8/ToV8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698