Commit f530556a authored by Jimmy Gong's avatar Jimmy Gong Committed by Chromium LUCI CQ

Return preferred size of the system web dialog when laptop's lid is closed

SystemWebDialogDelegate::ComputeDialogSizeForInternalScreen() returns a
valid dialog size only if the internal screen is available or if there
is no internal screen in the device hardware. There is another edge case
where the laptop's lid is closed which makes the internal screen
unavailable. We were previously not handling this edge case and returned
a (0,0) size for these dialogs. The fix is to return the preferred size
for this edge case.

Fixed: 1157591
Change-Id: I023dfcde33a1099aa14ac487e9ad109c1b9ad3a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2590688
Commit-Queue: Jimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836918}
parent e9406f77
...@@ -70,17 +70,21 @@ gfx::Size SystemWebDialogDelegate::ComputeDialogSizeForInternalScreen( ...@@ -70,17 +70,21 @@ gfx::Size SystemWebDialogDelegate::ComputeDialogSizeForInternalScreen(
if (!display::Display::HasInternalDisplay()) if (!display::Display::HasInternalDisplay())
return preferred_size; return preferred_size;
// According to the Chrome OS dialog spec, dialogs should have a 48px margin
// from the edge of an internal display.
static const gfx::Insets margins =
gfx::Insets(kDialogMarginForInternalScreenPx);
display::Display internal_display; display::Display internal_display;
if (!display::Screen::GetScreen()->GetDisplayWithDisplayId( if (!display::Screen::GetScreen()->GetDisplayWithDisplayId(
display::Display::InternalDisplayId(), &internal_display)) { display::Display::InternalDisplayId(), &internal_display)) {
NOTREACHED() << "Could not fetch metadata for internal display."; // GetDisplayWithDisplayId() returns false if the laptop's lid is closed.
// Return the preferred size instead.
// TODO(crbug/1158631): Test this edge case with displays
// (lid closed with external monitors).
return preferred_size;
} }
// According to the Chrome OS dialog spec, dialogs should have a 48px margin
// from the edge of an internal display.
static const gfx::Insets margins =
gfx::Insets(kDialogMarginForInternalScreenPx);
// Work area size does not include the status bar. // Work area size does not include the status bar.
gfx::Size work_area_size = internal_display.work_area_size(); gfx::Size work_area_size = internal_display.work_area_size();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment