Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% filter format_blink_cpp_source_code %} | 1 {% filter format_blink_cpp_source_code %} |
| 2 | 2 |
| 3 {% include 'copyright_block.txt' %} | 3 {% include 'copyright_block.txt' %} |
| 4 #include "{{v8_class_or_partial}}.h" | 4 #include "{{v8_class_or_partial}}.h" |
| 5 | 5 |
| 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} | 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} |
| 7 #include "{{filename}}" | 7 #include "{{filename}}" |
| 8 {% endfor %} | 8 {% endfor %} |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 {% if iterator_method %} | 525 {% if iterator_method %} |
| 526 {% filter exposed(iterator_method.exposed_test) %} | 526 {% filter exposed(iterator_method.exposed_test) %} |
| 527 {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %} | 527 {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %} |
| 528 // Iterator (@@iterator) | 528 // Iterator (@@iterator) |
| 529 static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIte ratorConfiguration = { v8::Symbol::GetIterator, {{v8_class_or_partial}}::iterato rMethodCallback, 0, v8::DontEnum, V8DOMConfiguration::OnPrototype, V8DOMConfigur ation::CheckHolder, V8DOMConfiguration::DoNotCheckAccess }; | 529 static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIte ratorConfiguration = { v8::Symbol::GetIterator, {{v8_class_or_partial}}::iterato rMethodCallback, 0, v8::DontEnum, V8DOMConfiguration::OnPrototype, V8DOMConfigur ation::CheckHolder, V8DOMConfiguration::DoNotCheckAccess }; |
| 530 V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signature , symbolKeyedIteratorConfiguration); | 530 V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signature , symbolKeyedIteratorConfiguration); |
| 531 {% endfilter %} | 531 {% endfilter %} |
| 532 {% endfilter %} | 532 {% endfilter %} |
| 533 {% endif %} | 533 {% endif %} |
| 534 | 534 |
| 535 {% if interface_name == 'Iterator' %} | |
| 536 // The WebIDL spec says when an interface has pair iterators the iterators it | |
| 537 // returns must be instances of the "default iterator object" whose | |
| 538 // [[Prototype]] points to an "iterator prototype object" whose | |
| 539 // [[Prototype]], on its turn, points to %IteratorPrototype%. next() must be | |
| 540 // implemented in the "iterator prototype object", while %IteratorPrototype% | |
| 541 // provides @@iterator. | |
| 542 // References: | |
| 543 // https://heycam.github.io/webidl/#es-default-iterator-object | |
| 544 // https://heycam.github.io/webidl/#es-iterator-prototype-object | |
| 545 // | |
| 546 // The iterators we return from interfaces that have pair interators adhere | |
| 547 // to the above by: | |
| 548 // - Adding the "next()" property to its prototype object. | |
| 549 // - Making the prototype object inherit from %IteratorPrototype% with the | |
| 550 // hack below, which creates another function template with no prototype | |
| 551 // and sets the "prototype" property of its function object. | |
| 552 // When |interfaceTemplate|'s function object is created, its | |
| 553 // prototype.__proto__ will point to the value of the "prototype" property | |
| 554 // of |iteratorPrototypeTemplate|, which is exactly what we want. | |
| 555 // | |
| 556 // Finally, creating a FunctionTemplate here might look expensive since they | |
| 557 // have the same lifetime as their context, but: | |
| 558 // - |interfaceTemplate| is is cached in V8PerIsolateData, so we create only | |
|
Yuki
2017/04/07 09:49:12
typo: s/is is/is/
| |
| 559 // one FunctionTemplate per interface. | |
| 560 // - There is only one Iterator interface that creates this FunctionTemplate, | |
| 561 // so there is no need to reuse this FunctionTemplate and register it in | |
| 562 // V8PerIsolateData. | |
| 563 v8::Local<v8::FunctionTemplate> intrinsicIteratorPrototypeInterfaceTemplate = | |
| 564 v8::FunctionTemplate::New(isolate); | |
| 565 intrinsicIteratorPrototypeInterfaceTemplate->RemovePrototype(); | |
| 566 intrinsicIteratorPrototypeInterfaceTemplate->SetIntrinsicDataProperty( | |
| 567 v8AtomicString(isolate, "prototype"), v8::kIteratorPrototype); | |
| 568 interfaceTemplate->Inherit(intrinsicIteratorPrototypeInterfaceTemplate); | |
| 569 {% endif %} | |
| 570 | |
| 535 {% if interface_name == 'Location' %} | 571 {% if interface_name == 'Location' %} |
| 536 // Symbol.toPrimitive | 572 // Symbol.toPrimitive |
| 537 // Prevent author scripts to inject Symbol.toPrimitive property into location | 573 // Prevent author scripts to inject Symbol.toPrimitive property into location |
| 538 // objects, also prevent the look-up of Symbol.toPrimitive through the | 574 // objects, also prevent the look-up of Symbol.toPrimitive through the |
| 539 // prototype chain. | 575 // prototype chain. |
| 540 instanceTemplate->Set(v8::Symbol::GetToPrimitive(isolate), | 576 instanceTemplate->Set(v8::Symbol::GetToPrimitive(isolate), |
| 541 v8::Undefined(isolate), | 577 v8::Undefined(isolate), |
| 542 static_cast<v8::PropertyAttribute>( | 578 static_cast<v8::PropertyAttribute>( |
| 543 v8::ReadOnly | v8::DontEnum | v8::DontDelete)); | 579 v8::ReadOnly | v8::DontEnum | v8::DontDelete)); |
| 544 {% endif %} | 580 {% endif %} |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 {% endif %} | 791 {% endif %} |
| 756 } | 792 } |
| 757 {% endif %} | 793 {% endif %} |
| 758 | 794 |
| 759 {% endblock %} | 795 {% endblock %} |
| 760 {##############################################################################} | 796 {##############################################################################} |
| 761 {% block partial_interface %}{% endblock %} | 797 {% block partial_interface %}{% endblock %} |
| 762 } // namespace blink | 798 } // namespace blink |
| 763 | 799 |
| 764 {% endfilter %}{# format_blink_cpp_source_code #} | 800 {% endfilter %}{# format_blink_cpp_source_code #} |
| OLD | NEW |