feat: replace BrowserView with WebContentsView (#35658)

This commit is contained in:
Jeremy Rose 2023-12-13 13:01:03 -08:00 committed by GitHub
parent a94fb2cb5d
commit 15c6014324
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
76 changed files with 2987 additions and 1531 deletions

View file

@ -7,18 +7,39 @@
#include "base/memory/raw_ptr.h"
#include "gin/handle.h"
#include "shell/common/gin_helper/wrappable.h"
#include "shell/common/color_util.h"
#include "shell/common/gin_helper/event_emitter.h"
#include "ui/views/view.h"
#include "ui/views/view_observer.h"
#include "v8/include/v8-value.h"
namespace electron::api {
class View : public gin_helper::Wrappable<View> {
class View : public gin_helper::EventEmitter<View>, public views::ViewObserver {
public:
static gin_helper::WrappableBase* New(gin::Arguments* args);
static gin::Handle<View> Create(v8::Isolate* isolate);
// Return the cached constructor function.
static v8::Local<v8::Function> GetConstructor(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
void AddChildViewAt(gin::Handle<View> child, absl::optional<size_t> index);
void RemoveChildView(gin::Handle<View> child);
void SetBounds(const gfx::Rect& bounds);
gfx::Rect GetBounds();
void SetLayout(v8::Isolate* isolate, v8::Local<v8::Object> value);
std::vector<v8::Local<v8::Value>> GetChildren();
void SetBackgroundColor(absl::optional<WrappedSkColor> color);
void SetVisible(bool visible);
// views::ViewObserver
void OnViewBoundsChanged(views::View* observed_view) override;
void OnViewIsDeleting(views::View* observed_view) override;
views::View* view() const { return view_; }
// disable copy
@ -34,6 +55,8 @@ class View : public gin_helper::Wrappable<View> {
void set_delete_view(bool should) { delete_view_ = should; }
private:
std::vector<v8::Global<v8::Object>> child_views_;
bool delete_view_ = true;
raw_ptr<views::View> view_ = nullptr;
};