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

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

Issue 1685543002: Supports "class string" based on @@toStringTag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synced. Created 4 years, 10 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 v8::Local<v8::Signature> V8DOMConfiguration::installDOMClassTemplate(v8::Isolate * isolate, v8::Local<v8::FunctionTemplate> functionDescriptor, const char* inter faceName, v8::Local<v8::FunctionTemplate> parentClass, size_t fieldCount, 307 v8::Local<v8::Signature> V8DOMConfiguration::installDOMClassTemplate(v8::Isolate * isolate, v8::Local<v8::FunctionTemplate> functionDescriptor, const char* inter faceName, v8::Local<v8::FunctionTemplate> parentClass, size_t fieldCount,
308 const AttributeConfiguration* attributes, size_t attributeCount, 308 const AttributeConfiguration* attributes, size_t attributeCount,
309 const AccessorConfiguration* accessors, size_t accessorCount, 309 const AccessorConfiguration* accessors, size_t accessorCount,
310 const MethodConfiguration* methods, size_t methodCount) 310 const MethodConfiguration* methods, size_t methodCount)
311 { 311 {
312 functionDescriptor->SetClassName(v8AtomicString(isolate, interfaceName)); 312 functionDescriptor->SetClassName(v8AtomicString(isolate, interfaceName));
313 v8::Local<v8::ObjectTemplate> instanceTemplate = functionDescriptor->Instanc eTemplate(); 313 v8::Local<v8::ObjectTemplate> instanceTemplate = functionDescriptor->Instanc eTemplate();
314 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionDescriptor->Protot ypeTemplate(); 314 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionDescriptor->Protot ypeTemplate();
315 instanceTemplate->SetInternalFieldCount(fieldCount); 315 instanceTemplate->SetInternalFieldCount(fieldCount);
316 // TODO(yukishiino): We should set the class string to the platform object
317 // (|instanceTemplate|), too. The reason that we don't set it is that
adamk 2016/02/12 18:31:33 Can you say more about exactly what this patch doe
318 // it prevents minor GC to collect unreachable DOM objects (a layout test
319 // fast/dom/minor-dom-gc.html fails if we set the class string).
320 // See also http://heycam.github.io/webidl/#es-platform-objects
caitp (gmail) 2016/02/12 14:44:46 Has there been more discussion about this since ht
321 setClassString(isolate, prototypeTemplate, interfaceName);
316 if (!parentClass.IsEmpty()) { 322 if (!parentClass.IsEmpty()) {
317 functionDescriptor->Inherit(parentClass); 323 functionDescriptor->Inherit(parentClass);
318 // Marks the prototype object as one of native-backed objects. 324 // Marks the prototype object as one of native-backed objects.
319 // This is needed since bug 110436 asks WebKit to tell native-initiated prototypes from pure-JS ones. 325 // This is needed since bug 110436 asks WebKit to tell native-initiated prototypes from pure-JS ones.
320 // This doesn't mark kinds "root" classes like Node, where setting this changes prototype chain structure. 326 // This doesn't mark kinds "root" classes like Node, where setting this changes prototype chain structure.
321 prototypeTemplate->SetInternalFieldCount(v8PrototypeInternalFieldcount); 327 prototypeTemplate->SetInternalFieldCount(v8PrototypeInternalFieldcount);
322 } 328 }
323 329
324 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, func tionDescriptor); 330 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, func tionDescriptor);
325 if (attributeCount) 331 if (attributeCount)
(...skipping 12 matching lines...) Expand all
338 if (!result.IsEmpty()) 344 if (!result.IsEmpty())
339 return result; 345 return result;
340 346
341 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); 347 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
342 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons tructorMode); 348 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons tructorMode);
343 configureDOMClassTemplate(result, isolate); 349 configureDOMClassTemplate(result, isolate);
344 data->setDOMTemplate(wrapperTypeInfo, result); 350 data->setDOMTemplate(wrapperTypeInfo, result);
345 return result; 351 return result;
346 } 352 }
347 353
354 void V8DOMConfiguration::setClassString(v8::Isolate* isolate, v8::Local<v8::Obje ctTemplate> objectTemplate, const char* classString)
355 {
356 objectTemplate->Set(v8::Symbol::GetToStringTag(isolate), v8AtomicString(isol ate, classString), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnu m));
357 }
358
348 } // namespace blink 359 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698