Files
electron/shell/browser/ui/electron_desktop_window_tree_host_linux.cc
electron-roller[bot] 8c89137ecd chore: bump chromium to 122.0.6194.0 (main) (#40750)
* chore: bump chromium in DEPS to 122.0.6180.0

* chore: update render_widget_host_view_base.patch

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

minor manual changes to match upstream changes

* chore: update printing.patch

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

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

Update patch to upstream changes in print_view_manager_base.cc.
CC @codebytere for 👀

* chore: update feat_add_onclose_to_messageport.patch

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

no manual changes; patch applied with fuzz 1

* chore: update build_do_not_depend_on_packed_resource_integrity.patch

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

minor manual changes to match upstream changes

* chore: update port_autofill_colors_to_the_color_pipeline.patch

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

no manual changes; patch applied with fuzz 2

* chore: update revert_api_dcheck-fail_when_we_reenter_v8_while_terminating.patch

Xref: https://chromium-review.googlesource.com/c/v8/v8/+/5076902
Xref: https://chromium-review.googlesource.com/c/v8/v8/+/5096253

The `bailout_value` variable, which allowed us to fail gracefully in
these macros, has been removed upstream. This raises the temperature
on https://github.com/electron/electron/issues/40741 ...

Since we don't have a bailout value, return a default-constructed
instance of whatever the return type is of the function that invokes
the macro.

* Remove performActionOnRemotePage

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

It appears it is not used by anything within Chromium or outside.

* perf: in SubmenuButton ctor, move() the PressedCallback

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

The copy construtor is more expensive and has been removed upstream

* chore: update constructor call for ElectronExtensionsRendererClient::dispatcher_

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

* chore: handle CAPTURED_SURFACE_CONTROL in Converter<blink::PermissionType>::ToV8()

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

* chore: e patches all

* chore: bump chromium to 122.0.6181.0

* chore: e patches all

* refactor: Add lookup for per-RenderFrame SpellCheckProvider

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

Previously we could pass a routing ID into the spellcheck methods.
This ID arg has been replaced with a SpellCheckHost& arg.

We can get the SpellCheckHost from an accessor in SpellCheckProvider,
which was already being created on a per-render-frame basis in
RenderClientBase.

This commit adds a RenderFrame-to-SpellCheckProvider accessor
in RenderClientBase so that it can be used to get that needed
SpellCheckHost.

* chore: make lint happy

* chore: restore the will_cause_resize arg to WebContents::ExitFullscreen

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

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

upstream reverted this change

* chore: bump chromium in DEPS to 122.0.6182.0

* chore: update patches

* chore: fix virtual function names that were renamed upstream

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

* chore: handle new blink::PermissionType::SMART_CARD in PermissionType converter

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

* chore: node script/gen-libc++-filenames.js

* fixup! chore: update build_do_not_depend_on_packed_resource_integrity.patch

* chore: remove revert_api_dcheck-fail_when_we_reenter_v8_while_terminating.patch

The previous experiment of removing the DCHECK in 35093783 was a huge
failure. We either need to either:

A) use upstream as-is and fix the DCHECK failure, or
B) revert https://chromium-review.googlesource.com/c/v8/v8/+/5076902 too
C) find some other workaround

This commit is the first half of option A, removing the patch to use
upstream as-is.

* chore: bump chromium in DEPS to 122.0.6184.0

* chore: bump chromium in DEPS to 122.0.6186.0

* chore; update mas_avoid_private_macos_api_usage.patch.patch

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

minor manual changes to match upstream changes

* chore: update build_do_not_depend_on_packed_resource_integrity.patch

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

minor manual changes to match upstream changes

* chore: update fix_move_autopipsettingshelper_behind_branding_buildflag.patch

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

no manual changes; patch applied with fuzz 1

* chore: e patches all

* chore: add refactor_update_node-platform_to_match_v8-platform_api_changes.patch

* chore: bump chromium in DEPS to 122.0.6188.0

* chore: bump chromium in DEPS to 122.0.6190.0

* chore: bump chromium in DEPS to 122.0.6192.0

* chore: bump chromium in DEPS to 122.0.6194.0

* Remove an unnecessary DCHECK which causes Lacros to crash.

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

* [FixIt Week] Add shared regular profile function that includes ash

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

* Simplify the PrintManagerHost::ScriptedPrint() call

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

* [local compile hints] Add tests

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

* chore: update patches

* fixup! chore: add refactor_update_node-platform_to_match_v8-platform_api_changes.patch

* chore: node script/gen-libc++-filenames.js

* Remove //ui/ozone/buildflags.h

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

* fixup! Remove //ui/ozone/buildflags.h

* fixup! Remove //ui/ozone/buildflags.h

* chore: update patches

* fixup! refactor: Add lookup for per-RenderFrame SpellCheckProvider

* fixup! Remove //ui/ozone/buildflags.h

* Add permission policy verification in PermissionControllerImpl

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

* fix: ensure spellcheck interface is registered for frame

* [exceptions] Unify pending and scheduled exceptions

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

* fix: dchecks in node.js tests

* fix: try adding termination check

* chore: document breaking iframe change

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2024-01-03 09:52:49 +01:00

223 lines
7.9 KiB
C++

// Copyright (c) 2021 Ryan Gonzalez.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
// Portions of this file are sourced from
// chrome/browser/ui/views/frame/browser_desktop_window_tree_host_linux.cc,
// Copyright (c) 2019 The Chromium Authors,
// which is governed by a BSD-style license
#include "shell/browser/ui/electron_desktop_window_tree_host_linux.h"
#include <vector>
#include "base/feature_list.h"
#include "base/i18n/rtl.h"
#include "shell/browser/native_window_features.h"
#include "shell/browser/ui/views/client_frame_view_linux.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/linux/linux_ui.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/platform_window/platform_window.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
#include "ui/views/window/non_client_view.h"
namespace electron {
ElectronDesktopWindowTreeHostLinux::ElectronDesktopWindowTreeHostLinux(
NativeWindowViews* native_window_view,
views::DesktopNativeWidgetAura* desktop_native_widget_aura)
: views::DesktopWindowTreeHostLinux(native_window_view->widget(),
desktop_native_widget_aura),
native_window_view_(native_window_view) {}
ElectronDesktopWindowTreeHostLinux::~ElectronDesktopWindowTreeHostLinux() =
default;
bool ElectronDesktopWindowTreeHostLinux::SupportsClientFrameShadow() const {
return platform_window()->CanSetDecorationInsets() &&
platform_window()->IsTranslucentWindowOpacitySupported();
}
void ElectronDesktopWindowTreeHostLinux::OnWidgetInitDone() {
views::DesktopWindowTreeHostLinux::OnWidgetInitDone();
UpdateFrameHints();
}
void ElectronDesktopWindowTreeHostLinux::OnBoundsChanged(
const BoundsChange& change) {
views::DesktopWindowTreeHostLinux::OnBoundsChanged(change);
UpdateFrameHints();
if (ui::OzonePlatform::GetInstance()
->GetPlatformProperties()
.electron_can_call_x11) {
// The OnWindowStateChanged should receive all updates but currently under
// X11 it doesn't receive changes to the fullscreen status because chromium
// is handling the fullscreen state changes synchronously, see
// X11Window::ToggleFullscreen in ui/ozone/platform/x11/x11_window.cc.
UpdateWindowState(platform_window()->GetPlatformWindowState());
}
}
void ElectronDesktopWindowTreeHostLinux::OnWindowStateChanged(
ui::PlatformWindowState old_state,
ui::PlatformWindowState new_state) {
views::DesktopWindowTreeHostLinux::OnWindowStateChanged(old_state, new_state);
UpdateFrameHints();
UpdateWindowState(new_state);
}
void ElectronDesktopWindowTreeHostLinux::OnWindowTiledStateChanged(
ui::WindowTiledEdges new_tiled_edges) {
static_cast<ClientFrameViewLinux*>(
native_window_view_->widget()->non_client_view()->frame_view())
->set_tiled_edges(new_tiled_edges);
UpdateFrameHints();
}
void ElectronDesktopWindowTreeHostLinux::UpdateWindowState(
ui::PlatformWindowState new_state) {
if (window_state_ == new_state)
return;
switch (window_state_) {
case ui::PlatformWindowState::kMinimized:
native_window_view_->NotifyWindowRestore();
break;
case ui::PlatformWindowState::kMaximized:
native_window_view_->NotifyWindowUnmaximize();
break;
case ui::PlatformWindowState::kFullScreen:
native_window_view_->NotifyWindowLeaveFullScreen();
break;
case ui::PlatformWindowState::kUnknown:
case ui::PlatformWindowState::kNormal:
case ui::PlatformWindowState::kSnappedPrimary:
case ui::PlatformWindowState::kSnappedSecondary:
case ui::PlatformWindowState::kFloated:
break;
}
switch (new_state) {
case ui::PlatformWindowState::kMinimized:
native_window_view_->NotifyWindowMinimize();
break;
case ui::PlatformWindowState::kMaximized:
native_window_view_->NotifyWindowMaximize();
break;
case ui::PlatformWindowState::kFullScreen:
native_window_view_->NotifyWindowEnterFullScreen();
break;
case ui::PlatformWindowState::kUnknown:
case ui::PlatformWindowState::kNormal:
case ui::PlatformWindowState::kSnappedPrimary:
case ui::PlatformWindowState::kSnappedSecondary:
case ui::PlatformWindowState::kFloated:
break;
}
window_state_ = new_state;
}
void ElectronDesktopWindowTreeHostLinux::OnNativeThemeUpdated(
ui::NativeTheme* observed_theme) {
UpdateFrameHints();
}
void ElectronDesktopWindowTreeHostLinux::OnDeviceScaleFactorChanged() {
UpdateFrameHints();
}
void ElectronDesktopWindowTreeHostLinux::UpdateFrameHints() {
if (base::FeatureList::IsEnabled(features::kWaylandWindowDecorations)) {
if (SupportsClientFrameShadow() && native_window_view_->has_frame() &&
native_window_view_->has_client_frame()) {
UpdateClientDecorationHints(static_cast<ClientFrameViewLinux*>(
native_window_view_->widget()->non_client_view()->frame_view()));
}
SizeConstraintsChanged();
}
}
void ElectronDesktopWindowTreeHostLinux::UpdateClientDecorationHints(
ClientFrameViewLinux* view) {
ui::PlatformWindow* window = platform_window();
bool showing_frame = !native_window_view_->IsFullscreen();
float scale = device_scale_factor();
bool should_set_opaque_region = window->IsTranslucentWindowOpacitySupported();
gfx::Insets insets;
gfx::Insets input_insets;
if (showing_frame) {
insets = view->GetBorderDecorationInsets();
if (base::i18n::IsRTL()) {
insets.set_left_right(insets.right(), insets.left());
}
input_insets = view->GetInputInsets();
}
const auto tiled_edges = view->tiled_edges();
if (tiled_edges.left)
insets.set_left(0);
if (tiled_edges.right)
insets.set_right(0);
if (tiled_edges.top)
insets.set_top(0);
if (tiled_edges.bottom)
insets.set_bottom(0);
gfx::Insets scaled_insets = gfx::ScaleToCeiledInsets(insets, scale);
window->SetDecorationInsets(&scaled_insets);
gfx::Rect input_bounds(view->GetWidget()->GetWindowBoundsInScreen().size());
input_bounds.Inset(insets + input_insets);
window->SetInputRegion(gfx::ScaleToEnclosingRect(input_bounds, scale));
if (should_set_opaque_region) {
// The opaque region is a list of rectangles that contain only fully
// opaque pixels of the window. We need to convert the clipping
// rounded-rect into this format.
SkRRect rrect = view->GetRoundedWindowContentBounds();
gfx::RectF rectf(view->GetWindowContentBounds());
rectf.Scale(scale);
// It is acceptable to omit some pixels that are opaque, but the region
// must not include any translucent pixels. Therefore, we must
// conservatively scale to the enclosed rectangle.
gfx::Rect rect = gfx::ToEnclosedRect(rectf);
// Create the initial region from the clipping rectangle without rounded
// corners.
SkRegion region(gfx::RectToSkIRect(rect));
// Now subtract out the small rectangles that cover the corners.
struct {
SkRRect::Corner corner;
bool left;
bool upper;
} kCorners[] = {
{SkRRect::kUpperLeft_Corner, true, true},
{SkRRect::kUpperRight_Corner, false, true},
{SkRRect::kLowerLeft_Corner, true, false},
{SkRRect::kLowerRight_Corner, false, false},
};
for (const auto& corner : kCorners) {
auto radii = rrect.radii(corner.corner);
auto rx = std::ceil(scale * radii.x());
auto ry = std::ceil(scale * radii.y());
auto corner_rect = SkIRect::MakeXYWH(
corner.left ? rect.x() : rect.right() - rx,
corner.upper ? rect.y() : rect.bottom() - ry, rx, ry);
region.op(corner_rect, SkRegion::kDifference_Op);
}
// Convert the region to a list of rectangles.
std::vector<gfx::Rect> opaque_region;
for (SkRegion::Iterator i(region); !i.done(); i.next())
opaque_region.emplace_back(gfx::SkIRectToRect(i.rect()));
window->SetOpaqueRegion(opaque_region);
}
}
} // namespace electron