electron/shell/browser/ui/views/opaque_frame_view.h
electron-roller[bot] 3e12da8ed1
chore: bump chromium to 142.0.7444.23 (39-x-y) (#48307)
* chore: bump chromium in DEPS to 142.0.7432.2

* chore: bump chromium in DEPS to 142.0.7434.1

* chore: bump chromium in DEPS to 142.0.7436.1

* chore: bump chromium in DEPS to 142.0.7438.1

* chore: bump chromium in DEPS to 142.0.7440.1

* chore: bump chromium in DEPS to 142.0.7442.1

* chore: bump chromium in DEPS to 142.0.7444.1

* chore: bump chromium in DEPS to 142.0.7444.6

* chore: bump chromium in DEPS to 142.0.7444.3

* 6973697: Use type tags for data stored in V8 internal fields

https://chromium-review.googlesource.com/c/chromium/src/+/6973697

* chore: update patches

* chore: update filenames.libcxx.gni

* fix: parse macOS SDK version across line break
https://chromium-review.googlesource.com/c/chromium/src/+/6980166

(cherry picked from commit 2bcbb33de04fa13e7c923b2420f89c3846f5988b)

* fix: replace v8::Object::SetPrototype() usage
https://chromium-review.googlesource.com/c/v8/v8/+/6983465
https://github.com/nodejs/node/pull/55453

(cherry picked from commit c31b9ed5ac84bbd111c72273d9334af6c50ed374)

* fix: replace additional usages of SetPrototype
https://chromium-review.googlesource.com/c/v8/v8/+/6983465

(cherry picked from commit bf151e9d28520c7dd74cba62240acbcaaab5433d)

* fixup! fix: replace additional usages of SetPrototype https://chromium-review.googlesource.com/c/v8/v8/+/6983465

(cherry picked from commit f4434755b82b098e4d83d42bab26f183b6824f99)

* build: use macos 15 minimum
https://chromium-review.googlesource.com/c/chromium/src/+/6980166

(cherry picked from commit 4d2b5d7b2cf9a1786cdb1a77bf73e4ad0d3e45d1)

* fixup! build: use macos 15 minimum https://chromium-review.googlesource.com/c/chromium/src/+/6980166

(cherry picked from commit 94bb41a66330dcaf6b92c80cfefd72759405793d)

* ci: ignore missing dir for strip_universal_deep

(cherry picked from commit 634963f171bc5f6050151f76973e7ffbab0e00cf)

* chore: update patches

* chore: update patches

* chore: bump chromium in DEPS to 142.0.7444.23

* fix: disable C++ modules in electron_lib builds
https://chromium-review.googlesource.com/c/chromium/src/+/6950738

(cherry picked from commit 6207c79aecae04675b1e258ec14025c3ddfdf270)

* Revert "build: use macos 15 minimum"

This reverts commit 2fc12d6acc1b24f3cbd0adb03122bf6b21eb14b9.

Initially this change was made to test if it fixes libcxx
compilation issues. As that's now resolved by disabling libcxx
modules, this can be reverted.

(cherry picked from commit ad52007d5baffc3da65c0a994943f25da0c3f1c2)

* fix: js2c compilation failure

https://chromium-review.googlesource.com/c/chromium/src/+/6950738

See patch description explaining MacOS 26 SDK headers incompatibility.

(cherry picked from commit 39e2470875cdbf20b86c30ee2c5caa8845465434)

* fix: disable C++ modules in libnode builds

(cherry picked from commit fd0a7b61a151c92729da41eba63fb7ee5b0beebc)

* fixup! fix: replace v8::Object::SetPrototype() usage https://chromium-review.googlesource.com/c/v8/v8/+/6983465 https://github.com/nodejs/node/pull/55453

(cherry picked from commit 2f52159b71ee4aa779dfd3e3050f3b09c2664c36)

* build: switch to macos-15 runner

build/mac/find_sdk.py now requires macOS 15 SDK as a minimum version. The
macos 15 runners default to an Xcode using the 15 SDK and removes older
versions.

(cherry picked from commit e368703f24577e73d904c684a0b4ae53bacfaef2)

* chore: update patches

* fix: partially revert is_headless_mode removal
https://chromium-review.googlesource.com/c/chromium/src/+/6955633

This patch should likely be reworked. For now, this partially reverts the
removal of a required class property to restore behavior.

(cherry picked from commit aff3bf9a244608863bc96b3e2aef911158b29574)

* 6938086: Rename native_widget_types.h -> native_ui_types.h | https://chromium-review.googlesource.com/c/chromium/src/+/6938086

(cherry picked from commit c95ac7bf2b1eda493167b8e36c59d70d86d51429)

* 6973697: Use type tags for data stored in V8 internal fields

https://chromium-review.googlesource.com/c/chromium/src/+/6973697

* fixup! fix: check new forced colors enum value https://chromium-review.googlesource.com/c/chromium/src/+/6944403

(cherry picked from commit 0829c74b2fbcdf03ca462b4b0b76efd727d3d891)

* fix: check new forced colors enum value
https://chromium-review.googlesource.com/c/chromium/src/+/6944403

(cherry picked from commit d5858798074719d19d041fa291c3fd1af8d17f5d)

* feat: add new memory-eviction exit reason
https://chromium-review.googlesource.com/c/chromium/src/+/6991933

(cherry picked from commit 6e63197a2292aece65cd52b7b849d3ff3d10bb90)

* fix: views::NonClientFrameView -> views::FrameView
https://chromium-review.googlesource.com/c/chromium/src/+/7005027
https://chromium-review.googlesource.com/c/chromium/src/+/6966937

(cherry picked from commit 1e86b6ddfb2d19b5bfe30e7539f0a377ffa907ab)

* fix: migrate NetworkConditions -> MatchedNetworkConditions
https://chromium-review.googlesource.com/c/chromium/src/+/6827307

(cherry picked from commit 97100ac1682053d3447e63ed5f03dc2d9938e6ca)

* fix: provide DeviceEmulationCacheBehavior param
https://chromium-review.googlesource.com/c/chromium/src/+/6965238

(cherry picked from commit f9a08c53846ab269c57c14eae6b1c03b163fb30c)

* fix: add missing image_skia include
https://chromium-review.googlesource.com/c/chromium/src/+/6986762

(cherry picked from commit dd5eaf03fd7fbfd49afbe3259c5bf036be566bd9)

* fixup! fix: add missing image_skia include https://chromium-review.googlesource.com/c/chromium/src/+/6986762

(cherry picked from commit 249c4d4de1df4d1588d6fa6fcf5f33b43a6c0f62)

* 6948286: [wasm-imported-strings] Drop feature flag

https://chromium-review.googlesource.com/c/v8/v8/+/6948286

* fix: disable protocol handler DCHECK

https://chromium-review.googlesource.com/c/chromium/src/+/6727594

Ignore the extension custom protocol handler registry DCHECK until
we invest in supporting it. Replacing this DCHECK seems harmless
and will unblock the roll.

(cherry picked from commit 019d3f0b09aeff8aed7991d9669a4ba7f265808b)

* 6986762: Remove some includes of //ui/gfx/image/image_skia.h

https: //chromium-review.googlesource.com/c/chromium/src/+/6986762

* fixup! fix: migrate NetworkConditions -> MatchedNetworkConditions https://chromium-review.googlesource.com/c/chromium/src/+/6827307

(cherry picked from commit a8f67f1ac3f8b07354d9457be9addf242ff70000)

* fixup: 6986762: Remove some includes of //ui/gfx/image/image_skia.h

s

* fix: replace deprecated usage of SetPrototype
https://chromium-review.googlesource.com/c/v8/v8/+/6983465

(cherry picked from commit 5435d87b40c15316bc8828fbc197be647b39b7bb)

* chore: restore electron embedder data tag patch

Co-Authored-By: Sam Maddock <sam@samuelmaddock.com>

* chore: update patches

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
Co-authored-by: Alice Zhao <alicelovescake@anthropic.com>
Co-authored-by: Sam Maddock <sam@samuelmaddock.com>
2025-10-14 11:25:30 -04:00

204 lines
7.9 KiB
C++

// Copyright 2024 Microsoft GmbH.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_OPAQUE_FRAME_VIEW_H_
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_OPAQUE_FRAME_VIEW_H_
#include <vector>
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/view_ids.h"
#include "shell/browser/ui/views/frameless_view.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/linux/window_button_order_observer.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/window/caption_button_types.h"
#include "ui/views/window/frame_buttons.h"
#include "ui/views/window/non_client_view.h"
class CaptionButtonPlaceholderContainer;
namespace electron {
class NativeWindowViews;
class OpaqueFrameView : public FramelessView {
METADATA_HEADER(OpaqueFrameView, FramelessView)
public:
// Constants used by OpaqueBrowserFrameView as well.
static const int kContentEdgeShadowThickness;
static constexpr int kNonClientExtraTopThickness = 1;
OpaqueFrameView();
~OpaqueFrameView() override;
// FramelessView:
void Init(NativeWindowViews* window, views::Widget* frame) override;
int ResizingBorderHitTest(const gfx::Point& point) override;
void InvalidateCaptionButtons() override;
// views::FrameView:
gfx::Rect GetBoundsForClientView() const override;
gfx::Rect GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const override;
int NonClientHitTest(const gfx::Point& point) override;
void ResetWindowControls() override;
views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override;
// views::View:
void Layout(PassKey) override;
void OnPaint(gfx::Canvas* canvas) override;
private:
enum ButtonAlignment { ALIGN_LEADING, ALIGN_TRAILING };
struct TopAreaPadding {
int leading;
int trailing;
};
void PaintAsActiveChanged();
void UpdateCaptionButtonPlaceholderContainerBackground();
void UpdateFrameCaptionButtons();
void LayoutWindowControls();
void LayoutWindowControlsOverlay();
// Creates and returns an ImageButton with |this| as its listener.
// Memory is owned by the caller.
views::Button* CreateButton(ViewID view_id,
int accessibility_string_id,
views::CaptionButtonIcon icon_type,
int ht_component,
const gfx::VectorIcon& icon_image,
views::Button::PressedCallback callback);
/** Layout-Related Utility Functions **/
// Returns the insets from the native window edge to the client view.
// This does not include any client edge. If |restored| is true, this
// is calculated as if the window was restored, regardless of its
// current node_data.
gfx::Insets FrameBorderInsets(bool restored) const;
// Returns the thickness of the border that makes up the window frame edge
// along the top of the frame. If |restored| is true, this acts as if the
// window is restored regardless of the actual mode.
int FrameTopBorderThickness(bool restored) const;
// Returns the spacing between the edge of the browser window and the first
// frame buttons.
TopAreaPadding GetTopAreaPadding(bool has_leading_buttons,
bool has_trailing_buttons) const;
// Determines whether the top frame is condensed vertically, as when the
// window is maximized. If true, the top frame is just the height of a tab,
// rather than having extra vertical space above the tabs.
bool IsFrameCondensed() const;
// The insets from the native window edge to the client view when the window
// is restored. This goes all the way to the web contents on the left, right,
// and bottom edges.
gfx::Insets RestoredFrameBorderInsets() const;
// The insets from the native window edge to the flat portion of the
// window border. That is, this function returns the "3D portion" of the
// border when the window is restored. The returned insets will not be larger
// than RestoredFrameBorderInsets().
gfx::Insets RestoredFrameEdgeInsets() const;
// Additional vertical padding between tabs and the top edge of the window
// when the window is restored.
int NonClientExtraTopThickness() const;
// Returns the height of the entire nonclient top border, from the edge of the
// window to the top of the tabs. If |restored| is true, this is calculated as
// if the window was restored, regardless of its current state.
int NonClientTopHeight(bool restored) const;
// Returns the y-coordinate of button |button_id|. If |restored| is true,
// acts as if the window is restored regardless of the real mode.
int CaptionButtonY(views::FrameButton button_id, bool restored) const;
// Returns the y-coordinate of the caption button when native frame buttons
// are disabled. If |restored| is true, acts as if the window is restored
// regardless of the real mode.
int DefaultCaptionButtonY(bool restored) const;
// Returns the insets from the native window edge to the flat portion of the
// window border. That is, this function returns the "3D portion" of the
// border. If |restored| is true, acts as if the window is restored
// regardless of the real mode.
gfx::Insets FrameEdgeInsets(bool restored) const;
// Returns the size of the window icon. This can be platform dependent
// because of differences in fonts.
int GetIconSize() const;
// Returns the spacing between the edge of the browser window and the first
// frame buttons.
TopAreaPadding GetTopAreaPadding() const;
// Returns the color of the frame.
SkColor GetFrameColor() const;
// Initializes the button with |button_id| to be aligned according to
// |alignment|.
void ConfigureButton(views::FrameButton button_id, ButtonAlignment alignment);
// Sets the visibility of all buttons associated with |button_id| to false.
void HideButton(views::FrameButton button_id);
// Adds a window caption button to either the leading or trailing side.
void SetBoundsForButton(views::FrameButton button_id,
views::Button* button,
ButtonAlignment alignment);
// Computes the height of the top area of the frame.
int GetTopAreaHeight() const;
// Returns the margin around button |button_id|. If |leading_spacing| is
// true, returns the left margin (in RTL), otherwise returns the right margin
// (in RTL). Extra margin may be added if |is_leading_button| is true.
int GetWindowCaptionSpacing(views::FrameButton button_id,
bool leading_spacing,
bool is_leading_button) const;
// Window controls.
raw_ptr<views::Button> minimize_button_;
raw_ptr<views::Button> maximize_button_;
raw_ptr<views::Button> restore_button_;
raw_ptr<views::Button> close_button_;
// The leading and trailing x positions of the empty space available for
// laying out titlebar elements.
int available_space_leading_x_ = 0;
int available_space_trailing_x_ = 0;
// Whether any of the window control buttons were packed on the leading or
// trailing sides. This state is only valid while layout is being performed.
bool placed_leading_button_ = false;
bool placed_trailing_button_ = false;
// The size of the window buttons. This does not count labels or other
// elements that should be counted in a minimal frame.
int minimum_size_for_buttons_ = 0;
std::vector<views::FrameButton> leading_buttons_;
std::vector<views::FrameButton> trailing_buttons_{
views::FrameButton::kMinimize, views::FrameButton::kMaximize,
views::FrameButton::kClose};
base::CallbackListSubscription paint_as_active_changed_subscription_;
// PlaceholderContainer beneath the controls button for WCO.
raw_ptr<CaptionButtonPlaceholderContainer>
caption_button_placeholder_container_;
};
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_UI_VIEWS_OPAQUE_FRAME_VIEW_H_