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

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

Issue 1153613007: bindings: Use CreateDataProperty() instead of ForceSet() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix uninitialized error Created 5 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
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptValueSerializer.cpp » ('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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (!v8CallBoolean(m_constructor->HasOwnProperty(context, prototypeKey))) 189 if (!v8CallBoolean(m_constructor->HasOwnProperty(context, prototypeKey)))
190 return false; 190 return false;
191 // This sets the property *value*; calling Set is safe because 191 // This sets the property *value*; calling Set is safe because
192 // "prototype" is a non-configurable data property so there can be 192 // "prototype" is a non-configurable data property so there can be
193 // no side effects. 193 // no side effects.
194 if (!v8CallBoolean(m_constructor->Set(context, prototypeKey, m_prototype))) 194 if (!v8CallBoolean(m_constructor->Set(context, prototypeKey, m_prototype)))
195 return false; 195 return false;
196 // This *configures* the property. ForceSet of a function's 196 // This *configures* the property. DefineOwnProperty of a function's
197 // "prototype" does not affect the value, but can reconfigure the 197 // "prototype" does not affect the value, but can reconfigure the
198 // property. 198 // property.
199 if (!v8CallBoolean(m_constructor->ForceSet(context, prototypeKey, m_prototyp e, v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum | v8::DontDelete)))) 199 if (!v8CallBoolean(m_constructor->DefineOwnProperty(context, prototypeKey, m _prototype, v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum | v8::DontDelete)) ))
200 return false; 200 return false;
201 201
202 v8::Local<v8::String> constructorKey = v8String(isolate, "constructor"); 202 v8::Local<v8::String> constructorKey = v8String(isolate, "constructor");
203 v8::Local<v8::Value> constructorPrototype; 203 v8::Local<v8::Value> constructorPrototype;
204 if (!m_prototype->Get(context, constructorKey).ToLocal(&constructorPrototype )) 204 if (!m_prototype->Get(context, constructorKey).ToLocal(&constructorPrototype ))
205 return false; 205 return false;
206 206
207 if (!v8CallBoolean(m_constructor->SetPrototype(context, constructorPrototype ))) 207 if (!v8CallBoolean(m_constructor->SetPrototype(context, constructorPrototype )))
208 return false; 208 return false;
209 209
210 V8HiddenValue::setHiddenValue(isolate, m_prototype, V8HiddenValue::customEle mentIsInterfacePrototypeObject(isolate), v8::True(isolate)); 210 V8HiddenValue::setHiddenValue(isolate, m_prototype, V8HiddenValue::customEle mentIsInterfacePrototypeObject(isolate), v8::True(isolate));
211 if (!v8CallBoolean(m_prototype->ForceSet(context, v8String(isolate, "constru ctor"), m_constructor, v8::DontEnum))) 211 if (!v8CallBoolean(m_prototype->DefineOwnProperty(context, v8String(isolate, "constructor"), m_constructor, v8::DontEnum)))
212 return false; 212 return false;
213 213
214 return true; 214 return true;
215 } 215 }
216 216
217 bool CustomElementConstructorBuilder::prototypeIsValid(const AtomicString& type, ExceptionState& exceptionState) const 217 bool CustomElementConstructorBuilder::prototypeIsValid(const AtomicString& type, ExceptionState& exceptionState) const
218 { 218 {
219 if (m_prototype->InternalFieldCount() || !V8HiddenValue::getHiddenValue(m_sc riptState->isolate(), m_prototype, V8HiddenValue::customElementIsInterfaceProtot ypeObject(m_scriptState->isolate())).IsEmpty()) { 219 if (m_prototype->InternalFieldCount() || !V8HiddenValue::getHiddenValue(m_sc riptState->isolate(), m_prototype, V8HiddenValue::customElementIsInterfaceProtot ypeObject(m_scriptState->isolate())).IsEmpty()) {
220 CustomElementException::throwException(CustomElementException::Prototype InUse, type, exceptionState); 220 CustomElementException::throwException(CustomElementException::Prototype InUse, type, exceptionState);
221 return false; 221 return false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 280
281 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl ement", info.Holder(), info.GetIsolate()); 281 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl ement", info.Holder(), info.GetIsolate());
282 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; 282 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
283 RefPtrWillBeRawPtr<Element> element = document->createElementNS(namespaceURI , tagName, maybeType->IsNull() ? nullAtom : type, exceptionState); 283 RefPtrWillBeRawPtr<Element> element = document->createElementNS(namespaceURI , tagName, maybeType->IsNull() ? nullAtom : type, exceptionState);
284 if (exceptionState.throwIfNeeded()) 284 if (exceptionState.throwIfNeeded())
285 return; 285 return;
286 v8SetReturnValueFast(info, element.release(), document); 286 v8SetReturnValueFast(info, element.release(), document);
287 } 287 }
288 288
289 } // namespace blink 289 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptValueSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698