Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp |
| index 3478c6b4cf5f6f23811b1f505bae7a320310c749..834a2897ebadfb3d6d8d7265165d1381f8d02b15 100644 |
| --- a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp |
| +++ b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp |
| @@ -24,24 +24,11 @@ |
| namespace blink { |
| CustomElementsRegistry* CustomElementsRegistry::create( |
| - ScriptState* scriptState, |
| V0CustomElementRegistrationContext* v0) |
| { |
| - DCHECK(scriptState->world().isMainWorld()); |
| CustomElementsRegistry* registry = new CustomElementsRegistry(v0); |
| if (v0) |
| v0->setV1(registry); |
| - |
| - v8::Isolate* isolate = scriptState->isolate(); |
| - v8::Local<v8::Object> wrapper = |
| - toV8(registry, scriptState).As<v8::Object>(); |
| - v8::Local<v8::String> name = |
| - V8HiddenValue::customElementsRegistryMap(isolate); |
| - v8::Local<v8::Map> map = v8::Map::New(isolate); |
| - bool didSetPrototype = |
| - V8HiddenValue::setHiddenValue(scriptState, wrapper, name, map); |
| - DCHECK(didSetPrototype); |
| - |
| return registry; |
| } |
| @@ -173,15 +160,34 @@ bool CustomElementsRegistry::nameIsDefined(const AtomicString& name) const |
| return m_names.contains(name); |
| } |
| +void CustomElementsRegistry::initializeScript( |
|
haraken
2016/05/23 01:46:37
I'd rename the method to ensureConstructorMap() an
|
| + ScriptState* scriptState, |
| + v8::Local<v8::Map>& map) |
| +{ |
| + CHECK(scriptState->world().isMainWorld()); |
| + v8::Local<v8::Object> wrapper = toV8(this, scriptState).As<v8::Object>(); |
| + v8::Isolate* isolate = scriptState->isolate(); |
| + v8::Local<v8::String> name = |
| + V8HiddenValue::customElementsRegistryMap(isolate); |
| + DCHECK(V8HiddenValue::getHiddenValue(scriptState, wrapper, name).IsEmpty()); |
| + map = v8::Map::New(isolate); |
| + V8HiddenValue::setHiddenValue(scriptState, wrapper, name, map); |
| +} |
| + |
| v8::Local<v8::Map> CustomElementsRegistry::idMap(ScriptState* scriptState) |
| { |
| - DCHECK(scriptState->world().isMainWorld()); |
| - v8::Local<v8::Object> wrapper = |
| - toV8(this, scriptState).As<v8::Object>(); |
| + CHECK(scriptState->world().isMainWorld()); |
| + v8::Local<v8::Object> wrapper = toV8(this, scriptState).As<v8::Object>(); |
| v8::Local<v8::String> name = V8HiddenValue::customElementsRegistryMap( |
| scriptState->isolate()); |
| - return V8HiddenValue::getHiddenValue(scriptState, wrapper, name) |
| - .As<v8::Map>(); |
| + v8::Local<v8::Value> mapValue = |
| + V8HiddenValue::getHiddenValue(scriptState, wrapper, name); |
| + v8::Local<v8::Map> map; |
| + if (!mapValue.IsEmpty()) |
| + map = mapValue.As<v8::Map>(); |
| + else |
| + initializeScript(scriptState, map); |
| + return map; |
| } |
| bool CustomElementsRegistry::idForConstructor( |