mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
* chore: bump chromium in DEPS to 121.0.6116.0
* chore: update patches
* Update webIDL to support close event.
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4970653
* Remove uses of implicit conversion of ScopedTypeRef
Refs https://bugs.chromium.org/p/chromium/issues/detail?id=1495439
* Add GlobalRenderFrameHostToken
Refs https://chromium-review.googlesource.com/c/chromium/src/+/5001743
* [DevTools] Console Insights: move from build flag to Feature API
Refs https://chromium-review.googlesource.com/c/chromium/src/+/5002232
* [Extensions] Use script serialization in scripting API
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4968680
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4998265
* [api] Remove AllCan Read/Write
https://chromium-review.googlesource.com/c/v8/v8/+/5006387
* chore: update libcxx files
* chore: address nan compilation error
* spec: use nan dependency from third_party
It is easier to get fixes for spec modules depending on nan
* ci: publish nan artifact for woa
* fix: bad patch update
* chore: update nan resolution
* Revert "chore: update nan resolution"
This reverts commit 786cdb858c.
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
97 lines
3.1 KiB
Plaintext
97 lines
3.1 KiB
Plaintext
// Copyright (c) 2017 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "shell/browser/native_browser_view_mac.h"
|
|
|
|
#include "shell/browser/ui/inspectable_web_contents.h"
|
|
#include "shell/browser/ui/inspectable_web_contents_view.h"
|
|
#include "skia/ext/skia_utils_mac.h"
|
|
#include "ui/gfx/geometry/rect.h"
|
|
|
|
// Match view::Views behavior where the view sticks to the top-left origin.
|
|
const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
|
NSViewMaxXMargin | NSViewMinYMargin;
|
|
|
|
namespace electron {
|
|
|
|
NativeBrowserViewMac::NativeBrowserViewMac(
|
|
InspectableWebContents* inspectable_web_contents)
|
|
: NativeBrowserView(inspectable_web_contents) {
|
|
auto* iwc_view = GetInspectableWebContentsView();
|
|
if (!iwc_view)
|
|
return;
|
|
auto* view = iwc_view->GetNativeView().GetNativeNSView();
|
|
view.autoresizingMask = kDefaultAutoResizingMask;
|
|
}
|
|
|
|
NativeBrowserViewMac::~NativeBrowserViewMac() = default;
|
|
|
|
void NativeBrowserViewMac::SetAutoResizeFlags(uint8_t flags) {
|
|
NSAutoresizingMaskOptions autoresizing_mask = kDefaultAutoResizingMask;
|
|
if (flags & kAutoResizeWidth) {
|
|
autoresizing_mask |= NSViewWidthSizable;
|
|
}
|
|
if (flags & kAutoResizeHeight) {
|
|
autoresizing_mask |= NSViewHeightSizable;
|
|
}
|
|
if (flags & kAutoResizeHorizontal) {
|
|
autoresizing_mask |=
|
|
NSViewMaxXMargin | NSViewMinXMargin | NSViewWidthSizable;
|
|
}
|
|
if (flags & kAutoResizeVertical) {
|
|
autoresizing_mask |=
|
|
NSViewMaxYMargin | NSViewMinYMargin | NSViewHeightSizable;
|
|
}
|
|
|
|
auto* iwc_view = GetInspectableWebContentsView();
|
|
if (!iwc_view)
|
|
return;
|
|
auto* view = iwc_view->GetNativeView().GetNativeNSView();
|
|
view.autoresizingMask = autoresizing_mask;
|
|
}
|
|
|
|
void NativeBrowserViewMac::SetBounds(const gfx::Rect& bounds) {
|
|
auto* iwc_view = GetInspectableWebContentsView();
|
|
if (!iwc_view)
|
|
return;
|
|
|
|
auto* view = iwc_view->GetNativeView().GetNativeNSView();
|
|
const auto superview_height =
|
|
view.superview ? view.superview.frame.size.height : 0;
|
|
int y_coord = superview_height - bounds.y() - bounds.height();
|
|
|
|
view.frame = NSMakeRect(bounds.x(), y_coord, bounds.width(), bounds.height());
|
|
}
|
|
|
|
gfx::Rect NativeBrowserViewMac::GetBounds() {
|
|
auto* iwc_view = GetInspectableWebContentsView();
|
|
if (!iwc_view)
|
|
return gfx::Rect();
|
|
|
|
NSView* view = iwc_view->GetNativeView().GetNativeNSView();
|
|
const int superview_height =
|
|
view.superview ? view.superview.frame.size.height : 0;
|
|
int y_coord = superview_height - view.frame.origin.y - view.frame.size.height;
|
|
|
|
return gfx::Rect(view.frame.origin.x, y_coord, view.frame.size.width,
|
|
view.frame.size.height);
|
|
}
|
|
|
|
void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {
|
|
auto* iwc_view = GetInspectableWebContentsView();
|
|
if (!iwc_view)
|
|
return;
|
|
auto* view = iwc_view->GetNativeView().GetNativeNSView();
|
|
view.wantsLayer = YES;
|
|
view.layer.backgroundColor = skia::CGColorCreateFromSkColor(color).get();
|
|
}
|
|
|
|
// static
|
|
NativeBrowserView* NativeBrowserView::Create(
|
|
InspectableWebContents* inspectable_web_contents) {
|
|
return new NativeBrowserViewMac(inspectable_web_contents);
|
|
}
|
|
|
|
} // namespace electron
|