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

Side by Side Diff: sky/engine/bindings/core/v8/CustomElementConstructorBuilder.cpp

Issue 831993005: Remove custom element type extensions. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | sky/engine/bindings/core/v8/V8HiddenValue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 164 }
165 165
166 bool CustomElementConstructorBuilder::createConstructor(Document* document, Cust omElementDefinition* definition, ExceptionState& exceptionState) 166 bool CustomElementConstructorBuilder::createConstructor(Document* document, Cust omElementDefinition* definition, ExceptionState& exceptionState)
167 { 167 {
168 ASSERT(!m_prototype.IsEmpty()); 168 ASSERT(!m_prototype.IsEmpty());
169 ASSERT(m_constructor.IsEmpty()); 169 ASSERT(m_constructor.IsEmpty());
170 ASSERT(document); 170 ASSERT(document);
171 171
172 v8::Isolate* isolate = m_scriptState->isolate(); 172 v8::Isolate* isolate = m_scriptState->isolate();
173 173
174 if (!prototypeIsValid(definition->descriptor().type(), exceptionState)) 174 if (!prototypeIsValid(definition->descriptor().localName(), exceptionState))
175 return false; 175 return false;
176 176
177 v8::Local<v8::FunctionTemplate> constructorTemplate = v8::FunctionTemplate:: New(isolate); 177 v8::Local<v8::FunctionTemplate> constructorTemplate = v8::FunctionTemplate:: New(isolate);
178 constructorTemplate->SetCallHandler(constructCustomElement); 178 constructorTemplate->SetCallHandler(constructCustomElement);
179 m_constructor = constructorTemplate->GetFunction(); 179 m_constructor = constructorTemplate->GetFunction();
180 if (m_constructor.IsEmpty()) { 180 if (m_constructor.IsEmpty()) {
181 CustomElementException::throwException(CustomElementException::ContextDe stroyedRegisteringDefinition, definition->descriptor().type(), exceptionState); 181 CustomElementException::throwException(CustomElementException::ContextDe stroyedRegisteringDefinition, definition->descriptor().localName(), exceptionSta te);
182 return false; 182 return false;
183 } 183 }
184 184
185 const CustomElementDescriptor& descriptor = definition->descriptor(); 185 const CustomElementDescriptor& descriptor = definition->descriptor();
186 186
187 v8::Handle<v8::String> v8TagName = v8String(isolate, descriptor.localName()) ; 187 v8::Handle<v8::String> v8TagName = v8String(isolate, descriptor.localName()) ;
188 v8::Handle<v8::Value> v8Type;
189 if (descriptor.isTypeExtension())
190 v8Type = v8String(isolate, descriptor.type());
191 else
192 v8Type = v8::Null(isolate);
193 188
194 m_constructor->SetName(v8Type->IsNull() ? v8TagName : v8Type.As<v8::String>( )); 189 m_constructor->SetName(v8TagName);
195 190
196 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementDocument(isolate), toV8(document, m_scriptState->context()->Global(), isol ate)); 191 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementDocument(isolate), toV8(document, m_scriptState->context()->Global(), isol ate));
197 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementTagName(isolate), v8TagName); 192 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementTagName(isolate), v8TagName);
198 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementType(isolate), v8Type);
199 193
200 v8::Handle<v8::String> prototypeKey = v8String(isolate, "prototype"); 194 v8::Handle<v8::String> prototypeKey = v8String(isolate, "prototype");
201 v8::Handle<v8::String> constructorKey = v8String(isolate, "constructor"); 195 v8::Handle<v8::String> constructorKey = v8String(isolate, "constructor");
202 196
203 ASSERT(m_constructor->HasOwnProperty(prototypeKey)); 197 ASSERT(m_constructor->HasOwnProperty(prototypeKey));
204 // This sets the property *value*; calling Set is safe because 198 // This sets the property *value*; calling Set is safe because
205 // "prototype" is a non-configurable data property so there can be 199 // "prototype" is a non-configurable data property so there can be
206 // no side effects. 200 // no side effects.
207 m_constructor->Set(prototypeKey, m_prototype); 201 m_constructor->Set(prototypeKey, m_prototype);
208 // This *configures* the property. ForceSet of a function's 202 // This *configures* the property. ForceSet of a function's
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 return; 264 return;
271 } 265 }
272 266
273 if (info.Length() > 0) { 267 if (info.Length() > 0) {
274 V8ThrowException::throwTypeError("This constructor should be called with out arguments.", isolate); 268 V8ThrowException::throwTypeError("This constructor should be called with out arguments.", isolate);
275 return; 269 return;
276 } 270 }
277 271
278 Document* document = V8Document::toNative(V8HiddenValue::getHiddenValue(info .GetIsolate(), info.Callee(), V8HiddenValue::customElementDocument(isolate)).As< v8::Object>()); 272 Document* document = V8Document::toNative(V8HiddenValue::getHiddenValue(info .GetIsolate(), info.Callee(), V8HiddenValue::customElementDocument(isolate)).As< v8::Object>());
279 TOSTRING_VOID(V8StringResource<>, tagName, V8HiddenValue::getHiddenValue(iso late, info.Callee(), V8HiddenValue::customElementTagName(isolate))); 273 TOSTRING_VOID(V8StringResource<>, tagName, V8HiddenValue::getHiddenValue(iso late, info.Callee(), V8HiddenValue::customElementTagName(isolate)));
280 v8::Handle<v8::Value> maybeType = V8HiddenValue::getHiddenValue(info.GetIsol ate(), info.Callee(), V8HiddenValue::customElementType(isolate));
281 TOSTRING_VOID(V8StringResource<>, type, maybeType);
282 274
283 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl ement", info.Holder(), info.GetIsolate()); 275 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl ement", info.Holder(), info.GetIsolate());
284 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; 276 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
285 RefPtr<Element> element = document->createElement(tagName, maybeType->IsNull () ? nullAtom : type, exceptionState); 277 RefPtr<Element> element = document->createElement(tagName, exceptionState);
286 if (exceptionState.throwIfNeeded()) 278 if (exceptionState.throwIfNeeded())
287 return; 279 return;
288 v8SetReturnValueFast(info, element.release(), document); 280 v8SetReturnValueFast(info, element.release(), document);
289 } 281 }
290 282
291 } // namespace blink 283 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/engine/bindings/core/v8/V8HiddenValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698