chromium/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_handler.h

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_OBSERVABLE_ARRAY_EXOTIC_OBJECT_HANDLER_H_
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_OBSERVABLE_ARRAY_EXOTIC_OBJECT_HANDLER_H_

#include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/observable_array.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/v8_binding.h"
#include "third_party/blink/renderer/platform/bindings/v8_set_return_value.h"
#include "third_party/blink/renderer/platform/bindings/wrapper_type_info.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "v8/include/v8-container.h"
#include "v8/include/v8-function-callback.h"
#include "v8/include/v8-object.h"
#include "v8/include/v8-primitive.h"

namespace blink {

namespace bindings {

// ObservableArrayExoticObjectHandler implements a handler object which is part
// of an observable array exotic object.
//
//   let observable_array_exotic_object = new Proxy(target, handler);
// where
//   target = v8::Array that has a private property to the V8 wrapper of Blink
//       implementation of observable array backing list object.
//   handler = v8::Object that has a set of trap functions implemented in
//       ObservableArrayExoticObjectHandler.
//
// https://webidl.spec.whatwg.org/#creating-an-observable-array-exotic-object
//
// Implementation notes:
// - v8::Value::ToArrayIndex returns an empty handle if the conversion fails
//   without throwing an exception despite that the return type is
//   v8::MaybeLocal.
// - The case of 'the property == an array index' has priority over the case of
//   'the property == "length"' in order to optimize the former case, which is
//   likely to happen more frequently.
template <typename BackingListWrappable, typename ElementIdlType>
class ObservableArrayExoticObjectHandler {};

}  // namespace bindings

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_OBSERVABLE_ARRAY_EXOTIC_OBJECT_HANDLER_H_