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 { ...@@ -693,6 +693,20 @@ enum class HitTestType {
kSurfaceLayer, 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 } // namespace
class SitePerProcessHitTestBrowserTest class SitePerProcessHitTestBrowserTest
...@@ -5620,12 +5634,13 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, PopupMenuTest) { ...@@ -5620,12 +5634,13 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, PopupMenuTest) {
SetWebEventPositions(&click_event, gfx::Point(1, 1), rwhv_root); SetWebEventPositions(&click_event, gfx::Point(1, 1), rwhv_root);
rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo());
ScreenInfo screen_info;
shell()->web_contents()->GetRenderWidgetHostView()->GetScreenInfo(
&screen_info);
filter->Wait(); filter->Wait();
gfx::Rect popup_rect = filter->last_initial_rect(); gfx::Rect popup_rect = filter->last_initial_rect();
if (IsUseZoomForDSFEnabled()) { if (IsUseZoomForDSFEnabled()) {
ScreenInfo screen_info;
shell()->web_contents()->GetRenderWidgetHostView()->GetScreenInfo(
&screen_info);
popup_rect = gfx::ScaleToRoundedRect(popup_rect, popup_rect = gfx::ScaleToRoundedRect(popup_rect,
1 / screen_info.device_scale_factor); 1 / screen_info.device_scale_factor);
} }
...@@ -5635,8 +5650,10 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, PopupMenuTest) { ...@@ -5635,8 +5650,10 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, PopupMenuTest) {
EXPECT_EQ(popup_rect.x(), 9); EXPECT_EQ(popup_rect.x(), 9);
EXPECT_EQ(popup_rect.y(), 9); EXPECT_EQ(popup_rect.y(), 9);
#else #else
EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); if (!IsScreenTooSmallForPopup(screen_info)) {
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94); EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354);
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94);
}
#endif #endif
#if defined(OS_LINUX) #if defined(OS_LINUX)
...@@ -5756,12 +5773,17 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, ...@@ -5756,12 +5773,17 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
gfx::Rect popup_rect = filter->last_initial_rect(); 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.x(), 9);
EXPECT_EQ(popup_rect.y(), 9); EXPECT_EQ(popup_rect.y(), 9);
#else #else
EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); ScreenInfo screen_info;
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 154); 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 #endif
// Save the screen rect for b_node. Since it updates asynchronously from // Save the screen rect for b_node. Since it updates asynchronously from
...@@ -5803,12 +5825,14 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, ...@@ -5803,12 +5825,14 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
popup_rect = filter->last_initial_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.x(), 9);
EXPECT_EQ(popup_rect.y(), 9); EXPECT_EQ(popup_rect.y(), 9);
#else #else
EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 203); if (!IsScreenTooSmallForPopup(screen_info)) {
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 248); EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 203);
EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 248);
}
#endif #endif
} }
......
...@@ -8,6 +8,6 @@ Test the media interface: http://dev.w3.org/csswg/cssom-view/#the-media-interfac ...@@ -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 true: PASS
"color" evaluates to false: PASS "color" evaluates to false: PASS
"garbage" 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 "(min-device-width: 50000px)" evaluates to false: PASS
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
testQuery('garbage', false); testQuery('garbage', false);
testQuery('(min-device-width: 100px)', true); testQuery('(min-device-width: 1px)', true);
testQuery('(min-device-width: 50000px)', false); testQuery('(min-device-width: 50000px)', false);
} }
......
...@@ -6,18 +6,12 @@ ...@@ -6,18 +6,12 @@
namespace ui { namespace ui {
namespace {
constexpr gfx::Size kDefaultWindowSize(800, 600);
} // namespace
HeadlessScreen::HeadlessScreen() { HeadlessScreen::HeadlessScreen() {
DCHECK_LE(next_display_id_, std::numeric_limits<int64_t>::max()); static constexpr int64_t kHeadlessDisplayId = 1;
static constexpr float kHeadlessDisplayScale = 1.0f;
display::Display display(next_display_id_++); static constexpr gfx::Rect kHeadlessDisplayBounds(gfx::Size(1, 1));
display.SetScaleAndBounds(1.0f, display::Display display(kHeadlessDisplayId);
gfx::Rect(gfx::Point(0, 0), kDefaultWindowSize)); display.SetScaleAndBounds(kHeadlessDisplayScale, kHeadlessDisplayBounds);
display_list_.AddDisplay(display, display::DisplayList::Type::PRIMARY); display_list_.AddDisplay(display, display::DisplayList::Type::PRIMARY);
} }
......
...@@ -36,9 +36,6 @@ class HeadlessScreen : public PlatformScreen { ...@@ -36,9 +36,6 @@ class HeadlessScreen : public PlatformScreen {
void RemoveObserver(display::DisplayObserver* observer) override; void RemoveObserver(display::DisplayObserver* observer) override;
private: private:
// The next available display id.
int64_t next_display_id_ = 0;
display::DisplayList display_list_; display::DisplayList display_list_;
base::ObserverList<display::DisplayObserver> observers_; 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