Commit f2a46333 authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

ozone: headless: Make headless display 1x1 by default

Avoid an arbitrary default display size of 800x600 on headless. Headless
is used on some products that don't have an attached display and having
a large dummy display can cause unnecessary work.

This doesn't stop tests from creating 800x600 windows; it's fine to
create a window larger than the display.

Bug: 1017311, 891613

Change-Id: If0ef5b7f41df5a987c4ce1d819432661e00e2a52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872949
Commit-Queue: Michael Spang <spang@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Auto-Submit: Michael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709215}
parent fbbd2056
......@@ -693,6 +693,20 @@ enum class HitTestType {
kSurfaceLayer,
};
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
bool IsScreenTooSmallForPopup(const ScreenInfo& screen_info) {
// Small display size will cause popup positions to be adjusted,
// causing test failures.
//
// The size adjustment happens in adjustWindowRect()
// (third_party/blink/renderer/core/html/forms/resources/pickerCommon.js
// lines 132-133).
static constexpr gfx::Size kMinimumScreenSize(300, 300);
return screen_info.rect.width() < kMinimumScreenSize.width() ||
screen_info.rect.height() < kMinimumScreenSize.height();
}
#endif
} // namespace
class SitePerProcessHitTestBrowserTest
......@@ -5620,12 +5634,13 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, PopupMenuTest) {
SetWebEventPositions(&click_event, gfx::Point(1, 1), rwhv_root);
rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo());
ScreenInfo screen_info;
shell()->web_contents()->GetRenderWidgetHostView()->GetScreenInfo(
&screen_info);
filter->Wait();
gfx::Rect popup_rect = filter->last_initial_rect();
if (IsUseZoomForDSFEnabled()) {
ScreenInfo screen_info;
shell()->web_contents()->GetRenderWidgetHostView()->GetScreenInfo(
&screen_info);
popup_rect = gfx::ScaleToRoundedRect(popup_rect,
1 / screen_info.device_scale_factor);
}
......@@ -5635,8 +5650,10 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, PopupMenuTest) {
EXPECT_EQ(popup_rect.x(), 9);
EXPECT_EQ(popup_rect.y(), 9);
#else
EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354);
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94);
if (!IsScreenTooSmallForPopup(screen_info)) {
EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354);
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94);
}
#endif
#if defined(OS_LINUX)
......@@ -5756,12 +5773,17 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
gfx::Rect popup_rect = filter->last_initial_rect();
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) || defined(OS_ANDROID)
EXPECT_EQ(popup_rect.x(), 9);
EXPECT_EQ(popup_rect.y(), 9);
#else
EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354);
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 154);
ScreenInfo screen_info;
shell()->web_contents()->GetRenderWidgetHostView()->GetScreenInfo(
&screen_info);
if (!IsScreenTooSmallForPopup(screen_info)) {
EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354);
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 154);
}
#endif
// Save the screen rect for b_node. Since it updates asynchronously from
......@@ -5803,12 +5825,14 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
popup_rect = filter->last_initial_rect();
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) || defined(OS_ANDROID)
EXPECT_EQ(popup_rect.x(), 9);
EXPECT_EQ(popup_rect.y(), 9);
#else
EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 203);
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 248);
if (!IsScreenTooSmallForPopup(screen_info)) {
EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 203);
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 248);
}
#endif
}
......
......@@ -8,6 +8,6 @@ Test the media interface: http://dev.w3.org/csswg/cssom-view/#the-media-interfac
"(color" evaluates to true: PASS
"color" evaluates to false: PASS
"garbage" evaluates to false: PASS
"(min-device-width: 100px)" evaluates to true: PASS
"(min-device-width: 1px)" evaluates to true: PASS
"(min-device-width: 50000px)" evaluates to false: PASS
......@@ -36,7 +36,7 @@
testQuery('garbage', false);
testQuery('(min-device-width: 100px)', true);
testQuery('(min-device-width: 1px)', true);
testQuery('(min-device-width: 50000px)', false);
}
......
......@@ -6,18 +6,12 @@
namespace ui {
namespace {
constexpr gfx::Size kDefaultWindowSize(800, 600);
} // namespace
HeadlessScreen::HeadlessScreen() {
DCHECK_LE(next_display_id_, std::numeric_limits<int64_t>::max());
display::Display display(next_display_id_++);
display.SetScaleAndBounds(1.0f,
gfx::Rect(gfx::Point(0, 0), kDefaultWindowSize));
static constexpr int64_t kHeadlessDisplayId = 1;
static constexpr float kHeadlessDisplayScale = 1.0f;
static constexpr gfx::Rect kHeadlessDisplayBounds(gfx::Size(1, 1));
display::Display display(kHeadlessDisplayId);
display.SetScaleAndBounds(kHeadlessDisplayScale, kHeadlessDisplayBounds);
display_list_.AddDisplay(display, display::DisplayList::Type::PRIMARY);
}
......
......@@ -36,9 +36,6 @@ class HeadlessScreen : public PlatformScreen {
void RemoveObserver(display::DisplayObserver* observer) override;
private:
// The next available display id.
int64_t next_display_id_ = 0;
display::DisplayList display_list_;
base::ObserverList<display::DisplayObserver> observers_;
......
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