OLD | NEW |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 ExceptionState exceptionState( | 49 ExceptionState exceptionState( |
50 ExceptionState::ConstructionContext, | 50 ExceptionState::ConstructionContext, |
51 "HTMLElement", | 51 "HTMLElement", |
52 info.Holder(), | 52 info.Holder(), |
53 isolate); | 53 isolate); |
54 | 54 |
55 Element* element; | 55 Element* element; |
56 if (definition->constructionStack().isEmpty()) { | 56 if (definition->constructionStack().isEmpty()) { |
57 // This is an element being created with 'new' from script | 57 // This is an element being created with 'new' from script |
58 element = window->document()->createElement( | 58 // TODO(kojii): When HTMLElementFactory has an option not to queue |
59 definition->descriptor().localName(), | 59 // upgrade, call that instead of HTMLElement. HTMLElement is enough |
60 AtomicString(), | 60 // for now, but type extension will require HTMLElementFactory. |
61 exceptionState); | 61 element = HTMLElement::create( |
62 if (exceptionState.throwIfNeeded()) | 62 QualifiedName(nullAtom, definition->descriptor().localName(), HTMLNa
mes::xhtmlNamespaceURI), |
63 return; | 63 *window->document()); |
| 64 element->setCustomElementState(CustomElementState::Undefined); |
64 } else { | 65 } else { |
65 element = definition->constructionStack().last(); | 66 element = definition->constructionStack().last(); |
66 if (element) { | 67 if (element) { |
67 // This is an element being upgraded that has called super | 68 // This is an element being upgraded that has called super |
68 definition->constructionStack().last().clear(); | 69 definition->constructionStack().last().clear(); |
69 } else { | 70 } else { |
70 // During upgrade an element has invoked the same constructor | 71 // During upgrade an element has invoked the same constructor |
71 // before calling 'super' and that invocation has poached the | 72 // before calling 'super' and that invocation has poached the |
72 // element. | 73 // element. |
73 exceptionState.throwDOMException( | 74 exceptionState.throwDOMException( |
(...skipping 10 matching lines...) Expand all Loading... |
84 wrapperType, | 85 wrapperType, |
85 info.Holder()); | 86 info.Holder()); |
86 // If the element had a wrapper, we now update and return that | 87 // If the element had a wrapper, we now update and return that |
87 // instead. | 88 // instead. |
88 v8SetReturnValue(info, wrapper); | 89 v8SetReturnValue(info, wrapper); |
89 | 90 |
90 v8CallOrCrash(wrapper->SetPrototype( | 91 v8CallOrCrash(wrapper->SetPrototype( |
91 scriptState->context(), | 92 scriptState->context(), |
92 definition->prototype())); | 93 definition->prototype())); |
93 | 94 |
94 // TODO(dominicc): These elements should be 'undefined', not | |
95 // 'uncustomized', on creation. Investigate why some elements are | |
96 // running around uncustomized. | |
97 if (element->getCustomElementState() == CustomElementState::Uncustomized) | |
98 element->setCustomElementState(CustomElementState::Undefined); | |
99 // TODO(dominicc): Move this to the exactly correct place when | 95 // TODO(dominicc): Move this to the exactly correct place when |
100 // https://github.com/whatwg/html/issues/1297 is closed. | 96 // https://github.com/whatwg/html/issues/1297 is closed. |
101 element->setCustomElementState(CustomElementState::Custom); | 97 element->setCustomElementState(CustomElementState::Custom); |
102 } | 98 } |
103 | 99 |
104 } // namespace blink | 100 } // namespace blink |
OLD | NEW |