Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 15 matching lines...) Expand all Loading... | |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "bindings/core/v8/V8DOMConfiguration.h" | 29 #include "bindings/core/v8/V8DOMConfiguration.h" |
| 30 | 30 |
| 31 #include "bindings/core/v8/GeneratedCodeHelper.h" // just for DCHECK | 31 #include "bindings/core/v8/GeneratedCodeHelper.h" // just for DCHECK |
| 32 #include "bindings/core/v8/V8ObjectConstructor.h" | 32 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 33 #include "bindings/core/v8/V8PerContextData.h" | 33 #include "bindings/core/v8/V8PerContextData.h" |
| 34 #include "platform/instrumentation/tracing/TraceEvent.h" | 34 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 35 | 35 |
| 36 #include <string> | |
| 37 | |
| 36 namespace blink { | 38 namespace blink { |
| 37 | 39 |
| 38 namespace { | 40 namespace { |
| 39 | 41 |
| 40 void installAttributeInternal( | 42 void installAttributeInternal( |
| 41 v8::Isolate* isolate, | 43 v8::Isolate* isolate, |
| 42 v8::Local<v8::ObjectTemplate> instanceTemplate, | 44 v8::Local<v8::ObjectTemplate> instanceTemplate, |
| 43 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 45 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
| 44 const V8DOMConfiguration::AttributeConfiguration& attribute, | 46 const V8DOMConfiguration::AttributeConfiguration& attribute, |
| 45 const DOMWrapperWorld& world) { | 47 const DOMWrapperWorld& world) { |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 608 v8::Local<v8::FunctionTemplate> interfaceTemplate, | 610 v8::Local<v8::FunctionTemplate> interfaceTemplate, |
| 609 const char* interfaceName, | 611 const char* interfaceName, |
| 610 v8::Local<v8::FunctionTemplate> parentInterfaceTemplate, | 612 v8::Local<v8::FunctionTemplate> parentInterfaceTemplate, |
| 611 size_t v8InternalFieldCount) { | 613 size_t v8InternalFieldCount) { |
| 612 interfaceTemplate->SetClassName(v8AtomicString(isolate, interfaceName)); | 614 interfaceTemplate->SetClassName(v8AtomicString(isolate, interfaceName)); |
| 613 interfaceTemplate->ReadOnlyPrototype(); | 615 interfaceTemplate->ReadOnlyPrototype(); |
| 614 v8::Local<v8::ObjectTemplate> instanceTemplate = | 616 v8::Local<v8::ObjectTemplate> instanceTemplate = |
| 615 interfaceTemplate->InstanceTemplate(); | 617 interfaceTemplate->InstanceTemplate(); |
| 616 v8::Local<v8::ObjectTemplate> prototypeTemplate = | 618 v8::Local<v8::ObjectTemplate> prototypeTemplate = |
| 617 interfaceTemplate->PrototypeTemplate(); | 619 interfaceTemplate->PrototypeTemplate(); |
| 618 instanceTemplate->SetInternalFieldCount(v8InternalFieldCount); | 620 // TODO(mgiuca): Setting the class string for |instanceTemplate| prevents |
| 619 // TODO(yukishiino): We should set the class string to the platform object | 621 // minor GC from collecting unreachable DOM objects (a layout test |
| 620 // (|instanceTemplate|), too. The reason that we don't set it is that | |
| 621 // it prevents minor GC to collect unreachable DOM objects (a layout test | |
| 622 // fast/dom/minor-dom-gc.html fails if we set the class string). | 622 // fast/dom/minor-dom-gc.html fails if we set the class string). |
|
haraken
2017/02/01 03:57:12
yukishiino@: Is this still true? We've made a lot
Matt Giuca
2017/02/01 03:59:47
I just tried it and it fails under this CL.
| |
| 623 // See also http://heycam.github.io/webidl/#es-platform-objects | 623 // See also http://heycam.github.io/webidl/#es-platform-objects |
| 624 setClassString(isolate, prototypeTemplate, interfaceName); | 624 // However, *not* setting this means that setting the class string for |
| 625 // |prototypeTemplate| below causes instances to also be named "Prototype". | |
| 626 // See https://crbug.com/687431. | |
| 627 // DO NOT SUBMIT. | |
| 628 setClassString(isolate, instanceTemplate, interfaceName); | |
| 629 instanceTemplate->SetInternalFieldCount(v8InternalFieldCount); | |
| 630 std::string prototypeName(interfaceName); | |
| 631 prototypeName += "Prototype"; | |
| 632 setClassString(isolate, prototypeTemplate, prototypeName.c_str()); | |
| 625 if (!parentInterfaceTemplate.IsEmpty()) { | 633 if (!parentInterfaceTemplate.IsEmpty()) { |
| 626 interfaceTemplate->Inherit(parentInterfaceTemplate); | 634 interfaceTemplate->Inherit(parentInterfaceTemplate); |
| 627 // Marks the prototype object as one of native-backed objects. | 635 // Marks the prototype object as one of native-backed objects. |
| 628 // This is needed since bug 110436 asks WebKit to tell native-initiated | 636 // This is needed since bug 110436 asks WebKit to tell native-initiated |
| 629 // prototypes from pure-JS ones. This doesn't mark kinds "root" classes | 637 // prototypes from pure-JS ones. This doesn't mark kinds "root" classes |
| 630 // like Node, where setting this changes prototype chain structure. | 638 // like Node, where setting this changes prototype chain structure. |
| 631 prototypeTemplate->SetInternalFieldCount(v8PrototypeInternalFieldcount); | 639 prototypeTemplate->SetInternalFieldCount(v8PrototypeInternalFieldcount); |
| 632 } | 640 } |
| 633 } | 641 } |
| 634 | 642 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 653 void V8DOMConfiguration::setClassString( | 661 void V8DOMConfiguration::setClassString( |
| 654 v8::Isolate* isolate, | 662 v8::Isolate* isolate, |
| 655 v8::Local<v8::ObjectTemplate> objectTemplate, | 663 v8::Local<v8::ObjectTemplate> objectTemplate, |
| 656 const char* classString) { | 664 const char* classString) { |
| 657 objectTemplate->Set( | 665 objectTemplate->Set( |
| 658 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), | 666 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), |
| 659 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); | 667 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); |
| 660 } | 668 } |
| 661 | 669 |
| 662 } // namespace blink | 670 } // namespace blink |
| OLD | NEW |