summaryrefslogtreecommitdiff
path: root/chromium/ui/aura
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/aura')
-rw-r--r--chromium/ui/aura/BUILD.gn11
-rw-r--r--chromium/ui/aura/client/aura_constants.cc1
-rw-r--r--chromium/ui/aura/client/aura_constants.h5
-rw-r--r--chromium/ui/aura/client/cursor_client.h5
-rw-r--r--chromium/ui/aura/env.cc14
-rw-r--r--chromium/ui/aura/env.h8
-rw-r--r--chromium/ui/aura/gestures/gesture_recognizer_unittest.cc19
-rw-r--r--chromium/ui/aura/screen_ozone.cc5
-rw-r--r--chromium/ui/aura/screen_ozone.h1
-rw-r--r--chromium/ui/aura/window.cc27
-rw-r--r--chromium/ui/aura/window.h18
-rw-r--r--chromium/ui/aura/window_event_dispatcher.cc41
-rw-r--r--chromium/ui/aura/window_event_dispatcher.h3
-rw-r--r--chromium/ui/aura/window_event_dispatcher_unittest.cc48
-rw-r--r--chromium/ui/aura/window_observer.h4
-rw-r--r--chromium/ui/aura/window_tree_host.cc24
-rw-r--r--chromium/ui/aura/window_tree_host.h9
-rw-r--r--chromium/ui/aura/window_tree_host_platform.cc19
-rw-r--r--chromium/ui/aura/window_tree_host_unittest.cc28
-rw-r--r--chromium/ui/aura/window_unittest.cc129
20 files changed, 268 insertions, 151 deletions
diff --git a/chromium/ui/aura/BUILD.gn b/chromium/ui/aura/BUILD.gn
index 633a0bb87db..fd917270bb3 100644
--- a/chromium/ui/aura/BUILD.gn
+++ b/chromium/ui/aura/BUILD.gn
@@ -127,6 +127,7 @@ jumbo_component("aura") {
"//ui/events:events_base",
"//ui/events/platform",
"//ui/gfx",
+ "//ui/gfx:gfx_switches",
"//ui/gfx/geometry",
"//ui/gl",
"//ui/platform_window",
@@ -134,12 +135,13 @@ jumbo_component("aura") {
]
public_deps = [
- "//ui/base/cursor",
+ "//ui/base/cursor:cursor_base",
"//ui/base/ime",
"//ui/compositor",
]
if (use_x11) {
+ public_deps += [ "//ui/base/x" ]
deps += [
"//ui/events/platform/x11",
"//ui/platform_window/x11",
@@ -151,6 +153,7 @@ jumbo_component("aura") {
deps += [
"//ipc",
+ "//ui/base/cursor",
"//ui/platform_window/win",
]
}
@@ -225,7 +228,7 @@ jumbo_static_library("test_support") {
"//skia",
"//testing/gtest",
"//ui/base:test_support",
- "//ui/base/cursor",
+ "//ui/base/cursor:cursor_base",
"//ui/base/cursor/mojom:cursor_type",
"//ui/base/ime/init",
"//ui/compositor:test_support",
@@ -347,6 +350,10 @@ test("aura_unittests") {
"//ui/wm",
]
+ if (use_ozone) {
+ deps += [ "//ui/ozone" ]
+ }
+
data_deps = [ "//third_party/mesa_headers" ]
}
diff --git a/chromium/ui/aura/client/aura_constants.cc b/chromium/ui/aura/client/aura_constants.cc
index 39e304b1ef7..3fa9141b582 100644
--- a/chromium/ui/aura/client/aura_constants.cc
+++ b/chromium/ui/aura/client/aura_constants.cc
@@ -72,6 +72,7 @@ DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Rect, kRestoreBoundsKey, nullptr)
DEFINE_UI_CLASS_PROPERTY_KEY(ui::WindowShowState,
kShowStateKey,
ui::SHOW_STATE_DEFAULT)
+DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSkipImeProcessing, false)
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(base::string16, kTitleKey, nullptr)
DEFINE_UI_CLASS_PROPERTY_KEY(int, kTopViewInset, 0)
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::ImageSkia, kWindowIconKey, nullptr)
diff --git a/chromium/ui/aura/client/aura_constants.h b/chromium/ui/aura/client/aura_constants.h
index 30c090399b9..138069130a8 100644
--- a/chromium/ui/aura/client/aura_constants.h
+++ b/chromium/ui/aura/client/aura_constants.h
@@ -137,6 +137,11 @@ AURA_EXPORT extern const WindowProperty<gfx::Rect*>* const kRestoreBoundsKey;
AURA_EXPORT extern const WindowProperty<ui::WindowShowState>* const
kShowStateKey;
+// A property key to store key event dispatch policy. The default value is
+// false, which means IME receives a key event in PREDISPATCH phace before a
+// window receives it. If it's true, a window receives a key event before IME.
+AURA_EXPORT extern const WindowProperty<bool>* const kSkipImeProcessing;
+
// A property key to store the title of the window; sometimes shown to users.
AURA_EXPORT extern const WindowProperty<base::string16*>* const kTitleKey;
diff --git a/chromium/ui/aura/client/cursor_client.h b/chromium/ui/aura/client/cursor_client.h
index ed6076995da..076ec1ab8bb 100644
--- a/chromium/ui/aura/client/cursor_client.h
+++ b/chromium/ui/aura/client/cursor_client.h
@@ -33,6 +33,11 @@ class AURA_EXPORT CursorClient {
// Returns the current cursor.
virtual gfx::NativeCursor GetCursor() const = 0;
+ // Forces the cursor to be updated. This is called when the system may have
+ // changed the cursor without the cursor client's knowledge, which breaks
+ // if the cursor client doesn't think the cursor has changed.
+ virtual void SetCursorForced(gfx::NativeCursor cursor) = 0;
+
// Shows the cursor. This does not take effect When mouse events are disabled.
virtual void ShowCursor() = 0;
diff --git a/chromium/ui/aura/env.cc b/chromium/ui/aura/env.cc
index 56d2ef94f1c..22b7aac67d4 100644
--- a/chromium/ui/aura/env.cc
+++ b/chromium/ui/aura/env.cc
@@ -25,6 +25,10 @@
#include "ui/ozone/public/ozone_platform.h"
#endif
+#if defined(USE_X11)
+#include "ui/gfx/switches.h"
+#endif
+
namespace aura {
namespace {
@@ -205,7 +209,15 @@ bool Env::initial_throttle_input_on_resize_ = true;
Env::Env()
: env_controller_(std::make_unique<EnvInputStateController>(this)),
gesture_recognizer_(std::make_unique<ui::GestureRecognizerImpl>()),
- input_state_lookup_(InputStateLookup::Create()) {}
+ input_state_lookup_(InputStateLookup::Create()) {
+#if defined(USE_X11)
+ // In Ozone/X11, the cursor factory is initialized by the platform
+ // initialization code.
+ if (!features::IsUsingOzonePlatform() &&
+ !base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless))
+ cursor_factory_ = std::make_unique<ui::X11CursorFactory>();
+#endif
+}
void Env::Init() {
#if defined(USE_OZONE)
diff --git a/chromium/ui/aura/env.h b/chromium/ui/aura/env.h
index 893c1578aca..12f91827271 100644
--- a/chromium/ui/aura/env.h
+++ b/chromium/ui/aura/env.h
@@ -19,6 +19,10 @@
#include "ui/events/types/event_type.h"
#include "ui/gfx/geometry/point.h"
+#if defined(USE_X11)
+#include "ui/base/x/x11_cursor_factory.h" // nogncheck
+#endif
+
namespace ui {
class ContextFactory;
class EventObserver;
@@ -171,6 +175,10 @@ class AURA_EXPORT Env : public ui::EventTarget,
std::unique_ptr<ui::GestureRecognizer> gesture_recognizer_;
+#if defined(USE_X11)
+ std::unique_ptr<ui::X11CursorFactory> cursor_factory_;
+#endif
+
std::unique_ptr<InputStateLookup> input_state_lookup_;
std::unique_ptr<ui::PlatformEventSource> event_source_;
diff --git a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
index a796c62911f..c681aa4b077 100644
--- a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -337,7 +337,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
class QueueTouchEventDelegate : public GestureEventConsumeDelegate {
public:
explicit QueueTouchEventDelegate(WindowEventDispatcher* dispatcher)
- : window_(NULL),
+ : window_(nullptr),
dispatcher_(dispatcher),
synchronous_ack_for_next_event_(AckState::PENDING) {}
@@ -2264,7 +2264,7 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
// A touch too far from other touches won't be locked to anything
target =
gesture_recognizer->GetTargetForLocation(gfx::PointF(1000.f, 1000.f), -1);
- EXPECT_TRUE(target == NULL);
+ EXPECT_TRUE(target == nullptr);
// Move a touch associated with windows[2] to 1000, 1000
ui::TouchEvent move2(
@@ -3066,11 +3066,11 @@ TEST_F(GestureRecognizerTest, FlushAllOnHide) {
DispatchEventUsingWindowDispatcher(&press2);
window->Hide();
EXPECT_EQ(
- NULL,
+ nullptr,
aura::Env::GetInstance()->gesture_recognizer()->GetTouchLockedTarget(
press1));
EXPECT_EQ(
- NULL,
+ nullptr,
aura::Env::GetInstance()->gesture_recognizer()->GetTouchLockedTarget(
press2));
}
@@ -3766,7 +3766,7 @@ TEST_F(GestureRecognizerTest, CancelAllActiveTouches) {
aura::Env::GetInstance()->gesture_recognizer()->CancelActiveTouchesExcept(
nullptr);
- EXPECT_EQ(NULL, gesture_recognizer->GetTouchLockedTarget(press));
+ EXPECT_EQ(nullptr, gesture_recognizer->GetTouchLockedTarget(press));
EXPECT_4_EVENTS(delegate->events(),
ui::ET_GESTURE_PINCH_END,
ui::ET_GESTURE_SCROLL_END,
@@ -4249,8 +4249,7 @@ TEST_F(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) {
// A delegate that deletes a window on long press.
class GestureEventDeleteWindowOnLongPress : public GestureEventConsumeDelegate {
public:
- GestureEventDeleteWindowOnLongPress()
- : window_(NULL) {}
+ GestureEventDeleteWindowOnLongPress() : window_(nullptr) {}
void set_window(aura::Window** window) { window_ = window; }
@@ -4259,7 +4258,7 @@ class GestureEventDeleteWindowOnLongPress : public GestureEventConsumeDelegate {
if (gesture->type() != ui::ET_GESTURE_LONG_PRESS)
return;
delete *window_;
- *window_ = NULL;
+ *window_ = nullptr;
}
private:
@@ -4283,11 +4282,11 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressDeletingWindow) {
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
- EXPECT_TRUE(window != NULL);
+ EXPECT_TRUE(window != nullptr);
// Wait until the timer runs out.
delegate.WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
- EXPECT_EQ(NULL, window);
+ EXPECT_EQ(nullptr, window);
}
TEST_F(GestureRecognizerWithSwitchTest, GestureEventSmallPinchDisabled) {
diff --git a/chromium/ui/aura/screen_ozone.cc b/chromium/ui/aura/screen_ozone.cc
index c811c1c4898..34fce55b9f6 100644
--- a/chromium/ui/aura/screen_ozone.cc
+++ b/chromium/ui/aura/screen_ozone.cc
@@ -8,7 +8,6 @@
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/display/display.h"
-#include "ui/display/screen.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/platform_screen.h"
@@ -22,7 +21,9 @@ ScreenOzone::ScreenOzone() {
}
}
-ScreenOzone::~ScreenOzone() = default;
+ScreenOzone::~ScreenOzone() {
+ display::Screen::SetScreenInstance(old_screen_);
+}
gfx::Point ScreenOzone::GetCursorScreenPoint() {
return platform_screen_->GetCursorScreenPoint();
diff --git a/chromium/ui/aura/screen_ozone.h b/chromium/ui/aura/screen_ozone.h
index 864c6e38681..ee3e1de23c3 100644
--- a/chromium/ui/aura/screen_ozone.h
+++ b/chromium/ui/aura/screen_ozone.h
@@ -53,6 +53,7 @@ class AURA_EXPORT ScreenOzone : public display::Screen {
gfx::AcceleratedWidget GetAcceleratedWidgetForWindow(
aura::Window* window) const;
+ display::Screen* const old_screen_ = display::Screen::SetScreenInstance(this);
std::unique_ptr<ui::PlatformScreen> platform_screen_;
DISALLOW_COPY_AND_ASSIGN(ScreenOzone);
diff --git a/chromium/ui/aura/window.cc b/chromium/ui/aura/window.cc
index c26afb965a4..7d6cff67049 100644
--- a/chromium/ui/aura/window.cc
+++ b/chromium/ui/aura/window.cc
@@ -175,7 +175,7 @@ Window::~Window() {
// The layer will either be destroyed by |layer_owner_|'s dtor, or by whoever
// acquired it.
- layer()->set_delegate(NULL);
+ layer()->set_delegate(nullptr);
DestroyLayer();
// If SetEmbedFrameSinkId() was called by client code, then we assume client
@@ -248,7 +248,7 @@ Window* Window::GetRootWindow() {
}
const Window* Window::GetRootWindow() const {
- return IsRootWindow() ? this : parent_ ? parent_->GetRootWindow() : NULL;
+ return IsRootWindow() ? this : parent_ ? parent_->GetRootWindow() : nullptr;
}
WindowTreeHost* Window::GetHost() {
@@ -258,7 +258,7 @@ WindowTreeHost* Window::GetHost() {
const WindowTreeHost* Window::GetHost() const {
const Window* root_window = GetRootWindow();
- return root_window ? root_window->host_ : NULL;
+ return root_window ? root_window->host_ : nullptr;
}
void Window::Show() {
@@ -444,12 +444,12 @@ void Window::RemoveChild(Window* child) {
WindowObserver::HierarchyChangeParams params;
params.target = child;
- params.new_parent = NULL;
+ params.new_parent = nullptr;
params.old_parent = this;
params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING;
NotifyWindowHierarchyChange(params);
- RemoveChildImpl(child, NULL);
+ RemoveChildImpl(child, nullptr);
params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGED;
NotifyWindowHierarchyChange(params);
@@ -476,7 +476,7 @@ const Window* Window::GetChildById(int id) const {
if (result)
return result;
}
- return NULL;
+ return nullptr;
}
// static
@@ -488,13 +488,13 @@ void Window::ConvertPointToTarget(const Window* source,
if (source->GetRootWindow() != target->GetRootWindow()) {
client::ScreenPositionClient* source_client =
client::GetScreenPositionClient(source->GetRootWindow());
- // |source_client| can be NULL in tests.
+ // |source_client| can be nullptr in tests.
if (source_client)
source_client->ConvertPointToScreen(source, point);
client::ScreenPositionClient* target_client =
client::GetScreenPositionClient(target->GetRootWindow());
- // |target_client| can be NULL in tests.
+ // |target_client| can be nullptr in tests.
if (target_client)
target_client->ConvertPointFromScreen(target, point);
} else {
@@ -660,8 +660,9 @@ Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) {
}
Window* Window::GetToplevelWindow() {
- Window* topmost_window_with_delegate = NULL;
- for (aura::Window* window = this; window != NULL; window = window->parent()) {
+ Window* topmost_window_with_delegate = nullptr;
+ for (aura::Window* window = this; window != nullptr;
+ window = window->parent()) {
if (window->delegate())
topmost_window_with_delegate = window;
}
@@ -745,7 +746,7 @@ std::unique_ptr<ScopedKeyboardHook> Window::CaptureSystemKeyEvents(
// {Set,Get,Clear}Property are implemented in class_property.h.
void Window::SetNativeWindowProperty(const char* key, void* value) {
- SetPropertyInternal(key, key, NULL, reinterpret_cast<int64_t>(value), 0);
+ SetPropertyInternal(key, key, nullptr, reinterpret_cast<int64_t>(value), 0);
}
void* Window::GetNativeWindowProperty(const char* key) const {
@@ -926,13 +927,13 @@ void Window::RemoveChildImpl(Window* child, Window* new_parent) {
for (WindowObserver& observer : observers_)
observer.OnWillRemoveWindow(child);
Window* root_window = child->GetRootWindow();
- Window* new_root_window = new_parent ? new_parent->GetRootWindow() : NULL;
+ Window* new_root_window = new_parent ? new_parent->GetRootWindow() : nullptr;
if (root_window && root_window != new_root_window)
child->NotifyRemovingFromRootWindow(new_root_window);
if (child->OwnsLayer())
layer()->Remove(child->layer());
- child->parent_ = NULL;
+ child->parent_ = nullptr;
auto i = std::find(children_.begin(), children_.end(), child);
DCHECK(i != children_.end());
children_.erase(i);
diff --git a/chromium/ui/aura/window.h b/chromium/ui/aura/window.h
index 05874dea71d..6251d9a30e8 100644
--- a/chromium/ui/aura/window.h
+++ b/chromium/ui/aura/window.h
@@ -13,9 +13,9 @@
#include <string>
#include <vector>
+#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/containers/flat_set.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
@@ -193,9 +193,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
const Window* parent() const { return parent_; }
// Returns the root Window that contains this Window. The root Window is
- // defined as the Window that has a dispatcher. These functions return NULL if
- // the Window is contained in a hierarchy that does not have a dispatcher at
- // its root.
+ // defined as the Window that has a dispatcher. These functions return nullptr
+ // if the Window is contained in a hierarchy that does not have a dispatcher
+ // at its root.
Window* GetRootWindow();
const Window* GetRootWindow() const;
@@ -278,7 +278,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
void StackChildAtTop(Window* child);
// Stacks |child| above |target|. Does nothing if |child| is already above
- // |target|. Does not stack on top of windows with NULL layer delegates,
+ // |target|. Does not stack on top of windows with nullptr layer delegates,
// see WindowTest.StackingMadrigal for details.
void StackChildAbove(Window* child, Window* target);
@@ -298,14 +298,14 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// Returns true if this Window contains |other| somewhere in its children.
bool Contains(const Window* other) const;
- // Retrieves the first-level child with the specified id, or NULL if no first-
- // level child is found matching |id|.
+ // Retrieves the first-level child with the specified id, or nullptr if no
+ // first- level child is found matching |id|.
Window* GetChildById(int id);
const Window* GetChildById(int id) const;
// Converts |point| from |source|'s coordinates to |target|'s. If |source| is
- // NULL, the function returns without modifying |point|. |target| cannot be
- // NULL.
+ // nullptr, the function returns without modifying |point|. |target| cannot be
+ // nullptr.
static void ConvertPointToTarget(const Window* source,
const Window* target,
gfx::PointF* point);
diff --git a/chromium/ui/aura/window_event_dispatcher.cc b/chromium/ui/aura/window_event_dispatcher.cc
index 47ed7c1f1a3..0429eed4ad2 100644
--- a/chromium/ui/aura/window_event_dispatcher.cc
+++ b/chromium/ui/aura/window_event_dispatcher.cc
@@ -14,6 +14,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/event_client.h"
@@ -52,7 +53,7 @@ bool IsNonClientLocation(Window* target, const gfx::Point& location) {
}
Window* ConsumerToWindow(ui::GestureConsumer* consumer) {
- return consumer ? static_cast<Window*>(consumer) : NULL;
+ return consumer ? static_cast<Window*>(consumer) : nullptr;
}
bool IsEventCandidateForHold(const ui::Event& event) {
@@ -149,7 +150,7 @@ void WindowEventDispatcher::DispatchCancelModeEvent() {
ui::CancelModeEvent event;
Window* focused_window = client::GetFocusClient(window())->GetFocusedWindow();
if (focused_window && !window()->Contains(focused_window))
- focused_window = NULL;
+ focused_window = nullptr;
DispatchDetails details =
DispatchEvent(focused_window ? focused_window : window(), &event);
if (details.dispatcher_destroyed)
@@ -245,8 +246,8 @@ gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const {
}
void WindowEventDispatcher::OnHostLostMouseGrab() {
- mouse_pressed_handler_ = NULL;
- mouse_moved_handler_ = NULL;
+ mouse_pressed_handler_ = nullptr;
+ mouse_moved_handler_ = nullptr;
}
void WindowEventDispatcher::OnCursorMovedToRootLocation(
@@ -357,9 +358,9 @@ void WindowEventDispatcher::OnWindowHidden(Window* invisible,
// If the window the mouse was pressed in becomes invisible, it should no
// longer receive mouse events.
if (invisible->Contains(mouse_pressed_handler_))
- mouse_pressed_handler_ = NULL;
+ mouse_pressed_handler_ = nullptr;
if (invisible->Contains(mouse_moved_handler_))
- mouse_moved_handler_ = NULL;
+ mouse_moved_handler_ = nullptr;
if (invisible->Contains(touchpad_pinch_handler_))
touchpad_pinch_handler_ = nullptr;
@@ -368,7 +369,7 @@ void WindowEventDispatcher::OnWindowHidden(Window* invisible,
// dispatching events in the inner loop, then reset the target for the outer
// loop.
if (invisible->Contains(old_dispatch_target_))
- old_dispatch_target_ = NULL;
+ old_dispatch_target_ = nullptr;
invisible->CleanupGestureState();
@@ -383,10 +384,10 @@ void WindowEventDispatcher::OnWindowHidden(Window* invisible,
client::CaptureClient* capture_client =
client::GetCaptureClient(host_->window());
Window* capture_window =
- capture_client ? capture_client->GetCaptureWindow() : NULL;
+ capture_client ? capture_client->GetCaptureWindow() : nullptr;
if (invisible->Contains(event_dispatch_target_))
- event_dispatch_target_ = NULL;
+ event_dispatch_target_ = nullptr;
// If the ancestor of the capture window is hidden, release the capture.
// Note that this may delete the window so do not use capture_window
@@ -410,7 +411,7 @@ void WindowEventDispatcher::UpdateCapture(Window* old_capture,
// (see below). Clear it here to ensure we don't end up referencing a stale
// Window.
if (mouse_moved_handler_ && !window()->Contains(mouse_moved_handler_))
- mouse_moved_handler_ = NULL;
+ mouse_moved_handler_ = nullptr;
if (old_capture && old_capture->GetRootWindow() == window() &&
old_capture->delegate()) {
@@ -438,7 +439,7 @@ void WindowEventDispatcher::UpdateCapture(Window* old_capture,
if (details.dispatcher_destroyed)
return;
}
- mouse_pressed_handler_ = NULL;
+ mouse_pressed_handler_ = nullptr;
}
void WindowEventDispatcher::OnOtherRootGotCapture() {
@@ -460,8 +461,8 @@ void WindowEventDispatcher::OnOtherRootGotCapture() {
}
#endif
- mouse_moved_handler_ = NULL;
- mouse_pressed_handler_ = NULL;
+ mouse_moved_handler_ = nullptr;
+ mouse_pressed_handler_ = nullptr;
}
void WindowEventDispatcher::SetNativeCapture() {
@@ -539,7 +540,7 @@ ui::EventDispatchDetails WindowEventDispatcher::PreDispatchEvent(
} else if (event->IsTouchEvent()) {
details = PreDispatchTouchEvent(target_window, event->AsTouchEvent());
} else if (event->IsKeyEvent()) {
- details = PreDispatchKeyEvent(event->AsKeyEvent());
+ details = PreDispatchKeyEvent(target_window, event->AsKeyEvent());
} else if (event->IsPinchEvent()) {
details = PreDispatchPinchEvent(target_window, event->AsGestureEvent());
}
@@ -558,7 +559,7 @@ ui::EventDispatchDetails WindowEventDispatcher::PostDispatchEvent(
if (!target || target != event_dispatch_target_)
details.target_destroyed = true;
event_dispatch_target_ = old_dispatch_target_;
- old_dispatch_target_ = NULL;
+ old_dispatch_target_ = nullptr;
#ifndef NDEBUG
DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_));
#endif
@@ -920,7 +921,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
event->SetHandled();
return details;
}
- mouse_moved_handler_ = NULL;
+ mouse_moved_handler_ = nullptr;
}
break;
case ui::ET_MOUSE_MOVED:
@@ -949,7 +950,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
return target_details;
}
if (details.target_destroyed || target_details.target_destroyed) {
- mouse_moved_handler_ = NULL;
+ mouse_moved_handler_ = nullptr;
event->SetHandled();
return target_details;
}
@@ -973,7 +974,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
mouse_pressed_handler_ = target;
break;
case ui::ET_MOUSE_RELEASED:
- mouse_pressed_handler_ = NULL;
+ mouse_pressed_handler_ = nullptr;
break;
default:
break;
@@ -1035,10 +1036,12 @@ DispatchDetails WindowEventDispatcher::PreDispatchTouchEvent(
}
DispatchDetails WindowEventDispatcher::PreDispatchKeyEvent(
+ Window* target,
ui::KeyEvent* event) {
if (skip_ime_ || !host_->has_input_method() ||
(event->flags() & ui::EF_IS_SYNTHESIZED) ||
- !host_->ShouldSendKeyEventToIme()) {
+ !host_->ShouldSendKeyEventToIme() ||
+ target->GetProperty(aura::client::kSkipImeProcessing)) {
return DispatchDetails();
}
diff --git a/chromium/ui/aura/window_event_dispatcher.h b/chromium/ui/aura/window_event_dispatcher.h
index 74d4510901c..5435ce7b7f3 100644
--- a/chromium/ui/aura/window_event_dispatcher.h
+++ b/chromium/ui/aura/window_event_dispatcher.h
@@ -281,7 +281,8 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor,
ui::GestureEvent* event);
ui::EventDispatchDetails PreDispatchTouchEvent(Window* target,
ui::TouchEvent* event);
- ui::EventDispatchDetails PreDispatchKeyEvent(ui::KeyEvent* event);
+ ui::EventDispatchDetails PreDispatchKeyEvent(Window* target,
+ ui::KeyEvent* event);
WindowTreeHost* host_;
diff --git a/chromium/ui/aura/window_event_dispatcher_unittest.cc b/chromium/ui/aura/window_event_dispatcher_unittest.cc
index ef8dcda8b67..41e3c0cb331 100644
--- a/chromium/ui/aura/window_event_dispatcher_unittest.cc
+++ b/chromium/ui/aura/window_event_dispatcher_unittest.cc
@@ -19,6 +19,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/event_client.h"
#include "ui/aura/client/focus_client.h"
@@ -33,6 +34,7 @@
#include "ui/aura/window_targeter.h"
#include "ui/aura/window_tracker.h"
#include "ui/base/hit_test.h"
+#include "ui/base/ime/mock_input_method.h"
#include "ui/base/ui_base_features.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
@@ -106,6 +108,25 @@ class ConsumeKeyHandler : public ui::test::TestEventHandler {
DISALLOW_COPY_AND_ASSIGN(ConsumeKeyHandler);
};
+// InputMethodDelegate that tracks the events passed to PostIME phase.
+class TestInputMethodDelegate : public ui::internal::InputMethodDelegate {
+ public:
+ TestInputMethodDelegate() = default;
+ ~TestInputMethodDelegate() override = default;
+
+ // ui::internal::InputMethodDelegate:
+ ui::EventDispatchDetails DispatchKeyEventPostIME(
+ ui::KeyEvent* event) override {
+ ++dispatched_event_count_;
+ return ui::EventDispatchDetails();
+ }
+
+ int dispatched_event_count() const { return dispatched_event_count_; }
+
+ private:
+ int dispatched_event_count_{0};
+};
+
bool IsFocusedWindow(aura::Window* window) {
return client::GetFocusClient(window)->GetFocusedWindow() == window;
}
@@ -468,6 +489,33 @@ TEST_F(WindowEventDispatcherTest, ScrollEventDispatch) {
root_window()->RemovePreTargetHandler(&handler);
}
+TEST_F(WindowEventDispatcherTest, PreDispatchKeyEventToIme) {
+ ui::MockInputMethod mock_ime(nullptr);
+ TestInputMethodDelegate delegate;
+ mock_ime.SetDelegate(&delegate);
+ host()->SetSharedInputMethod(&mock_ime);
+
+ ConsumeKeyHandler handler;
+ std::unique_ptr<Window> w(CreateNormalWindow(1, root_window(), nullptr));
+ w->AddPostTargetHandler(&handler);
+ w->Show();
+ w->Focus();
+
+ // The dispatched event went to IME before the event target.
+ ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
+ DispatchEventUsingWindowDispatcher(&key_press);
+ EXPECT_EQ(0, handler.num_key_events());
+ EXPECT_EQ(1, delegate.dispatched_event_count());
+
+ // However, for the window with kSkipImeProcessing
+ // The event went to the event target at first.
+ w->SetProperty(client::kSkipImeProcessing, true);
+ ui::KeyEvent key_release(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE);
+ DispatchEventUsingWindowDispatcher(&key_release);
+ EXPECT_EQ(1, handler.num_key_events());
+ EXPECT_EQ(1, delegate.dispatched_event_count());
+}
+
namespace {
// ui::EventHandler that tracks the types of events it's seen.
diff --git a/chromium/ui/aura/window_observer.h b/chromium/ui/aura/window_observer.h
index 071c5c884bc..4c34dbe7a12 100644
--- a/chromium/ui/aura/window_observer.h
+++ b/chromium/ui/aura/window_observer.h
@@ -175,10 +175,6 @@ class AURA_EXPORT WindowObserver : public base::CheckedObserver {
// (is_animating|IsAnimatingProperty|IsAnimatingOnePropertyOf)() from it.
virtual void OnWindowLayerRecreated(Window* window) {}
- // Called when the app embedded in |window| disconnects (is no longer
- // embedded).
- virtual void OnEmbeddedAppDisconnected(Window* window) {}
-
// Called when the occlusion state of |window| changes.
virtual void OnWindowOcclusionChanged(Window* window) {}
diff --git a/chromium/ui/aura/window_tree_host.cc b/chromium/ui/aura/window_tree_host.cc
index 29c93adb189..b0e2720fe05 100644
--- a/chromium/ui/aura/window_tree_host.cc
+++ b/chromium/ui/aura/window_tree_host.cc
@@ -6,7 +6,6 @@
#include "base/command_line.h"
#include "base/feature_list.h"
-#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "components/viz/common/features.h"
@@ -504,13 +503,18 @@ void WindowTreeHost::OnHostLostWindowCapture() {
void WindowTreeHost::OnDisplayMetricsChanged(const display::Display& display,
uint32_t metrics) {
- if (metrics & DisplayObserver::DISPLAY_METRIC_COLOR_SPACE) {
- display::Screen* screen = display::Screen::GetScreen();
- if (compositor_ &&
- display.id() == screen->GetDisplayNearestView(window()).id()) {
- compositor_->SetDisplayColorSpaces(display.color_spaces());
- }
- }
+ if (metrics & DisplayObserver::DISPLAY_METRIC_COLOR_SPACE && compositor_ &&
+ display.id() == GetDisplayId())
+ compositor_->SetDisplayColorSpaces(display.color_spaces());
+
+// Chrome OS is handled in WindowTreeHostManager::OnDisplayMetricsChanged.
+// Chrome OS requires additional handling for the bounds that we do not need to
+// do for other OSes.
+#if !defined(OS_CHROMEOS)
+ if (metrics & DISPLAY_METRIC_DEVICE_SCALE_FACTOR &&
+ display.id() == GetDisplayId())
+ OnHostResizedInPixels(GetBoundsInPixels().size());
+#endif
}
gfx::Rect WindowTreeHost::GetTransformedRootWindowBoundsInPixels(
@@ -549,15 +553,11 @@ void WindowTreeHost::OnCompositingEnded(ui::Compositor* compositor) {
dispatcher_->ReleasePointerMoves();
holding_pointer_moves_ = false;
- DCHECK(!synchronization_start_time_.is_null());
- UMA_HISTOGRAM_TIMES("UI.WindowTreeHost.SurfaceSynchronizationDuration",
- base::TimeTicks::Now() - synchronization_start_time_);
}
void WindowTreeHost::OnCompositingChildResizing(ui::Compositor* compositor) {
if (!Env::GetInstance()->throttle_input_on_resize() || holding_pointer_moves_)
return;
- synchronization_start_time_ = base::TimeTicks::Now();
dispatcher_->HoldPointerMoves();
holding_pointer_moves_ = true;
}
diff --git a/chromium/ui/aura/window_tree_host.h b/chromium/ui/aura/window_tree_host.h
index af78e44ce00..e00fb7b60ba 100644
--- a/chromium/ui/aura/window_tree_host.h
+++ b/chromium/ui/aura/window_tree_host.h
@@ -16,7 +16,6 @@
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/optional.h"
-#include "base/time/time.h"
#include "build/build_config.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "ui/aura/aura_export.h"
@@ -248,7 +247,10 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
// Requests using unadjusted movement mouse events, i.e. WM_INPUT on Windows.
// Returns a ScopedEnableUnadjustedMouseEvents instance which stops using
// unadjusted mouse events when destroyed, returns nullptr if unadjusted mouse
- // event is not not implemented or failed.
+ // event is not not implemented or failed. On some platforms this function may
+ // temporarily affect the global state of mouse settings. This function is
+ // currently only intended to be used with PointerLock as it is not set up for
+ // multiple calls.
virtual std::unique_ptr<ScopedEnableUnadjustedMouseEvents>
RequestUnadjustedMovement();
@@ -380,9 +382,6 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
// Whether the InputMethod instance is owned by this WindowTreeHost.
bool owned_input_method_;
- // Set to the time the synchronization event began.
- base::TimeTicks synchronization_start_time_;
-
// Set to true if this WindowTreeHost is currently holding pointer moves.
bool holding_pointer_moves_ = false;
diff --git a/chromium/ui/aura/window_tree_host_platform.cc b/chromium/ui/aura/window_tree_host_platform.cc
index 8cb0d96a566..917b45bf3f8 100644
--- a/chromium/ui/aura/window_tree_host_platform.cc
+++ b/chromium/ui/aura/window_tree_host_platform.cc
@@ -28,6 +28,7 @@
#include "ui/platform_window/platform_window_init_properties.h"
#if defined(USE_OZONE)
+#include "ui/base/ui_base_features.h"
#include "ui/ozone/public/ozone_platform.h"
#endif
@@ -68,18 +69,26 @@ WindowTreeHostPlatform::WindowTreeHostPlatform(std::unique_ptr<Window> window)
void WindowTreeHostPlatform::CreateAndSetPlatformWindow(
ui::PlatformWindowInitProperties properties) {
+#if defined(USE_OZONE) || defined(USE_X11)
#if defined(USE_OZONE)
- platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
- this, std::move(properties));
-#elif defined(OS_WIN)
- platform_window_.reset(new ui::WinWindow(this, properties.bounds));
-#elif defined(USE_X11)
+ if (features::IsUsingOzonePlatform()) {
+ platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
+ this, std::move(properties));
+ return;
+ }
+#endif
+#if defined(USE_X11)
auto platform_window = std::make_unique<ui::X11Window>(this);
auto* x11_window = platform_window.get();
// platform_window() may be called during Initialize(), so call
// SetPlatformWindow() now.
SetPlatformWindow(std::move(platform_window));
x11_window->Initialize(std::move(properties));
+ return;
+#endif
+ NOTREACHED();
+#elif defined(OS_WIN)
+ platform_window_.reset(new ui::WinWindow(this, properties.bounds));
#else
NOTIMPLEMENTED();
#endif
diff --git a/chromium/ui/aura/window_tree_host_unittest.cc b/chromium/ui/aura/window_tree_host_unittest.cc
index 761e4f030c7..2bf6cb83460 100644
--- a/chromium/ui/aura/window_tree_host_unittest.cc
+++ b/chromium/ui/aura/window_tree_host_unittest.cc
@@ -21,7 +21,9 @@ namespace aura {
using WindowTreeHostTest = test::AuraTestBase;
TEST_F(WindowTreeHostTest, DPIWindowSize) {
- gfx::Rect starting_bounds(0, 0, 800, 600);
+ constexpr gfx::Rect starting_bounds(
+ aura::test::AuraTestHelper::kDefaultHostSize);
+
EXPECT_EQ(starting_bounds.size(), host()->compositor()->size());
EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
EXPECT_EQ(starting_bounds, root_window()->bounds());
@@ -113,6 +115,30 @@ TEST_F(WindowTreeHostTest, HoldPointerMovesOnChildResizing) {
}
#endif
+#if !defined(OS_CHROMEOS)
+// Tests if scale factor changes take effect. Previously a scale factor change
+// wouldn't take effect without a bounds change. For context see
+// https://crbug.com/1087626
+TEST_F(WindowTreeHostTest, ShouldHandleTextScale) {
+ constexpr gfx::Rect starting_bounds(
+ aura::test::AuraTestHelper::kDefaultHostSize);
+ auto asserter = [&](float test_scale_factor) {
+ test_screen()->SetDeviceScaleFactor(test_scale_factor, false);
+
+ EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
+ // Size should be rounded up after scaling.
+ EXPECT_EQ(
+ gfx::ScaleToEnclosingRect(starting_bounds, 1.0f / test_scale_factor),
+ root_window()->bounds());
+ EXPECT_EQ(test_scale_factor, host()->device_scale_factor());
+ };
+
+ asserter(1.0f);
+ asserter(1.05f);
+ asserter(1.5f);
+}
+#endif
+
TEST_F(WindowTreeHostTest, NoRewritesPostIME) {
ui::test::TestEventRewriter event_rewriter;
host()->AddEventRewriter(&event_rewriter);
diff --git a/chromium/ui/aura/window_unittest.cc b/chromium/ui/aura/window_unittest.cc
index 86204d85e62..c9045d65c15 100644
--- a/chromium/ui/aura/window_unittest.cc
+++ b/chromium/ui/aura/window_unittest.cc
@@ -203,8 +203,7 @@ class ChildWindowDelegateImpl : public DestroyTrackingDelegateImpl {
// OnWindowDestroyed is called.
class DestroyOrphanDelegate : public TestWindowDelegate {
public:
- DestroyOrphanDelegate() : window_(NULL) {
- }
+ DestroyOrphanDelegate() : window_(nullptr) {}
void set_window(Window* window) { window_ = window; }
@@ -323,7 +322,7 @@ TEST_F(WindowTest, GetChildById) {
std::unique_ptr<Window> w111(CreateTestWindowWithId(111, w11.get()));
std::unique_ptr<Window> w12(CreateTestWindowWithId(12, w1.get()));
- EXPECT_EQ(NULL, w1->GetChildById(57));
+ EXPECT_FALSE(w1->GetChildById(57));
EXPECT_EQ(w12.get(), w1->GetChildById(12));
EXPECT_EQ(w111.get(), w1->GetChildById(111));
}
@@ -331,11 +330,11 @@ TEST_F(WindowTest, GetChildById) {
// Make sure that Window::Contains correctly handles children, grandchildren,
// and not containing NULL or parents.
TEST_F(WindowTest, Contains) {
- Window parent(NULL);
+ Window parent(nullptr);
parent.Init(ui::LAYER_NOT_DRAWN);
- Window child1(NULL);
+ Window child1(nullptr);
child1.Init(ui::LAYER_NOT_DRAWN);
- Window child2(NULL);
+ Window child2(nullptr);
child2.Init(ui::LAYER_NOT_DRAWN);
parent.AddChild(&child1);
@@ -345,7 +344,7 @@ TEST_F(WindowTest, Contains) {
EXPECT_TRUE(parent.Contains(&child1));
EXPECT_TRUE(parent.Contains(&child2));
- EXPECT_FALSE(parent.Contains(NULL));
+ EXPECT_FALSE(parent.Contains(nullptr));
EXPECT_FALSE(child1.Contains(&parent));
EXPECT_FALSE(child2.Contains(&child1));
}
@@ -376,7 +375,7 @@ TEST_F(WindowTest, ConvertPointToWindow) {
std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window()));
gfx::Point reference_point(100, 100);
gfx::Point test_point = reference_point;
- Window::ConvertPointToTarget(NULL, w1.get(), &test_point);
+ Window::ConvertPointToTarget(nullptr, w1.get(), &test_point);
EXPECT_EQ(reference_point, test_point);
}
@@ -560,7 +559,7 @@ TEST_F(WindowTest, GetEventHandlerForPoint) {
Window* root = root_window();
w1->parent()->SetBounds(gfx::Rect(500, 500));
- EXPECT_EQ(NULL, root->GetEventHandlerForPoint(gfx::Point(5, 5)));
+ EXPECT_EQ(nullptr, root->GetEventHandlerForPoint(gfx::Point(5, 5)));
EXPECT_EQ(w1.get(), root->GetEventHandlerForPoint(gfx::Point(11, 11)));
EXPECT_EQ(w11.get(), root->GetEventHandlerForPoint(gfx::Point(16, 16)));
EXPECT_EQ(w111.get(), root->GetEventHandlerForPoint(gfx::Point(21, 21)));
@@ -606,8 +605,8 @@ TEST_F(WindowTest, GetToplevelWindow) {
std::unique_ptr<Window> w1111(
CreateTestWindowWithDelegate(&delegate, 1111, kBounds, w111.get()));
- EXPECT_TRUE(root_window()->GetToplevelWindow() == NULL);
- EXPECT_TRUE(w1->GetToplevelWindow() == NULL);
+ EXPECT_TRUE(root_window()->GetToplevelWindow() == nullptr);
+ EXPECT_TRUE(w1->GetToplevelWindow() == nullptr);
EXPECT_EQ(w11.get(), w11->GetToplevelWindow());
EXPECT_EQ(w11.get(), w111->GetToplevelWindow());
EXPECT_EQ(w11.get(), w1111->GetToplevelWindow());
@@ -632,7 +631,7 @@ TEST_F(WindowTest, WindowAddedToRootWindowShouldNotifyChildAndNotParent) {
AddedToRootWindowObserver child_observer;
std::unique_ptr<Window> parent_window(
CreateTestWindowWithId(1, root_window()));
- std::unique_ptr<Window> child_window(new Window(NULL));
+ std::unique_ptr<Window> child_window(new Window(nullptr));
child_window->Init(ui::LAYER_TEXTURED);
child_window->Show();
@@ -679,11 +678,11 @@ TEST_F(WindowTest, OrphanedBeforeOnDestroyed) {
// Make sure StackChildAtTop moves both the window and layer to the front.
TEST_F(WindowTest, StackChildAtTop) {
- Window parent(NULL);
+ Window parent(nullptr);
parent.Init(ui::LAYER_NOT_DRAWN);
- Window child1(NULL);
+ Window child1(nullptr);
child1.Init(ui::LAYER_NOT_DRAWN);
- Window child2(NULL);
+ Window child2(nullptr);
child2.Init(ui::LAYER_NOT_DRAWN);
parent.AddChild(&child1);
@@ -706,15 +705,15 @@ TEST_F(WindowTest, StackChildAtTop) {
// Make sure StackChildBelow works.
TEST_F(WindowTest, StackChildBelow) {
- Window parent(NULL);
+ Window parent(nullptr);
parent.Init(ui::LAYER_NOT_DRAWN);
- Window child1(NULL);
+ Window child1(nullptr);
child1.Init(ui::LAYER_NOT_DRAWN);
child1.set_id(1);
- Window child2(NULL);
+ Window child2(nullptr);
child2.Init(ui::LAYER_NOT_DRAWN);
child2.set_id(2);
- Window child3(NULL);
+ Window child3(nullptr);
child3.Init(ui::LAYER_NOT_DRAWN);
child3.set_id(3);
@@ -738,13 +737,13 @@ TEST_F(WindowTest, StackChildBelow) {
// Various assertions for StackChildAbove.
TEST_F(WindowTest, StackChildAbove) {
- Window parent(NULL);
+ Window parent(nullptr);
parent.Init(ui::LAYER_NOT_DRAWN);
- Window child1(NULL);
+ Window child1(nullptr);
child1.Init(ui::LAYER_NOT_DRAWN);
- Window child2(NULL);
+ Window child2(nullptr);
child2.Init(ui::LAYER_NOT_DRAWN);
- Window child3(NULL);
+ Window child3(nullptr);
child3.Init(ui::LAYER_NOT_DRAWN);
parent.AddChild(&child1);
@@ -844,7 +843,7 @@ TEST_F(WindowTest, CaptureTests) {
EXPECT_EQ(window.get(), aura::client::GetCaptureWindow(root_window()));
window->parent()->RemoveChild(window.get());
EXPECT_FALSE(window->HasCapture());
- EXPECT_EQ(NULL, aura::client::GetCaptureWindow(root_window()));
+ EXPECT_EQ(nullptr, aura::client::GetCaptureWindow(root_window()));
}
TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) {
@@ -1097,8 +1096,8 @@ TEST_F(WindowTest, ReleaseCaptureOnDestroy) {
window.reset();
// Make sure the root window doesn't reference the window anymore.
- EXPECT_EQ(NULL, host()->dispatcher()->mouse_pressed_handler());
- EXPECT_EQ(NULL, aura::client::GetCaptureWindow(root_window()));
+ EXPECT_EQ(nullptr, host()->dispatcher()->mouse_pressed_handler());
+ EXPECT_EQ(nullptr, aura::client::GetCaptureWindow(root_window()));
}
TEST_F(WindowTest, GetBoundsInRootWindow) {
@@ -1455,13 +1454,13 @@ TEST_F(WindowTest, MouseEnterExitWithParentDelete) {
TEST_F(WindowTest, GetEventHandlerForPoint_NoDelegate) {
TestWindowDelegate d111;
std::unique_ptr<Window> w1(CreateTestWindowWithDelegate(
- NULL, 1, gfx::Rect(0, 0, 500, 500), root_window()));
+ nullptr, 1, gfx::Rect(0, 0, 500, 500), root_window()));
std::unique_ptr<Window> w11(CreateTestWindowWithDelegate(
- NULL, 11, gfx::Rect(0, 0, 500, 500), w1.get()));
+ nullptr, 11, gfx::Rect(0, 0, 500, 500), w1.get()));
std::unique_ptr<Window> w111(CreateTestWindowWithDelegate(
&d111, 111, gfx::Rect(50, 50, 450, 450), w11.get()));
std::unique_ptr<Window> w12(CreateTestWindowWithDelegate(
- NULL, 12, gfx::Rect(0, 0, 500, 500), w1.get()));
+ nullptr, 12, gfx::Rect(0, 0, 500, 500), w1.get()));
gfx::Point target_point = w111->bounds().CenterPoint();
EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(target_point));
@@ -1561,7 +1560,7 @@ TEST_F(WindowTest, EventTargetingPolicy) {
TestWindowDelegate d111;
TestWindowDelegate d121;
std::unique_ptr<Window> w1(CreateTestWindowWithDelegate(
- NULL, 1, gfx::Rect(0, 0, 500, 500), root_window()));
+ nullptr, 1, gfx::Rect(0, 0, 500, 500), root_window()));
std::unique_ptr<Window> w11(CreateTestWindowWithDelegate(
&d11, 11, gfx::Rect(0, 0, 500, 500), w1.get()));
std::unique_ptr<Window> w111(CreateTestWindowWithDelegate(
@@ -1871,7 +1870,7 @@ class WindowObserverTest : public WindowTest,
// Return a tuple of the arguments passed in OnPropertyChanged callback.
PropertyChangeInfo PropertyChangeInfoAndClear() {
PropertyChangeInfo result(property_key_, old_property_value_);
- property_key_ = NULL;
+ property_key_ = nullptr;
old_property_value_ = -3;
return result;
}
@@ -2079,14 +2078,13 @@ TEST_F(WindowObserverTest, PropertyChanged) {
w1->SetNativeWindowProperty(native_prop_key, &*w1);
EXPECT_EQ(PropertyChangeInfo(native_prop_key, 0),
PropertyChangeInfoAndClear());
- w1->SetNativeWindowProperty(native_prop_key, NULL);
+ w1->SetNativeWindowProperty(native_prop_key, nullptr);
EXPECT_EQ(PropertyChangeInfo(native_prop_key,
reinterpret_cast<intptr_t>(&*w1)),
PropertyChangeInfoAndClear());
// Sanity check to see if |PropertyChangeInfoAndClear| really clears.
- EXPECT_EQ(PropertyChangeInfo(
- reinterpret_cast<const void*>(NULL), -3), PropertyChangeInfoAndClear());
+ EXPECT_EQ(PropertyChangeInfo(nullptr, -3), PropertyChangeInfoAndClear());
}
// Verify that WindowObserver::OnWindowBoundsChanged() is notified when the
@@ -2232,17 +2230,14 @@ TEST_F(WindowObserverTest, SetTransformAnimation) {
EXPECT_EQ(target_transform,
window_target_transform_changing_info().new_transform);
- ASSERT_EQ(1, window_transformed_info().changed_count);
- EXPECT_EQ(window.get(), window_transformed_info().window);
- EXPECT_EQ(ui::PropertyChangeReason::FROM_ANIMATION,
- window_transformed_info().reason);
+ ASSERT_EQ(0, window_transformed_info().changed_count);
window->layer()->GetAnimator()->StopAnimatingProperty(
ui::LayerAnimationElement::TRANSFORM);
EXPECT_EQ(1, window_target_transform_changing_info().changed_count);
- ASSERT_EQ(2, window_transformed_info().changed_count);
+ ASSERT_EQ(1, window_transformed_info().changed_count);
EXPECT_EQ(window.get(), window_transformed_info().window);
EXPECT_EQ(ui::PropertyChangeReason::FROM_ANIMATION,
window_transformed_info().reason);
@@ -2336,7 +2331,7 @@ TEST_F(WindowTest, AcquireLayer) {
window2.reset();
// This should be set by the window's destructor.
- EXPECT_TRUE(window1_layer->delegate() == NULL);
+ EXPECT_FALSE(window1_layer->delegate());
EXPECT_EQ(1U, parent->children().size());
}
@@ -2388,7 +2383,7 @@ TEST_F(WindowTest, AcquireThenRecreateLayer) {
SK_ColorWHITE, 1, gfx::Rect(0, 0, 100, 100), root_window()));
std::unique_ptr<ui::Layer> acquired_layer(w->AcquireLayer());
std::unique_ptr<ui::Layer> doubly_acquired_layer(w->RecreateLayer());
- EXPECT_EQ(NULL, doubly_acquired_layer.get());
+ EXPECT_FALSE(doubly_acquired_layer);
// Destroy window before layer gets destroyed.
w.reset();
@@ -2605,7 +2600,7 @@ TEST_F(WindowTest, RootWindowAttachment) {
RootWindowAttachmentObserver observer;
// Test a direct add/remove from the RootWindow.
- std::unique_ptr<Window> w1(new Window(NULL));
+ std::unique_ptr<Window> w1(new Window(nullptr));
w1->Init(ui::LAYER_NOT_DRAWN);
w1->AddObserver(&observer);
@@ -2620,9 +2615,9 @@ TEST_F(WindowTest, RootWindowAttachment) {
observer.Clear();
// Test an indirect add/remove from the RootWindow.
- w1.reset(new Window(NULL));
+ w1.reset(new Window(nullptr));
w1->Init(ui::LAYER_NOT_DRAWN);
- Window* w11 = new Window(NULL);
+ Window* w11 = new Window(nullptr);
w11->Init(ui::LAYER_NOT_DRAWN);
w11->AddObserver(&observer);
w1->AddChild(w11);
@@ -2634,20 +2629,20 @@ TEST_F(WindowTest, RootWindowAttachment) {
EXPECT_EQ(0, observer.removed_count());
w1.reset(); // Deletes w11.
- w11 = NULL;
+ w11 = nullptr;
EXPECT_EQ(1, observer.added_count());
EXPECT_EQ(1, observer.removed_count());
observer.Clear();
// Test an indirect add/remove with nested observers.
- w1.reset(new Window(NULL));
+ w1.reset(new Window(nullptr));
w1->Init(ui::LAYER_NOT_DRAWN);
- w11 = new Window(NULL);
+ w11 = new Window(nullptr);
w11->Init(ui::LAYER_NOT_DRAWN);
w11->AddObserver(&observer);
w1->AddChild(w11);
- Window* w111 = new Window(NULL);
+ Window* w111 = new Window(nullptr);
w111->Init(ui::LAYER_NOT_DRAWN);
w111->AddObserver(&observer);
w11->AddChild(w111);
@@ -2660,8 +2655,8 @@ TEST_F(WindowTest, RootWindowAttachment) {
EXPECT_EQ(0, observer.removed_count());
w1.reset(); // Deletes w11 and w111.
- w11 = NULL;
- w111 = NULL;
+ w11 = nullptr;
+ w111 = nullptr;
EXPECT_EQ(2, observer.added_count());
EXPECT_EQ(2, observer.removed_count());
}
@@ -2674,7 +2669,7 @@ class BoundsChangedWindowObserver : public WindowObserver {
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) override {
- root_set_ = window->GetRootWindow() != NULL;
+ root_set_ = !!window->GetRootWindow();
}
bool root_set() const { return root_set_; }
@@ -2686,9 +2681,9 @@ class BoundsChangedWindowObserver : public WindowObserver {
};
TEST_F(WindowTest, RootWindowSetWhenReparenting) {
- Window parent1(NULL);
+ Window parent1(nullptr);
parent1.Init(ui::LAYER_NOT_DRAWN);
- Window parent2(NULL);
+ Window parent2(nullptr);
parent2.Init(ui::LAYER_NOT_DRAWN);
ParentWindow(&parent1);
ParentWindow(&parent2);
@@ -2696,7 +2691,7 @@ TEST_F(WindowTest, RootWindowSetWhenReparenting) {
parent2.SetBounds(gfx::Rect(20, 20, 300, 300));
BoundsChangedWindowObserver observer;
- Window child(NULL);
+ Window child(nullptr);
child.Init(ui::LAYER_NOT_DRAWN);
child.SetBounds(gfx::Rect(5, 5, 100, 100));
parent1.AddChild(&child);
@@ -2727,9 +2722,9 @@ TEST_F(WindowTest, OwnedByParentFalse) {
// By default, a window is owned by its parent. If this is set to false, the
// window will not be destroyed when its parent is.
- std::unique_ptr<Window> w1(new Window(NULL));
+ std::unique_ptr<Window> w1(new Window(nullptr));
w1->Init(ui::LAYER_NOT_DRAWN);
- std::unique_ptr<Window> w2(new Window(NULL));
+ std::unique_ptr<Window> w2(new Window(nullptr));
w2->set_owned_by_parent(false);
w2->Init(ui::LAYER_NOT_DRAWN);
w1->AddChild(w2.get());
@@ -2737,7 +2732,7 @@ TEST_F(WindowTest, OwnedByParentFalse) {
w1.reset();
// We should be able to deref w2 still, but its parent should now be NULL.
- EXPECT_EQ(NULL, w2->parent());
+ EXPECT_FALSE(w2->parent());
}
// Used By DeleteWindowFromOnWindowDestroyed. Destroys a Window from
@@ -2750,7 +2745,7 @@ class OwningWindowDelegate : public TestWindowDelegate {
owned_window_.reset(window);
}
- void OnWindowDestroyed(Window* window) override { owned_window_.reset(NULL); }
+ void OnWindowDestroyed(Window* window) override { owned_window_.reset(); }
private:
std::unique_ptr<Window> owned_window_;
@@ -2764,13 +2759,13 @@ class OwningWindowDelegate : public TestWindowDelegate {
// same parent and destroying BrowserView triggers it destroying the status
// bubble.
TEST_F(WindowTest, DeleteWindowFromOnWindowDestroyed) {
- std::unique_ptr<Window> parent(new Window(NULL));
+ std::unique_ptr<Window> parent(new Window(nullptr));
parent->Init(ui::LAYER_NOT_DRAWN);
OwningWindowDelegate delegate;
Window* c1 = new Window(&delegate);
c1->Init(ui::LAYER_NOT_DRAWN);
parent->AddChild(c1);
- Window* c2 = new Window(NULL);
+ Window* c2 = new Window(nullptr);
c2->Init(ui::LAYER_NOT_DRAWN);
parent->AddChild(c2);
delegate.SetOwnedWindow(c2);
@@ -2900,7 +2895,7 @@ TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) {
// Suppress paint on the layer since it is hidden (should reset the layer's
// delegate to NULL)
window->layer()->SuppressPaint();
- EXPECT_EQ(NULL, window->layer()->delegate());
+ EXPECT_FALSE(window->layer()->delegate());
// Animate to a different position.
{
@@ -3024,7 +3019,7 @@ TEST_F(WindowTest, OnWindowHierarchyChange) {
// Simple add & remove.
HierarchyObserver oroot(root_window());
- std::unique_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
+ std::unique_ptr<Window> w1(CreateTestWindowWithId(1, nullptr));
HierarchyObserver o1(w1.get());
// Add.
@@ -3033,7 +3028,7 @@ TEST_F(WindowTest, OnWindowHierarchyChange) {
WindowObserver::HierarchyChangeParams params;
params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING;
params.target = w1.get();
- params.old_parent = NULL;
+ params.old_parent = nullptr;
params.new_parent = root_window();
params.receiver = w1.get();
o1.ValidateState(0, params);
@@ -3053,7 +3048,7 @@ TEST_F(WindowTest, OnWindowHierarchyChange) {
params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING;
params.old_parent = root_window();
- params.new_parent = NULL;
+ params.new_parent = nullptr;
params.receiver = w1.get();
o1.ValidateState(0, params);
@@ -3070,7 +3065,7 @@ TEST_F(WindowTest, OnWindowHierarchyChange) {
// Add & remove of hierarchy. Tests notification order per documentation in
// WindowObserver.
HierarchyObserver o(root_window());
- std::unique_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
+ std::unique_ptr<Window> w1(CreateTestWindowWithId(1, nullptr));
Window* w11 = CreateTestWindowWithId(11, w1.get());
w1->AddObserver(&o);
w11->AddObserver(&o);
@@ -3083,7 +3078,7 @@ TEST_F(WindowTest, OnWindowHierarchyChange) {
WindowObserver::HierarchyChangeParams params;
params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING;
params.target = w1.get();
- params.old_parent = NULL;
+ params.old_parent = nullptr;
params.new_parent = root_window();
params.receiver = w1.get();
o.ValidateState(index++, params);
@@ -3106,7 +3101,7 @@ TEST_F(WindowTest, OnWindowHierarchyChange) {
root_window()->RemoveChild(w1.get());
params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING;
params.old_parent = root_window();
- params.new_parent = NULL;
+ params.new_parent = nullptr;
params.receiver = w1.get();
o.ValidateState(index++, params);
params.receiver = w11;