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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLElementCustom.cpp

Issue 2279703002: Add a scoped context object for synchronous CE creation (Closed)
Patch Set: Clean up Created 4 years, 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "bindings/core/v8/V8HTMLElement.h" 5 #include "bindings/core/v8/V8HTMLElement.h"
6 6
7 #include "bindings/core/v8/DOMWrapperWorld.h" 7 #include "bindings/core/v8/DOMWrapperWorld.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptCustomElementDefinition.h" 9 #include "bindings/core/v8/ScriptCustomElementDefinition.h"
10 #include "bindings/core/v8/V8Binding.h" 10 #include "bindings/core/v8/V8Binding.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 "HTMLElement", 52 "HTMLElement",
53 info.Holder(), 53 info.Holder(),
54 isolate); 54 isolate);
55 55
56 Element* element; 56 Element* element;
57 if (definition->constructionStack().isEmpty()) { 57 if (definition->constructionStack().isEmpty()) {
58 // This is an element being created with 'new' from script 58 // This is an element being created with 'new' from script
59 // TODO(kojii): When HTMLElementFactory has an option not to queue 59 // TODO(kojii): When HTMLElementFactory has an option not to queue
60 // upgrade, call that instead of HTMLElement. HTMLElement is enough 60 // upgrade, call that instead of HTMLElement. HTMLElement is enough
61 // for now, but type extension will require HTMLElementFactory. 61 // for now, but type extension will require HTMLElementFactory.
62 Document* context = window->customElementCreationContext();
63 if (!context)
64 context = window->document();
65
62 element = HTMLElement::create( 66 element = HTMLElement::create(
63 QualifiedName(nullAtom, definition->descriptor().localName(), HTMLNa mes::xhtmlNamespaceURI), 67 QualifiedName(nullAtom, definition->descriptor().localName(), HTMLNa mes::xhtmlNamespaceURI),
64 *window->document()); 68 *context);
65 // TODO(davaajav): write this as one call to setCustomElementState inste ad of two 69 // TODO(davaajav): write this as one call to setCustomElementState inste ad of two
66 element->setCustomElementState(CustomElementState::Undefined); 70 element->setCustomElementState(CustomElementState::Undefined);
67 element->setCustomElementDefinition(definition); 71 element->setCustomElementDefinition(definition);
68 } else { 72 } else {
69 element = definition->constructionStack().last(); 73 element = definition->constructionStack().last();
70 if (element) { 74 if (element) {
71 // This is an element being upgraded that has called super 75 // This is an element being upgraded that has called super
72 definition->constructionStack().last().clear(); 76 definition->constructionStack().last().clear();
73 } else { 77 } else {
74 // During upgrade an element has invoked the same constructor 78 // During upgrade an element has invoked the same constructor
(...skipping 13 matching lines...) Expand all
88 wrapperType, 92 wrapperType,
89 info.Holder()); 93 info.Holder());
90 // If the element had a wrapper, we now update and return that 94 // If the element had a wrapper, we now update and return that
91 // instead. 95 // instead.
92 v8SetReturnValue(info, wrapper); 96 v8SetReturnValue(info, wrapper);
93 97
94 wrapper->SetPrototype(scriptState->context(), definition->prototype()).ToChe cked(); 98 wrapper->SetPrototype(scriptState->context(), definition->prototype()).ToChe cked();
95 } 99 }
96 100
97 } // namespace blink 101 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698