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

bind-gen: Move IDL callback APIs to public

Since https://crrev.com/c/2434004 will be going to introduce
bindings::CallbackInvokeHelper, which is expected to reduce
the APK size by 7KB, then some of IDL callback APIs need to
be accessible from CallbackInvokeHelper.  So this patch
moves such APIs to public.

Bug: 839389
Change-Id: I3eafa3992d21d7c011b7fcff07e4c7d57eb8a32f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432149Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811129}
parent e57ef9d2
...@@ -80,9 +80,8 @@ unsigned NodeIteratorBase::AcceptNode(Node* node, ...@@ -80,9 +80,8 @@ unsigned NodeIteratorBase::AcceptNode(Node* node,
UseCounter::Count( UseCounter::Count(
ExecutionContext::From(filter_->CallbackRelevantScriptState()), ExecutionContext::From(filter_->CallbackRelevantScriptState()),
filter_->IsCallbackObjectCallableForNodeIteratorBase() filter_->IsCallbackObjectCallable() ? WebFeature::kNodeFilterIsFunction
? WebFeature::kNodeFilterIsFunction : WebFeature::kNodeFilterIsObject);
: WebFeature::kNodeFilterIsObject);
// 7. Unset the active flag. // 7. Unset the active flag.
// 8. Return result. // 8. Return result.
......
...@@ -63,6 +63,8 @@ class PLATFORM_EXPORT CallbackFunctionBase ...@@ -63,6 +63,8 @@ class PLATFORM_EXPORT CallbackFunctionBase
const char* interface_name, const char* interface_name,
const char* operation_name); const char* operation_name);
ScriptState* IncumbentScriptState() { return incumbent_script_state_; }
DOMWrapperWorld& GetWorld() const { return incumbent_script_state_->World(); } DOMWrapperWorld& GetWorld() const { return incumbent_script_state_->World(); }
// Returns true if the ES function has a [[Construct]] internal method. // Returns true if the ES function has a [[Construct]] internal method.
...@@ -93,8 +95,6 @@ class PLATFORM_EXPORT CallbackFunctionBase ...@@ -93,8 +95,6 @@ class PLATFORM_EXPORT CallbackFunctionBase
return callback_function_.NewLocal(GetIsolate()).As<v8::Function>(); return callback_function_.NewLocal(GetIsolate()).As<v8::Function>();
} }
ScriptState* IncumbentScriptState() { return incumbent_script_state_; }
private: private:
// The "callback function type" value. // The "callback function type" value.
// Use v8::Object instead of v8::Function in order to handle // Use v8::Object instead of v8::Function in order to handle
......
...@@ -47,6 +47,10 @@ class PLATFORM_EXPORT CallbackInterfaceBase ...@@ -47,6 +47,10 @@ class PLATFORM_EXPORT CallbackInterfaceBase
return callback_object_.NewLocal(GetIsolate()); return callback_object_.NewLocal(GetIsolate());
} }
// Returns true iff the callback interface is a single operation callback
// interface and the callback interface type value is callable.
bool IsCallbackObjectCallable() const { return is_callback_object_callable_; }
v8::Isolate* GetIsolate() { return incumbent_script_state_->GetIsolate(); } v8::Isolate* GetIsolate() { return incumbent_script_state_->GetIsolate(); }
// Returns the ScriptState of the relevant realm of the callback object. // Returns the ScriptState of the relevant realm of the callback object.
...@@ -74,24 +78,14 @@ class PLATFORM_EXPORT CallbackInterfaceBase ...@@ -74,24 +78,14 @@ class PLATFORM_EXPORT CallbackInterfaceBase
const char* interface_name, const char* interface_name,
const char* operation_name); const char* operation_name);
DOMWrapperWorld& GetWorld() const { return incumbent_script_state_->World(); } ScriptState* IncumbentScriptState() { return incumbent_script_state_; }
// NodeIteratorBase counts the invocation of those which are callable and DOMWrapperWorld& GetWorld() const { return incumbent_script_state_->World(); }
// those which are not.
bool IsCallbackObjectCallableForNodeIteratorBase() const {
return IsCallbackObjectCallable();
}
protected: protected:
explicit CallbackInterfaceBase(v8::Local<v8::Object> callback_object, explicit CallbackInterfaceBase(v8::Local<v8::Object> callback_object,
SingleOperationOrNot); SingleOperationOrNot);
// Returns true iff the callback interface is a single operation callback
// interface and the callback interface type value is callable.
bool IsCallbackObjectCallable() const { return is_callback_object_callable_; }
ScriptState* IncumbentScriptState() { return incumbent_script_state_; }
private: private:
// The "callback interface type" value. // The "callback interface type" value.
TraceWrapperV8Reference<v8::Object> callback_object_; TraceWrapperV8Reference<v8::Object> callback_object_;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "third_party/blink/renderer/platform/bindings/callback_interface_base.h" #include "third_party/blink/renderer/platform/bindings/callback_interface_base.h"
#include "third_party/blink/renderer/platform/bindings/dictionary_base.h" #include "third_party/blink/renderer/platform/bindings/dictionary_base.h"
#include "third_party/blink/renderer/platform/bindings/dom_data_store.h" #include "third_party/blink/renderer/platform/bindings/dom_data_store.h"
#include "third_party/blink/renderer/platform/bindings/enumeration_base.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/bindings/union_base.h" #include "third_party/blink/renderer/platform/bindings/union_base.h"
...@@ -86,6 +87,14 @@ inline v8::Local<v8::Value> ToV8(CallbackInterfaceBase* callback, ...@@ -86,6 +87,14 @@ inline v8::Local<v8::Value> ToV8(CallbackInterfaceBase* callback,
: v8::Null(isolate).As<v8::Value>(); : v8::Null(isolate).As<v8::Value>();
} }
// Enumeration
inline v8::Local<v8::Value> ToV8(const bindings::EnumerationBase& enumeration,
v8::Local<v8::Object> creation_context,
v8::Isolate* isolate) {
return V8String(isolate, enumeration.AsCStr());
}
// Union type // Union type
inline v8::Local<v8::Value> ToV8(const bindings::UnionBase& value, inline v8::Local<v8::Value> ToV8(const bindings::UnionBase& value,
......
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