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

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: patch update Created 4 years, 5 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 element->setCustomElementState(CustomElementState::Undefined); 64 element->setCustomElementState(CustomElementState::Undefined);
65 element->setCustomElementState(CustomElementState::Custom);
dominicc (has gone to gerrit) 2016/07/22 09:11:25 Could we put a TODO here to just write this as one
65 } else { 66 } else {
66 element = definition->constructionStack().last(); 67 element = definition->constructionStack().last();
67 if (element) { 68 if (element) {
68 // This is an element being upgraded that has called super 69 // This is an element being upgraded that has called super
69 definition->constructionStack().last().clear(); 70 definition->constructionStack().last().clear();
70 } else { 71 } else {
71 // During upgrade an element has invoked the same constructor 72 // During upgrade an element has invoked the same constructor
72 // before calling 'super' and that invocation has poached the 73 // before calling 'super' and that invocation has poached the
73 // element. 74 // element.
74 exceptionState.throwDOMException( 75 exceptionState.throwDOMException(
75 InvalidStateError, 76 InvalidStateError,
76 "this instance is already constructed"); 77 "this instance is already constructed");
77 exceptionState.throwIfNeeded(); 78 exceptionState.throwIfNeeded();
78 return; 79 return;
79 } 80 }
80 } 81 }
81 const WrapperTypeInfo* wrapperType = element->wrapperTypeInfo(); 82 const WrapperTypeInfo* wrapperType = element->wrapperTypeInfo();
82 v8::Local<v8::Object> wrapper = V8DOMWrapper::associateObjectWithWrapper( 83 v8::Local<v8::Object> wrapper = V8DOMWrapper::associateObjectWithWrapper(
83 isolate, 84 isolate,
84 element, 85 element,
85 wrapperType, 86 wrapperType,
86 info.Holder()); 87 info.Holder());
87 // If the element had a wrapper, we now update and return that 88 // If the element had a wrapper, we now update and return that
88 // instead. 89 // instead.
89 v8SetReturnValue(info, wrapper); 90 v8SetReturnValue(info, wrapper);
90 91
91 v8CallOrCrash(wrapper->SetPrototype( 92 v8CallOrCrash(wrapper->SetPrototype(
92 scriptState->context(), 93 scriptState->context(),
93 definition->prototype())); 94 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 } 95 }
99 96
100 } // namespace blink 97 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698