Commit f86ed755 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

aura: removes WindowPort*

And inlines what was in WindowPortLocal into Window.

BUG=958245
TEST=covered by tests

Change-Id: I67d2769504a72f5ad00a18c2a50344f5aecab9b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1620045Reviewed-by: default avatarJonathan Ross <jonross@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661983}
parent 7f85bfaa
...@@ -35,7 +35,6 @@ jumbo_component("aura") { ...@@ -35,7 +35,6 @@ jumbo_component("aura") {
"input_state_lookup.h", "input_state_lookup.h",
"input_state_lookup_win.h", "input_state_lookup_win.h",
"layout_manager.h", "layout_manager.h",
"local/window_port_local.h",
"null_window_targeter.h", "null_window_targeter.h",
"scoped_keyboard_hook.h", "scoped_keyboard_hook.h",
"scoped_simple_keyboard_hook.h", "scoped_simple_keyboard_hook.h",
...@@ -47,7 +46,6 @@ jumbo_component("aura") { ...@@ -47,7 +46,6 @@ jumbo_component("aura") {
"window_observer.h", "window_observer.h",
"window_occlusion_change_builder.h", "window_occlusion_change_builder.h",
"window_occlusion_tracker.h", "window_occlusion_tracker.h",
"window_port.h",
"window_targeter.h", "window_targeter.h",
"window_tracker.h", "window_tracker.h",
"window_tree_host.h", "window_tree_host.h",
...@@ -77,7 +75,6 @@ jumbo_component("aura") { ...@@ -77,7 +75,6 @@ jumbo_component("aura") {
"input_state_lookup.cc", "input_state_lookup.cc",
"input_state_lookup_win.cc", "input_state_lookup_win.cc",
"layout_manager.cc", "layout_manager.cc",
"local/window_port_local.cc",
"native_window_occlusion_tracker_win.cc", "native_window_occlusion_tracker_win.cc",
"native_window_occlusion_tracker_win.h", "native_window_occlusion_tracker_win.h",
"null_window_targeter.cc", "null_window_targeter.cc",
...@@ -90,9 +87,6 @@ jumbo_component("aura") { ...@@ -90,9 +87,6 @@ jumbo_component("aura") {
"window_observer.cc", "window_observer.cc",
"window_occlusion_change_builder.cc", "window_occlusion_change_builder.cc",
"window_occlusion_tracker.cc", "window_occlusion_tracker.cc",
"window_port.cc",
"window_port_for_shutdown.cc",
"window_port_for_shutdown.h",
"window_targeter.cc", "window_targeter.cc",
"window_tracker.cc", "window_tracker.cc",
"window_tree_host.cc", "window_tree_host.cc",
......
include_rules = [ include_rules = [
"+cc/base", "+cc/base",
"+cc/mojo_embedder",
# TODO(danakj): This should not use LayerTreeFrameSink, which is part of the # TODO(danakj): This should not use LayerTreeFrameSink, which is part of the
# layer compositor. It should use CompositorFrameSink instead. # layer compositor. It should use CompositorFrameSink instead.
"+cc/trees/layer_tree_frame_sink.h", "+cc/trees/layer_tree_frame_sink.h",
......
...@@ -13,11 +13,9 @@ ...@@ -13,11 +13,9 @@
#include "ui/aura/env_input_state_controller.h" #include "ui/aura/env_input_state_controller.h"
#include "ui/aura/env_observer.h" #include "ui/aura/env_observer.h"
#include "ui/aura/input_state_lookup.h" #include "ui/aura/input_state_lookup.h"
#include "ui/aura/local/window_port_local.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher_observer.h" #include "ui/aura/window_event_dispatcher_observer.h"
#include "ui/aura/window_occlusion_tracker.h" #include "ui/aura/window_occlusion_tracker.h"
#include "ui/aura/window_port_for_shutdown.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#include "ui/events/event_observer.h" #include "ui/events/event_observer.h"
#include "ui/events/event_target_iterator.h" #include "ui/events/event_target_iterator.h"
...@@ -113,10 +111,6 @@ bool Env::HasInstance() { ...@@ -113,10 +111,6 @@ bool Env::HasInstance() {
return !!g_primary_instance; return !!g_primary_instance;
} }
std::unique_ptr<WindowPort> Env::CreateWindowPort(Window* window) {
return std::make_unique<WindowPortLocal>(window);
}
void Env::AddObserver(EnvObserver* observer) { void Env::AddObserver(EnvObserver* observer) {
observers_.AddObserver(observer); observers_.AddObserver(observer);
} }
......
...@@ -38,7 +38,6 @@ class InputStateLookup; ...@@ -38,7 +38,6 @@ class InputStateLookup;
class Window; class Window;
class WindowEventDispatcherObserver; class WindowEventDispatcherObserver;
class WindowOcclusionTracker; class WindowOcclusionTracker;
class WindowPort;
class WindowTreeHost; class WindowTreeHost;
// A singleton object that tracks general state within Aura. // A singleton object that tracks general state within Aura.
...@@ -56,9 +55,6 @@ class AURA_EXPORT Env : public ui::EventTarget, ...@@ -56,9 +55,6 @@ class AURA_EXPORT Env : public ui::EventTarget,
static Env* GetInstance(); static Env* GetInstance();
static bool HasInstance(); static bool HasInstance();
// Called internally to create the appropriate WindowPort implementation.
std::unique_ptr<WindowPort> CreateWindowPort(Window* window);
void AddObserver(EnvObserver* observer); void AddObserver(EnvObserver* observer);
void RemoveObserver(EnvObserver* observer); void RemoveObserver(EnvObserver* observer);
......
include_rules = [
"+cc/mojo_embedder",
"+cc/output",
"+cc/scheduler",
"+components/viz/service/frame_sinks",
"+services/viz/public/interfaces",
]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/aura/local/window_port_local.h"
#include "cc/mojo_embedder/async_layer_tree_frame_sink.h"
#include "components/viz/client/hit_test_data_provider_draw_quad.h"
#include "components/viz/client/local_surface_id_provider.h"
#include "components/viz/common/features.h"
#include "components/viz/common/surfaces/local_surface_id_allocation.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "services/ws/public/mojom/window_tree_constants.mojom.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_occlusion_tracker.h"
#include "ui/base/layout.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
namespace aura {
namespace {
static const char* kExo = "Exo";
class ScopedCursorHider {
public:
explicit ScopedCursorHider(Window* window)
: window_(window), hid_cursor_(false) {
if (!window_->IsRootWindow())
return;
const bool cursor_is_in_bounds = window_->GetBoundsInScreen().Contains(
Env::GetInstance()->last_mouse_location());
client::CursorClient* cursor_client = client::GetCursorClient(window_);
if (cursor_is_in_bounds && cursor_client &&
cursor_client->IsCursorVisible()) {
cursor_client->HideCursor();
hid_cursor_ = true;
}
}
~ScopedCursorHider() {
if (!window_->IsRootWindow())
return;
// Update the device scale factor of the cursor client only when the last
// mouse location is on this root window.
if (hid_cursor_) {
client::CursorClient* cursor_client = client::GetCursorClient(window_);
if (cursor_client) {
const display::Display& display =
display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
cursor_client->SetDisplay(display);
cursor_client->ShowCursor();
}
}
}
private:
Window* window_;
bool hid_cursor_;
DISALLOW_COPY_AND_ASSIGN(ScopedCursorHider);
};
} // namespace
WindowPortLocal::WindowPortLocal(Window* window)
: WindowPort(WindowPort::Type::kLocal),
window_(window),
weak_factory_(this) {}
WindowPortLocal::~WindowPortLocal() {
if (frame_sink_id_.is_valid()) {
auto* context_factory_private =
Env::GetInstance()->context_factory_private();
auto* host_frame_sink_manager =
context_factory_private->GetHostFrameSinkManager();
host_frame_sink_manager->InvalidateFrameSinkId(frame_sink_id_);
}
}
void WindowPortLocal::OnPreInit(Window* window) {}
void WindowPortLocal::OnDeviceScaleFactorChanged(
float old_device_scale_factor,
float new_device_scale_factor) {
if (!window_->IsRootWindow() &&
last_device_scale_factor_ != new_device_scale_factor &&
IsEmbeddingExternalContent()) {
last_device_scale_factor_ = new_device_scale_factor;
parent_local_surface_id_allocator_->GenerateId();
if (frame_sink_) {
frame_sink_->SetLocalSurfaceId(
GetCurrentLocalSurfaceIdAllocation().local_surface_id());
}
}
ScopedCursorHider hider(window_);
if (window_->delegate()) {
window_->delegate()->OnDeviceScaleFactorChanged(old_device_scale_factor,
new_device_scale_factor);
}
}
void WindowPortLocal::OnWillAddChild(Window* child) {}
void WindowPortLocal::OnWillRemoveChild(Window* child) {}
void WindowPortLocal::OnWillMoveChild(size_t current_index, size_t dest_index) {
}
void WindowPortLocal::OnVisibilityChanged(bool visible) {}
void WindowPortLocal::OnTransparentChanged(bool visible) {}
void WindowPortLocal::OnDidChangeBounds(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
if (!window_->IsRootWindow() && last_size_ != new_bounds.size() &&
IsEmbeddingExternalContent()) {
last_size_ = new_bounds.size();
parent_local_surface_id_allocator_->GenerateId();
if (frame_sink_) {
frame_sink_->SetLocalSurfaceId(
GetCurrentLocalSurfaceIdAllocation().local_surface_id());
}
}
}
void WindowPortLocal::OnDidChangeTransform(
const gfx::Transform& old_transform,
const gfx::Transform& new_transform) {}
std::unique_ptr<ui::PropertyData> WindowPortLocal::OnWillChangeProperty(
const void* key) {
return nullptr;
}
void WindowPortLocal::OnPropertyChanged(
const void* key,
int64_t old_value,
std::unique_ptr<ui::PropertyData> data) {}
std::unique_ptr<cc::LayerTreeFrameSink>
WindowPortLocal::CreateLayerTreeFrameSink() {
auto* context_factory_private = Env::GetInstance()->context_factory_private();
auto* host_frame_sink_manager =
context_factory_private->GetHostFrameSinkManager();
if (!frame_sink_id_.is_valid()) {
frame_sink_id_ = context_factory_private->AllocateFrameSinkId();
host_frame_sink_manager->RegisterFrameSinkId(
frame_sink_id_, this, viz::ReportFirstSurfaceActivation::kYes);
window_->SetEmbedFrameSinkId(frame_sink_id_);
}
// For creating a async frame sink which connects to the viz display
// compositor.
viz::mojom::CompositorFrameSinkPtrInfo sink_info;
viz::mojom::CompositorFrameSinkRequest sink_request =
mojo::MakeRequest(&sink_info);
viz::mojom::CompositorFrameSinkClientPtr client;
viz::mojom::CompositorFrameSinkClientRequest client_request =
mojo::MakeRequest(&client);
host_frame_sink_manager->CreateCompositorFrameSink(
frame_sink_id_, std::move(sink_request), std::move(client));
cc::mojo_embedder::AsyncLayerTreeFrameSink::InitParams params;
params.gpu_memory_buffer_manager =
Env::GetInstance()->context_factory()->GetGpuMemoryBufferManager();
params.pipes.compositor_frame_sink_info = std::move(sink_info);
params.pipes.client_request = std::move(client_request);
params.enable_surface_synchronization = true;
params.client_name = kExo;
bool root_accepts_events =
(window_->event_targeting_policy() ==
ws::mojom::EventTargetingPolicy::TARGET_ONLY) ||
(window_->event_targeting_policy() ==
ws::mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
if (features::IsVizHitTestingDrawQuadEnabled()) {
params.hit_test_data_provider =
std::make_unique<viz::HitTestDataProviderDrawQuad>(
true /* should_ask_for_child_region */, root_accepts_events);
}
auto frame_sink =
std::make_unique<cc::mojo_embedder::AsyncLayerTreeFrameSink>(
nullptr /* context_provider */, nullptr /* worker_context_provider */,
&params);
frame_sink_ = frame_sink->GetWeakPtr();
AllocateLocalSurfaceId();
return std::move(frame_sink);
}
void WindowPortLocal::AllocateLocalSurfaceId() {
if (!parent_local_surface_id_allocator_)
parent_local_surface_id_allocator_.emplace();
parent_local_surface_id_allocator_->GenerateId();
UpdateLocalSurfaceId();
}
void WindowPortLocal::InvalidateLocalSurfaceId() {
if (!parent_local_surface_id_allocator_)
return;
parent_local_surface_id_allocator_->Invalidate();
}
viz::ScopedSurfaceIdAllocator WindowPortLocal::GetSurfaceIdAllocator(
base::OnceCallback<void()> allocation_task) {
return viz::ScopedSurfaceIdAllocator(
&parent_local_surface_id_allocator_.value(), std::move(allocation_task));
}
void WindowPortLocal::UpdateLocalSurfaceIdFromEmbeddedClient(
const viz::LocalSurfaceIdAllocation&
embedded_client_local_surface_id_allocation) {
parent_local_surface_id_allocator_->UpdateFromChild(
embedded_client_local_surface_id_allocation);
UpdateLocalSurfaceId();
}
const viz::LocalSurfaceIdAllocation&
WindowPortLocal::GetLocalSurfaceIdAllocation() {
if (!parent_local_surface_id_allocator_)
AllocateLocalSurfaceId();
return GetCurrentLocalSurfaceIdAllocation();
}
void WindowPortLocal::OnEventTargetingPolicyChanged() {}
bool WindowPortLocal::ShouldRestackTransientChildren() {
return true;
}
void WindowPortLocal::TrackOcclusionState() {
Env::GetInstance()->GetWindowOcclusionTracker()->Track(window_);
}
void WindowPortLocal::OnFirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) {
DCHECK_EQ(surface_info.id().frame_sink_id(), window_->GetFrameSinkId());
window_->layer()->SetShowSurface(surface_info.id(), window_->bounds().size(),
SK_ColorWHITE,
cc::DeadlinePolicy::UseDefaultDeadline(),
false /* stretch_content_to_fill_bounds */);
}
void WindowPortLocal::OnFrameTokenChanged(uint32_t frame_token) {}
void WindowPortLocal::UpdateLocalSurfaceId() {
last_device_scale_factor_ = ui::GetScaleFactorForNativeView(window_);
last_size_ = window_->bounds().size();
if (frame_sink_) {
frame_sink_->SetLocalSurfaceId(
GetCurrentLocalSurfaceIdAllocation().local_surface_id());
}
}
const viz::LocalSurfaceIdAllocation&
WindowPortLocal::GetCurrentLocalSurfaceIdAllocation() const {
return parent_local_surface_id_allocator_
->GetCurrentLocalSurfaceIdAllocation();
}
bool WindowPortLocal::IsEmbeddingExternalContent() const {
return parent_local_surface_id_allocator_.has_value();
}
} // namespace aura
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_LOCAL_WINDOW_PORT_LOCAL_H_
#define UI_AURA_LOCAL_WINDOW_PORT_LOCAL_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "components/viz/host/host_frame_sink_client.h"
#include "ui/aura/window_port.h"
#include "ui/base/property_data.h"
#include "ui/gfx/geometry/size.h"
namespace gfx {
class Size;
}
namespace aura {
class Window;
// WindowPort implementation for classic aura, e.g. not mus.
class AURA_EXPORT WindowPortLocal : public WindowPort,
public viz::HostFrameSinkClient {
public:
explicit WindowPortLocal(Window* window);
~WindowPortLocal() override;
// WindowPort:
void OnPreInit(Window* window) override;
void OnDeviceScaleFactorChanged(float old_device_scale_factor,
float new_device_scale_factor) override;
void OnWillAddChild(Window* child) override;
void OnWillRemoveChild(Window* child) override;
void OnWillMoveChild(size_t current_index, size_t dest_index) override;
void OnVisibilityChanged(bool visible) override;
void OnTransparentChanged(bool transparent) override;
void OnDidChangeBounds(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override;
void OnDidChangeTransform(const gfx::Transform& old_transform,
const gfx::Transform& new_transform) override;
std::unique_ptr<ui::PropertyData> OnWillChangeProperty(
const void* key) override;
void OnPropertyChanged(const void* key,
int64_t old_value,
std::unique_ptr<ui::PropertyData> data) override;
std::unique_ptr<cc::LayerTreeFrameSink> CreateLayerTreeFrameSink() override;
void AllocateLocalSurfaceId() override;
viz::ScopedSurfaceIdAllocator GetSurfaceIdAllocator(
base::OnceCallback<void()> allocation_task) override;
void InvalidateLocalSurfaceId() override;
void UpdateLocalSurfaceIdFromEmbeddedClient(
const viz::LocalSurfaceIdAllocation&
embedded_client_local_surface_id_allocation) override;
const viz::LocalSurfaceIdAllocation& GetLocalSurfaceIdAllocation() override;
void OnEventTargetingPolicyChanged() override;
bool ShouldRestackTransientChildren() override;
void TrackOcclusionState() override;
// viz::HostFrameSinkClient:
void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override;
void OnFrameTokenChanged(uint32_t frame_token) override;
private:
void UpdateLocalSurfaceId();
const viz::LocalSurfaceIdAllocation& GetCurrentLocalSurfaceIdAllocation()
const;
bool IsEmbeddingExternalContent() const;
Window* const window_;
gfx::Size last_size_;
float last_device_scale_factor_ = 1.0f;
base::Optional<viz::ParentLocalSurfaceIdAllocator>
parent_local_surface_id_allocator_;
base::WeakPtr<cc::LayerTreeFrameSink> frame_sink_;
viz::FrameSinkId frame_sink_id_;
base::WeakPtrFactory<WindowPortLocal> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WindowPortLocal);
};
} // namespace aura
#endif // UI_AURA_LOCAL_WINDOW_PORT_LOCAL_H_
This diff is collapsed.
This diff is collapsed.
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/aura/window_port.h"
#include "ui/aura/window.h"
namespace aura {
WindowPort::WindowPort(Type type) : type_(type) {}
// static
WindowPort* WindowPort::Get(Window* window) {
return window ? window->port_ : nullptr;
}
// static
base::ReentrantObserverList<WindowObserver, true>* WindowPort::GetObservers(
Window* window) {
return &(window->observers_);
}
} // namespace aura
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_WINDOW_PORT_H_
#define UI_AURA_WINDOW_PORT_H_
#include <stdint.h>
#include <memory>
#include <string>
#include "base/callback.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "components/viz/common/surfaces/local_surface_id_allocation.h"
#include "components/viz/common/surfaces/scoped_surface_id_allocator.h"
#include "components/viz/common/surfaces/surface_id.h"
#include "ui/aura/aura_export.h"
#include "ui/base/class_property.h"
namespace cc {
class LayerTreeFrameSink;
}
namespace gfx {
class Rect;
class Transform;
}
namespace aura {
class Window;
class WindowObserver;
// WindowPort defines an interface to enable Window to be used with or without
// mus. WindowPort is owned by Window and called at key points in Windows
// lifetime that enable Window to be used in both environments.
//
// If a Window is created without an explicit WindowPort then
// Env::CreateWindowPort() is used to create the WindowPort.
class AURA_EXPORT WindowPort {
public:
// Corresponds to the concrete implementation of this interface.
enum class Type {
// WindowPortLocal.
kLocal,
// WindowPortMus.
kMus,
// WindowPortForShutdown.
kShutdown,
};
virtual ~WindowPort() {}
Type type() const { return type_; }
// Called from Window::Init().
virtual void OnPreInit(Window* window) = 0;
virtual void OnDeviceScaleFactorChanged(float old_device_scale_factor,
float new_device_scale_factor) = 0;
// Called when a window is being added as a child. |child| may already have
// a parent, but its parent is not the Window this WindowPort is associated
// with.
virtual void OnWillAddChild(Window* child) = 0;
virtual void OnWillRemoveChild(Window* child) = 0;
// Called to move the child at |current_index| to |dest_index|. |dest_index|
// is calculated assuming the window at |current_index| has been removed, e.g.
// Window* child = children_[current_index];
// children_.erase(children_.begin() + current_index);
// children_.insert(children_.begin() + dest_index, child);
virtual void OnWillMoveChild(size_t current_index, size_t dest_index) = 0;
virtual void OnVisibilityChanged(bool visible) = 0;
virtual void OnTransparentChanged(bool transparent) = 0;
virtual void OnDidChangeBounds(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) = 0;
virtual void OnDidChangeTransform(const gfx::Transform& old_transform,
const gfx::Transform& new_transform) = 0;
// Called before a property is changed. The return value from this is supplied
// into OnPropertyChanged() so that WindowPort may pass data between the two
// calls.
virtual std::unique_ptr<ui::PropertyData> OnWillChangeProperty(
const void* key) = 0;
// Called after a property changes, but before observers are notified. |data|
// is the return value from OnWillChangeProperty().
virtual void OnPropertyChanged(const void* key,
int64_t old_value,
std::unique_ptr<ui::PropertyData> data) = 0;
// Called for creating a cc::LayerTreeFrameSink for the window.
virtual std::unique_ptr<cc::LayerTreeFrameSink>
CreateLayerTreeFrameSink() = 0;
// Forces the window to allocate a new viz::LocalSurfaceId for the next
// CompositorFrame submission in anticipation of a synchronization operation
// that does not involve a resize or a device scale factor change.
virtual void AllocateLocalSurfaceId() = 0;
// When a ScopedSurfaceIdAllocator is alive, it prevents the
// allocator from actually allocating. Instead, it triggers its
// |allocation_task| upon destruction. This allows us to issue only one
// allocation during the lifetime. This is used to continue routing and
// processing when a child allocates its own LocalSurfaceId.
virtual viz::ScopedSurfaceIdAllocator GetSurfaceIdAllocator(
base::OnceCallback<void()> allocation_task) = 0;
// Marks the current viz::LocalSurfaceId as invalid. AllocateLocalSurfaceId
// must be called before submitting new CompositorFrames.
virtual void InvalidateLocalSurfaceId() = 0;
virtual void UpdateLocalSurfaceIdFromEmbeddedClient(
const viz::LocalSurfaceIdAllocation&
embedded_client_local_surface_id_allocation) = 0;
// Gets the current viz::LocalSurfaceIdAllocation which incorporates both
// the viz::LocalSurfaceId and its allocation time.
virtual const viz::LocalSurfaceIdAllocation&
GetLocalSurfaceIdAllocation() = 0;
virtual void OnEventTargetingPolicyChanged() = 0;
// See description of function with same name in transient_window_client.
virtual bool ShouldRestackTransientChildren() = 0;
// Called to register/unregister an embedded FramesSinkId. This is only called
// if SetEmbedFrameSinkId() is called on the associated Window.
virtual void RegisterFrameSinkId(const viz::FrameSinkId& frame_sink_id) {}
virtual void UnregisterFrameSinkId(const viz::FrameSinkId& frame_sink_id) {}
// Called to start occlusion state tracking.
virtual void TrackOcclusionState() {}
protected:
explicit WindowPort(Type type);
// Returns the WindowPort associated with a Window.
static WindowPort* Get(Window* window);
// Returns the ObserverList of a Window.
static base::ReentrantObserverList<WindowObserver, true>* GetObservers(
Window* window);
private:
const Type type_;
};
} // namespace aura
#endif // UI_AURA_WINDOW_PORT_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/aura/window_port_for_shutdown.h"
#include "cc/trees/layer_tree_frame_sink.h"
#include "ui/aura/window.h"
namespace aura {
WindowPortForShutdown::WindowPortForShutdown()
: WindowPort(WindowPort::Type::kShutdown) {}
WindowPortForShutdown::~WindowPortForShutdown() {}
// static
void WindowPortForShutdown::Install(aura::Window* window) {
window->port_owner_.reset(new WindowPortForShutdown);
window->port_ = window->port_owner_.get();
}
void WindowPortForShutdown::OnPreInit(Window* window) {}
void WindowPortForShutdown::OnDeviceScaleFactorChanged(
float old_device_scale_factor,
float new_device_scale_factor) {}
void WindowPortForShutdown::OnWillAddChild(Window* child) {}
void WindowPortForShutdown::OnWillRemoveChild(Window* child) {}
void WindowPortForShutdown::OnWillMoveChild(size_t current_index,
size_t dest_index) {}
void WindowPortForShutdown::OnVisibilityChanged(bool visible) {}
void WindowPortForShutdown::OnTransparentChanged(bool transparent) {}
void WindowPortForShutdown::OnDidChangeBounds(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {}
void WindowPortForShutdown::OnDidChangeTransform(
const gfx::Transform& old_transform,
const gfx::Transform& new_transform) {}
std::unique_ptr<ui::PropertyData> WindowPortForShutdown::OnWillChangeProperty(
const void* key) {
return nullptr;
}
void WindowPortForShutdown::OnPropertyChanged(
const void* key,
int64_t old_value,
std::unique_ptr<ui::PropertyData> data) {}
std::unique_ptr<cc::LayerTreeFrameSink>
WindowPortForShutdown::CreateLayerTreeFrameSink() {
return nullptr;
}
void WindowPortForShutdown::AllocateLocalSurfaceId() {}
void WindowPortForShutdown::InvalidateLocalSurfaceId() {}
void WindowPortForShutdown::UpdateLocalSurfaceIdFromEmbeddedClient(
const viz::LocalSurfaceIdAllocation&
embedded_client_local_surface_id_allocation) {}
viz::ScopedSurfaceIdAllocator WindowPortForShutdown::GetSurfaceIdAllocator(
base::OnceCallback<void()> allocation_task) {
return viz::ScopedSurfaceIdAllocator(std::move(allocation_task));
}
const viz::LocalSurfaceIdAllocation&
WindowPortForShutdown::GetLocalSurfaceIdAllocation() {
return local_surface_id_allocation_;
}
void WindowPortForShutdown::OnEventTargetingPolicyChanged() {}
bool WindowPortForShutdown::ShouldRestackTransientChildren() {
return true;
}
} // namespace aura
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_WINDOW_PORT_FOR_SHUTDOWN_H_
#define UI_AURA_WINDOW_PORT_FOR_SHUTDOWN_H_
#include "ui/aura/window_port.h"
#include "base/time/time.h"
#include "components/viz/common/surfaces/local_surface_id_allocation.h"
namespace aura {
// When WindowTreeClient is destroyed any existing windows get a
// WindowPortForShutdown assigned to them. This allows for the Window to keep
// working without a WindowTreeClient. This class is *only* used inside aura.
class WindowPortForShutdown : public WindowPort {
public:
WindowPortForShutdown();
~WindowPortForShutdown() override;
static void Install(aura::Window* window);
// WindowPort:
void OnPreInit(Window* window) override;
void OnDeviceScaleFactorChanged(float old_device_scale_factor,
float new_device_scale_factor) override;
void OnWillAddChild(Window* child) override;
void OnWillRemoveChild(Window* child) override;
void OnWillMoveChild(size_t current_index, size_t dest_index) override;
void OnVisibilityChanged(bool visible) override;
void OnTransparentChanged(bool transparent) override;
void OnDidChangeBounds(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override;
void OnDidChangeTransform(const gfx::Transform& old_transform,
const gfx::Transform& new_transform) override;
std::unique_ptr<ui::PropertyData> OnWillChangeProperty(
const void* key) override;
void OnPropertyChanged(const void* key,
int64_t old_value,
std::unique_ptr<ui::PropertyData> data) override;
std::unique_ptr<cc::LayerTreeFrameSink> CreateLayerTreeFrameSink() override;
void AllocateLocalSurfaceId() override;
viz::ScopedSurfaceIdAllocator GetSurfaceIdAllocator(
base::OnceCallback<void()> allocation_task) override;
void InvalidateLocalSurfaceId() override;
void UpdateLocalSurfaceIdFromEmbeddedClient(
const viz::LocalSurfaceIdAllocation&
embedded_client_local_surface_id_allocation) override;
const viz::LocalSurfaceIdAllocation& GetLocalSurfaceIdAllocation() override;
void OnEventTargetingPolicyChanged() override;
bool ShouldRestackTransientChildren() override;
private:
viz::LocalSurfaceIdAllocation local_surface_id_allocation_;
DISALLOW_COPY_AND_ASSIGN(WindowPortForShutdown);
};
} // namespace aura
#endif // UI_AURA_WINDOW_PORT_FOR_SHUTDOWN_H_
...@@ -3257,7 +3257,7 @@ TEST_F(WindowTest, LocalSurfaceIdChanges) { ...@@ -3257,7 +3257,7 @@ TEST_F(WindowTest, LocalSurfaceIdChanges) {
EXPECT_NE(nullptr, frame_sink.get()); EXPECT_NE(nullptr, frame_sink.get());
EXPECT_TRUE(local_surface_id1.is_valid()); EXPECT_TRUE(local_surface_id1.is_valid());
// Resize 0x0 to make sure WindowPort* stores the correct window size before // Resize to 0x0 to make sure the correct window size is stored before
// creating the frame sink. // creating the frame sink.
window.SetBounds(gfx::Rect(0, 0)); window.SetBounds(gfx::Rect(0, 0));
viz::LocalSurfaceId local_surface_id2 = viz::LocalSurfaceId local_surface_id2 =
......
...@@ -224,7 +224,6 @@ jumbo_component("base") { ...@@ -224,7 +224,6 @@ jumbo_component("base") {
"page_transition_types.h", "page_transition_types.h",
"platform_window_defaults.cc", "platform_window_defaults.cc",
"platform_window_defaults.h", "platform_window_defaults.h",
"property_data.h",
"resource/resource_bundle.cc", "resource/resource_bundle.cc",
"resource/resource_bundle.h", "resource/resource_bundle.h",
"resource/resource_bundle_android.cc", "resource/resource_bundle_android.cc",
......
...@@ -20,14 +20,6 @@ int64_t PropertyHandler::SetPropertyInternal(const void* key, ...@@ -20,14 +20,6 @@ int64_t PropertyHandler::SetPropertyInternal(const void* key,
PropertyDeallocator deallocator, PropertyDeallocator deallocator,
int64_t value, int64_t value,
int64_t default_value) { int64_t default_value) {
// TODO(https://crbug.com/952087): ideally this code would early out if the
// value isn't changing. Unfortunately that breaks some assumptions.
// |is_value_changing| is a best guess at whether the value is changing, and
// doesn't handle non-POD types.
const bool is_value_changing =
value != GetPropertyInternal(key, default_value);
std::unique_ptr<PropertyData> data =
BeforePropertyChange(key, is_value_changing);
int64_t old = GetPropertyInternal(key, default_value); int64_t old = GetPropertyInternal(key, default_value);
if (value == default_value) { if (value == default_value) {
prop_map_.erase(key); prop_map_.erase(key);
...@@ -38,16 +30,10 @@ int64_t PropertyHandler::SetPropertyInternal(const void* key, ...@@ -38,16 +30,10 @@ int64_t PropertyHandler::SetPropertyInternal(const void* key,
prop_value.deallocator = deallocator; prop_value.deallocator = deallocator;
prop_map_[key] = prop_value; prop_map_[key] = prop_value;
} }
AfterPropertyChange(key, old, std::move(data)); AfterPropertyChange(key, old);
return old; return old;
} }
std::unique_ptr<PropertyData> PropertyHandler::BeforePropertyChange(
const void* key,
bool is_value_changing) {
return nullptr;
}
void PropertyHandler::ClearProperties() { void PropertyHandler::ClearProperties() {
// Clear properties. // Clear properties.
for (std::map<const void*, Value>::const_iterator iter = prop_map_.begin(); for (std::map<const void*, Value>::const_iterator iter = prop_map_.begin();
......
...@@ -8,11 +8,9 @@ ...@@ -8,11 +8,9 @@
#include <stdint.h> #include <stdint.h>
#include <map> #include <map>
#include <memory>
#include <set> #include <set>
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/base/property_data.h"
#include "ui/base/ui_base_export.h" #include "ui/base/ui_base_export.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
...@@ -93,16 +91,7 @@ class UI_BASE_EXPORT PropertyHandler { ...@@ -93,16 +91,7 @@ class UI_BASE_EXPORT PropertyHandler {
protected: protected:
friend class subtle::PropertyHelper; friend class subtle::PropertyHelper;
// Called from SetPropertyInternal() prior to changing the value. If virtual void AfterPropertyChange(const void* key, int64_t old_value) {}
// |is_value_changing| is false, the new value is the same as the old value
// (in other words, the value isn't really changing, but observers will
// still be notified).
virtual std::unique_ptr<PropertyData> BeforePropertyChange(
const void* key,
bool is_value_changing);
virtual void AfterPropertyChange(const void* key,
int64_t old_value,
std::unique_ptr<PropertyData> data) {}
void ClearProperties(); void ClearProperties();
// Called by the public {Set,Get,Clear}Property functions. // Called by the public {Set,Get,Clear}Property functions.
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_BASE_PROPERTY_DATA_H_
#define UI_BASE_PROPERTY_DATA_H_
#include "ui/base/ui_base_export.h"
namespace ui {
// Descendants of ui::PropertyHandler may return a descendant of this class
// when overriding BeforePropertyChange(). This instance is then passed to
// AfterPropertyChange() in order to preserve and/or communicate data between
// those two calls.
struct UI_BASE_EXPORT PropertyData {
virtual ~PropertyData() {}
};
}
#endif
...@@ -124,7 +124,7 @@ TransientWindowManager::TransientWindowManager(Window* window) ...@@ -124,7 +124,7 @@ TransientWindowManager::TransientWindowManager(Window* window)
void TransientWindowManager::RestackTransientDescendants() { void TransientWindowManager::RestackTransientDescendants() {
Window* parent = window_->parent(); Window* parent = window_->parent();
if (!parent || !parent->ShouldRestackTransientChildren()) if (!parent)
return; return;
// Stack any transient children that share the same parent to be in front of // Stack any transient children that share the same parent to be in front of
......
...@@ -79,9 +79,6 @@ bool TransientWindowStackingClient::AdjustStacking( ...@@ -79,9 +79,6 @@ bool TransientWindowStackingClient::AdjustStacking(
if (transient_manager && transient_manager->IsStackingTransient(*target)) if (transient_manager && transient_manager->IsStackingTransient(*target))
return true; return true;
if (!(*child)->parent()->ShouldRestackTransientChildren())
return true;
// For windows that have transient children stack the transient ancestors that // For windows that have transient children stack the transient ancestors that
// are siblings. This prevents one transient group from being inserted in the // are siblings. This prevents one transient group from being inserted in the
// middle of another. // middle of another.
......
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