mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
* 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 commit2bcbb33de0) * 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 commitc31b9ed5ac) * 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 commit6207c79aec) * Revert "build: use macos 15 minimum" This reverts commit2fc12d6acc. 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 commitad52007d5b) * 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 commit39e2470875) * fix: disable C++ modules in libnode builds (cherry picked from commitfd0a7b61a1) * 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 commit2f52159b71) * 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 commite368703f24) * 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 commitaff3bf9a24) * 6938086: Rename native_widget_types.h -> native_ui_types.h | https://chromium-review.googlesource.com/c/chromium/src/+/6938086 (cherry picked from commitc95ac7bf2b) * 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 commit0829c74b2f) * fix: check new forced colors enum value https://chromium-review.googlesource.com/c/chromium/src/+/6944403 (cherry picked from commitd585879807) * feat: add new memory-eviction exit reason https://chromium-review.googlesource.com/c/chromium/src/+/6991933 (cherry picked from commit6e63197a22) * 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 commit1e86b6ddfb) * fix: migrate NetworkConditions -> MatchedNetworkConditions https://chromium-review.googlesource.com/c/chromium/src/+/6827307 (cherry picked from commit97100ac168) * fix: provide DeviceEmulationCacheBehavior param https://chromium-review.googlesource.com/c/chromium/src/+/6965238 (cherry picked from commitf9a08c5384) * fix: add missing image_skia include https://chromium-review.googlesource.com/c/chromium/src/+/6986762 (cherry picked from commitdd5eaf03fd) * fixup! fix: add missing image_skia include https://chromium-review.googlesource.com/c/chromium/src/+/6986762 (cherry picked from commit249c4d4de1) * 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 commit019d3f0b09) * 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 commita8f67f1ac3) * 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 commit5435d87b40) * 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>
205 lines
7.9 KiB
C++
205 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_
|