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

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

Issue 2321073002: binding: Let indexed interceptor falls through to named interceptor. (Closed)
Patch Set: Updated global-interface-listing expectations. Created 4 years, 3 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/V8TestInterface2.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp
index e6cd2c1b5fcd2840d67f3b2bbdf39398115e95e8..7227600340b897d7611839c8f9eea4d544933ce0 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp
@@ -379,33 +379,40 @@ static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
v8SetReturnValue(info, wrapper);
}
-static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
+static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
+ const CString& nameInUtf8 = name.utf8();
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext, "TestInterface2", nameInUtf8.data());
+
TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
- ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "TestInterface2", info.Holder(), info.GetIsolate());
- TestInterfaceEmpty* result = impl->item(index, exceptionState);
- if (exceptionState.hadException())
- return;
+ TestInterfaceEmpty* result = impl->namedItem(name, exceptionState);
if (!result)
return;
v8SetReturnValueFast(info, result, impl);
}
-void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
+void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
- TestInterface2V8Internal::indexedPropertyGetter(index, info);
+ if (!name->IsString())
+ return;
+ const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>());
+
+ TestInterface2V8Internal::namedPropertyGetter(propertyName, info);
}
-static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
+static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
+ const CString& nameInUtf8 = name.utf8();
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface2", nameInUtf8.data());
+
TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), v8Value);
- ExceptionState exceptionState(ExceptionState::IndexedSetterContext, "TestInterface2", info.Holder(), info.GetIsolate());
- if (!propertyValue) {
+ if (!propertyValue && !isUndefinedOrNull(v8Value)) {
exceptionState.throwTypeError("The provided value is not of type 'TestInterfaceEmpty'.");
return;
}
- bool result = impl->setItem(index, propertyValue, exceptionState);
+
+ bool result = impl->setNamedItem(name, propertyValue, exceptionState);
if (exceptionState.hadException())
return;
if (!result)
@@ -413,138 +420,137 @@ static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
v8SetReturnValue(info, v8Value);
}
-void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
+void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
- TestInterface2V8Internal::indexedPropertySetter(index, v8Value, info);
+ if (!name->IsString())
+ return;
+ const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>());
+
+ TestInterface2V8Internal::namedPropertySetter(propertyName, v8Value, info);
}
-static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info)
+static void namedPropertyDeleter(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Boolean>& info)
{
+ const CString& nameInUtf8 = name.utf8();
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::DeletionContext, "TestInterface2", nameInUtf8.data());
+
TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
- ExceptionState exceptionState(ExceptionState::IndexedDeletionContext, "TestInterface2", info.Holder(), info.GetIsolate());
- DeleteResult result = impl->deleteItem(index, exceptionState);
+
+ DeleteResult result = impl->deleteNamedItem(name, exceptionState);
if (exceptionState.hadException())
return;
- if (result != DeleteUnknownProperty)
- return v8SetReturnValueBool(info, result == DeleteSuccess);
+ if (result == DeleteUnknownProperty)
+ return;
+ v8SetReturnValue(info, result == DeleteSuccess);
}
-void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info)
+void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info)
{
- TestInterface2V8Internal::indexedPropertyDeleter(index, info);
+ if (!name->IsString())
+ return;
+ const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>());
+
+ TestInterface2V8Internal::namedPropertyDeleter(propertyName, info);
}
-static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
+static void namedPropertyQuery(const AtomicString& name, const v8::PropertyCallbackInfo<v8::Integer>& info)
{
- auto nameString = name.As<v8::String>();
+ const CString& nameInUtf8 = name.utf8();
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext, "TestInterface2", nameInUtf8.data());
+
TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
- AtomicString propertyName = toCoreAtomicString(nameString);
- v8::String::Utf8Value namedProperty(nameString);
- ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate());
- TestInterfaceEmpty* result = impl->namedItem(propertyName, exceptionState);
- if (exceptionState.hadException())
- return;
+
+ bool result = impl->namedPropertyQuery(name, exceptionState);
if (!result)
return;
- v8SetReturnValueFast(info, result, impl);
+ v8SetReturnValueInt(info, v8::None);
}
-void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
+void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
{
if (!name->IsString())
return;
- TestInterface2V8Internal::namedPropertyGetter(name, info);
+ const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>());
+
+ TestInterface2V8Internal::namedPropertyQuery(propertyName, info);
}
-static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
+static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
{
- auto nameString = name.As<v8::String>();
- v8::String::Utf8Value namedProperty(nameString);
- ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::EnumerationContext, "TestInterface2");
+
TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
- V8StringResource<> propertyName(nameString);
- if (!propertyName.prepare())
- return;
- TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), v8Value);
- if (!propertyValue && !isUndefinedOrNull(v8Value)) {
- exceptionState.throwTypeError("The provided value is not of type 'TestInterfaceEmpty'.");
- return;
- }
- bool result = impl->setNamedItem(propertyName, propertyValue, exceptionState);
+
+ Vector<String> names;
+ impl->namedPropertyEnumerator(names, exceptionState);
if (exceptionState.hadException())
return;
- if (!result)
- return;
- v8SetReturnValue(info, v8Value);
+ v8SetReturnValue(info, toV8(names, info.Holder(), info.GetIsolate()).As<v8::Array>());
}
-void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
+void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
{
- if (!name->IsString())
- return;
- TestInterface2V8Internal::namedPropertySetter(name, v8Value, info);
+ TestInterface2V8Internal::namedPropertyEnumerator(info);
}
-static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
+static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
{
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetterContext, "TestInterface2");
+
TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
- AtomicString propertyName = toCoreAtomicString(name.As<v8::String>());
- v8::String::Utf8Value namedProperty(name);
- ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate());
- bool result = impl->namedPropertyQuery(propertyName, exceptionState);
- if (exceptionState.hadException())
- return;
+
+ TestInterfaceEmpty* result = impl->item(index, exceptionState);
if (!result)
return;
- v8SetReturnValueInt(info, v8::None);
+ v8SetReturnValueFast(info, result, impl);
}
-void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
+void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
{
- if (!name->IsString())
- return;
- TestInterface2V8Internal::namedPropertyQuery(name, info);
+ TestInterface2V8Internal::indexedPropertyGetter(index, info);
}
-static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info)
+static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedSetterContext, "TestInterface2");
+
TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
- AtomicString propertyName = toCoreAtomicString(name.As<v8::String>());
- v8::String::Utf8Value namedProperty(name);
- ExceptionState exceptionState(ExceptionState::DeletionContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate());
- DeleteResult result = impl->deleteNamedItem(propertyName, exceptionState);
+ TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), v8Value);
+ if (!propertyValue) {
+ exceptionState.throwTypeError("The provided value is not of type 'TestInterfaceEmpty'.");
+ return;
+ }
+
+ bool result = impl->setItem(index, propertyValue, exceptionState);
if (exceptionState.hadException())
return;
- if (result != DeleteUnknownProperty)
- return v8SetReturnValueBool(info, result == DeleteSuccess);
+ if (!result)
+ return;
+ v8SetReturnValue(info, v8Value);
}
-void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info)
+void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
- if (!name->IsString())
- return;
- TestInterface2V8Internal::namedPropertyDeleter(name, info);
+ TestInterface2V8Internal::indexedPropertySetter(index, v8Value, info);
}
-static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
+static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info)
{
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedDeletionContext, "TestInterface2");
+
TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
- Vector<String> names;
- ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestInterface2", info.Holder(), info.GetIsolate());
- impl->namedPropertyEnumerator(names, exceptionState);
+
+ DeleteResult result = impl->deleteItem(index, exceptionState);
if (exceptionState.hadException())
return;
- v8::Local<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size());
- for (size_t i = 0; i < names.size(); ++i) {
- if (!v8CallBoolean(v8names->CreateDataProperty(info.GetIsolate()->GetCurrentContext(), i, v8String(info.GetIsolate(), names[i]))))
- return;
- }
- v8SetReturnValue(info, v8names);
+ if (result == DeleteUnknownProperty)
+ return;
+ v8SetReturnValue(info, result == DeleteSuccess);
}
-void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
+void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info)
{
- TestInterface2V8Internal::namedPropertyEnumerator(info);
+ TestInterface2V8Internal::indexedPropertyDeleter(index, info);
}
} // namespace TestInterface2V8Internal

Powered by Google App Engine
This is Rietveld 408576698