Commit 4807e00d authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Remove the use of aura::Window::env() from ash

Bug: 958467
Test: trybot
Change-Id: I698465f59b1cace337780276f9f0c6dd9e91c1b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1613573
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660500}
parent 4796097e
......@@ -324,8 +324,7 @@ FastInkView::FastInkView(aura::Window* container,
// but with potential tearing. Note that we have to draw into a temporary
// surface and copy it into GPU memory buffer to avoid flicker.
gpu_memory_buffer_ =
widget_->GetNativeWindow()
->env()
aura::Env::GetInstance()
->context_factory()
->GetGpuMemoryBufferManager()
->CreateGpuMemoryBuffer(buffer_size_,
......@@ -407,8 +406,7 @@ void FastInkView::SubmitCompositorFrame() {
// new instance to be created in lost context situations is acceptable and
// keeps the code simple.
if (!resource->context_provider) {
resource->context_provider = widget_->GetNativeWindow()
->env()
resource->context_provider = aura::Env::GetInstance()
->context_factory()
->SharedMainThreadContextProvider();
if (!resource->context_provider) {
......@@ -424,8 +422,7 @@ void FastInkView::SubmitCompositorFrame() {
const uint32_t usage =
gpu::SHARED_IMAGE_USAGE_DISPLAY | gpu::SHARED_IMAGE_USAGE_SCANOUT;
gpu::GpuMemoryBufferManager* gmb_manager =
widget_->GetNativeWindow()
->env()
aura::Env::GetInstance()
->context_factory()
->GetGpuMemoryBufferManager();
resource->mailbox = sii->CreateSharedImage(
......
......@@ -21,7 +21,7 @@ int FrameBorderNonClientHitTest(views::NonClientFrameView* view,
gfx::Rect expanded_bounds = view->bounds();
int outside_bounds = kResizeOutsideBoundsSize;
if (view->GetWidget()->GetNativeWindow()->env()->is_touch_down())
if (aura::Env::GetInstance()->is_touch_down())
outside_bounds *= kResizeOutsideBoundsScaleForTouch;
expanded_bounds.Inset(-outside_bounds, -outside_bounds);
......
......@@ -7,8 +7,6 @@
#include "ash/public/cpp/immersive/immersive_fullscreen_controller.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller_delegate.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/events/base_event_utils.h"
#include "ui/gfx/geometry/rect.h"
namespace ash {
......
......@@ -82,8 +82,7 @@ ArcNotificationSurfaceImpl::ArcNotificationSurfaceImpl(
: surface_(surface) {
DCHECK(surface);
native_view_ = std::make_unique<aura::Window>(
new CustomWindowDelegate(surface), aura::client::WINDOW_TYPE_CONTROL,
surface_->host_window()->env());
new CustomWindowDelegate(surface), aura::client::WINDOW_TYPE_CONTROL);
native_view_->set_owned_by_parent(false);
native_view_->Init(ui::LAYER_NOT_DRAWN);
native_view_->AddChild(surface_->host_window());
......
......@@ -146,14 +146,14 @@ TrayBubbleView::InitParams::InitParams() = default;
TrayBubbleView::InitParams::InitParams(const InitParams& other) = default;
TrayBubbleView::RerouteEventHandler::RerouteEventHandler(
TrayBubbleView* tray_bubble_view,
aura::Env* aura_env)
: tray_bubble_view_(tray_bubble_view), aura_env_(aura_env) {
aura_env_->AddPreTargetHandler(this, ui::EventTarget::Priority::kSystem);
TrayBubbleView* tray_bubble_view)
: tray_bubble_view_(tray_bubble_view) {
aura::Env::GetInstance()->AddPreTargetHandler(
this, ui::EventTarget::Priority::kSystem);
}
TrayBubbleView::RerouteEventHandler::~RerouteEventHandler() {
aura_env_->RemovePreTargetHandler(this);
aura::Env::GetInstance()->RemovePreTargetHandler(this);
}
void TrayBubbleView::RerouteEventHandler::OnKeyEvent(ui::KeyEvent* event) {
......@@ -287,10 +287,8 @@ void TrayBubbleView::InitializeAndShowBubble() {
// If TrayBubbleView cannot be activated and is shown by clicking on the
// corresponding tray view, register pre target event handler to reroute key
// events to the widget for activating the view or closing it.
if (!CanActivate() && params_.show_by_click) {
reroute_event_handler_ = std::make_unique<RerouteEventHandler>(
this, GetWidget()->GetNativeWindow()->env());
}
if (!CanActivate() && params_.show_by_click)
reroute_event_handler_ = std::make_unique<RerouteEventHandler>(this);
}
void TrayBubbleView::UpdateBubble() {
......
......@@ -19,10 +19,6 @@
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/mouse_watcher.h"
namespace aura {
class Env;
}
namespace ui {
class LayerOwner;
}
......@@ -200,7 +196,7 @@ class ASH_EXPORT TrayBubbleView : public views::BubbleDialogDelegateView,
// process accelerator as menu is currently open.
class RerouteEventHandler : public ui::EventHandler {
public:
RerouteEventHandler(TrayBubbleView* tray_bubble_view, aura::Env* aura_env);
RerouteEventHandler(TrayBubbleView* tray_bubble_view);
~RerouteEventHandler() override;
// Overridden from ui::EventHandler
......@@ -210,11 +206,6 @@ class ASH_EXPORT TrayBubbleView : public views::BubbleDialogDelegateView,
// TrayBubbleView to which key events are going to be rerouted. Not owned.
TrayBubbleView* tray_bubble_view_;
// The aura::Env where this EventHandler is installed. Needed because
// SingleProcessMash has more than one aura::Env. Cached so this object
// can unregister itself during TrayBubbleView teardown.
aura::Env* aura_env_;
DISALLOW_COPY_AND_ASSIGN(RerouteEventHandler);
};
......
......@@ -349,7 +349,7 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
DCHECK_EQ(ui::ET_GESTURE_SCROLL_BEGIN, event->type());
aura::Window::ConvertPointToTarget(target, new_target, &event_location);
original_target->env()->gesture_recognizer()->TransferEventsTo(
aura::Env::GetInstance()->gesture_recognizer()->TransferEventsTo(
original_target, new_target, ui::TransferTouchesBehavior::kCancel);
UpdateGestureTarget(new_target, event_location);
target = new_target;
......@@ -532,7 +532,7 @@ bool ToplevelWindowEventHandler::AttemptToStartDrag(
if (gesture_target_ != nullptr && update_gesture_target) {
DCHECK_EQ(source, ::wm::WINDOW_MOVE_SOURCE_TOUCH);
// Transfer events for gesture if switching to new target.
window->env()->gesture_recognizer()->TransferEventsTo(
aura::Env::GetInstance()->gesture_recognizer()->TransferEventsTo(
gesture_target_, window, ui::TransferTouchesBehavior::kDontCancel);
}
......@@ -567,11 +567,11 @@ void ToplevelWindowEventHandler::RevertDrag() {
DCHECK(root_window);
gfx::Point drag_location;
if (move_source == ::wm::WINDOW_MOVE_SOURCE_TOUCH &&
Shell::Get()->aura_env()->is_touch_down()) {
aura::Env::GetInstance()->is_touch_down()) {
gfx::PointF drag_location_f;
bool has_point =
source->env()->gesture_recognizer()->GetLastTouchPointForTarget(
source, &drag_location_f);
bool has_point = aura::Env::GetInstance()
->gesture_recognizer()
->GetLastTouchPointForTarget(source, &drag_location_f);
drag_location = gfx::ToFlooredPoint(drag_location_f);
DCHECK(has_point);
} else {
......
......@@ -112,8 +112,8 @@ void WindowMirrorView::AddedToWidget() {
// This is done to minimize the amount of work during the initial animation
// when entering overview. In particular, telling the remote client it is
// visible is likely to result in a fair amount of work.
if (source_->env()->GetWindowOcclusionTracker()->IsPaused())
env_observer_.Add(target_->env());
if (aura::Env::GetInstance()->GetWindowOcclusionTracker()->IsPaused())
env_observer_.Add(aura::Env::GetInstance());
else
ForceVisibilityAndOcclusion();
}
......
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