0

Refactor HWNDMessageHandler::SizeConstraintsChanged()

Separate the logic to determine whether WS_FOO bits should be set from
the code that actually (un)set the bits.

Change-Id: I1396c22d59e274b1165dc54aac804e6cc621eaff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6378687
Reviewed-by: Robert Liao <robliao@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1436294}
This commit is contained in:
Lei Zhang
2025-03-21 14:32:01 -07:00
committed by Chromium LUCI CQ
parent 483b244f28
commit cc5bac16f7

@@ -1036,19 +1036,19 @@ void HWNDMessageHandler::SizeConstraintsChanged() {
// Windows cannot have WS_THICKFRAME set if translucent.
// See CalculateWindowStylesFromInitParams().
if (delegate_->CanResize() && !is_translucent_) {
style |= WS_THICKFRAME | WS_MAXIMIZEBOX;
if (!delegate_->CanMaximize()) {
style &= ~WS_MAXIMIZEBOX;
const bool thick_frame = !is_translucent_ && delegate_->CanResize();
bool can_maximize = thick_frame && delegate_->CanMaximize();
auto set_style_func = [](LONG& style, LONG bit, bool should_set) {
if (should_set) {
style |= bit;
} else {
style &= ~bit;
}
} else {
style &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
}
if (delegate_->CanMinimize()) {
style |= WS_MINIMIZEBOX;
} else {
style &= ~WS_MINIMIZEBOX;
}
};
set_style_func(style, WS_THICKFRAME, thick_frame);
set_style_func(style, WS_MAXIMIZEBOX, can_maximize);
set_style_func(style, WS_MINIMIZEBOX, delegate_->CanMinimize());
SetWindowLong(hwnd(), GWL_STYLE, style);
}