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

Unified Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp

Issue 2683853005: bindings: Make some value iterator properties aliases to Array.prototype functions (Closed)
Patch Set: Remove constexpr from Internals.h to fix the Android build Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp
index 132d1542abafa643e9984ec6cf9a2a8a9c2d5751..fde3ff0575cbf310fab810565bc0a655401ec1b6 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp
@@ -13,15 +13,11 @@
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/GeneratedCodeHelper.h"
-#include "bindings/core/v8/ScriptState.h"
-#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/V8DOMConfiguration.h"
#include "bindings/core/v8/V8Document.h"
-#include "bindings/core/v8/V8Iterator.h"
#include "bindings/core/v8/V8Node.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
#include "core/dom/Document.h"
-#include "platform/RuntimeEnabledFeatures.h"
#include "wtf/GetPtr.h"
#include "wtf/RefPtr.h"
@@ -58,6 +54,14 @@ static_assert(
namespace TestInterface3V8Internal {
+static void lengthAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> holder = info.Holder();
+
+ TestInterface3* impl = V8TestInterface3::toImpl(holder);
+
+ v8SetReturnValueUnsigned(info, impl->length());
+}
+
static void readonlyStringifierAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
@@ -85,99 +89,18 @@ static void voidMethodDocumentMethod(const v8::FunctionCallbackInfo<v8::Value>&
impl->voidMethodDocument(document);
}
-static void keysMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
- ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface3", "keys");
-
- TestInterface3* impl = V8TestInterface3::toImpl(info.Holder());
-
- ScriptState* scriptState = ScriptState::forReceiverObject(info);
-
- Iterator* result = impl->keysForBinding(scriptState, exceptionState);
- if (exceptionState.hadException()) {
- return;
- }
- v8SetReturnValue(info, result);
-}
-
-static void valuesMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
- ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface3", "values");
-
- TestInterface3* impl = V8TestInterface3::toImpl(info.Holder());
-
- ScriptState* scriptState = ScriptState::forReceiverObject(info);
-
- Iterator* result = impl->valuesForBinding(scriptState, exceptionState);
- if (exceptionState.hadException()) {
- return;
- }
- v8SetReturnValue(info, result);
-}
-
-static void entriesMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
- ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface3", "entries");
-
- TestInterface3* impl = V8TestInterface3::toImpl(info.Holder());
-
- ScriptState* scriptState = ScriptState::forReceiverObject(info);
-
- Iterator* result = impl->entriesForBinding(scriptState, exceptionState);
- if (exceptionState.hadException()) {
- return;
- }
- v8SetReturnValue(info, result);
-}
-
-static void forEachMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
- ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface3", "forEach");
-
- TestInterface3* impl = V8TestInterface3::toImpl(info.Holder());
-
- ScriptState* scriptState = ScriptState::forReceiverObject(info);
-
- if (UNLIKELY(info.Length() < 1)) {
- exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
- return;
- }
-
- ScriptValue callback;
- ScriptValue thisArg;
- if (!(info[0]->IsObject() && v8::Local<v8::Object>::Cast(info[0])->IsCallable())) {
- exceptionState.throwTypeError("The callback provided as parameter 1 is not a function.");
-
- return;
- }
- callback = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]);
-
- thisArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[1]);
-
- impl->forEachForBinding(scriptState, ScriptValue(scriptState, info.Holder()), callback, thisArg, exceptionState);
- if (exceptionState.hadException()) {
- return;
- }
-}
-
static void toStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface3* impl = V8TestInterface3::toImpl(info.Holder());
v8SetReturnValueString(info, impl->readonlyStringifierAttribute(), info.GetIsolate());
}
-static void iteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
- ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface3", "iterator");
-
- TestInterface3* impl = V8TestInterface3::toImpl(info.Holder());
-
- ScriptState* scriptState = ScriptState::forReceiverObject(info);
+} // namespace TestInterface3V8Internal
- Iterator* result = impl->iterator(scriptState, exceptionState);
- if (exceptionState.hadException()) {
- return;
- }
- v8SetReturnValue(info, result);
+void V8TestInterface3::lengthAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ TestInterface3V8Internal::lengthAttributeGetter(info);
}
-} // namespace TestInterface3V8Internal
-
void V8TestInterface3::readonlyStringifierAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface3V8Internal::readonlyStringifierAttributeAttributeGetter(info);
}
@@ -186,30 +109,10 @@ void V8TestInterface3::voidMethodDocumentMethodCallback(const v8::FunctionCallba
TestInterface3V8Internal::voidMethodDocumentMethod(info);
}
-void V8TestInterface3::keysMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface3V8Internal::keysMethod(info);
-}
-
-void V8TestInterface3::valuesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface3V8Internal::valuesMethod(info);
-}
-
-void V8TestInterface3::entriesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface3V8Internal::entriesMethod(info);
-}
-
-void V8TestInterface3::forEachMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface3V8Internal::forEachMethod(info);
-}
-
void V8TestInterface3::toStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface3V8Internal::toStringMethod(info);
}
-void V8TestInterface3::iteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface3V8Internal::iteratorMethod(info);
-}
-
void V8TestInterface3::namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
if (!name->IsString())
return;
@@ -259,6 +162,7 @@ void V8TestInterface3::indexedPropertyDeleterCallback(uint32_t index, const v8::
}
const V8DOMConfiguration::AccessorConfiguration V8TestInterface3Accessors[] = {
+ {"length", V8TestInterface3::lengthAttributeGetterCallback, nullptr, nullptr, nullptr, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"readonlyStringifierAttribute", V8TestInterface3::readonlyStringifierAttributeAttributeGetterCallback, nullptr, nullptr, nullptr, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
};
@@ -289,28 +193,14 @@ static void installV8TestInterface3Template(v8::Isolate* isolate, const DOMWrapp
v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig(V8TestInterface3::namedPropertyGetterCallback, V8TestInterface3::namedPropertySetterCallback, V8TestInterface3::namedPropertyQueryCallback, V8TestInterface3::namedPropertyDeleterCallback, V8TestInterface3::namedPropertyEnumeratorCallback, v8::Local<v8::Value>(), static_cast<v8::PropertyHandlerFlags>(int(v8::PropertyHandlerFlags::kOnlyInterceptStrings) | int(v8::PropertyHandlerFlags::kNonMasking)));
instanceTemplate->SetHandler(namedPropertyHandlerConfig);
- if (RuntimeEnabledFeatures::featureNameEnabled()) {
- // Iterator (@@iterator)
- const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, V8TestInterface3::iteratorMethodCallback, 0, v8::DontEnum, V8DOMConfiguration::OnPrototype };
- V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signature, symbolKeyedIteratorConfiguration);
- }
-
- if (RuntimeEnabledFeatures::featureNameEnabled()) {
- const V8DOMConfiguration::MethodConfiguration keysMethodConfiguration = {"keys", V8TestInterface3::keysMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
- V8DOMConfiguration::installMethod(isolate, world, instanceTemplate, prototypeTemplate, interfaceTemplate, signature, keysMethodConfiguration);
- }
- if (RuntimeEnabledFeatures::featureNameEnabled()) {
- const V8DOMConfiguration::MethodConfiguration valuesMethodConfiguration = {"values", V8TestInterface3::valuesMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
- V8DOMConfiguration::installMethod(isolate, world, instanceTemplate, prototypeTemplate, interfaceTemplate, signature, valuesMethodConfiguration);
- }
- if (RuntimeEnabledFeatures::featureNameEnabled()) {
- const V8DOMConfiguration::MethodConfiguration entriesMethodConfiguration = {"entries", V8TestInterface3::entriesMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
- V8DOMConfiguration::installMethod(isolate, world, instanceTemplate, prototypeTemplate, interfaceTemplate, signature, entriesMethodConfiguration);
- }
- if (RuntimeEnabledFeatures::featureNameEnabled()) {
- const V8DOMConfiguration::MethodConfiguration forEachMethodConfiguration = {"forEach", V8TestInterface3::forEachMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
- V8DOMConfiguration::installMethod(isolate, world, instanceTemplate, prototypeTemplate, interfaceTemplate, signature, forEachMethodConfiguration);
- }
+ // Array iterator (@@iterator)
+ prototypeTemplate->SetIntrinsicDataProperty(v8::Symbol::GetIterator(isolate), v8::kArrayProto_values, v8::DontEnum);
+ // For value iterators, the properties below must originally be set to the corresponding ones in %ArrayPrototype%.
+ // See https://heycam.github.io/webidl/#es-iterators.
+ prototypeTemplate->SetIntrinsicDataProperty(v8AtomicString(isolate, "entries"), v8::kArrayProto_entries);
+ prototypeTemplate->SetIntrinsicDataProperty(v8AtomicString(isolate, "forEach"), v8::kArrayProto_forEach);
+ prototypeTemplate->SetIntrinsicDataProperty(v8AtomicString(isolate, "keys"), v8::kArrayProto_keys);
+ prototypeTemplate->SetIntrinsicDataProperty(v8AtomicString(isolate, "values"), v8::kArrayProto_values);
}
v8::Local<v8::FunctionTemplate> V8TestInterface3::domTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world) {

Powered by Google App Engine
This is Rietveld 408576698