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

Side by Side Diff: Source/bindings/core/v8/CustomElementConstructorBuilder.cpp

Issue 1069953002: Implement Custom Element's class side inheritance (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 /* 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 v8Type = v8::Null(isolate); 179 v8Type = v8::Null(isolate);
180 180
181 m_constructor->SetName(v8Type->IsNull() ? v8TagName : v8Type.As<v8::String>( )); 181 m_constructor->SetName(v8Type->IsNull() ? v8TagName : v8Type.As<v8::String>( ));
182 182
183 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementDocument(isolate), toV8(document, context->Global(), isolate)); 183 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementDocument(isolate), toV8(document, context->Global(), isolate));
184 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementNamespaceURI(isolate), v8String(isolate, descriptor.namespaceURI())); 184 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementNamespaceURI(isolate), v8String(isolate, descriptor.namespaceURI()));
185 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementTagName(isolate), v8TagName); 185 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementTagName(isolate), v8TagName);
186 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementType(isolate), v8Type); 186 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE lementType(isolate), v8Type);
187 187
188 v8::Local<v8::String> prototypeKey = v8String(isolate, "prototype"); 188 v8::Local<v8::String> prototypeKey = v8String(isolate, "prototype");
189 v8::Local<v8::String> constructorKey = v8String(isolate, "constructor");
dominicc (has gone to gerrit) 2015/04/09 06:37:57 Move this down near to where it is used.
deepak.s 2015/04/15 06:44:53 Done.
190
189 if (!v8CallBoolean(m_constructor->HasOwnProperty(context, prototypeKey))) 191 if (!v8CallBoolean(m_constructor->HasOwnProperty(context, prototypeKey)))
190 return false; 192 return false;
191 // This sets the property *value*; calling Set is safe because 193 // This sets the property *value*; calling Set is safe because
192 // "prototype" is a non-configurable data property so there can be 194 // "prototype" is a non-configurable data property so there can be
193 // no side effects. 195 // no side effects.
194 if (!v8CallBoolean(m_constructor->Set(context, prototypeKey, m_prototype))) 196 if (!v8CallBoolean(m_constructor->Set(context, prototypeKey, m_prototype)))
195 return false; 197 return false;
196 // This *configures* the property. ForceSet of a function's 198 // This *configures* the property. ForceSet of a function's
197 // "prototype" does not affect the value, but can reconfigure the 199 // "prototype" does not affect the value, but can reconfigure the
198 // property. 200 // property.
199 if (!v8CallBoolean(m_constructor->ForceSet(context, prototypeKey, m_prototyp e, v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum | v8::DontDelete)))) 201 if (!v8CallBoolean(m_constructor->ForceSet(context, prototypeKey, m_prototyp e, v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum | v8::DontDelete))))
200 return false; 202 return false;
203 // The generated constructor should inherit from constructor.
204 if (!v8CallBoolean(m_constructor->SetPrototype(context, m_prototype->Get(con structorKey))))
dominicc (has gone to gerrit) 2015/04/09 06:37:57 FYI It looks like the bool SetPrototype is depreca
205 return false;
201 206
202 V8HiddenValue::setHiddenValue(isolate, m_prototype, V8HiddenValue::customEle mentIsInterfacePrototypeObject(isolate), v8::True(isolate)); 207 V8HiddenValue::setHiddenValue(isolate, m_prototype, V8HiddenValue::customEle mentIsInterfacePrototypeObject(isolate), v8::True(isolate));
203 if (!v8CallBoolean(m_prototype->ForceSet(context, v8String(isolate, "constru ctor"), m_constructor, v8::DontEnum))) 208 if (!v8CallBoolean(m_prototype->ForceSet(context, constructorKey, m_construc tor, v8::DontEnum)))
204 return false; 209 return false;
205 210
206 return true; 211 return true;
207 } 212 }
208 213
209 bool CustomElementConstructorBuilder::prototypeIsValid(const AtomicString& type, ExceptionState& exceptionState) const 214 bool CustomElementConstructorBuilder::prototypeIsValid(const AtomicString& type, ExceptionState& exceptionState) const
210 { 215 {
211 if (m_prototype->InternalFieldCount() || !V8HiddenValue::getHiddenValue(m_sc riptState->isolate(), m_prototype, V8HiddenValue::customElementIsInterfaceProtot ypeObject(m_scriptState->isolate())).IsEmpty()) { 216 if (m_prototype->InternalFieldCount() || !V8HiddenValue::getHiddenValue(m_sc riptState->isolate(), m_prototype, V8HiddenValue::customElementIsInterfaceProtot ypeObject(m_scriptState->isolate())).IsEmpty()) {
212 CustomElementException::throwException(CustomElementException::Prototype InUse, type, exceptionState); 217 CustomElementException::throwException(CustomElementException::Prototype InUse, type, exceptionState);
213 return false; 218 return false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 277
273 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl ement", info.Holder(), info.GetIsolate()); 278 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl ement", info.Holder(), info.GetIsolate());
274 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; 279 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
275 RefPtrWillBeRawPtr<Element> element = document->createElementNS(namespaceURI , tagName, maybeType->IsNull() ? nullAtom : type, exceptionState); 280 RefPtrWillBeRawPtr<Element> element = document->createElementNS(namespaceURI , tagName, maybeType->IsNull() ? nullAtom : type, exceptionState);
276 if (exceptionState.throwIfNeeded()) 281 if (exceptionState.throwIfNeeded())
277 return; 282 return;
278 v8SetReturnValueFast(info, element.release(), document); 283 v8SetReturnValueFast(info, element.release(), document);
279 } 284 }
280 285
281 } // namespace blink 286 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698