Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "bindings/core/v8/V8ObjectBuilder.h" | |
| 7 | |
| 8 #include "bindings/core/v8/V8Binding.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 V8ObjectBuilder::V8ObjectBuilder(v8::Isolate* isolate) | |
| 13 : m_isolate(isolate) | |
| 14 , m_object(v8::Object::New(isolate)) | |
| 15 { | |
| 16 } | |
| 17 | |
| 18 ScriptValue V8ObjectBuilder::scriptValue() const | |
| 19 { | |
| 20 return ScriptValue(ScriptState::current(m_isolate), m_object); | |
|
haraken
2015/03/24 14:33:32
Using ScriptState::current is not nice, since the
Jens Widell
2015/03/24 15:16:29
Done.
The constructor now takes (and stores) a Sc
| |
| 21 } | |
| 22 | |
| 23 V8ObjectBuilder& V8ObjectBuilder::add(String name, const ScriptValue& value) | |
| 24 { | |
| 25 add(name, value.v8Value()); | |
| 26 return *this; | |
| 27 } | |
| 28 | |
| 29 V8ObjectBuilder& V8ObjectBuilder::add(String name, const V8ObjectBuilder& value) | |
| 30 { | |
| 31 add(name, value.v8Value()); | |
| 32 return *this; | |
| 33 } | |
| 34 | |
| 35 V8ObjectBuilder& V8ObjectBuilder::addNull(String name) | |
| 36 { | |
| 37 add(name, v8::Null(m_isolate)); | |
| 38 return *this; | |
| 39 } | |
| 40 | |
| 41 V8ObjectBuilder& V8ObjectBuilder::addBoolean(String name, bool value) | |
| 42 { | |
| 43 add(name, value ? v8::True(m_isolate) : v8::False(m_isolate)); | |
| 44 return *this; | |
| 45 } | |
| 46 | |
| 47 V8ObjectBuilder& V8ObjectBuilder::addNumber(String name, double value) | |
| 48 { | |
| 49 add(name, v8::Number::New(m_isolate, value)); | |
| 50 return *this; | |
| 51 } | |
| 52 | |
| 53 V8ObjectBuilder& V8ObjectBuilder::addString(String name, String value) | |
| 54 { | |
| 55 add(name, v8String(m_isolate, value)); | |
| 56 return *this; | |
| 57 } | |
| 58 | |
| 59 void V8ObjectBuilder::add(String name, v8::Local<v8::Value> value) | |
| 60 { | |
| 61 m_object->ForceSet(m_isolate->GetCurrentContext(), v8String(m_isolate, name) , value); | |
|
haraken
2015/03/24 14:33:32
Why do we use ForceSet, not Set?
haraken
2015/03/24 14:33:33
Also we should use m_scriptState->context().
Jens Widell
2015/03/24 14:38:40
Web IDL uses [[DefineOwnProperty]] to describe ECM
Jens Widell
2015/03/24 15:16:29
Done.
| |
| 62 } | |
| 63 | |
| 64 } // namespace blink | |
| OLD | NEW |