Commit 4143bf38 authored by Shawn Gallea's avatar Shawn Gallea Committed by Commit Bot

Add extra rounded corners case

Adds rounded corners if the topmost visible window
has a visible unmanaged app as a parent.

Bug: b/168272523
Test: Locally on device
Change-Id: Ic23f38e12b4a3aa873777def8271a5f8c2e3d537
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2407073Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Shawn Gallea <sagallea@google.com>
Cr-Commit-Position: refs/heads/master@{#807032}
parent 1893b6c0
...@@ -33,6 +33,17 @@ aura::Window* FindTopmostVisibleNonCornersWindow( ...@@ -33,6 +33,17 @@ aura::Window* FindTopmostVisibleNonCornersWindow(
return window->id() != CastWindowManager::CORNERS_OVERLAY ? window : nullptr; return window->id() != CastWindowManager::CORNERS_OVERLAY ? window : nullptr;
} }
bool HasNonAppParent(const aura::Window* window) {
const aura::Window* parent = window->parent();
while (parent && parent->IsVisible()) {
if (parent->id() != CastWindowManager::APP)
return true;
else
parent = parent->parent();
}
return false;
}
} // namespace } // namespace
// Keeps track of the creation and destruction of webview container windows, and // Keeps track of the creation and destruction of webview container windows, and
...@@ -101,9 +112,12 @@ class RoundedCornersObserver : public aura::WindowObserver, ...@@ -101,9 +112,12 @@ class RoundedCornersObserver : public aura::WindowObserver,
return; return;
int window_id = topmost_visible_window->id(); int window_id = topmost_visible_window->id();
// The window may be a child to a visible non-app window that does not draw
// its own corners, so this needs to be checked for.
bool set_rounded_corners = bool set_rounded_corners =
(window_id != CastWindowManager::APP) || (window_id != CastWindowManager::APP) ||
base::Contains(observed_container_windows_, topmost_visible_window); base::Contains(observed_container_windows_, topmost_visible_window) ||
HasNonAppParent(topmost_visible_window);
if (rounded_corners_ == set_rounded_corners) if (rounded_corners_ == set_rounded_corners)
return; return;
......
...@@ -344,4 +344,32 @@ TEST_F(RoundedWindowCornersManagerTest, ...@@ -344,4 +344,32 @@ TEST_F(RoundedWindowCornersManagerTest,
webview = nullptr; webview = nullptr;
} }
TEST_F(RoundedWindowCornersManagerTest, UnmanagedAppWithChild) {
aura::Window* root_window = mock_cast_window_manager_->GetRootWindow();
root_window->Show();
std::unique_ptr<aura::Window> window_host =
std::make_unique<aura::Window>(nullptr);
window_host->Init(ui::LAYER_TEXTURED);
window_host->Show();
root_window->AddChild(window_host.get());
std::unique_ptr<aura::Window> unmanaged_app =
std::make_unique<aura::Window>(nullptr);
unmanaged_app->Init(ui::LAYER_TEXTURED);
unmanaged_app->set_id(CastWindowManager::UNMANAGED_APP);
window_host->AddChild(unmanaged_app.get());
EXPECT_CALL(*mock_cast_window_manager_, SetEnableRoundedCorners(true));
unmanaged_app->Show();
std::unique_ptr<aura::Window> child = std::make_unique<aura::Window>(nullptr);
child->Init(ui::LAYER_TEXTURED);
unmanaged_app->AddChild(child.get());
// Rounded corners should be retained if the unmanaged app parent is visible.
child->Show();
child = nullptr;
EXPECT_CALL(*mock_cast_window_manager_, SetEnableRoundedCorners(false));
unmanaged_app = nullptr;
}
} // namespace chromecast } // namespace chromecast
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