Commit 632a8797 authored by Ria Jiang's avatar Ria Jiang Committed by Commit Bot

Set hit-test data child surface flag based on embed_frame_sink_id_.

This CL moves |embed_frame_sink_id_| from WindowPortMus to aura::Window.
When a window is an embed window, |embed_frame_sink_id_| gets set from
WindowPortMus(WindowServer) or RenderWidgetHostViewAura. It adds
IsEmbeddingClient() in aura::Window to determine if a window should be
a child surface based on that.

Bug: 732395
Test: aura_unittests
Change-Id: I4f25491b55a031cd10a3440c9066abcdf607ff39
Reviewed-on: https://chromium-review.googlesource.com/749502
Commit-Queue: Ria Jiang <riajiang@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515832}
parent 50084b5b
......@@ -974,6 +974,8 @@ void RenderWidgetHostViewAura::SubmitCompositorFrame(
if (delegated_frame_host_) {
delegated_frame_host_->SubmitCompositorFrame(
local_surface_id, std::move(frame), std::move(hit_test_region_list));
if (window_)
window_->set_embed_frame_sink_id(frame_sink_id_);
}
if (frame.metadata.selection.start != selection_start_ ||
frame.metadata.selection.end != selection_end_) {
......
......@@ -22,7 +22,8 @@ viz::mojom::HitTestRegionPtr CreateHitTestRegion(const aura::Window* window,
hit_test_region->frame_sink_id = window->GetFrameSinkId();
// Checking |layer| may not be correct, since the actual layer that embeds
// the surface may be a descendent of |layer|, instead of |layer| itself.
if (window->GetLocalSurfaceId().is_valid()) {
if (window->IsEmbeddingClient()) {
DCHECK(window->GetLocalSurfaceId().is_valid());
hit_test_region->local_surface_id = window->GetLocalSurfaceId();
hit_test_region->flags = flags | viz::mojom::kHitTestChildSurface;
} else {
......@@ -66,7 +67,7 @@ viz::mojom::HitTestRegionListPtr HitTestDataProviderAura::GetHitTestData()
void HitTestDataProviderAura::GetHitTestDataRecursively(
aura::Window* window,
viz::mojom::HitTestRegionList* hit_test_region_list) const {
if (window->GetLocalSurfaceId().is_valid())
if (window->IsEmbeddingClient())
return;
WindowTargeter* parent_targeter =
......
......@@ -87,17 +87,23 @@ class HitTestDataProviderAuraTest : public test::AuraTestBaseMus {
test::AuraTestBaseMus::SetUp();
root_ = std::make_unique<Window>(nullptr);
root_->SetProperty(aura::client::kEmbedType,
aura::client::WindowEmbedType::TOP_LEVEL_IN_WM);
root_->Init(ui::LAYER_NOT_DRAWN);
root_->SetEventTargeter(std::make_unique<WindowTargeter>());
root_->SetBounds(gfx::Rect(0, 0, 300, 200));
root_->Show();
window2_ = new Window(nullptr);
window2_->SetProperty(aura::client::kEmbedType,
aura::client::WindowEmbedType::EMBED_IN_OWNER);
window2_->Init(ui::LAYER_TEXTURED);
window2_->SetBounds(gfx::Rect(20, 30, 40, 60));
window2_->Show();
window3_ = new Window(nullptr);
window3_->SetProperty(aura::client::kEmbedType,
aura::client::WindowEmbedType::EMBED_IN_OWNER);
window3_->Init(ui::LAYER_TEXTURED);
window3_->SetEventTargeter(std::make_unique<WindowTargeter>());
window3_->SetBounds(gfx::Rect(50, 60, 100, 40));
......@@ -180,7 +186,7 @@ TEST_F(HitTestDataProviderAuraTest, Stacking) {
// Tests that the hit-test regions get expanded with a custom event targeter.
TEST_F(HitTestDataProviderAuraTest, CustomTargeter) {
window3()->SetEventTargeter(std::make_unique<TestWindowTargeter>());
window2()->AllocateLocalSurfaceId();
window2()->set_embed_frame_sink_id(viz::FrameSinkId(1, 2));
const auto hit_test_data = hit_test_data_provider()->GetHitTestData();
ASSERT_TRUE(hit_test_data);
EXPECT_EQ(hit_test_data->flags, viz::mojom::kHitTestMine);
......@@ -307,7 +313,7 @@ TEST_F(HitTestDataProviderAuraTest, DoNotSubmit) {
ASSERT_TRUE(hit_test_data);
EXPECT_EQ(hit_test_data->regions.size(), 2u);
window3()->AllocateLocalSurfaceId();
window3()->set_embed_frame_sink_id(viz::FrameSinkId(1, 3));
hit_test_data = hit_test_data_provider()->GetHitTestData();
ASSERT_TRUE(hit_test_data);
EXPECT_EQ(hit_test_data->regions.size(), 1u);
......@@ -320,7 +326,7 @@ TEST_F(HitTestDataProviderAuraTest, DoNotSubmit) {
hit_test_data = hit_test_data_provider()->GetHitTestData();
ASSERT_TRUE(hit_test_data);
EXPECT_EQ(hit_test_data->regions.size(), 1u);
root()->AllocateLocalSurfaceId();
root()->set_embed_frame_sink_id(viz::FrameSinkId(1, 1));
hit_test_data = hit_test_data_provider()->GetHitTestData();
ASSERT_TRUE(hit_test_data);
EXPECT_EQ(hit_test_data->regions.size(), 0u);
......
......@@ -124,8 +124,8 @@ WindowPortMus::RequestLayerTreeFrameSink(
}
viz::FrameSinkId WindowPortMus::GetFrameSinkId() const {
if (embed_frame_sink_id_.is_valid())
return embed_frame_sink_id_;
if (window_->IsEmbeddingClient())
return window_->embed_frame_sink_id();
return viz::FrameSinkId(0, server_id());
}
......@@ -294,7 +294,7 @@ void WindowPortMus::SetFrameSinkIdFromServer(
const viz::FrameSinkId& frame_sink_id) {
DCHECK(window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
window_mus_type() == WindowMusType::EMBED_IN_OWNER);
embed_frame_sink_id_ = frame_sink_id;
window_->set_embed_frame_sink_id(frame_sink_id);
UpdatePrimarySurfaceInfo();
}
......@@ -312,7 +312,7 @@ const viz::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
// The newly generated frame by the embedder will block in the display
// compositor until the child submits a corresponding CompositorFrame or a
// deadline hits.
if (embed_frame_sink_id_.is_valid())
if (window_->IsEmbeddingClient())
UpdatePrimarySurfaceInfo();
if (local_layer_tree_frame_sink_)
......@@ -323,16 +323,16 @@ const viz::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
void WindowPortMus::SetFallbackSurfaceInfo(
const viz::SurfaceInfo& surface_info) {
if (!embed_frame_sink_id_.is_valid()) {
if (!window_->IsEmbeddingClient()) {
// |primary_surface_info_| shold not be valid, since we didn't know the
// |embed_frame_sink_id_|.
// |window_->embed_frame_sink_id()|.
DCHECK(!primary_surface_info_.is_valid());
embed_frame_sink_id_ = surface_info.id().frame_sink_id();
window_->set_embed_frame_sink_id(surface_info.id().frame_sink_id());
UpdatePrimarySurfaceInfo();
}
// The frame sink id should never be changed.
DCHECK_EQ(surface_info.id().frame_sink_id(), embed_frame_sink_id_);
DCHECK_EQ(surface_info.id().frame_sink_id(), window_->embed_frame_sink_id());
fallback_surface_info_ = surface_info;
UpdateClientSurfaceEmbedder();
......@@ -559,7 +559,7 @@ WindowPortMus::CreateLayerTreeFrameSink() {
}
viz::SurfaceId WindowPortMus::GetSurfaceId() const {
return viz::SurfaceId(embed_frame_sink_id_, local_surface_id_);
return viz::SurfaceId(window_->embed_frame_sink_id(), local_surface_id_);
}
void WindowPortMus::OnWindowAddedToRootWindow() {}
......@@ -582,12 +582,12 @@ void WindowPortMus::UpdatePrimarySurfaceInfo() {
return;
}
if (!embed_frame_sink_id_.is_valid() || !local_surface_id_.is_valid())
if (!window_->IsEmbeddingClient() || !local_surface_id_.is_valid())
return;
primary_surface_info_ =
viz::SurfaceInfo(viz::SurfaceId(embed_frame_sink_id_, local_surface_id_),
GetDeviceScaleFactor(), last_surface_size_in_pixels_);
primary_surface_info_ = viz::SurfaceInfo(
viz::SurfaceId(window_->embed_frame_sink_id(), local_surface_id_),
GetDeviceScaleFactor(), last_surface_size_in_pixels_);
UpdateClientSurfaceEmbedder();
}
......
......@@ -290,9 +290,6 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
ServerChangeIdType next_server_change_id_ = 0;
ServerChanges server_changes_;
// Only set when it is embedding another client inside.
viz::FrameSinkId embed_frame_sink_id_;
viz::SurfaceInfo primary_surface_info_;
viz::SurfaceInfo fallback_surface_info_;
......
......@@ -1045,6 +1045,10 @@ viz::FrameSinkId Window::GetFrameSinkId() const {
return port_->GetFrameSinkId();
}
bool Window::IsEmbeddingClient() const {
return embed_frame_sink_id_.is_valid();
}
void Window::OnPaintLayer(const ui::PaintContext& context) {
Paint(context);
}
......
......@@ -345,6 +345,15 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// return a valid FrameSinkId.
viz::FrameSinkId GetFrameSinkId() const;
const viz::FrameSinkId& embed_frame_sink_id() const {
return embed_frame_sink_id_;
}
void set_embed_frame_sink_id(const viz::FrameSinkId& embed_frame_sink_id) {
embed_frame_sink_id_ = embed_frame_sink_id;
}
// Returns whether this window is an embed window.
bool IsEmbeddingClient() const;
protected:
// Deletes (or removes if not owned by parent) all child windows. Intended for
// use from the destructor.
......@@ -507,6 +516,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
int id_;
// Only set when it is embedding another client inside.
viz::FrameSinkId embed_frame_sink_id_;
// Whether layer is initialized as non-opaque. Defaults to false.
bool transparent_;
......
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