Commit 0ef1727a authored by Yuki Yamada's avatar Yuki Yamada Committed by Commit Bot

Rename V8EventListener to V8EventListenerOrEventHandler

This CL renames V8EventListener to V8EventListenerOrEventHandler in
order to use callback interface EventListener generated by
event_listener.idl:
https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/dom/events/event_listener.idl?type=cs&q=%22callback+interface+EventListener%22&sq=package:chromium&g=0&l=23
https://dom.spec.whatwg.org/#interface-eventtarget
The generated class will be named as "V8EventListener", so we have to
rename current V8EventListener.

Bug: 872138
Change-Id: Iceaf2e0ccbfb0f0b4be38381b14d79c63d0982af
Reviewed-on: https://chromium-review.googlesource.com/1170670Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Yamada <yukiy@google.com>
Cr-Commit-Position: refs/heads/master@{#582495}
parent a98a9d46
......@@ -112,8 +112,8 @@ bindings_core_v8_files =
"core/v8/v8_embedder_graph_builder.h",
"core/v8/v8_error_handler.cc",
"core/v8/v8_error_handler.h",
"core/v8/v8_event_listener.cc",
"core/v8/v8_event_listener.h",
"core/v8/v8_event_listener_or_event_handler.cc",
"core/v8/v8_event_listener_or_event_handler.h",
"core/v8/v8_event_listener_helper.cc",
"core/v8/v8_event_listener_helper.h",
"core/v8/v8_event_listener_info.h",
......
......@@ -35,7 +35,7 @@
#include "third_party/blink/renderer/bindings/core/v8/script_source_code.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener_or_event_handler.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_html_collection.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_node.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
......
......@@ -40,15 +40,17 @@
namespace blink {
V8ErrorHandler::V8ErrorHandler(bool is_inline, ScriptState* script_state)
: V8EventListener(is_inline, script_state) {}
: V8EventListenerOrEventHandler(is_inline, script_state) {}
v8::Local<v8::Value> V8ErrorHandler::CallListenerFunction(
ScriptState* script_state,
v8::Local<v8::Value> js_event,
Event* event) {
DCHECK(!js_event.IsEmpty());
if (!event->HasInterface(EventNames::ErrorEvent))
return V8EventListener::CallListenerFunction(script_state, js_event, event);
if (!event->HasInterface(EventNames::ErrorEvent)) {
return V8EventListenerOrEventHandler::CallListenerFunction(script_state,
js_event, event);
}
ErrorEvent* error_event = static_cast<ErrorEvent*>(event);
if (error_event->World() && error_event->World() != &World())
......
......@@ -32,14 +32,14 @@
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_ERROR_HANDLER_H_
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener_or_event_handler.h"
#include "v8/include/v8.h"
namespace blink {
class ErrorEvent;
class V8ErrorHandler final : public V8EventListener {
class V8ErrorHandler final : public V8EventListenerOrEventHandler {
public:
static V8ErrorHandler* Create(v8::Local<v8::Object> listener,
bool is_inline,
......
......@@ -33,7 +33,6 @@
#include "third_party/blink/renderer/bindings/core/v8/custom_wrappable_adapter.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_error_handler.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_window.h"
#include "third_party/blink/renderer/platform/bindings/v8_private_property.h"
......@@ -73,14 +72,16 @@ V8AbstractEventListener* V8EventListenerHelper::GetEventListener(
v8::Isolate* isolate = script_state->GetIsolate();
V8PrivateProperty::Symbol listener_property =
is_attribute
? V8PrivateProperty::GetV8EventListenerAttributeListener(isolate)
: V8PrivateProperty::GetV8EventListenerListener(isolate);
? V8PrivateProperty::
GetV8EventListenerOrEventHandlerAttributeListener(isolate)
: V8PrivateProperty::GetV8EventListenerOrEventHandlerListener(
isolate);
return GetEventListenerInternal<V8AbstractEventListener>(
script_state, object, listener_property, lookup,
[object, is_attribute, script_state, listener_property]() {
return V8EventListener::Create(object, is_attribute, script_state,
listener_property);
return V8EventListenerOrEventHandler::Create(
object, is_attribute, script_state, listener_property);
});
}
......
......@@ -32,14 +32,13 @@
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_EVENT_LISTENER_HELPER_H_
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener_or_event_handler.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "v8/include/v8.h"
namespace blink {
class V8EventListener;
class V8ErrorHandler;
enum ListenerLookupType {
......@@ -47,8 +46,8 @@ enum ListenerLookupType {
kListenerFindOrCreate,
};
// This is a container for V8EventListener objects that uses hidden properties
// of v8::Object to speed up lookups.
// This is a container for V8EventListenerOrEventHandler objects that uses
// hidden properties of v8::Object to speed up lookups.
class V8EventListenerHelper {
STATIC_ONLY(V8EventListenerHelper);
......
......@@ -28,7 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener_or_event_handler.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
......@@ -39,12 +39,14 @@
namespace blink {
V8EventListener::V8EventListener(bool is_attribute, ScriptState* script_state)
V8EventListenerOrEventHandler::V8EventListenerOrEventHandler(
bool is_attribute,
ScriptState* script_state)
: V8AbstractEventListener(script_state->GetIsolate(),
is_attribute,
script_state->World()) {}
v8::Local<v8::Function> V8EventListener::GetListenerFunction(
v8::Local<v8::Function> V8EventListenerOrEventHandler::GetListenerFunction(
ScriptState* script_state) {
v8::Local<v8::Object> listener =
GetListenerObject(ExecutionContext::From(script_state));
......@@ -85,7 +87,7 @@ v8::Local<v8::Function> V8EventListener::GetListenerFunction(
return v8::Local<v8::Function>();
}
v8::Local<v8::Value> V8EventListener::CallListenerFunction(
v8::Local<v8::Value> V8EventListenerOrEventHandler::CallListenerFunction(
ScriptState* script_state,
v8::Local<v8::Value> js_event,
Event* event) {
......
......@@ -28,8 +28,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_EVENT_LISTENER_H_
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_EVENT_LISTENER_H_
#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_EVENT_LISTENER_OR_EVENT_HANDLER_H_
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_EVENT_LISTENER_OR_EVENT_HANDLER_H_
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_abstract_event_listener.h"
......@@ -39,23 +39,24 @@ namespace blink {
class Event;
// V8EventListener is a wrapper of a JS object implements EventListener
// interface (has handleEvent(event) method), or a JS function that can handle
// the event.
class V8EventListener : public V8AbstractEventListener {
// V8EventListenerOrEventHandler is a wrapper of a JS object implements
// EventListener interface (has handleEvent(event) method), or a JS function
// that can handle the event.
class V8EventListenerOrEventHandler : public V8AbstractEventListener {
public:
static V8EventListener* Create(v8::Local<v8::Object> listener,
bool is_attribute,
ScriptState* script_state,
const V8PrivateProperty::Symbol& property) {
V8EventListener* event_listener =
new V8EventListener(is_attribute, script_state);
static V8EventListenerOrEventHandler* Create(
v8::Local<v8::Object> listener,
bool is_attribute,
ScriptState* script_state,
const V8PrivateProperty::Symbol& property) {
V8EventListenerOrEventHandler* event_listener =
new V8EventListenerOrEventHandler(is_attribute, script_state);
event_listener->SetListenerObject(script_state, listener, property);
return event_listener;
}
protected:
V8EventListener(bool is_attribute, ScriptState*);
V8EventListenerOrEventHandler(bool is_attribute, ScriptState*);
v8::Local<v8::Function> GetListenerFunction(ScriptState*);
v8::Local<v8::Value> CallListenerFunction(ScriptState*,
v8::Local<v8::Value>,
......@@ -64,4 +65,4 @@ class V8EventListener : public V8AbstractEventListener {
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_EVENT_LISTENER_H_
#endif // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_EVENT_LISTENER_OR_EVENT_HANDLER_H_
......@@ -203,9 +203,9 @@ void V8LazyEventListener::CompileScript(ScriptState* script_state,
wrapped_function->SetName(V8String(GetIsolate(), function_name_));
SetListenerObject(
script_state, wrapped_function,
V8PrivateProperty::GetV8EventListenerListener(GetIsolate()));
SetListenerObject(script_state, wrapped_function,
V8PrivateProperty::GetV8EventListenerOrEventHandlerListener(
GetIsolate()));
}
void V8LazyEventListener::FireErrorEvent(v8::Local<v8::Context> v8_context,
......
......@@ -12,9 +12,9 @@
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_token_list.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener_helper.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener_info.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener_or_event_handler.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_html_all_collection.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_html_collection.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_node.h"
......
......@@ -51,8 +51,8 @@ class ScriptWrappable;
X(SameObject, PerformanceLongTaskTimingAttribution) \
X(SameObject, PushManagerSupportedContentEncodings) \
X(V8ErrorHandler, ErrorHandler) \
X(V8EventListener, AttributeListener) \
X(V8EventListener, Listener) \
X(V8EventListenerOrEventHandler, AttributeListener) \
X(V8EventListenerOrEventHandler, Listener) \
SCRIPT_PROMISE_PROPERTIES(X, Promise) \
SCRIPT_PROMISE_PROPERTIES(X, Resolver)
......
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