Commit ee6792e5 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Make IDL callback callers work with the new bindings

The new bindings of IDL callbacks take the new IDL enumeration
instead of WTFString.  This patch adds adapter code so that
the callers of IDL callbacks work with both of the old and new
bindings.

Bug: 839389
Change-Id: Ia8b60105347f9e64d7e99ddbca831c22eec8d223
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2434104
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811138}
parent 5ae5e597
......@@ -14,6 +14,7 @@
#include "third_party/blink/renderer/bindings/core/v8/v8_custom_element_form_state_restore_callback.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_custom_element_registry.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_element.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_form_state_restore_mode.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_function.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_script_runner.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
......@@ -347,7 +348,12 @@ void ScriptCustomElementDefinition::RunFormStateRestoreCallback(
const String& mode) {
if (!form_state_restore_callback_)
return;
#if defined(USE_BLINK_V8_BINDING_NEW_IDL_CALLBACK_FUNCTION)
form_state_restore_callback_->InvokeAndReportException(
&element, value, V8FormStateRestoreMode::Create(mode).value());
#else
form_state_restore_callback_->InvokeAndReportException(&element, value, mode);
#endif
}
} // namespace blink
......@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/testing/callback_function_test.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_internal_enum.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_test_callback.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_test_enum_callback.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_test_interface_callback.h"
......@@ -72,7 +73,12 @@ Vector<String> CallbackFunctionTest::testSequenceCallback(
void CallbackFunctionTest::testEnumCallback(V8TestEnumCallback* callback,
const String& enum_value,
ExceptionState& exception_state) {
#if defined(USE_BLINK_V8_BINDING_NEW_IDL_CALLBACK_FUNCTION)
callback->InvokeAndReportException(
nullptr, V8InternalEnum::Create(enum_value).value());
#else
callback->InvokeAndReportException(nullptr, enum_value);
#endif
}
} // namespace blink
......@@ -14,6 +14,7 @@
#include "third_party/blink/public/mojom/permissions/permission_status.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_notification_permission.h"
#include "third_party/blink/renderer/core/frame/frame.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
......@@ -102,8 +103,14 @@ void NotificationManager::OnPermissionRequestComplete(
V8NotificationPermissionCallback* deprecated_callback,
mojom::blink::PermissionStatus status) {
String status_string = Notification::PermissionString(status);
if (deprecated_callback)
if (deprecated_callback) {
#if defined(USE_BLINK_V8_BINDING_NEW_IDL_CALLBACK_FUNCTION)
deprecated_callback->InvokeAndReportException(
nullptr, V8NotificationPermission::Create(status_string).value());
#else
deprecated_callback->InvokeAndReportException(nullptr, status_string);
#endif
}
resolver->Resolve(status_string);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment