summaryrefslogtreecommitdiff
path: root/chromium/ui/aura
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-29 10:46:47 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-11-02 12:02:10 +0000
commit99677208ff3b216fdfec551fbe548da5520cd6fb (patch)
tree476a4865c10320249360e859d8fdd3e01833b03a /chromium/ui/aura
parentc30a6232df03e1efbd9f3b226777b07e087a1122 (diff)
downloadqtwebengine-chromium-99677208ff3b216fdfec551fbe548da5520cd6fb.tar.gz
BASELINE: Update Chromium to 86.0.4240.124
Change-Id: Ide0ff151e94cd665ae6521a446995d34a9d1d644 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/aura')
-rw-r--r--chromium/ui/aura/BUILD.gn24
-rw-r--r--chromium/ui/aura/DEPS1
-rw-r--r--chromium/ui/aura/client/drag_drop_client.h4
-rw-r--r--chromium/ui/aura/env.cc17
-rw-r--r--chromium/ui/aura/test/ui_controls_factory_ozone.cc358
-rw-r--r--chromium/ui/aura/test/ui_controls_ozone.cc358
-rw-r--r--chromium/ui/aura/test/ui_controls_ozone.h135
-rw-r--r--chromium/ui/aura/window.cc19
-rw-r--r--chromium/ui/aura/window.h30
-rw-r--r--chromium/ui/aura/window_delegate.h7
-rw-r--r--chromium/ui/aura/window_occlusion_change_builder_unittest.cc10
-rw-r--r--chromium/ui/aura/window_occlusion_tracker.cc1
-rw-r--r--chromium/ui/aura/window_occlusion_tracker_unittest.cc54
-rw-r--r--chromium/ui/aura/window_tree_host_platform.cc14
-rw-r--r--chromium/ui/aura/window_tree_host_platform.h10
15 files changed, 597 insertions, 445 deletions
diff --git a/chromium/ui/aura/BUILD.gn b/chromium/ui/aura/BUILD.gn
index fd917270bb3..0b7516f4ee7 100644
--- a/chromium/ui/aura/BUILD.gn
+++ b/chromium/ui/aura/BUILD.gn
@@ -2,11 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("//build/config/jumbo.gni")
import("//build/config/ui.gni")
import("//testing/test.gni")
-jumbo_component("aura") {
+component("aura") {
public = [
"client/aura_constants.h",
"client/capture_client.h",
@@ -136,6 +135,7 @@ jumbo_component("aura") {
public_deps = [
"//ui/base/cursor:cursor_base",
+ "//ui/base/dragdrop/mojom:mojom_headers",
"//ui/base/ime",
"//ui/compositor",
]
@@ -174,7 +174,7 @@ jumbo_component("aura") {
configs += [ "//build/config/compiler:noshadowing" ]
}
-jumbo_static_library("test_support") {
+static_library("test_support") {
testonly = true
sources = [
"test/aura_test_base.cc",
@@ -247,9 +247,14 @@ jumbo_static_library("test_support") {
sources += [ "test/ui_controls_factory_aurawin.cc" ]
}
+ if (is_linux) {
+ sources += [ "test/ui_controls_factory_aura_linux.cc" ]
+ }
+
if (use_x11) {
sources += [
- "test/ui_controls_factory_aurax11.cc",
+ "test/ui_controls_aurax11.cc",
+ "test/ui_controls_aurax11.h",
"test/x11_event_sender.cc",
"test/x11_event_sender.h",
]
@@ -264,10 +269,13 @@ jumbo_static_library("test_support") {
if (is_fuchsia) {
deps += [ "//ui/ozone" ]
}
- sources += [ "test/ui_controls_factory_ozone.cc" ]
+ sources += [
+ "test/ui_controls_ozone.cc",
+ "test/ui_controls_ozone.h",
+ ]
}
- if (is_linux) {
+ if (is_linux || is_chromeos) {
deps += [ "//ui/platform_window/common" ]
}
}
@@ -306,6 +314,10 @@ executable("aura_demo") {
}
test("aura_unittests") {
+ if ((is_linux && !is_chromeos) || chromeos_is_browser_only) {
+ use_xvfb = true
+ }
+
sources = [
"../compositor_extra/shadow_unittest.cc",
"gestures/gesture_recognizer_unittest.cc",
diff --git a/chromium/ui/aura/DEPS b/chromium/ui/aura/DEPS
index 06cfc0080e1..5c4046ee903 100644
--- a/chromium/ui/aura/DEPS
+++ b/chromium/ui/aura/DEPS
@@ -21,6 +21,7 @@ include_rules = [
"+ui/gl/test",
"+ui/ozone/public",
"+ui/platform_window",
+ "+ui/base/ui_base_features.h",
]
specific_include_rules = {
diff --git a/chromium/ui/aura/client/drag_drop_client.h b/chromium/ui/aura/client/drag_drop_client.h
index 3d082567ca7..a6fa5efeb1d 100644
--- a/chromium/ui/aura/client/drag_drop_client.h
+++ b/chromium/ui/aura/client/drag_drop_client.h
@@ -8,7 +8,7 @@
#include <memory>
#include "ui/aura/aura_export.h"
-#include "ui/base/dragdrop/drag_drop_types.h"
+#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-forward.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
@@ -39,7 +39,7 @@ class AURA_EXPORT DragDropClient {
aura::Window* source_window,
const gfx::Point& screen_location,
int operation,
- ui::DragDropTypes::DragEventSource source) = 0;
+ ui::mojom::DragEventSource source) = 0;
// Called when a drag and drop session is cancelled.
virtual void DragCancel() = 0;
diff --git a/chromium/ui/aura/env.cc b/chromium/ui/aura/env.cc
index 22b7aac67d4..ae56d8fcb85 100644
--- a/chromium/ui/aura/env.cc
+++ b/chromium/ui/aura/env.cc
@@ -224,14 +224,15 @@ void Env::Init() {
// The ozone platform can provide its own event source. So initialize the
// platform before creating the default event source. If running inside mus
// let the mus process initialize ozone instead.
- ui::OzonePlatform::InitParams params;
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- // TODO(kylechar): Pass in single process information to Env::CreateInstance()
- // instead of checking flags here.
- params.single_process = command_line->HasSwitch("single-process") ||
- command_line->HasSwitch("in-process-gpu");
-
- ui::OzonePlatform::InitializeForUI(params);
+ if (features::IsUsingOzonePlatform()) {
+ ui::OzonePlatform::InitParams params;
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ // TODO(kylechar): Pass in single process information to
+ // Env::CreateInstance() instead of checking flags here.
+ params.single_process = command_line->HasSwitch("single-process") ||
+ command_line->HasSwitch("in-process-gpu");
+ ui::OzonePlatform::InitializeForUI(params);
+ }
#endif
if (!ui::PlatformEventSource::GetInstance())
event_source_ = ui::PlatformEventSource::CreateDefault();
diff --git a/chromium/ui/aura/test/ui_controls_factory_ozone.cc b/chromium/ui/aura/test/ui_controls_factory_ozone.cc
deleted file mode 100644
index 23e318e82c9..00000000000
--- a/chromium/ui/aura/test/ui_controls_factory_ozone.cc
+++ /dev/null
@@ -1,358 +0,0 @@
-// Copyright 2014 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 "base/bind.h"
-#include "base/location.h"
-#include "base/logging.h"
-#include "base/macros.h"
-#include "base/single_thread_task_runner.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "ui/aura/env.h"
-#include "ui/aura/test/aura_test_utils.h"
-#include "ui/aura/test/env_test_helper.h"
-#include "ui/aura/test/ui_controls_factory_aura.h"
-#include "ui/aura/window_tree_host.h"
-#include "ui/base/test/ui_controls_aura.h"
-#include "ui/display/display.h"
-#include "ui/display/screen.h"
-#include "ui/events/event_utils.h"
-#include "ui/events/test/events_test_utils.h"
-#include "ui/gfx/geometry/point_conversions.h"
-
-namespace aura {
-namespace test {
-namespace {
-
-class UIControlsOzone : public ui_controls::UIControlsAura {
- public:
- UIControlsOzone(WindowTreeHost* host) : host_(host) {
- }
- ~UIControlsOzone() override = default;
-
- private:
- // ui_controls::UIControlsAura:
- bool SendKeyPress(gfx::NativeWindow window,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command) override {
- return SendKeyPressNotifyWhenDone(window, key, control, shift, alt, command,
- base::OnceClosure());
- }
- bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command,
- base::OnceClosure closure) override {
- int flags = button_down_mask_;
- int64_t display_id =
- display::Screen::GetScreen()->GetDisplayNearestWindow(window).id();
-
- if (control) {
- flags |= ui::EF_CONTROL_DOWN;
- PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, flags, display_id,
- base::OnceClosure());
- }
-
- if (shift) {
- flags |= ui::EF_SHIFT_DOWN;
- PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, flags, display_id,
- base::OnceClosure());
- }
-
- if (alt) {
- flags |= ui::EF_ALT_DOWN;
- PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_MENU, flags, display_id,
- base::OnceClosure());
- }
-
- if (command) {
- flags |= ui::EF_COMMAND_DOWN;
- PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_LWIN, flags, display_id,
- base::OnceClosure());
- }
-
- PostKeyEvent(ui::ET_KEY_PRESSED, key, flags, display_id,
- base::OnceClosure());
- const bool has_modifier = control || shift || alt || command;
- // Pass the real closure to the last generated KeyEvent.
- PostKeyEvent(ui::ET_KEY_RELEASED, key, flags, display_id,
- has_modifier ? base::OnceClosure() : std::move(closure));
-
- if (alt) {
- flags &= ~ui::EF_ALT_DOWN;
- PostKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_MENU, flags, display_id,
- (shift || control || command) ? base::OnceClosure()
- : std::move(closure));
- }
-
- if (shift) {
- flags &= ~ui::EF_SHIFT_DOWN;
- PostKeyEvent(
- ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, flags, display_id,
- (control || command) ? base::OnceClosure() : std::move(closure));
- }
-
- if (control) {
- flags &= ~ui::EF_CONTROL_DOWN;
- PostKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, flags, display_id,
- command ? base::OnceClosure() : std::move(closure));
- }
-
- if (command) {
- flags &= ~ui::EF_COMMAND_DOWN;
- PostKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_LWIN, flags, display_id,
- std::move(closure));
- }
-
- return true;
- }
-
- bool SendMouseMove(int screen_x, int screen_y) override {
- return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::OnceClosure());
- }
- bool SendMouseMoveNotifyWhenDone(int screen_x,
- int screen_y,
- base::OnceClosure closure) override {
- gfx::PointF host_location(screen_x, screen_y);
- int64_t display_id = display::kInvalidDisplayId;
- if (!ScreenDIPToHostPixels(&host_location, &display_id))
- return false;
- ui::EventType event_type;
-
- if (button_down_mask_)
- event_type = ui::ET_MOUSE_DRAGGED;
- else
- event_type = ui::ET_MOUSE_MOVED;
-
- PostMouseEvent(event_type, host_location, button_down_mask_, 0, display_id,
- std::move(closure));
-
- return true;
- }
- bool SendMouseEvents(ui_controls::MouseButton type,
- int button_state,
- int accelerator_state) override {
- return SendMouseEventsNotifyWhenDone(
- type, button_state, base::OnceClosure(), accelerator_state);
- }
- bool SendMouseEventsNotifyWhenDone(ui_controls::MouseButton type,
- int button_state,
- base::OnceClosure closure,
- int accelerator_state) override {
- gfx::PointF host_location(Env::GetInstance()->last_mouse_location());
- int64_t display_id = display::kInvalidDisplayId;
- if (!ScreenDIPToHostPixels(&host_location, &display_id))
- return false;
-
- int changed_button_flag = 0;
-
- switch (type) {
- case ui_controls::LEFT:
- changed_button_flag = ui::EF_LEFT_MOUSE_BUTTON;
- break;
- case ui_controls::MIDDLE:
- changed_button_flag = ui::EF_MIDDLE_MOUSE_BUTTON;
- break;
- case ui_controls::RIGHT:
- changed_button_flag = ui::EF_RIGHT_MOUSE_BUTTON;
- break;
- default:
- NOTREACHED();
- break;
- }
-
- // Process the accelerator key state.
- int flag = changed_button_flag;
- if (accelerator_state & ui_controls::kShift)
- flag |= ui::EF_SHIFT_DOWN;
- if (accelerator_state & ui_controls::kControl)
- flag |= ui::EF_CONTROL_DOWN;
- if (accelerator_state & ui_controls::kAlt)
- flag |= ui::EF_ALT_DOWN;
- if (accelerator_state & ui_controls::kCommand)
- flag |= ui::EF_COMMAND_DOWN;
-
- if (button_state & ui_controls::DOWN) {
- button_down_mask_ |= flag;
- // Pass the real closure to the last generated MouseEvent.
- PostMouseEvent(ui::ET_MOUSE_PRESSED, host_location,
- button_down_mask_ | flag, changed_button_flag, display_id,
- (button_state & ui_controls::UP) ? base::OnceClosure()
- : std::move(closure));
- }
- if (button_state & ui_controls::UP) {
- button_down_mask_ &= ~flag;
- PostMouseEvent(ui::ET_MOUSE_RELEASED, host_location,
- button_down_mask_ | flag, changed_button_flag, display_id,
- std::move(closure));
- }
-
- return true;
- }
- bool SendMouseClick(ui_controls::MouseButton type) override {
- return SendMouseEvents(type, ui_controls::UP | ui_controls::DOWN,
- ui_controls::kNoAccelerator);
- }
-#if defined(OS_CHROMEOS)
- bool SendTouchEvents(int action, int id, int x, int y) override {
- return SendTouchEventsNotifyWhenDone(action, id, x, y, base::OnceClosure());
- }
- bool SendTouchEventsNotifyWhenDone(int action,
- int id,
- int x,
- int y,
- base::OnceClosure task) override {
- DCHECK_NE(0, action);
- gfx::PointF host_location(x, y);
- int64_t display_id = display::kInvalidDisplayId;
- if (!ScreenDIPToHostPixels(&host_location, &display_id))
- return false;
- bool has_move = action & ui_controls::MOVE;
- bool has_release = action & ui_controls::RELEASE;
- if (action & ui_controls::PRESS) {
- PostTouchEvent(
- ui::ET_TOUCH_PRESSED, host_location, id, display_id,
- (has_move || has_release) ? base::OnceClosure() : std::move(task));
- }
- if (has_move) {
- PostTouchEvent(ui::ET_TOUCH_MOVED, host_location, id, display_id,
- has_release ? base::OnceClosure() : std::move(task));
- }
- if (has_release) {
- PostTouchEvent(ui::ET_TOUCH_RELEASED, host_location, id, display_id,
- std::move(task));
- }
- return true;
- }
-#endif
-
- void SendEventToSink(ui::Event* event,
- int64_t display_id,
- base::OnceClosure closure) {
- // Post the task before processing the event. This is necessary in case
- // processing the event results in a nested message loop.
- if (closure) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
- std::move(closure));
- }
-
- ui::EventSourceTestApi event_source_test(host_->GetEventSource());
- ignore_result(event_source_test.SendEventToSink(event));
- }
-
- void PostKeyEvent(ui::EventType type,
- ui::KeyboardCode key_code,
- int flags,
- int64_t display_id,
- base::OnceClosure closure) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(&UIControlsOzone::PostKeyEventTask,
- base::Unretained(this), type, key_code, flags,
- display_id, std::move(closure)));
- }
-
- void PostKeyEventTask(ui::EventType type,
- ui::KeyboardCode key_code,
- int flags,
- int64_t display_id,
- base::OnceClosure closure) {
- // Do not rewrite injected events. See crbug.com/136465.
- flags |= ui::EF_FINAL;
-
- ui::KeyEvent key_event(type, key_code, flags);
- SendEventToSink(&key_event, display_id, std::move(closure));
- }
-
- void PostMouseEvent(ui::EventType type,
- const gfx::PointF& host_location,
- int flags,
- int changed_button_flags,
- int64_t display_id,
- base::OnceClosure closure) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::BindOnce(&UIControlsOzone::PostMouseEventTask,
- base::Unretained(this), type, host_location, flags,
- changed_button_flags, display_id, std::move(closure)));
- }
-
- void PostMouseEventTask(ui::EventType type,
- const gfx::PointF& host_location,
- int flags,
- int changed_button_flags,
- int64_t display_id,
- base::OnceClosure closure) {
- ui::MouseEvent mouse_event(type, host_location, host_location,
- ui::EventTimeForNow(), flags,
- changed_button_flags);
-
- // This hack is necessary to set the repeat count for clicks.
- ui::MouseEvent mouse_event2(&mouse_event);
-
- SendEventToSink(&mouse_event2, display_id, std::move(closure));
- }
-
- void PostTouchEvent(ui::EventType type,
- const gfx::PointF& host_location,
- int id,
- int64_t display_id,
- base::OnceClosure closure) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(&UIControlsOzone::PostTouchEventTask,
- base::Unretained(this), type, host_location,
- id, display_id, std::move(closure)));
- }
-
- void PostTouchEventTask(ui::EventType type,
- const gfx::PointF& host_location,
- int id,
- int64_t display_id,
- base::OnceClosure closure) {
- ui::PointerDetails details(ui::EventPointerType::kTouch, id, 1.0f, 1.0f,
- 0.0f);
- ui::TouchEvent touch_event(type, host_location, host_location,
- ui::EventTimeForNow(), details);
- SendEventToSink(&touch_event, display_id, std::move(closure));
- }
-
- bool ScreenDIPToHostPixels(gfx::PointF* location, int64_t* display_id) {
- // The location needs to be in display's coordinate.
- display::Display display =
- display::Screen::GetScreen()->GetDisplayNearestPoint(
- gfx::ToFlooredPoint(*location));
- if (!display.is_valid()) {
- LOG(ERROR) << "Failed to find the display for " << location->ToString();
- return false;
- }
- *display_id = display.id();
- *location -= display.bounds().OffsetFromOrigin();
- location->Scale(display.device_scale_factor());
- return true;
- }
-
- WindowTreeHost* host_;
-
- // Mask of the mouse buttons currently down. This is static as it needs to
- // track the state globally for all displays. A UIControlsOzone instance is
- // created for each display host.
- static unsigned button_down_mask_;
-
- DISALLOW_COPY_AND_ASSIGN(UIControlsOzone);
-};
-
-// static
-unsigned UIControlsOzone::button_down_mask_ = 0;
-
-} // namespace
-
-ui_controls::UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) {
- return new UIControlsOzone(host);
-}
-
-} // namespace test
-} // namespace aura
diff --git a/chromium/ui/aura/test/ui_controls_ozone.cc b/chromium/ui/aura/test/ui_controls_ozone.cc
new file mode 100644
index 00000000000..93ee63a84c0
--- /dev/null
+++ b/chromium/ui/aura/test/ui_controls_ozone.cc
@@ -0,0 +1,358 @@
+// Copyright 2020 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/test/ui_controls_ozone.h"
+
+#include "build/build_config.h"
+
+namespace aura {
+namespace test {
+
+// static
+unsigned UIControlsOzone::button_down_mask_ = 0;
+
+UIControlsOzone::UIControlsOzone(WindowTreeHost* host) : host_(host) {}
+
+UIControlsOzone::~UIControlsOzone() = default;
+
+bool UIControlsOzone::SendKeyPress(gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command) {
+ return SendKeyPressNotifyWhenDone(window, key, control, shift, alt, command,
+ base::OnceClosure());
+}
+
+bool UIControlsOzone::SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ base::OnceClosure closure) {
+ WindowTreeHost* optional_host = nullptr;
+ // Send the key event to the window's host, which may not match |host_|.
+ // This logic should probably exist for the non-aura path as well.
+ // TODO(https://crbug.com/1116649) Support non-aura path.
+#if defined(USE_AURA)
+ if (window != nullptr && window->GetHost() != nullptr &&
+ window->GetHost() != host_)
+ optional_host = window->GetHost();
+#endif
+
+ int flags = button_down_mask_;
+ int64_t display_id =
+ display::Screen::GetScreen()->GetDisplayNearestWindow(window).id();
+
+ if (control) {
+ flags |= ui::EF_CONTROL_DOWN;
+ PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, flags, display_id,
+ base::OnceClosure(), optional_host);
+ }
+
+ if (shift) {
+ flags |= ui::EF_SHIFT_DOWN;
+ PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, flags, display_id,
+ base::OnceClosure(), optional_host);
+ }
+
+ if (alt) {
+ flags |= ui::EF_ALT_DOWN;
+ PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_MENU, flags, display_id,
+ base::OnceClosure(), optional_host);
+ }
+
+ if (command) {
+ flags |= ui::EF_COMMAND_DOWN;
+ PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_LWIN, flags, display_id,
+ base::OnceClosure(), optional_host);
+ }
+
+ PostKeyEvent(ui::ET_KEY_PRESSED, key, flags, display_id, base::OnceClosure(),
+ optional_host);
+ const bool has_modifier = control || shift || alt || command;
+ // Pass the real closure to the last generated KeyEvent.
+ PostKeyEvent(ui::ET_KEY_RELEASED, key, flags, display_id,
+ has_modifier ? base::OnceClosure() : std::move(closure),
+ optional_host);
+
+ if (alt) {
+ flags &= ~ui::EF_ALT_DOWN;
+ PostKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_MENU, flags, display_id,
+ (shift || control || command) ? base::OnceClosure()
+ : std::move(closure),
+ optional_host);
+ }
+
+ if (shift) {
+ flags &= ~ui::EF_SHIFT_DOWN;
+ PostKeyEvent(
+ ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, flags, display_id,
+ (control || command) ? base::OnceClosure() : std::move(closure),
+ optional_host);
+ }
+
+ if (control) {
+ flags &= ~ui::EF_CONTROL_DOWN;
+ PostKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, flags, display_id,
+ command ? base::OnceClosure() : std::move(closure),
+ optional_host);
+ }
+
+ if (command) {
+ flags &= ~ui::EF_COMMAND_DOWN;
+ PostKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_LWIN, flags, display_id,
+ std::move(closure), optional_host);
+ }
+
+ return true;
+}
+
+bool UIControlsOzone::SendMouseMove(int screen_x, int screen_y) {
+ return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::OnceClosure());
+}
+
+bool UIControlsOzone::SendMouseMoveNotifyWhenDone(int screen_x,
+ int screen_y,
+ base::OnceClosure closure) {
+ gfx::PointF host_location(screen_x, screen_y);
+ int64_t display_id = display::kInvalidDisplayId;
+ if (!ScreenDIPToHostPixels(&host_location, &display_id))
+ return false;
+ ui::EventType event_type;
+
+ if (button_down_mask_)
+ event_type = ui::ET_MOUSE_DRAGGED;
+ else
+ event_type = ui::ET_MOUSE_MOVED;
+
+ PostMouseEvent(event_type, host_location, button_down_mask_, 0, display_id,
+ std::move(closure));
+
+ return true;
+}
+
+bool UIControlsOzone::SendMouseEvents(ui_controls::MouseButton type,
+ int button_state,
+ int accelerator_state) {
+ return SendMouseEventsNotifyWhenDone(type, button_state, base::OnceClosure(),
+ accelerator_state);
+}
+
+bool UIControlsOzone::SendMouseEventsNotifyWhenDone(
+ ui_controls::MouseButton type,
+ int button_state,
+ base::OnceClosure closure,
+ int accelerator_state) {
+ gfx::PointF host_location(Env::GetInstance()->last_mouse_location());
+ int64_t display_id = display::kInvalidDisplayId;
+ if (!ScreenDIPToHostPixels(&host_location, &display_id))
+ return false;
+
+ int changed_button_flag = 0;
+
+ switch (type) {
+ case ui_controls::LEFT:
+ changed_button_flag = ui::EF_LEFT_MOUSE_BUTTON;
+ break;
+ case ui_controls::MIDDLE:
+ changed_button_flag = ui::EF_MIDDLE_MOUSE_BUTTON;
+ break;
+ case ui_controls::RIGHT:
+ changed_button_flag = ui::EF_RIGHT_MOUSE_BUTTON;
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+
+ // Process the accelerator key state.
+ int flag = changed_button_flag;
+ if (accelerator_state & ui_controls::kShift)
+ flag |= ui::EF_SHIFT_DOWN;
+ if (accelerator_state & ui_controls::kControl)
+ flag |= ui::EF_CONTROL_DOWN;
+ if (accelerator_state & ui_controls::kAlt)
+ flag |= ui::EF_ALT_DOWN;
+ if (accelerator_state & ui_controls::kCommand)
+ flag |= ui::EF_COMMAND_DOWN;
+
+ if (button_state & ui_controls::DOWN) {
+ button_down_mask_ |= flag;
+ // Pass the real closure to the last generated MouseEvent.
+ PostMouseEvent(ui::ET_MOUSE_PRESSED, host_location,
+ button_down_mask_ | flag, changed_button_flag, display_id,
+ (button_state & ui_controls::UP) ? base::OnceClosure()
+ : std::move(closure));
+ }
+ if (button_state & ui_controls::UP) {
+ button_down_mask_ &= ~flag;
+ PostMouseEvent(ui::ET_MOUSE_RELEASED, host_location,
+ button_down_mask_ | flag, changed_button_flag, display_id,
+ std::move(closure));
+ }
+
+ return true;
+}
+
+bool UIControlsOzone::SendMouseClick(ui_controls::MouseButton type) {
+ return SendMouseEvents(type, ui_controls::UP | ui_controls::DOWN,
+ ui_controls::kNoAccelerator);
+}
+
+#if defined(OS_CHROMEOS)
+bool UIControlsOzone::SendTouchEvents(int action, int id, int x, int y) {
+ return SendTouchEventsNotifyWhenDone(action, id, x, y, base::OnceClosure());
+}
+
+bool UIControlsOzone::SendTouchEventsNotifyWhenDone(int action,
+ int id,
+ int x,
+ int y,
+ base::OnceClosure task) {
+ DCHECK_NE(0, action);
+ gfx::PointF host_location(x, y);
+ int64_t display_id = display::kInvalidDisplayId;
+ if (!ScreenDIPToHostPixels(&host_location, &display_id))
+ return false;
+ bool has_move = action & ui_controls::MOVE;
+ bool has_release = action & ui_controls::RELEASE;
+ if (action & ui_controls::PRESS) {
+ PostTouchEvent(
+ ui::ET_TOUCH_PRESSED, host_location, id, display_id,
+ (has_move || has_release) ? base::OnceClosure() : std::move(task));
+ }
+ if (has_move) {
+ PostTouchEvent(ui::ET_TOUCH_MOVED, host_location, id, display_id,
+ has_release ? base::OnceClosure() : std::move(task));
+ }
+ if (has_release) {
+ PostTouchEvent(ui::ET_TOUCH_RELEASED, host_location, id, display_id,
+ std::move(task));
+ }
+ return true;
+}
+#endif
+
+void UIControlsOzone::SendEventToSink(ui::Event* event,
+ int64_t display_id,
+ base::OnceClosure closure,
+ WindowTreeHost* optional_host) {
+ // Post the task before processing the event. This is necessary in case
+ // processing the event results in a nested message loop.
+ if (closure) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
+ std::move(closure));
+ }
+ WindowTreeHost* host = optional_host ? optional_host : host_;
+ ui::EventSourceTestApi event_source_test(host->GetEventSource());
+ ignore_result(event_source_test.SendEventToSink(event));
+}
+
+void UIControlsOzone::PostKeyEvent(ui::EventType type,
+ ui::KeyboardCode key_code,
+ int flags,
+ int64_t display_id,
+ base::OnceClosure closure,
+ WindowTreeHost* optional_host) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(&UIControlsOzone::PostKeyEventTask,
+ base::Unretained(this), type, key_code, flags,
+ display_id, std::move(closure), optional_host));
+}
+
+void UIControlsOzone::PostKeyEventTask(ui::EventType type,
+ ui::KeyboardCode key_code,
+ int flags,
+ int64_t display_id,
+ base::OnceClosure closure,
+ WindowTreeHost* optional_host) {
+ // Do not rewrite injected events. See crbug.com/136465.
+ flags |= ui::EF_FINAL;
+
+ ui::KeyEvent key_event(type, key_code, flags);
+ SendEventToSink(&key_event, display_id, std::move(closure), optional_host);
+}
+
+void UIControlsOzone::PostMouseEvent(ui::EventType type,
+ const gfx::PointF& host_location,
+ int flags,
+ int changed_button_flags,
+ int64_t display_id,
+ base::OnceClosure closure) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::BindOnce(&UIControlsOzone::PostMouseEventTask,
+ base::Unretained(this), type, host_location, flags,
+ changed_button_flags, display_id, std::move(closure)));
+}
+
+void UIControlsOzone::PostMouseEventTask(ui::EventType type,
+ const gfx::PointF& host_location,
+ int flags,
+ int changed_button_flags,
+ int64_t display_id,
+ base::OnceClosure closure) {
+ ui::MouseEvent mouse_event(type, host_location, host_location,
+ ui::EventTimeForNow(), flags,
+ changed_button_flags);
+
+ // This hack is necessary to set the repeat count for clicks.
+ ui::MouseEvent mouse_event2(&mouse_event);
+
+ SendEventToSink(&mouse_event2, display_id, std::move(closure));
+}
+
+void UIControlsOzone::PostTouchEvent(ui::EventType type,
+ const gfx::PointF& host_location,
+ int id,
+ int64_t display_id,
+ base::OnceClosure closure) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(&UIControlsOzone::PostTouchEventTask,
+ base::Unretained(this), type, host_location, id,
+ display_id, std::move(closure)));
+}
+
+void UIControlsOzone::PostTouchEventTask(ui::EventType type,
+ const gfx::PointF& host_location,
+ int id,
+ int64_t display_id,
+ base::OnceClosure closure) {
+ ui::PointerDetails details(ui::EventPointerType::kTouch, id, 1.0f, 1.0f,
+ 0.0f);
+ ui::TouchEvent touch_event(type, host_location, host_location,
+ ui::EventTimeForNow(), details);
+ SendEventToSink(&touch_event, display_id, std::move(closure));
+}
+
+bool UIControlsOzone::ScreenDIPToHostPixels(gfx::PointF* location,
+ int64_t* display_id) {
+ // The location needs to be in display's coordinate.
+ display::Display display =
+ display::Screen::GetScreen()->GetDisplayNearestPoint(
+ gfx::ToFlooredPoint(*location));
+ if (!display.is_valid()) {
+ LOG(ERROR) << "Failed to find the display for " << location->ToString();
+ return false;
+ }
+ *display_id = display.id();
+ *location -= display.bounds().OffsetFromOrigin();
+ location->Scale(display.device_scale_factor());
+ return true;
+}
+
+// To avoid multiple definitions when use_x11 && use_ozone is true, disable this
+// factory method for OS_LINUX as Linux has a factory method that decides what
+// UIControls to use based on IsUsingOzonePlatform feature flag.
+#if !defined(OS_LINUX)
+ui_controls::UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) {
+ return new UIControlsOzone(host);
+}
+#endif
+
+} // namespace test
+} // namespace aura
diff --git a/chromium/ui/aura/test/ui_controls_ozone.h b/chromium/ui/aura/test/ui_controls_ozone.h
new file mode 100644
index 00000000000..e85844fba15
--- /dev/null
+++ b/chromium/ui/aura/test/ui_controls_ozone.h
@@ -0,0 +1,135 @@
+// Copyright 2020 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_TEST_UI_CONTROLS_OZONE_H_
+#define UI_AURA_TEST_UI_CONTROLS_OZONE_H_
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/logging.h"
+#include "base/macros.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "ui/aura/env.h"
+#include "ui/aura/test/aura_test_utils.h"
+#include "ui/aura/test/env_test_helper.h"
+#include "ui/aura/test/ui_controls_factory_aura.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/base/test/ui_controls_aura.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
+#include "ui/events/event_utils.h"
+#include "ui/events/test/events_test_utils.h"
+#include "ui/gfx/geometry/point_conversions.h"
+
+namespace aura {
+namespace test {
+
+class UIControlsOzone : public ui_controls::UIControlsAura {
+ public:
+ explicit UIControlsOzone(WindowTreeHost* host);
+ UIControlsOzone(const UIControlsOzone&) = delete;
+ UIControlsOzone& operator=(const UIControlsOzone&) = delete;
+ ~UIControlsOzone() override;
+
+ private:
+ // ui_controls::UIControlsAura:
+ bool SendKeyPress(gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command) override;
+ bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ base::OnceClosure closure) override;
+ bool SendMouseMove(int screen_x, int screen_y) override;
+ bool SendMouseMoveNotifyWhenDone(int screen_x,
+ int screen_y,
+ base::OnceClosure closure) override;
+ bool SendMouseEvents(ui_controls::MouseButton type,
+ int button_state,
+ int accelerator_state) override;
+ bool SendMouseEventsNotifyWhenDone(ui_controls::MouseButton type,
+ int button_state,
+ base::OnceClosure closure,
+ int accelerator_state) override;
+ bool SendMouseClick(ui_controls::MouseButton type) override;
+#if defined(OS_CHROMEOS)
+ bool SendTouchEvents(int action, int id, int x, int y) override;
+ bool SendTouchEventsNotifyWhenDone(int action,
+ int id,
+ int x,
+ int y,
+ base::OnceClosure task) override;
+#endif
+
+ // Use |optional_host| to specify the host.
+ // When |optional_host| is not null, event will be sent to |optional_host|.
+ // When |optional_host| is null, event will be sent to the default host.
+ void SendEventToSink(ui::Event* event,
+ int64_t display_id,
+ base::OnceClosure closure,
+ WindowTreeHost* optional_host = nullptr);
+
+ void PostKeyEvent(ui::EventType type,
+ ui::KeyboardCode key_code,
+ int flags,
+ int64_t display_id,
+ base::OnceClosure closure,
+ WindowTreeHost* optional_host = nullptr);
+
+ void PostKeyEventTask(ui::EventType type,
+ ui::KeyboardCode key_code,
+ int flags,
+ int64_t display_id,
+ base::OnceClosure closure,
+ WindowTreeHost* optional_host);
+
+ void PostMouseEvent(ui::EventType type,
+ const gfx::PointF& host_location,
+ int flags,
+ int changed_button_flags,
+ int64_t display_id,
+ base::OnceClosure closure);
+
+ void PostMouseEventTask(ui::EventType type,
+ const gfx::PointF& host_location,
+ int flags,
+ int changed_button_flags,
+ int64_t display_id,
+ base::OnceClosure closure);
+
+ void PostTouchEvent(ui::EventType type,
+ const gfx::PointF& host_location,
+ int id,
+ int64_t display_id,
+ base::OnceClosure closure);
+
+ void PostTouchEventTask(ui::EventType type,
+ const gfx::PointF& host_location,
+ int id,
+ int64_t display_id,
+ base::OnceClosure closure);
+
+ bool ScreenDIPToHostPixels(gfx::PointF* location, int64_t* display_id);
+
+ // This is the default host used for events that are not scoped to a window.
+ // Events scoped to a window always use the window's host.
+ WindowTreeHost* const host_;
+
+ // Mask of the mouse buttons currently down. This is static as it needs to
+ // track the state globally for all displays. A UIControlsOzone instance is
+ // created for each display host.
+ static unsigned button_down_mask_;
+};
+
+} // namespace test
+} // namespace aura
+
+#endif // UI_AURA_TEST_UI_CONTROLS_OZONE_H_
diff --git a/chromium/ui/aura/window.cc b/chromium/ui/aura/window.cc
index 7d6cff67049..6151f197ad6 100644
--- a/chromium/ui/aura/window.cc
+++ b/chromium/ui/aura/window.cc
@@ -900,16 +900,17 @@ void Window::SetVisible(bool visible) {
void Window::SetOcclusionInfo(OcclusionState occlusion_state,
const SkRegion& occluded_region) {
- if (occlusion_state != occlusion_state_ ||
- occluded_region_ != occluded_region) {
- occlusion_state_ = occlusion_state;
- occluded_region_ = occluded_region;
- if (delegate_)
- delegate_->OnWindowOcclusionChanged(occlusion_state, occluded_region);
-
- for (WindowObserver& observer : observers_)
- observer.OnWindowOcclusionChanged(this);
+ if (occlusion_state == occlusion_state_ &&
+ occluded_region_in_root_ == occluded_region) {
+ return;
}
+ occlusion_state_ = occlusion_state;
+ occluded_region_in_root_ = occluded_region;
+ if (delegate_)
+ delegate_->OnWindowOcclusionChanged(occlusion_state);
+
+ for (WindowObserver& observer : observers_)
+ observer.OnWindowOcclusionChanged(this);
}
void Window::SchedulePaint() {
diff --git a/chromium/ui/aura/window.h b/chromium/ui/aura/window.h
index 6251d9a30e8..e2a908f7ab3 100644
--- a/chromium/ui/aura/window.h
+++ b/chromium/ui/aura/window.h
@@ -41,7 +41,7 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
-#if defined(OS_MACOSX)
+#if defined(OS_APPLE)
#error This file must not be included on macOS; Chromium Mac doesn't use Aura.
#endif
@@ -219,17 +219,19 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// WindowOcclusionTracker::ScopedPause.
OcclusionState occlusion_state() const { return occlusion_state_; }
- // Returns the currently occluded region. This will be empty unless
- // the window is tracked and has a VISIBLE occlusion state. That is,
- // this is only maintained when the window is partially occluded. Further,
- // this region may extend outside the window bounds. For performance reasons,
- // the actual intersection with the window is not computed. The occluded
- // region is the set of window rectangles that may occlude this window.
- // Note that this means that the occluded region may be updated if one of
- // those windows moves, even if the actual intersection of the occluded
- // region with this window does not change. Clients may compute the actual
- // intersection region if necessary.
- const SkRegion& occluded_region() const { return occluded_region_; }
+ // Returns the currently occluded region in the root Window coordinates. This
+ // will be empty unless the window is tracked and has a VISIBLE occlusion
+ // state. That is, this is only maintained when the window is partially
+ // occluded. Further, this region may extend outside the window bounds. For
+ // performance reasons, the actual intersection with the window is not
+ // computed. The occluded region is the set of window rectangles that may
+ // occlude this window. Note that this means that the occluded region may be
+ // updated if one of those windows moves, even if the actual intersection of
+ // the occluded region with this window does not change. Clients may compute
+ // the actual intersection region if necessary.
+ const SkRegion& occluded_region_in_root() const {
+ return occluded_region_in_root_;
+ }
// Returns the window's bounds in root window's coordinates.
gfx::Rect GetBoundsInRootWindow() const;
@@ -662,8 +664,8 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// Occlusion state of the window.
OcclusionState occlusion_state_ = OcclusionState::UNKNOWN;
- // Occluded region of the window.
- SkRegion occluded_region_;
+ // Occluded region of the window in the root window coordiantes.
+ SkRegion occluded_region_in_root_;
int id_ = kInitialId;
diff --git a/chromium/ui/aura/window_delegate.h b/chromium/ui/aura/window_delegate.h
index a4eb06ad390..67fd3e78394 100644
--- a/chromium/ui/aura/window_delegate.h
+++ b/chromium/ui/aura/window_delegate.h
@@ -89,10 +89,9 @@ class AURA_EXPORT WindowDelegate : public ui::EventHandler {
// Called when the occlusion state or occluded region of the Window changes
// while tracked (see WindowOcclusionTracker::Track). |occlusion_state| is
- // the new occlusion state of the Window. |occluded_region| is the new
- // occluded region of the Window.
- virtual void OnWindowOcclusionChanged(Window::OcclusionState occlusion_state,
- const SkRegion& occluded_region) {}
+ // the new occlusion state of the Window.
+ virtual void OnWindowOcclusionChanged(
+ Window::OcclusionState occlusion_state) {}
// Called from Window::HitTest to check if the window has a custom hit test
// mask. It works similar to the views counterparts. That is, if the function
diff --git a/chromium/ui/aura/window_occlusion_change_builder_unittest.cc b/chromium/ui/aura/window_occlusion_change_builder_unittest.cc
index 6291fc0d4fa..8338e77a86a 100644
--- a/chromium/ui/aura/window_occlusion_change_builder_unittest.cc
+++ b/chromium/ui/aura/window_occlusion_change_builder_unittest.cc
@@ -21,6 +21,8 @@ class OcclusionTrackWindowDelegate : public test::TestWindowDelegate {
OcclusionTrackWindowDelegate() = default;
~OcclusionTrackWindowDelegate() override = default;
+ void set_window(Window* window) { window_ = window; }
+
bool occlusion_change_count() const { return occlusion_change_count_; }
Window::OcclusionState last_occlusion_state() const {
return last_occlusion_state_;
@@ -29,13 +31,14 @@ class OcclusionTrackWindowDelegate : public test::TestWindowDelegate {
private:
// test::TestWindowDelegate:
- void OnWindowOcclusionChanged(Window::OcclusionState occlusion_state,
- const SkRegion& occluded_region) override {
+ void OnWindowOcclusionChanged(
+ Window::OcclusionState occlusion_state) override {
++occlusion_change_count_;
last_occlusion_state_ = occlusion_state;
- last_occluded_region_ = occluded_region;
+ last_occluded_region_ = window_->occluded_region_in_root();
}
+ Window* window_ = nullptr;
int occlusion_change_count_ = 0;
Window::OcclusionState last_occlusion_state_ =
Window::OcclusionState::UNKNOWN;
@@ -54,6 +57,7 @@ class WindowOcclusionChangeBuilderTest : public test::AuraTestBase {
std::unique_ptr<Window> CreateTestWindow(
OcclusionTrackWindowDelegate* delegate) {
auto window = std::make_unique<Window>(delegate);
+ delegate->set_window(window.get());
window->set_owned_by_parent(false);
window->SetType(client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_TEXTURED);
diff --git a/chromium/ui/aura/window_occlusion_tracker.cc b/chromium/ui/aura/window_occlusion_tracker.cc
index fe5146c337e..8a13839bfdb 100644
--- a/chromium/ui/aura/window_occlusion_tracker.cc
+++ b/chromium/ui/aura/window_occlusion_tracker.cc
@@ -14,7 +14,6 @@
#include "ui/aura/window_occlusion_change_builder.h"
#include "ui/aura/window_tree_host.h"
#include "ui/gfx/geometry/rect_conversions.h"
-#include "ui/gfx/geometry/safe_integer_conversions.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/transform.h"
diff --git a/chromium/ui/aura/window_occlusion_tracker_unittest.cc b/chromium/ui/aura/window_occlusion_tracker_unittest.cc
index b252a999cb5..31ba4e71245 100644
--- a/chromium/ui/aura/window_occlusion_tracker_unittest.cc
+++ b/chromium/ui/aura/window_occlusion_tracker_unittest.cc
@@ -39,6 +39,7 @@ class MockWindowDelegate : public test::ColorTestWindowDelegate {
~MockWindowDelegate() override { EXPECT_FALSE(is_expecting_call()); }
void set_window(Window* window) { window_ = window; }
+ Window* window() { return window_; }
void SetName(const std::string& name) { window_->SetName(name); }
@@ -52,13 +53,13 @@ class MockWindowDelegate : public test::ColorTestWindowDelegate {
return expected_occlusion_state_ != Window::OcclusionState::UNKNOWN;
}
- void OnWindowOcclusionChanged(Window::OcclusionState occlusion_state,
- const SkRegion& occluded_region) override {
+ void OnWindowOcclusionChanged(
+ Window::OcclusionState occlusion_state) override {
SCOPED_TRACE(window_->GetName());
ASSERT_TRUE(window_);
EXPECT_NE(occlusion_state, Window::OcclusionState::UNKNOWN);
EXPECT_EQ(occlusion_state, expected_occlusion_state_);
- EXPECT_EQ(occluded_region, expected_occluded_region_);
+ EXPECT_EQ(window_->occluded_region_in_root(), expected_occluded_region_);
expected_occlusion_state_ = Window::OcclusionState::UNKNOWN;
expected_occluded_region_ = SkRegion();
}
@@ -1561,17 +1562,15 @@ namespace {
class WindowDelegateHidingWindowIfOccluded : public MockWindowDelegate {
public:
- WindowDelegateHidingWindowIfOccluded(Window* other_window)
+ explicit WindowDelegateHidingWindowIfOccluded(Window* other_window)
: other_window_(other_window) {}
// MockWindowDelegate:
- void OnWindowOcclusionChanged(Window::OcclusionState occlusion_state,
- const SkRegion& occluded_region) override {
- MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state,
- occluded_region);
- if (occlusion_state == Window::OcclusionState::HIDDEN) {
+ void OnWindowOcclusionChanged(
+ Window::OcclusionState occlusion_state) override {
+ MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state);
+ if (occlusion_state == Window::OcclusionState::HIDDEN)
other_window_->Hide();
- }
}
private:
@@ -1591,10 +1590,9 @@ class WindowDelegateWithQueuedExpectation : public MockWindowDelegate {
}
// MockWindowDelegate:
- void OnWindowOcclusionChanged(Window::OcclusionState occlusion_state,
- const SkRegion& occluded_region) override {
- MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state,
- occluded_region);
+ void OnWindowOcclusionChanged(
+ Window::OcclusionState occlusion_state) override {
+ MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state);
if (queued_expected_occlusion_state_ != Window::OcclusionState::UNKNOWN) {
set_expectation(queued_expected_occlusion_state_,
queued_expected_occluded_region_);
@@ -1657,10 +1655,9 @@ class WindowDelegateDeletingWindow : public MockWindowDelegate {
void set_other_window(Window* other_window) { other_window_ = other_window; }
// MockWindowDelegate:
- void OnWindowOcclusionChanged(Window::OcclusionState occlusion_state,
- const SkRegion& occluded_region) override {
- MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state,
- occluded_region);
+ void OnWindowOcclusionChanged(
+ Window::OcclusionState occlusion_state) override {
+ MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state);
if (occlusion_state == Window::OcclusionState::OCCLUDED) {
delete other_window_;
other_window_ = nullptr;
@@ -1728,10 +1725,9 @@ class WindowDelegateChangingWindowVisibility : public MockWindowDelegate {
void set_window_to_update(Window* window) { window_to_update_ = window; }
// MockWindowDelegate:
- void OnWindowOcclusionChanged(Window::OcclusionState occlusion_state,
- const SkRegion& occluded_region) override {
- MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state,
- occluded_region);
+ void OnWindowOcclusionChanged(
+ Window::OcclusionState occlusion_state) override {
+ MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state);
if (!window_to_update_)
return;
@@ -1920,10 +1916,9 @@ class WindowDelegateHidingWindow : public MockWindowDelegate {
void set_window_to_update(Window* window) { window_to_update_ = window; }
// MockWindowDelegate:
- void OnWindowOcclusionChanged(Window::OcclusionState occlusion_state,
- const SkRegion& occluded_region) override {
- MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state,
- occluded_region);
+ void OnWindowOcclusionChanged(
+ Window::OcclusionState occlusion_state) override {
+ MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state);
if (!window_to_update_)
return;
@@ -1950,10 +1945,9 @@ class WindowDelegateAddingAndHidingChild : public MockWindowDelegate {
void set_window_to_update(Window* window) { window_to_update_ = window; }
// MockWindowDelegate:
- void OnWindowOcclusionChanged(Window::OcclusionState occlusion_state,
- const SkRegion& occluded_region) override {
- MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state,
- occluded_region);
+ void OnWindowOcclusionChanged(
+ Window::OcclusionState occlusion_state) override {
+ MockWindowDelegate::OnWindowOcclusionChanged(occlusion_state);
if (queued_expected_occlusion_state_ != Window::OcclusionState::UNKNOWN) {
set_expectation(queued_expected_occlusion_state_,
queued_expected_occluded_region_);
diff --git a/chromium/ui/aura/window_tree_host_platform.cc b/chromium/ui/aura/window_tree_host_platform.cc
index 917b45bf3f8..01843f47b17 100644
--- a/chromium/ui/aura/window_tree_host_platform.cc
+++ b/chromium/ui/aura/window_tree_host_platform.cc
@@ -29,6 +29,7 @@
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
+#include "ui/events/keycodes/dom/dom_keyboard_layout_map.h"
#include "ui/ozone/public/ozone_platform.h"
#endif
@@ -39,8 +40,6 @@
#if defined(USE_X11)
#include "ui/platform_window/x11/x11_window.h" // nogncheck
-#else
-#include "ui/events/keycodes/dom/dom_keyboard_layout_map.h"
#endif
namespace aura {
@@ -172,12 +171,13 @@ bool WindowTreeHostPlatform::IsKeyLocked(ui::DomCode dom_code) {
base::flat_map<std::string, std::string>
WindowTreeHostPlatform::GetKeyboardLayoutMap() {
-#if !defined(USE_X11)
- return ui::GenerateDomKeyboardLayoutMap();
-#else
+#if defined(USE_OZONE)
+ // USE_X11 supports keyboard layout map through LinuxUI.
+ if (features::IsUsingOzonePlatform())
+ return ui::GenerateDomKeyboardLayoutMap();
+#endif
NOTIMPLEMENTED();
return {};
-#endif
}
void WindowTreeHostPlatform::SetCursorNative(gfx::NativeCursor cursor) {
@@ -261,6 +261,8 @@ void WindowTreeHostPlatform::OnAcceleratedWidgetAvailable(
WindowTreeHost::OnAcceleratedWidgetAvailable();
}
+void WindowTreeHostPlatform::OnWillDestroyAcceleratedWidget() {}
+
void WindowTreeHostPlatform::OnAcceleratedWidgetDestroyed() {
gfx::AcceleratedWidget widget = compositor()->ReleaseAcceleratedWidget();
DCHECK_EQ(widget, widget_);
diff --git a/chromium/ui/aura/window_tree_host_platform.h b/chromium/ui/aura/window_tree_host_platform.h
index ff4050c1ed4..27d7d78a34a 100644
--- a/chromium/ui/aura/window_tree_host_platform.h
+++ b/chromium/ui/aura/window_tree_host_platform.h
@@ -49,6 +49,11 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
const gfx::Point& location_in_pixels) override;
void OnCursorVisibilityChangedNative(bool show) override;
+ ui::PlatformWindow* platform_window() { return platform_window_.get(); }
+ const ui::PlatformWindow* platform_window() const {
+ return platform_window_.get();
+ }
+
protected:
// NOTE: this does not call CreateCompositor(); subclasses must call
// CreateCompositor() at the appropriate time.
@@ -59,10 +64,6 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
void CreateAndSetPlatformWindow(ui::PlatformWindowInitProperties properties);
void SetPlatformWindow(std::unique_ptr<ui::PlatformWindow> window);
- ui::PlatformWindow* platform_window() { return platform_window_.get(); }
- const ui::PlatformWindow* platform_window() const {
- return platform_window_.get();
- }
// ui::PlatformWindowDelegate:
void OnBoundsChanged(const gfx::Rect& new_bounds) override;
@@ -73,6 +74,7 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
void OnWindowStateChanged(ui::PlatformWindowState new_state) override;
void OnLostCapture() override;
void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override;
+ void OnWillDestroyAcceleratedWidget() override;
void OnAcceleratedWidgetDestroyed() override;
void OnActivationChanged(bool active) override;
void OnMouseEnter() override;