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

Unified Diff: third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.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/modules/V8TestInterface5.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp b/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp
index 1bd1273b4e5447d0086aba310b8d36eeca726350..aaa4a6dd370603a5b890255a270c1f1cb876541a 100644
--- a/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp
@@ -13,10 +13,7 @@
#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/V8Iterator.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
#include "bindings/core/v8/V8TestInterfaceEmpty.h"
#include "bindings/modules/v8/BooleanOrString.h"
@@ -188,6 +185,14 @@ static void staticStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, c
TestInterface5Implementation::setStaticStringAttribute(cppValue);
}
+static void lengthAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> holder = info.Holder();
+
+ TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
+
+ v8SetReturnValueUnsigned(info, impl->length());
+}
+
static void alwaysExposedAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
@@ -441,97 +446,12 @@ static void voidMethodVoidCallbackFunctionModulesArgMethod(const v8::FunctionCal
impl->voidMethodVoidCallbackFunctionModulesArg(arg);
}
-static void keysMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
- ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface5", "keys");
-
- TestInterface5Implementation* impl = V8TestInterface5::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, "TestInterface5", "values");
-
- TestInterface5Implementation* impl = V8TestInterface5::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, "TestInterface5", "entries");
-
- TestInterface5Implementation* impl = V8TestInterface5::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, "TestInterface5", "forEach");
-
- TestInterface5Implementation* impl = V8TestInterface5::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) {
TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
v8SetReturnValueString(info, impl->toString(), info.GetIsolate());
}
-static void iteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
- ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface5", "iterator");
-
- TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
-
- ScriptState* scriptState = ScriptState::forReceiverObject(info);
-
- Iterator* result = impl->iterator(scriptState, exceptionState);
- if (exceptionState.hadException()) {
- return;
- }
- v8SetReturnValue(info, result);
-}
-
static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Value>& info) {
TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
String result = impl->anonymousNamedGetter(name);
@@ -682,6 +602,10 @@ void V8TestInterface5::staticStringAttributeAttributeSetterCallback(const v8::Fu
TestInterface5ImplementationV8Internal::staticStringAttributeAttributeSetter(v8Value, info);
}
+void V8TestInterface5::lengthAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ TestInterface5ImplementationV8Internal::lengthAttributeGetter(info);
+}
+
void V8TestInterface5::alwaysExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5ImplementationV8Internal::alwaysExposedAttributeAttributeGetter(info);
}
@@ -776,30 +700,10 @@ void V8TestInterface5::voidMethodVoidCallbackFunctionModulesArgMethodCallback(co
TestInterface5ImplementationV8Internal::voidMethodVoidCallbackFunctionModulesArgMethod(info);
}
-void V8TestInterface5::keysMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface5ImplementationV8Internal::keysMethod(info);
-}
-
-void V8TestInterface5::valuesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface5ImplementationV8Internal::valuesMethod(info);
-}
-
-void V8TestInterface5::entriesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface5ImplementationV8Internal::entriesMethod(info);
-}
-
-void V8TestInterface5::forEachMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface5ImplementationV8Internal::forEachMethod(info);
-}
-
void V8TestInterface5::toStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestInterface5ImplementationV8Internal::toStringMethod(info);
}
-void V8TestInterface5::iteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- TestInterface5ImplementationV8Internal::iteratorMethod(info);
-}
-
void V8TestInterface5::namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
if (!name->IsString())
return;
@@ -868,6 +772,7 @@ const V8DOMConfiguration::AccessorConfiguration V8TestInterface5Accessors[] = {
{"unrestrictedDoubleAttribute", V8TestInterface5::unrestrictedDoubleAttributeAttributeGetterCallback, V8TestInterface5::unrestrictedDoubleAttributeAttributeSetterCallback, nullptr, nullptr, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"unrestrictedFloatAttribute", V8TestInterface5::unrestrictedFloatAttributeAttributeGetterCallback, V8TestInterface5::unrestrictedFloatAttributeAttributeSetterCallback, nullptr, nullptr, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"staticStringAttribute", V8TestInterface5::staticStringAttributeAttributeGetterCallback, V8TestInterface5::staticStringAttributeAttributeSetterCallback, nullptr, nullptr, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::OnInterface, V8DOMConfiguration::CheckHolder},
+ {"length", V8TestInterface5::lengthAttributeGetterCallback, nullptr, nullptr, nullptr, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"alwaysExposedAttribute", V8TestInterface5::alwaysExposedAttributeAttributeGetterCallback, V8TestInterface5::alwaysExposedAttributeAttributeSetterCallback, nullptr, nullptr, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
};
@@ -882,10 +787,6 @@ const V8DOMConfiguration::MethodConfiguration V8TestInterface5Methods[] = {
{"voidMethodDoubleOrDOMStringArg", V8TestInterface5::voidMethodDoubleOrDOMStringArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"voidMethodVoidExperimentalCallbackFunction", V8TestInterface5::voidMethodVoidExperimentalCallbackFunctionMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"voidMethodVoidCallbackFunctionModulesArg", V8TestInterface5::voidMethodVoidCallbackFunctionModulesArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
- {"keys", V8TestInterface5::keysMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
- {"values", V8TestInterface5::valuesMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
- {"entries", V8TestInterface5::entriesMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
- {"forEach", V8TestInterface5::forEachMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"toString", V8TestInterface5::toStringMethodCallback, nullptr, 0, static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
};
@@ -921,9 +822,14 @@ static void installV8TestInterface5Template(v8::Isolate* isolate, const DOMWrapp
v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig(V8TestInterface5::namedPropertyGetterCallback, V8TestInterface5::namedPropertySetterCallback, V8TestInterface5::namedPropertyQueryCallback, V8TestInterface5::namedPropertyDeleterCallback, V8TestInterface5::namedPropertyEnumeratorCallback, v8::Local<v8::Value>(), static_cast<v8::PropertyHandlerFlags>(int(v8::PropertyHandlerFlags::kOnlyInterceptStrings) | int(v8::PropertyHandlerFlags::kNonMasking)));
instanceTemplate->SetHandler(namedPropertyHandlerConfig);
- // Iterator (@@iterator)
- const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, V8TestInterface5::iteratorMethodCallback, 0, v8::DontEnum, V8DOMConfiguration::OnPrototype };
- V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signature, symbolKeyedIteratorConfiguration);
+ // 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);
instanceTemplate->SetCallAsFunctionHandler(V8TestInterface5::legacyCallCustom);
}

Powered by Google App Engine
This is Rietveld 408576698