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

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

Issue 2161003002: CustomElements: upgrade element patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@upgrade-element
Patch Set: RegistryTest update, removed setting element`s state to custom in the test 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // TODO(kojii): When HTMLElementFactory has an option not to queue 58 // TODO(kojii): When HTMLElementFactory has an option not to queue
59 // upgrade, call that instead of HTMLElement. HTMLElement is enough 59 // upgrade, call that instead of HTMLElement. HTMLElement is enough
60 // for now, but type extension will require HTMLElementFactory. 60 // for now, but type extension will require HTMLElementFactory.
61 element = HTMLElement::create( 61 element = HTMLElement::create(
62 QualifiedName(nullAtom, definition->descriptor().localName(), HTMLNa mes::xhtmlNamespaceURI), 62 QualifiedName(nullAtom, definition->descriptor().localName(), HTMLNa mes::xhtmlNamespaceURI),
63 *window->document()); 63 *window->document());
64 // TODO(davaajav): write this as one call to setCustomElementState inste ad of two
64 element->setCustomElementState(CustomElementState::Undefined); 65 element->setCustomElementState(CustomElementState::Undefined);
66 element->setCustomElementState(CustomElementState::Custom);
65 } else { 67 } else {
66 element = definition->constructionStack().last(); 68 element = definition->constructionStack().last();
67 if (element) { 69 if (element) {
68 // This is an element being upgraded that has called super 70 // This is an element being upgraded that has called super
69 definition->constructionStack().last().clear(); 71 definition->constructionStack().last().clear();
70 } else { 72 } else {
71 // During upgrade an element has invoked the same constructor 73 // During upgrade an element has invoked the same constructor
72 // before calling 'super' and that invocation has poached the 74 // before calling 'super' and that invocation has poached the
73 // element. 75 // element.
74 exceptionState.throwDOMException( 76 exceptionState.throwDOMException(
75 InvalidStateError, 77 InvalidStateError,
76 "this instance is already constructed"); 78 "this instance is already constructed");
77 exceptionState.throwIfNeeded(); 79 exceptionState.throwIfNeeded();
78 return; 80 return;
79 } 81 }
80 } 82 }
81 const WrapperTypeInfo* wrapperType = element->wrapperTypeInfo(); 83 const WrapperTypeInfo* wrapperType = element->wrapperTypeInfo();
82 v8::Local<v8::Object> wrapper = V8DOMWrapper::associateObjectWithWrapper( 84 v8::Local<v8::Object> wrapper = V8DOMWrapper::associateObjectWithWrapper(
83 isolate, 85 isolate,
84 element, 86 element,
85 wrapperType, 87 wrapperType,
86 info.Holder()); 88 info.Holder());
87 // If the element had a wrapper, we now update and return that 89 // If the element had a wrapper, we now update and return that
88 // instead. 90 // instead.
89 v8SetReturnValue(info, wrapper); 91 v8SetReturnValue(info, wrapper);
90 92
91 v8CallOrCrash(wrapper->SetPrototype( 93 v8CallOrCrash(wrapper->SetPrototype(
92 scriptState->context(), 94 scriptState->context(),
93 definition->prototype())); 95 definition->prototype()));
94
95 // TODO(dominicc): Move this to the exactly correct place when
96 // https://github.com/whatwg/html/issues/1297 is closed.
97 element->setCustomElementState(CustomElementState::Custom);
98 } 96 }
99 97
100 } // namespace blink 98 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698