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

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

Issue 2831943002: bindings: Port bindings/core/v8 away from ToImplArray APIs. (Closed)
Patch Set: Check for exception in SerializedScriptValue Created 3 years, 8 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/ScriptCustomElementDefinitionBuilder.h" 5 #include "bindings/core/v8/ScriptCustomElementDefinitionBuilder.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/IDLTypes.h"
10 #include "bindings/core/v8/NativeValueTraitsImpl.h"
9 #include "bindings/core/v8/ScriptCustomElementDefinition.h" 11 #include "bindings/core/v8/ScriptCustomElementDefinition.h"
10 #include "bindings/core/v8/ScriptState.h" 12 #include "bindings/core/v8/ScriptState.h"
11 #include "bindings/core/v8/ScriptValue.h" 13 #include "bindings/core/v8/ScriptValue.h"
12 #include "bindings/core/v8/V8Binding.h" 14 #include "bindings/core/v8/V8Binding.h"
13 #include "bindings/core/v8/V8BindingMacros.h" 15 #include "bindings/core/v8/V8BindingMacros.h"
14 #include "core/dom/ExceptionCode.h" 16 #include "core/dom/ExceptionCode.h"
15 17
16 namespace blink { 18 namespace blink {
17 19
18 ScriptCustomElementDefinitionBuilder* 20 ScriptCustomElementDefinitionBuilder*
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return true; 123 return true;
122 } 124 }
123 125
124 bool ScriptCustomElementDefinitionBuilder::RetrieveObservedAttributes() { 126 bool ScriptCustomElementDefinitionBuilder::RetrieveObservedAttributes() {
125 v8::Local<v8::Value> observed_attributes_value; 127 v8::Local<v8::Value> observed_attributes_value;
126 if (!ValueForName(constructor_, "observedAttributes", 128 if (!ValueForName(constructor_, "observedAttributes",
127 observed_attributes_value)) 129 observed_attributes_value))
128 return false; 130 return false;
129 if (observed_attributes_value->IsUndefined()) 131 if (observed_attributes_value->IsUndefined())
130 return true; 132 return true;
131 Vector<AtomicString> list = ToImplSequence<Vector<AtomicString>>( 133 Vector<String> list = NativeValueTraits<IDLSequence<IDLString>>::NativeValue(
132 script_state_->GetIsolate(), observed_attributes_value, exception_state_); 134 script_state_->GetIsolate(), observed_attributes_value, exception_state_);
133 if (exception_state_.HadException()) 135 if (exception_state_.HadException())
134 return false; 136 return false;
135 if (list.IsEmpty()) 137 if (list.IsEmpty())
136 return true; 138 return true;
137 observed_attributes_.ReserveCapacityForSize(list.size()); 139 observed_attributes_.ReserveCapacityForSize(list.size());
138 for (const auto& attribute : list) 140 for (const auto& attribute : list)
139 observed_attributes_.insert(attribute); 141 observed_attributes_.insert(AtomicString(attribute));
140 return true; 142 return true;
141 } 143 }
142 144
143 bool ScriptCustomElementDefinitionBuilder::RememberOriginalProperties() { 145 bool ScriptCustomElementDefinitionBuilder::RememberOriginalProperties() {
144 // Spec requires to use values of these properties at the point 146 // Spec requires to use values of these properties at the point
145 // CustomElementDefinition is built, even if JS changes them afterwards. 147 // CustomElementDefinition is built, even if JS changes them afterwards.
146 return CallableForName("connectedCallback", connected_callback_) && 148 return CallableForName("connectedCallback", connected_callback_) &&
147 CallableForName("disconnectedCallback", disconnected_callback_) && 149 CallableForName("disconnectedCallback", disconnected_callback_) &&
148 CallableForName("adoptedCallback", adopted_callback_) && 150 CallableForName("adoptedCallback", adopted_callback_) &&
149 CallableForName("attributeChangedCallback", 151 CallableForName("attributeChangedCallback",
150 attribute_changed_callback_) && 152 attribute_changed_callback_) &&
151 (attribute_changed_callback_.IsEmpty() || 153 (attribute_changed_callback_.IsEmpty() ||
152 RetrieveObservedAttributes()); 154 RetrieveObservedAttributes());
153 } 155 }
154 156
155 CustomElementDefinition* ScriptCustomElementDefinitionBuilder::Build( 157 CustomElementDefinition* ScriptCustomElementDefinitionBuilder::Build(
156 const CustomElementDescriptor& descriptor) { 158 const CustomElementDescriptor& descriptor) {
157 return ScriptCustomElementDefinition::Create( 159 return ScriptCustomElementDefinition::Create(
158 script_state_.Get(), registry_, descriptor, constructor_, 160 script_state_.Get(), registry_, descriptor, constructor_,
159 connected_callback_, disconnected_callback_, adopted_callback_, 161 connected_callback_, disconnected_callback_, adopted_callback_,
160 attribute_changed_callback_, observed_attributes_); 162 attribute_changed_callback_, observed_attributes_);
161 } 163 }
162 164
163 } // namespace blink 165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698