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

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

Issue 2054433002: Implement "create an element" when sync for Custom Element V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-ce
Patch Set: Fix building tests Created 4 years, 6 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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): We can't call HTMLElementFactory or
dominicc (has gone to gerrit) 2016/06/09 06:39:23 This is good!
59 definition->descriptor().localName(), 59 // Document::createElement because they will invoke custom element
60 AtomicString(), 60 // constructors. HTMLElement is enough for now, but type extesion
61 exceptionState); 61 // will require to hook HTMLElementFactory.
62 if (exceptionState.throwIfNeeded()) 62 element = HTMLElement::create(
63 return; 63 QualifiedName(nullAtom, definition->descriptor().localName(), HTMLNa mes::xhtmlNamespaceURI),
64 *window->document());
65 element->setCustomElementState(CustomElementState::Undefined);
64 } else { 66 } else {
65 element = definition->constructionStack().last(); 67 element = definition->constructionStack().last();
66 if (element) { 68 if (element) {
67 // This is an element being upgraded that has called super 69 // This is an element being upgraded that has called super
68 definition->constructionStack().last().clear(); 70 definition->constructionStack().last().clear();
69 } else { 71 } else {
70 // During upgrade an element has invoked the same constructor 72 // During upgrade an element has invoked the same constructor
71 // before calling 'super' and that invocation has poached the 73 // before calling 'super' and that invocation has poached the
72 // element. 74 // element.
73 exceptionState.throwDOMException( 75 exceptionState.throwDOMException(
(...skipping 10 matching lines...) Expand all
84 wrapperType, 86 wrapperType,
85 info.Holder()); 87 info.Holder());
86 // 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
87 // instead. 89 // instead.
88 v8SetReturnValue(info, wrapper); 90 v8SetReturnValue(info, wrapper);
89 91
90 v8CallOrCrash(wrapper->SetPrototype( 92 v8CallOrCrash(wrapper->SetPrototype(
91 scriptState->context(), 93 scriptState->context(),
92 definition->prototype())); 94 definition->prototype()));
93 95
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 96 // TODO(dominicc): Move this to the exactly correct place when
100 // https://github.com/whatwg/html/issues/1297 is closed. 97 // https://github.com/whatwg/html/issues/1297 is closed.
101 element->setCustomElementState(CustomElementState::Custom); 98 element->setCustomElementState(CustomElementState::Custom);
102 } 99 }
103 100
104 } // namespace blink 101 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698