diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-07-14 17:41:05 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-08-04 12:37:36 +0000 |
commit | 399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch) | |
tree | 6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/ui/aura | |
parent | 7366110654eec46f21b6824f302356426f48cd74 (diff) | |
download | qtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz |
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/ui/aura')
36 files changed, 727 insertions, 701 deletions
diff --git a/chromium/ui/aura/BUILD.gn b/chromium/ui/aura/BUILD.gn index b1b32287118..99b3b1f705e 100644 --- a/chromium/ui/aura/BUILD.gn +++ b/chromium/ui/aura/BUILD.gn @@ -77,7 +77,6 @@ component("aura") { "window_observer.h", "window_targeter.cc", "window_targeter.h", - "window_tracker.cc", "window_tracker.h", "window_tree_host.cc", "window_tree_host.h", @@ -100,6 +99,7 @@ component("aura") { "//ui/base", "//ui/base/ime", "//ui/compositor", + "//ui/display", "//ui/events", "//ui/events:events_base", "//ui/events/platform", @@ -116,6 +116,7 @@ component("aura") { deps += [ "//ui/events:events_base", "//ui/events/devices", + "//ui/events/devices/x11", "//ui/events/platform/x11", "//ui/gfx/x", ] @@ -190,6 +191,7 @@ source_set("test_support") { "//ui/base:test_support", "//ui/base/ime", "//ui/compositor:test_support", + "//ui/display", "//ui/events", "//ui/events:events_base", "//ui/events:test_support", @@ -231,15 +233,17 @@ executable("demo") { "//base", "//base:i18n", "//build/config/sanitizers:deps", + "//build/win:default_exe_manifest", "//skia", "//third_party/icu", "//ui/base", "//ui/compositor", "//ui/compositor:test_support", + "//ui/display", "//ui/events", "//ui/gfx", "//ui/gfx/geometry", - "//ui/gl", + "//ui/gl/init", ] if (use_x11) { @@ -263,6 +267,7 @@ test("aura_unittests") { "//testing/gtest", "//ui/base:test_support", "//ui/compositor:test_support", + "//ui/display:test_support", "//ui/events:gesture_detection", "//ui/events:test_support", "//ui/gfx", diff --git a/chromium/ui/aura/DEPS b/chromium/ui/aura/DEPS index 9b9ca339813..2ed6f5262e1 100644 --- a/chromium/ui/aura/DEPS +++ b/chromium/ui/aura/DEPS @@ -3,6 +3,7 @@ include_rules = [ "+third_party/skia", "+ui/base", "+ui/compositor", + "+ui/display", "+ui/events", "+ui/gfx", "+ui/metro_viewer", # TODO(beng): investigate moving remote_root_window_host diff --git a/chromium/ui/aura/aura.gyp b/chromium/ui/aura/aura.gyp index 3020e2d4da2..5b15beed62e 100644 --- a/chromium/ui/aura/aura.gyp +++ b/chromium/ui/aura/aura.gyp @@ -19,6 +19,7 @@ '../base/ime/ui_base_ime.gyp:ui_base_ime', '../base/ui_base.gyp:ui_base', '../compositor/compositor.gyp:compositor', + '../display/display.gyp:display', '../events/events.gyp:events', '../events/events.gyp:events_base', '../events/platform/events_platform.gyp:events_platform', @@ -99,7 +100,6 @@ 'window_observer.h', 'window_targeter.cc', 'window_targeter.h', - 'window_tracker.cc', 'window_tracker.h', 'window_tree_host.cc', 'window_tree_host.h', @@ -117,7 +117,9 @@ '../../build/linux/system.gyp:x11', '../../build/linux/system.gyp:xrandr', '../../build/linux/system.gyp:xi', + '../base/x/ui_base_x.gyp:ui_base_x', '../events/devices/events_devices.gyp:events_devices', + '../events/devices/x11/events_devices_x11.gyp:events_devices_x11', '../events/platform/x11/x11_events_platform.gyp:x11_events_platform', '../gfx/x/gfx_x11.gyp:gfx_x11', ], @@ -200,6 +202,13 @@ ], # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. 'msvs_disabled_warnings': [ 4267, ], + 'conditions': [ + ['use_x11==1', { + 'dependencies': [ + '../base/x/ui_base_x.gyp:ui_base_x', + ], + }], + ], }, { 'target_name': 'aura_demo', @@ -213,6 +222,7 @@ '../base/ui_base.gyp:ui_base', '../compositor/compositor.gyp:compositor', '../compositor/compositor.gyp:compositor_test_support', + '../display/display.gyp:display', '../events/events.gyp:events', '../gfx/gfx.gyp:gfx', '../gfx/gfx.gyp:gfx_geometry', @@ -251,6 +261,7 @@ '../gfx/gfx.gyp:gfx', '../gfx/gfx.gyp:gfx_geometry', '../gl/gl.gyp:gl', + '../gl/init/gl_init.gyp:gl_init', 'aura_test_support', 'aura', ], diff --git a/chromium/ui/aura/client/aura_constants.cc b/chromium/ui/aura/client/aura_constants.cc index 18733c7d3b1..55e39776eeb 100644 --- a/chromium/ui/aura/client/aura_constants.cc +++ b/chromium/ui/aura/client/aura_constants.cc @@ -36,6 +36,7 @@ DEFINE_WINDOW_PROPERTY_KEY( ui::WindowShowState, kRestoreShowStateKey, ui::SHOW_STATE_DEFAULT); DEFINE_WINDOW_PROPERTY_KEY( ui::WindowShowState, kShowStateKey, ui::SHOW_STATE_DEFAULT); +DEFINE_WINDOW_PROPERTY_KEY(int, kTopViewInset, 0); } // namespace client } // namespace aura diff --git a/chromium/ui/aura/client/aura_constants.h b/chromium/ui/aura/client/aura_constants.h index 5999b850978..aca8ea99251 100644 --- a/chromium/ui/aura/client/aura_constants.h +++ b/chromium/ui/aura/client/aura_constants.h @@ -61,6 +61,12 @@ AURA_EXPORT extern const WindowProperty<ui::WindowShowState>* const AURA_EXPORT extern const WindowProperty<ui::WindowShowState>* const kShowStateKey; +// The inset of the topmost view in the client view from the top of the +// non-client view. The topmost view depends on the window type. The topmost +// view is the tab strip for tabbed browser windows, the toolbar for popups, +// the web contents for app windows and varies for fullscreen windows. +AURA_EXPORT extern const aura::WindowProperty<int>* const kTopViewInset; + // Alphabetical sort. } // namespace client diff --git a/chromium/ui/aura/client/cursor_client.h b/chromium/ui/aura/client/cursor_client.h index fc48e036107..138e5e44b30 100644 --- a/chromium/ui/aura/client/cursor_client.h +++ b/chromium/ui/aura/client/cursor_client.h @@ -10,7 +10,7 @@ #include "ui/base/cursor/cursor.h" #include "ui/gfx/native_widget_types.h" -namespace gfx { +namespace display { class Display; } @@ -59,7 +59,7 @@ class AURA_EXPORT CursorClient { virtual bool IsMouseEventsEnabled() const = 0; // Sets the display for the cursor. - virtual void SetDisplay(const gfx::Display& display) = 0; + virtual void SetDisplay(const display::Display& display) = 0; // Locks the cursor change. The cursor type, cursor visibility, and mouse // events enable state never change as long as lock is held by anyone. diff --git a/chromium/ui/aura/client/default_capture_client.cc b/chromium/ui/aura/client/default_capture_client.cc index 2740c9f8e19..b0719fc14e6 100644 --- a/chromium/ui/aura/client/default_capture_client.cc +++ b/chromium/ui/aura/client/default_capture_client.cc @@ -11,6 +11,10 @@ namespace aura { namespace client { +// static +// Track the active capture window across root windows. +Window* global_capture_window_ = nullptr; + DefaultCaptureClient::DefaultCaptureClient(Window* root_window) : root_window_(root_window), capture_window_(NULL) { @@ -18,6 +22,8 @@ DefaultCaptureClient::DefaultCaptureClient(Window* root_window) } DefaultCaptureClient::~DefaultCaptureClient() { + if (global_capture_window_ == capture_window_) + global_capture_window_ = nullptr; SetCaptureClient(root_window_, NULL); } @@ -29,6 +35,7 @@ void DefaultCaptureClient::SetCapture(Window* window) { Window* old_capture_window = capture_window_; capture_window_ = window; + global_capture_window_ = window; CaptureDelegate* capture_delegate = root_window_->GetHost()->dispatcher(); if (capture_window_) @@ -50,7 +57,7 @@ Window* DefaultCaptureClient::GetCaptureWindow() { } Window* DefaultCaptureClient::GetGlobalCaptureWindow() { - return capture_window_; + return global_capture_window_; } } // namespace client diff --git a/chromium/ui/aura/client/screen_position_client.h b/chromium/ui/aura/client/screen_position_client.h index 9dceb222e2f..f6d5ad950a5 100644 --- a/chromium/ui/aura/client/screen_position_client.h +++ b/chromium/ui/aura/client/screen_position_client.h @@ -40,7 +40,7 @@ class AURA_EXPORT ScreenPositionClient { // for finding out and translating the right coordinates for the |window|. virtual void SetBounds(Window* window, const gfx::Rect& bounds, - const gfx::Display& display) = 0; + const display::Display& display) = 0; }; // Sets/Gets the activation client on the Window. diff --git a/chromium/ui/aura/client/window_stacking_client.h b/chromium/ui/aura/client/window_stacking_client.h index f0b9b666f51..657e5997147 100644 --- a/chromium/ui/aura/client/window_stacking_client.h +++ b/chromium/ui/aura/client/window_stacking_client.h @@ -5,7 +5,8 @@ #ifndef UI_AURA_CLIENT_WINDOW_STACKING_CLIENT_H_ #define UI_AURA_CLIENT_WINDOW_STACKING_CLIENT_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "ui/aura/aura_export.h" #include "ui/aura/window.h" diff --git a/chromium/ui/aura/demo/DEPS b/chromium/ui/aura/demo/DEPS index 07d824381a5..305f5f68a81 100644 --- a/chromium/ui/aura/demo/DEPS +++ b/chromium/ui/aura/demo/DEPS @@ -1,3 +1,4 @@ include_rules = [ - "+ui/gl/gl_surface.h", # To initialize GL bindings. + "+ui/display", # Windows DPI Initialization. + "+ui/gl/init/gl_factory.h", # To initialize GL bindings. ] diff --git a/chromium/ui/aura/demo/demo_main.cc b/chromium/ui/aura/demo/demo_main.cc index ea86753f8b3..8f52346cb53 100644 --- a/chromium/ui/aura/demo/demo_main.cc +++ b/chromium/ui/aura/demo/demo_main.cc @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "base/at_exit.h" #include "base/command_line.h" #include "base/i18n/icu_util.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/power_monitor/power_monitor.h" #include "base/power_monitor/power_monitor_device_source.h" @@ -27,14 +29,14 @@ #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/skia_util.h" -#include "ui/gl/gl_surface.h" +#include "ui/gl/init/gl_factory.h" #if defined(USE_X11) #include "ui/gfx/x/x11_connection.h" // nogncheck #endif #if defined(OS_WIN) -#include "ui/gfx/win/dpi.h" +#include "ui/display/win/dpi.h" #endif namespace { @@ -116,7 +118,7 @@ class DemoWindowTreeClient : public aura::client::WindowTreeClient { private: aura::Window* window_; - scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; + std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient); }; @@ -128,32 +130,32 @@ int DemoMain() { gfx::InitializeThreadedX11(); #endif - gfx::GLSurface::InitializeOneOff(); + gl::init::InitializeGLOneOff(); #if defined(OS_WIN) - gfx::SetDefaultDeviceScaleFactor(1.0f); + display::win::SetDefaultDeviceScaleFactor(1.0f); #endif // The ContextFactory must exist before any Compositors are created. bool context_factory_for_test = false; - scoped_ptr<ui::InProcessContextFactory> context_factory( + std::unique_ptr<ui::InProcessContextFactory> context_factory( new ui::InProcessContextFactory(context_factory_for_test, nullptr)); context_factory->set_use_test_surface(false); // Create the message-loop here before creating the root window. base::MessageLoopForUI message_loop; - base::PowerMonitor power_monitor(make_scoped_ptr( - new base::PowerMonitorDeviceSource)); + base::PowerMonitor power_monitor( + base::WrapUnique(new base::PowerMonitorDeviceSource)); - aura::Env::CreateInstance(true); - aura::Env::GetInstance()->set_context_factory(context_factory.get()); - scoped_ptr<aura::TestScreen> test_screen( + std::unique_ptr<aura::Env> env = aura::Env::CreateInstance(); + env->set_context_factory(context_factory.get()); + std::unique_ptr<aura::TestScreen> test_screen( aura::TestScreen::Create(gfx::Size())); - gfx::Screen::SetScreenInstance(test_screen.get()); - scoped_ptr<aura::WindowTreeHost> host( + display::Screen::SetScreenInstance(test_screen.get()); + std::unique_ptr<aura::WindowTreeHost> host( test_screen->CreateHostForPrimaryDisplay()); - scoped_ptr<DemoWindowTreeClient> window_tree_client( + std::unique_ptr<DemoWindowTreeClient> window_tree_client( new DemoWindowTreeClient(host->window())); aura::test::TestFocusClient focus_client; aura::client::SetFocusClient(host->window(), &focus_client); diff --git a/chromium/ui/aura/env.cc b/chromium/ui/aura/env.cc index 7e82d4e13cd..058d94a05ee 100644 --- a/chromium/ui/aura/env.cc +++ b/chromium/ui/aura/env.cc @@ -24,23 +24,29 @@ namespace { base::LazyInstance<base::ThreadLocalPointer<Env> >::Leaky lazy_tls_ptr = LAZY_INSTANCE_INITIALIZER; -#if defined(USE_OZONE) // Returns true if running inside of mus. Checks for mojo specific flag. bool RunningInsideMus() { return base::CommandLine::ForCurrentProcess()->HasSwitch( "primordial-pipe-token"); } -#endif } // namespace //////////////////////////////////////////////////////////////////////////////// // Env, public: +Env::~Env() { + FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); + DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get()); + lazy_tls_ptr.Pointer()->Set(NULL); +} + // static -void Env::CreateInstance(bool create_event_source) { - if (!lazy_tls_ptr.Pointer()->Get()) - (new Env())->Init(create_event_source); +std::unique_ptr<Env> Env::CreateInstance() { + DCHECK(!lazy_tls_ptr.Pointer()->Get()); + std::unique_ptr<Env> env(new Env()); + env->Init(); + return env; } // static @@ -56,11 +62,6 @@ Env* Env::GetInstanceDontCreate() { return lazy_tls_ptr.Pointer()->Get(); } -// static -void Env::DeleteInstance() { - delete lazy_tls_ptr.Pointer()->Get(); -} - void Env::AddObserver(EnvObserver* observer) { observers_.AddObserver(observer); } @@ -86,21 +87,14 @@ Env::Env() lazy_tls_ptr.Pointer()->Set(this); } -Env::~Env() { - FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); - DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get()); - lazy_tls_ptr.Pointer()->Set(NULL); -} - -void Env::Init(bool create_event_source) { - if (!create_event_source) +void Env::Init() { + if (RunningInsideMus()) return; #if defined(USE_OZONE) // 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. - if (!RunningInsideMus()) - ui::OzonePlatform::InitializeForUI(); + ui::OzonePlatform::InitializeForUI(); #endif if (!ui::PlatformEventSource::GetInstance()) event_source_ = ui::PlatformEventSource::CreateDefault(); @@ -129,7 +123,7 @@ ui::EventTarget* Env::GetParentTarget() { return NULL; } -scoped_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { +std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { return nullptr; } diff --git a/chromium/ui/aura/env.h b/chromium/ui/aura/env.h index e8cdb243ff2..01b9e0ddaf4 100644 --- a/chromium/ui/aura/env.h +++ b/chromium/ui/aura/env.h @@ -5,8 +5,9 @@ #ifndef UI_AURA_ENV_H_ #define UI_AURA_ENV_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/supports_user_data.h" #include "ui/aura/aura_export.h" @@ -32,14 +33,11 @@ class WindowTreeHost; // A singleton object that tracks general state within Aura. class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData { public: - // Creates the single Env instance (if it hasn't been created yet). If - // |create_event_source| is true a PlatformEventSource is created. - // TODO(sky): nuke |create_event_source|. Only necessary while mojo's - // nativeviewportservice lives in the same process as the viewmanager. - static void CreateInstance(bool create_event_source); + ~Env() override; + + static std::unique_ptr<Env> CreateInstance(); static Env* GetInstance(); static Env* GetInstanceDontCreate(); - static void DeleteInstance(); void AddObserver(EnvObserver* observer); void RemoveObserver(EnvObserver* observer); @@ -74,10 +72,8 @@ class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData { friend class WindowTreeHost; Env(); - ~Env() override; - // See description of CreateInstance() for deatils of |create_event_source|. - void Init(bool create_event_source); + void Init(); // Called by the Window when it is initialized. Notifies observers. void NotifyWindowInitialized(Window* window); @@ -91,7 +87,7 @@ class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData { // Overridden from ui::EventTarget: bool CanAcceptEvent(const ui::Event& event) override; ui::EventTarget* GetParentTarget() override; - scoped_ptr<ui::EventTargetIterator> GetChildIterator() const override; + std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; ui::EventTargeter* GetEventTargeter() override; base::ObserverList<EnvObserver> observers_; @@ -101,8 +97,8 @@ class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData { gfx::Point last_mouse_location_; bool is_touch_down_; - scoped_ptr<InputStateLookup> input_state_lookup_; - scoped_ptr<ui::PlatformEventSource> event_source_; + std::unique_ptr<InputStateLookup> input_state_lookup_; + std::unique_ptr<ui::PlatformEventSource> event_source_; ui::ContextFactory* context_factory_; diff --git a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc index a32c0f7e987..fc4e5842115 100644 --- a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc +++ b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc @@ -284,7 +284,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { } private: - scoped_ptr<base::RunLoop> run_loop_; + std::unique_ptr<base::RunLoop> run_loop_; std::vector<ui::EventType> events_; bool tap_; @@ -474,7 +474,7 @@ class ScopedGestureRecognizerSetter { private: ui::GestureRecognizer* original_gr_; - scoped_ptr<ui::GestureRecognizer> new_gr_; + std::unique_ptr<ui::GestureRecognizer> new_gr_; DISALLOW_COPY_AND_ASSIGN(ScopedGestureRecognizerSetter); }; @@ -684,14 +684,14 @@ class GestureRecognizerWithSwitchTest : public GestureRecognizerTest { // Check that appropriate touch events generate tap gesture events. TEST_F(GestureRecognizerTest, GestureEventTap) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 2; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -735,14 +735,14 @@ TEST_F(GestureRecognizerTest, GestureEventTap) { // Check that appropriate touch events generate tap gesture events // when information about the touch radii are provided. TEST_F(GestureRecognizerTest, GestureEventTapRegion) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 800; const int kWindowHeight = 600; const int kTouchId = 2; gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); // Test with no ET_TOUCH_MOVED events. @@ -968,14 +968,14 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) { // sqrt(5 * 5 + 5 * 5). ui::GestureConfiguration::GetInstance() ->set_max_touch_move_in_pixels_for_click(sqrt(5.f * 5 + 5 * 5)); - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 5; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -1040,14 +1040,14 @@ TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) { ui::GestureConfiguration::GetInstance() ->set_max_touch_move_in_pixels_for_click(sqrt(5.f * 5 + 5 * 5)); - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 5; gfx::Rect bounds(95, 195, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -1110,13 +1110,13 @@ TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { TimedEvents tes; for (int radius = 1; radius <= 10; ++radius) { ui::GestureConfiguration::GetInstance()->set_default_radius(radius); - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 5; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); const int kPositionX = 101; @@ -1158,12 +1158,12 @@ TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { // Check Scroll End Events report correct velocities // if the user was on a horizontal rail TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kTouchId = 7; gfx::Rect bounds(0, 0, 1000, 1000); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), @@ -1209,12 +1209,12 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { // Check Scroll End Events report correct velocities // if the user was on a vertical rail TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kTouchId = 7; gfx::Rect bounds(0, 0, 1000, 1000); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), @@ -1263,12 +1263,12 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) { TEST_F(GestureRecognizerTest, GestureEventNonRailFling) { ui::GestureConfiguration::GetInstance() ->set_max_touch_move_in_pixels_for_click(0); - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kTouchId = 7; gfx::Rect bounds(0, 0, 1000, 1000); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), @@ -1305,13 +1305,13 @@ TEST_F(GestureRecognizerTest, GestureEventNonRailFling) { // Check that appropriate touch events generate long press events TEST_F(GestureRecognizerTest, GestureEventLongPress) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 2; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -1348,14 +1348,14 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) { // Check that scrolling prevents a long press. TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 6; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -1391,13 +1391,13 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { TEST_F(GestureRecognizerTest, GestureEventLongTap) { ui::GestureConfiguration::GetInstance() ->set_max_touch_down_duration_for_click_in_ms(3); - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 2; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -1435,7 +1435,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongTap) { // Check that second tap cancels a long press TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 300; @@ -1443,7 +1443,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { const int kTouchId1 = 8; const int kTouchId2 = 2; gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -1483,12 +1483,12 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { // Check that horizontal scroll gestures cause scrolls on horizontal rails. // Also tests that horizontal rails can be broken. TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kTouchId = 7; gfx::Rect bounds(0, 0, 1000, 1000); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), @@ -1539,12 +1539,12 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { // Check that vertical scroll gestures cause scrolls on vertical rails. // Also tests that vertical rails can be broken. TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kTouchId = 7; gfx::Rect bounds(0, 0, 1000, 1000); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), @@ -1600,14 +1600,14 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) { ->set_max_touch_move_in_pixels_for_click(sqrt(5.f * 5 + 5 * 5)); // First, tap. Then, do a scroll using the same touch-id. - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 3; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -1720,7 +1720,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) { } TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { - scoped_ptr<QueueTouchEventDelegate> queued_delegate( + std::unique_ptr<QueueTouchEventDelegate> queued_delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kWindowWidth = 123; @@ -1728,7 +1728,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { const int kTouchId1 = 6; const int kTouchId2 = 4; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> queue(CreateTestWindowWithDelegate( queued_delegate.get(), -1234, bounds, root_window())); queued_delegate->set_window(queue.get()); @@ -1766,9 +1766,9 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { // Create another window, and place a touch-down on it. This should create a // tap-down gesture. - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), root_window())); delegate->Reset(); ui::TouchEvent press2( @@ -1919,7 +1919,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { // Check that appropriate touch events generate pinch gesture events. TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 300; @@ -1927,7 +1927,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) { const int kTouchId1 = 5; const int kTouchId2 = 3; gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -2002,7 +2002,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) { } TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { -scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 300; @@ -2010,7 +2010,7 @@ scoped_ptr<GestureEventConsumeDelegate> delegate( const int kTouchId1 = 5; const int kTouchId2 = 3; gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), @@ -2059,7 +2059,7 @@ scoped_ptr<GestureEventConsumeDelegate> delegate( } TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 300; @@ -2067,7 +2067,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { const int kTouchId1 = 3; const int kTouchId2 = 5; gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -2134,7 +2134,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { } TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; @@ -2155,19 +2155,19 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { ui::GestureConsumer* target; const int kNumWindows = 4; - scoped_ptr<GestureEventConsumeDelegate*[]> delegates( + std::unique_ptr<GestureEventConsumeDelegate* []> delegates( new GestureEventConsumeDelegate*[kNumWindows]); ui::GestureConfiguration::GetInstance() ->set_max_separation_for_gesture_touches_in_pixels(499); - scoped_ptr<gfx::Rect[]> window_bounds(new gfx::Rect[kNumWindows]); + std::unique_ptr<gfx::Rect[]> window_bounds(new gfx::Rect[kNumWindows]); window_bounds[0] = gfx::Rect(0, 0, 1, 1); window_bounds[1] = gfx::Rect(500, 0, 1, 1); window_bounds[2] = gfx::Rect(0, 500, 1, 1); window_bounds[3] = gfx::Rect(500, 500, 1, 1); - scoped_ptr<aura::Window*[]> windows(new aura::Window*[kNumWindows]); + std::unique_ptr<aura::Window* []> windows(new aura::Window*[kNumWindows]); // Instantiate windows with |window_bounds| and touch each window at // its origin. @@ -2243,10 +2243,10 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { // Check that a touch's target will not be effected by a touch on a different // screen. TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); gfx::Rect bounds(0, 0, 10, 10); - scoped_ptr<aura::Window> window( + std::unique_ptr<aura::Window> window( CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); const int kTouchId1 = 8; @@ -2276,7 +2276,7 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) { // by the root window's gesture sequence. TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { TimedEvents tes; - scoped_ptr<aura::Window> window(CreateTestWindowWithBounds( + std::unique_ptr<aura::Window> window(CreateTestWindowWithBounds( gfx::Rect(-100, -100, 2000, 2000), root_window())); gfx::Point pos1(-10, -10); @@ -2298,12 +2298,12 @@ TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { } TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kTouchId = 2; gfx::Rect bounds(100, 200, 100, 100); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); @@ -2325,13 +2325,13 @@ TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { } TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kTouchId1 = 7; const int kTouchId2 = 5; gfx::Rect bounds(10, 20, 100, 100); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); @@ -2428,7 +2428,7 @@ TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { TEST_F(GestureRecognizerTest, GestureEndLocation) { GestureEventConsumeDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, -1234, gfx::Rect(10, 10, 300, 300), root_window())); ui::test::EventGenerator generator(root_window(), window.get()); const gfx::Point begin(20, 20); @@ -2445,9 +2445,9 @@ TEST_F(GestureRecognizerTest, GestureEndLocation) { } TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); ui::test::EventGenerator generator(root_window()); @@ -2457,8 +2457,8 @@ TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) { EXPECT_TRUE(delegate->tap_down()); - scoped_ptr<aura::Window> capture(CreateTestWindowWithBounds( - gfx::Rect(10, 10, 200, 200), root_window())); + std::unique_ptr<aura::Window> capture( + CreateTestWindowWithBounds(gfx::Rect(10, 10, 200, 200), root_window())); capture->SetCapture(); RunAllPendingInMessageLoop(); @@ -2470,26 +2470,24 @@ TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) { // released or cancelled), do not receive extra synthetic cancels upon change of // capture. TEST_F(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); - scoped_ptr<TestEventHandler> handler(new TestEventHandler); + std::unique_ptr<TestEventHandler> handler(new TestEventHandler); root_window()->AddPreTargetHandler(handler.get()); // Create a window and set it as the capture window. - scoped_ptr<aura::Window> window1(CreateTestWindowWithDelegate(delegate.get(), - -1234, gfx::Rect(10, 10, 300, 300), root_window())); + std::unique_ptr<aura::Window> window1(CreateTestWindowWithDelegate( + delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); window1->SetCapture(); ui::test::EventGenerator generator(root_window()); TimedEvents tes; // Generate two touch-press events on the window. - scoped_ptr<ui::TouchEvent> touch0(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, - gfx::Point(20, 20), 0, - tes.Now())); - scoped_ptr<ui::TouchEvent> touch1(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, - gfx::Point(30, 30), 1, - tes.Now())); + std::unique_ptr<ui::TouchEvent> touch0(new ui::TouchEvent( + ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 0, tes.Now())); + std::unique_ptr<ui::TouchEvent> touch1(new ui::TouchEvent( + ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 1, tes.Now())); generator.Dispatch(touch0.get()); generator.Dispatch(touch1.get()); RunAllPendingInMessageLoop(); @@ -2511,8 +2509,8 @@ TEST_F(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) { EXPECT_EQ(1, handler->touch_cancelled_count()); // Create a new window and set it as the new capture window. - scoped_ptr<aura::Window> window2(CreateTestWindowWithBounds( - gfx::Rect(100, 100, 300, 300), root_window())); + std::unique_ptr<aura::Window> window2( + CreateTestWindowWithBounds(gfx::Rect(100, 100, 300, 300), root_window())); window2->SetCapture(); RunAllPendingInMessageLoop(); // Check that setting capture does not generate any synthetic touch-cancels @@ -2524,11 +2522,11 @@ TEST_F(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) { // Tests that a press with the same touch id as an existing touch is ignored. TEST_F(GestureRecognizerTest, PressDoesNotCrash) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, tes.Now()); @@ -2549,14 +2547,14 @@ TEST_F(GestureRecognizerTest, PressDoesNotCrash) { } TEST_F(GestureRecognizerTest, TwoFingerTap) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId1 = 2; const int kTouchId2 = 3; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -2608,14 +2606,14 @@ TEST_F(GestureRecognizerTest, TwoFingerTap) { } TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId1 = 2; const int kTouchId2 = 3; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -2649,7 +2647,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { } TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; @@ -2660,7 +2658,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) { // Test moving first finger { gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -2691,7 +2689,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) { // Test moving second finger { gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -2721,7 +2719,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) { } TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; @@ -2730,7 +2728,7 @@ TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) { TimedEvents tes; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -2758,13 +2756,13 @@ TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) { } TEST_F(GestureRecognizerTest, MultiFingerSwipe) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; gfx::Rect bounds(5, 10, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); const int kSteps = 15; @@ -2820,7 +2818,7 @@ TEST_F(GestureRecognizerTest, MultiFingerSwipe) { } TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; @@ -2831,7 +2829,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) { // Test canceling first finger. { gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -2863,7 +2861,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) { // Test canceling second finger { gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -2894,14 +2892,14 @@ TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) { } TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 523; const int kWindowHeight = 45; const int kTouchId1 = 2; const int kTouchId2 = 3; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -2951,10 +2949,10 @@ TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) { // Verifies if a window is the target of multiple touch-ids and we hide the // window everything is cleaned up correctly. TEST_F(GestureRecognizerTest, FlushAllOnHide) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); gfx::Rect bounds(0, 0, 200, 200); - scoped_ptr<aura::Window> window( + std::unique_ptr<aura::Window> window( CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); const int kTouchId1 = 8; const int kTouchId2 = 2; @@ -2974,11 +2972,11 @@ TEST_F(GestureRecognizerTest, FlushAllOnHide) { } TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); const int kTouchId = 2; gfx::Rect bounds(100, 200, 100, 100); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); TimedEvents tes; @@ -3027,13 +3025,13 @@ class ConsumesTouchMovesDelegate : public GestureEventConsumeDelegate { // Same as GestureEventScroll, but tests that the behavior is the same // even if all the touch-move events are consumed. TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) { - scoped_ptr<ConsumesTouchMovesDelegate> delegate( + std::unique_ptr<ConsumesTouchMovesDelegate> delegate( new ConsumesTouchMovesDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 5; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -3082,7 +3080,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) { // Tests the behavior of 2F scroll when some of the touch-move events are // consumed. TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) { - scoped_ptr<ConsumesTouchMovesDelegate> delegate( + std::unique_ptr<ConsumesTouchMovesDelegate> delegate( new ConsumesTouchMovesDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 100; @@ -3091,7 +3089,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) { TimedEvents tes; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -3147,13 +3145,13 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) { // depending on whether the events were consumed before or after the scroll // started. TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) { - scoped_ptr<ConsumesTouchMovesDelegate> delegate( + std::unique_ptr<ConsumesTouchMovesDelegate> delegate( new ConsumesTouchMovesDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 5; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -3245,13 +3243,13 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) { // Check that appropriate touch events generate double tap gesture events. TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 2; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -3286,13 +3284,13 @@ TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { // Check that appropriate touch events generate triple tap gesture events. TEST_F(GestureRecognizerTest, GestureEventTripleTap) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 2; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -3354,13 +3352,13 @@ TEST_F(GestureRecognizerTest, GestureEventTripleTap) { // Check that we don't get a double tap when the two taps are far apart. TEST_F(GestureRecognizerTest, TwoTapsFarApart) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 2; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -3396,13 +3394,13 @@ TEST_F(GestureRecognizerTest, TwoTapsFarApart) { // Check that we don't get a double tap when the two taps have a long enough // delay in between. TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 2; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -3439,13 +3437,13 @@ TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) { // radius of a touch-point, and not because of change in position, then there // are not gesture events from that. TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 234; const int kWindowHeight = 345; const int kTouchId = 5, kTouchId2 = 7; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -3494,14 +3492,14 @@ TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) { TEST_F(GestureRecognizerTest, NoDriftInScroll) { ui::GestureConfiguration::GetInstance() ->set_max_touch_move_in_pixels_for_click(3); - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 234; const int kWindowHeight = 345; const int kTouchId = 5; TimedEvents tes; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press1( @@ -3550,11 +3548,11 @@ TEST_F(GestureRecognizerTest, NoDriftInScroll) { // cancel gesture event to be fired if the move would normally cause a // scroll. See bug http://crbug.com/146397. TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) { - scoped_ptr<ConsumesTouchMovesDelegate> delegate( + std::unique_ptr<ConsumesTouchMovesDelegate> delegate( new ConsumesTouchMovesDelegate()); const int kTouchId = 5; gfx::Rect bounds(100, 200, 123, 45); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); TimedEvents tes; @@ -3581,7 +3579,7 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) { } TEST_F(GestureRecognizerTest, CancelAllActiveTouches) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 800; @@ -3589,9 +3587,9 @@ TEST_F(GestureRecognizerTest, CancelAllActiveTouches) { const int kTouchId1 = 1; const int kTouchId2 = 2; gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); - scoped_ptr<TestEventHandler> handler(new TestEventHandler()); + std::unique_ptr<TestEventHandler> handler(new TestEventHandler()); window->AddPreTargetHandler(handler.get()); // Start a gesture sequence on |window|. Then cancel all touches. @@ -3640,14 +3638,14 @@ TEST_F(GestureRecognizerTest, CancelAllActiveTouches) { // Check that appropriate touch events generate show press events TEST_F(GestureRecognizerTest, GestureEventShowPress) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 2; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -3680,14 +3678,14 @@ TEST_F(GestureRecognizerTest, GestureEventShowPress) { // Check that scrolling cancels a show press TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 6; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -3718,14 +3716,14 @@ TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) { // Test that show press events are sent immediately on tap TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 6; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -3750,12 +3748,12 @@ TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) { // Test that consuming the first move touch event prevents a scroll. TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kTouchId = 7; gfx::Rect bounds(0, 0, 1000, 1000); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); @@ -3785,12 +3783,12 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { // Test that consuming the first move touch doesn't prevent a tap. TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kTouchId = 7; gfx::Rect bounds(0, 0, 1000, 1000); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); @@ -3814,14 +3812,14 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { // Test that consuming the first move touch doesn't prevent a long press. TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 2; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); @@ -3846,14 +3844,14 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) { ui::GestureConfiguration::GetInstance() ->set_max_touch_move_in_pixels_for_click(3); - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); const int kWindowWidth = 234; const int kWindowHeight = 345; const int kTouchId = 5; TimedEvents tes; gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press( @@ -3903,14 +3901,14 @@ TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) { } TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kWindowWidth = 3000; const int kWindowHeight = 3000; const int kTouchId = 2; gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); @@ -3963,7 +3961,7 @@ TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) { } TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kWindowWidth = 3000; @@ -3971,7 +3969,7 @@ TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) { const int kTouchId1 = 5; const int kTouchId2 = 7; gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); delegate->Reset(); @@ -4048,14 +4046,14 @@ TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) { // Test that touch event flags are passed through to the gesture event. TEST_F(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 123; const int kWindowHeight = 45; const int kTouchId = 6; gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->Reset(); @@ -4122,7 +4120,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressDeletingWindow) { } TEST_F(GestureRecognizerWithSwitchTest, GestureEventSmallPinchDisabled) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 300; @@ -4130,7 +4128,7 @@ TEST_F(GestureRecognizerWithSwitchTest, GestureEventSmallPinchDisabled) { const int kTouchId1 = 3; const int kTouchId2 = 5; gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), @@ -4161,7 +4159,7 @@ TEST_F(GestureRecognizerWithSwitchTest, GestureEventSmallPinchDisabled) { } TEST_F(GestureRecognizerTest, GestureEventSmallPinchEnabled) { - scoped_ptr<GestureEventConsumeDelegate> delegate( + std::unique_ptr<GestureEventConsumeDelegate> delegate( new GestureEventConsumeDelegate()); TimedEvents tes; const int kWindowWidth = 300; @@ -4169,7 +4167,7 @@ TEST_F(GestureRecognizerTest, GestureEventSmallPinchEnabled) { const int kTouchId1 = 3; const int kTouchId2 = 5; gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), @@ -4202,12 +4200,12 @@ TEST_F(GestureRecognizerTest, GestureEventSmallPinchEnabled) { // Tests that delaying the ack of a touch release doesn't trigger a long press // gesture. TEST_F(GestureRecognizerTest, EagerGestureDetection) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kTouchId = 2; gfx::Rect bounds(100, 200, 100, 100); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); @@ -4237,14 +4235,14 @@ TEST_F(GestureRecognizerTest, EagerGestureDetection) { // This tests crbug.com/405519, in which touch events which the gesture detector // ignores interfere with gesture recognition. TEST_F(GestureRecognizerTest, IgnoredEventsDontBreakGestureRecognition) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kWindowWidth = 300; const int kWindowHeight = 400; const int kTouchId1 = 3; gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); @@ -4291,14 +4289,14 @@ TEST_F(GestureRecognizerTest, IgnoredEventsDontBreakGestureRecognition) { // Tests that an event stream can have a mix of sync and async acks. TEST_F(GestureRecognizerTest, MixedSyncAndAsyncAcksDontCauseOutOfOrderDispatch) { - scoped_ptr<QueueTouchEventDelegate> delegate( + std::unique_ptr<QueueTouchEventDelegate> delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kWindowWidth = 300; const int kWindowHeight = 400; const int kTouchId1 = 3; gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( delegate.get(), -1234, bounds, root_window())); delegate->set_window(window.get()); @@ -4366,7 +4364,7 @@ TEST_F(GestureRecognizerTest, } TEST_F(GestureRecognizerTest, GestureEventTwoWindowsActive) { - scoped_ptr<QueueTouchEventDelegate> queued_delegate( + std::unique_ptr<QueueTouchEventDelegate> queued_delegate( new QueueTouchEventDelegate(host()->dispatcher())); TimedEvents tes; const int kWindowWidth = 123; @@ -4374,7 +4372,7 @@ TEST_F(GestureRecognizerTest, GestureEventTwoWindowsActive) { const int kTouchId1 = 6; const int kTouchId2 = 4; gfx::Rect bounds(150, 200, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( queued_delegate.get(), -1234, bounds, root_window())); queued_delegate->set_window(window.get()); @@ -4393,10 +4391,10 @@ TEST_F(GestureRecognizerTest, GestureEventTwoWindowsActive) { // Touch down on the second window. This should not generate any // gesture event. - scoped_ptr<QueueTouchEventDelegate> queued_delegate2( + std::unique_ptr<QueueTouchEventDelegate> queued_delegate2( new QueueTouchEventDelegate(host()->dispatcher())); gfx::Rect bounds2(0, 0, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window2(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window2(CreateTestWindowWithDelegate( queued_delegate2.get(), -2345, bounds2, root_window())); queued_delegate2->set_window(window2.get()); diff --git a/chromium/ui/aura/input_state_lookup.cc b/chromium/ui/aura/input_state_lookup.cc index bbfa6ce81eb..c348a184ee0 100644 --- a/chromium/ui/aura/input_state_lookup.cc +++ b/chromium/ui/aura/input_state_lookup.cc @@ -7,7 +7,7 @@ namespace aura { // static -scoped_ptr<InputStateLookup> InputStateLookup::Create() { +std::unique_ptr<InputStateLookup> InputStateLookup::Create() { return nullptr; } diff --git a/chromium/ui/aura/input_state_lookup.h b/chromium/ui/aura/input_state_lookup.h index 4c2b424e404..822d0b98b3e 100644 --- a/chromium/ui/aura/input_state_lookup.h +++ b/chromium/ui/aura/input_state_lookup.h @@ -5,7 +5,8 @@ #ifndef UI_AURA_INPUT_STATE_LOOKUP_H_ #define UI_AURA_INPUT_STATE_LOOKUP_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "ui/aura/aura_export.h" namespace aura { @@ -16,7 +17,7 @@ class AURA_EXPORT InputStateLookup { virtual ~InputStateLookup() {} // Creates the platform specific InputStateLookup. May return NULL. - static scoped_ptr<InputStateLookup> Create(); + static std::unique_ptr<InputStateLookup> Create(); // Returns true if any mouse button is down. virtual bool IsMouseButtonDown() const = 0; diff --git a/chromium/ui/aura/input_state_lookup_win.cc b/chromium/ui/aura/input_state_lookup_win.cc index f88073ac5ad..67c82778b35 100644 --- a/chromium/ui/aura/input_state_lookup_win.cc +++ b/chromium/ui/aura/input_state_lookup_win.cc @@ -7,11 +7,13 @@ #include <windows.h> #include <winuser.h> +#include "base/memory/ptr_util.h" + namespace aura { // static -scoped_ptr<InputStateLookup> InputStateLookup::Create() { - return make_scoped_ptr(new InputStateLookupWin); +std::unique_ptr<InputStateLookup> InputStateLookup::Create() { + return base::WrapUnique(new InputStateLookupWin); } InputStateLookupWin::InputStateLookupWin() { diff --git a/chromium/ui/aura/scoped_window_targeter.cc b/chromium/ui/aura/scoped_window_targeter.cc index ae7c06bc669..d7849c6595b 100644 --- a/chromium/ui/aura/scoped_window_targeter.cc +++ b/chromium/ui/aura/scoped_window_targeter.cc @@ -12,7 +12,7 @@ namespace aura { ScopedWindowTargeter::ScopedWindowTargeter( Window* window, - scoped_ptr<ui::EventTargeter> new_targeter) + std::unique_ptr<ui::EventTargeter> new_targeter) : window_(window), old_targeter_(window->SetEventTargeter(std::move(new_targeter))) { window_->AddObserver(this); diff --git a/chromium/ui/aura/scoped_window_targeter.h b/chromium/ui/aura/scoped_window_targeter.h index d268792009e..d452e9f3b00 100644 --- a/chromium/ui/aura/scoped_window_targeter.h +++ b/chromium/ui/aura/scoped_window_targeter.h @@ -5,8 +5,9 @@ #ifndef UI_AURA_SCOPED_WINDOW_TARGETER_H_ #define UI_AURA_SCOPED_WINDOW_TARGETER_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "ui/aura/window_observer.h" namespace ui { @@ -23,7 +24,7 @@ class Window; class AURA_EXPORT ScopedWindowTargeter : public WindowObserver { public: ScopedWindowTargeter(Window* window, - scoped_ptr<ui::EventTargeter> new_targeter); + std::unique_ptr<ui::EventTargeter> new_targeter); ~ScopedWindowTargeter() override; @@ -36,7 +37,7 @@ class AURA_EXPORT ScopedWindowTargeter : public WindowObserver { void OnWindowDestroyed(Window* window) override; Window* window_; - scoped_ptr<ui::EventTargeter> old_targeter_; + std::unique_ptr<ui::EventTargeter> old_targeter_; DISALLOW_COPY_AND_ASSIGN(ScopedWindowTargeter); }; diff --git a/chromium/ui/aura/window.cc b/chromium/ui/aura/window.cc index 0b848e9fb50..ca155d9f0d5 100644 --- a/chromium/ui/aura/window.cc +++ b/chromium/ui/aura/window.cc @@ -14,6 +14,7 @@ #include "base/callback.h" #include "base/logging.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -33,11 +34,12 @@ #include "ui/aura/window_tree_host.h" #include "ui/compositor/compositor.h" #include "ui/compositor/layer.h" +#include "ui/display/display.h" +#include "ui/display/screen.h" #include "ui/events/event_target_iterator.h" #include "ui/gfx/canvas.h" #include "ui/gfx/path.h" #include "ui/gfx/scoped_canvas.h" -#include "ui/gfx/screen.h" namespace aura { @@ -66,8 +68,8 @@ class ScopedCursorHider { if (hid_cursor_) { client::CursorClient* cursor_client = client::GetCursorClient(window_); if (cursor_client) { - const gfx::Display& display = - gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); + const display::Display& display = + display::Screen::GetScreen()->GetDisplayNearestWindow(window_); cursor_client->SetDisplay(display); cursor_client->ShowCursor(); } @@ -149,6 +151,10 @@ Window::~Window() { observer->OnWindowDestroyed(this); } + // Delete the LayoutManager before properties. This way if the LayoutManager + // depends upon properties existing the properties are still valid. + layout_manager_.reset(); + // Clear properties. for (std::map<const void*, Value>::const_iterator iter = prop_map_.begin(); iter != prop_map_.end(); @@ -292,9 +298,9 @@ void Window::SetLayoutManager(LayoutManager* layout_manager) { layout_manager_->OnWindowAddedToLayout(*it); } -scoped_ptr<ui::EventTargeter> -Window::SetEventTargeter(scoped_ptr<ui::EventTargeter> targeter) { - scoped_ptr<ui::EventTargeter> old_targeter = std::move(targeter_); +std::unique_ptr<ui::EventTargeter> Window::SetEventTargeter( + std::unique_ptr<ui::EventTargeter> targeter) { + std::unique_ptr<ui::EventTargeter> old_targeter = std::move(targeter_); targeter_ = std::move(targeter); return old_targeter; } @@ -316,7 +322,7 @@ void Window::SetBounds(const gfx::Rect& new_bounds) { } void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen, - const gfx::Display& dst_display) { + const display::Display& dst_display) { Window* root = GetRootWindow(); if (root) { aura::client::ScreenPositionClient* screen_position_client = @@ -571,7 +577,7 @@ void Window::SetCapture() { client::CaptureClient* capture_client = client::GetCaptureClient(root_window); if (!capture_client) return; - client::GetCaptureClient(root_window)->SetCapture(this); + capture_client->SetCapture(this); } void Window::ReleaseCapture() { @@ -581,7 +587,7 @@ void Window::ReleaseCapture() { client::CaptureClient* capture_client = client::GetCaptureClient(root_window); if (!capture_client) return; - client::GetCaptureClient(root_window)->ReleaseCapture(this); + capture_client->ReleaseCapture(this); } bool Window::HasCapture() { @@ -1087,8 +1093,8 @@ ui::EventTarget* Window::GetParentTarget() { return parent_; } -scoped_ptr<ui::EventTargetIterator> Window::GetChildIterator() const { - return make_scoped_ptr(new ui::EventTargetIteratorImpl<Window>(children())); +std::unique_ptr<ui::EventTargetIterator> Window::GetChildIterator() const { + return base::WrapUnique(new ui::EventTargetIteratorImpl<Window>(children())); } ui::EventTargeter* Window::GetEventTargeter() { diff --git a/chromium/ui/aura/window.h b/chromium/ui/aura/window.h index 9a88d80d4b9..c036dbe915f 100644 --- a/chromium/ui/aura/window.h +++ b/chromium/ui/aura/window.h @@ -8,12 +8,12 @@ #include <stdint.h> #include <map> +#include <memory> #include <string> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/strings/string16.h" #include "ui/aura/aura_export.h" @@ -30,8 +30,11 @@ #include "ui/gfx/native_widget_types.h" #include "ui/wm/public/window_types.h" -namespace gfx { +namespace display { class Display; +} + +namespace gfx { class Transform; class Vector2d; } @@ -162,8 +165,8 @@ class AURA_EXPORT Window : public ui::LayerDelegate, // Sets a new event-targeter for the window, and returns the previous // event-targeter. - scoped_ptr<ui::EventTargeter> SetEventTargeter( - scoped_ptr<ui::EventTargeter> targeter); + std::unique_ptr<ui::EventTargeter> SetEventTargeter( + std::unique_ptr<ui::EventTargeter> targeter); // Changes the bounds of the window. If present, the window's parent's // LayoutManager may adjust the bounds. @@ -172,7 +175,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate, // Changes the bounds of the window in the screen coordintates. // If present, the window's parent's LayoutManager may adjust the bounds. void SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen_coords, - const gfx::Display& dst_display); + const display::Display& dst_display); // Returns the target bounds of the window. If the window's layer is // not animating, it simply returns the current bounds. @@ -451,7 +454,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate, // Overridden from ui::EventTarget: bool CanAcceptEvent(const ui::Event& event) override; EventTarget* GetParentTarget() override; - scoped_ptr<ui::EventTargetIterator> GetChildIterator() const override; + std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; ui::EventTargeter* GetEventTargeter() override; void ConvertEventToTarget(ui::EventTarget* target, ui::LocatedEvent* event) override; @@ -494,8 +497,8 @@ class AURA_EXPORT Window : public ui::LayerDelegate, // Whether layer is initialized as non-opaque. bool transparent_; - scoped_ptr<LayoutManager> layout_manager_; - scoped_ptr<ui::EventTargeter> targeter_; + std::unique_ptr<LayoutManager> layout_manager_; + std::unique_ptr<ui::EventTargeter> targeter_; void* user_data_; diff --git a/chromium/ui/aura/window_event_dispatcher.cc b/chromium/ui/aura/window_event_dispatcher.cc index 96e97aea669..8b2228096f0 100644 --- a/chromium/ui/aura/window_event_dispatcher.cc +++ b/chromium/ui/aura/window_event_dispatcher.cc @@ -8,7 +8,7 @@ #include "base/bind.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "build/build_config.h" #include "ui/aura/client/capture_client.h" @@ -120,7 +120,7 @@ void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent* event) { } if (held_repostable_event_) { - base::MessageLoop::current()->PostNonNestableTask( + base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( FROM_HERE, base::Bind( base::IgnoreResult(&WindowEventDispatcher::DispatchHeldEvents), repost_event_factory_.GetWeakPtr())); @@ -171,7 +171,7 @@ DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( void WindowEventDispatcher::ProcessedTouchEvent(uint32_t unique_event_id, Window* window, ui::EventResult result) { - scoped_ptr<ui::GestureRecognizer::Gestures> gestures( + std::unique_ptr<ui::GestureRecognizer::Gestures> gestures( ui::GestureRecognizer::Get()->AckTouchEvent(unique_event_id, result, window)); DispatchDetails details = ProcessGestures(window, gestures.get()); @@ -195,7 +195,7 @@ void WindowEventDispatcher::ReleasePointerMoves() { // called from a deep stack while another event, in which case dispatching // another one may not be safe/expected. Instead we post a task, that we // may cancel if HoldPointerMoves is called again before it executes. - base::MessageLoop::current()->PostNonNestableTask( + base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( FROM_HERE, base::Bind( base::IgnoreResult(&WindowEventDispatcher::DispatchHeldEvents), held_event_factory_.GetWeakPtr())); @@ -505,7 +505,7 @@ ui::EventDispatchDetails WindowEventDispatcher::PostDispatchEvent( const ui::TouchEvent& touchevent = *event.AsTouchEvent(); if (!touchevent.synchronous_handling_disabled()) { - scoped_ptr<ui::GestureRecognizer::Gestures> gestures; + std::unique_ptr<ui::GestureRecognizer::Gestures> gestures; Window* window = static_cast<Window*>(target); gestures.reset(ui::GestureRecognizer::Get()->AckTouchEvent( @@ -667,7 +667,8 @@ ui::EventDispatchDetails WindowEventDispatcher::DispatchHeldEvents() { if (held_repostable_event_) { if (held_repostable_event_->type() == ui::ET_MOUSE_PRESSED || held_repostable_event_->type() == ui::ET_TOUCH_PRESSED) { - scoped_ptr<ui::LocatedEvent> event = std::move(held_repostable_event_); + std::unique_ptr<ui::LocatedEvent> event = + std::move(held_repostable_event_); dispatching_held_event_ = event.get(); dispatch_details = OnEventFromSource(event.get()); } else { @@ -699,7 +700,7 @@ void WindowEventDispatcher::PostSynthesizeMouseMove() { if (synthesize_mouse_move_) return; synthesize_mouse_move_ = true; - base::MessageLoop::current()->PostNonNestableTask( + base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( FROM_HERE, base::Bind(base::IgnoreResult( &WindowEventDispatcher::SynthesizeMouseMoveEvent), diff --git a/chromium/ui/aura/window_event_dispatcher.h b/chromium/ui/aura/window_event_dispatcher.h index 2c93589c735..d54d10a3a83 100644 --- a/chromium/ui/aura/window_event_dispatcher.h +++ b/chromium/ui/aura/window_event_dispatcher.h @@ -7,12 +7,12 @@ #include <stdint.h> +#include <memory> #include <vector> #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/scoped_observer.h" @@ -260,10 +260,10 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, // touch/mouse moves while the count is > 0. int move_hold_count_; // The location of |held_move_event_| is in |window_|'s coordinate. - scoped_ptr<ui::LocatedEvent> held_move_event_; + std::unique_ptr<ui::LocatedEvent> held_move_event_; // Allowing for reposting of events. Used when exiting context menus. - scoped_ptr<ui::LocatedEvent> held_repostable_event_; + std::unique_ptr<ui::LocatedEvent> held_repostable_event_; // Set when dispatching a held event. ui::LocatedEvent* dispatching_held_event_; diff --git a/chromium/ui/aura/window_event_dispatcher_unittest.cc b/chromium/ui/aura/window_event_dispatcher_unittest.cc index ef992595830..f67984792b6 100644 --- a/chromium/ui/aura/window_event_dispatcher_unittest.cc +++ b/chromium/ui/aura/window_event_dispatcher_unittest.cc @@ -12,7 +12,7 @@ #include "base/bind.h" #include "base/macros.h" #include "base/run_loop.h" -#include "base/thread_task_runner_handle.h" +#include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/aura/client/capture_client.h" @@ -28,6 +28,7 @@ #include "ui/aura/window.h" #include "ui/aura/window_tracker.h" #include "ui/base/hit_test.h" +#include "ui/display/screen.h" #include "ui/events/event.h" #include "ui/events/event_handler.h" #include "ui/events/event_utils.h" @@ -37,7 +38,6 @@ #include "ui/events/test/test_event_handler.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/rect.h" -#include "ui/gfx/screen.h" #include "ui/gfx/transform.h" namespace aura { @@ -109,15 +109,15 @@ typedef test::AuraTestBase WindowEventDispatcherTest; TEST_F(WindowEventDispatcherTest, OnHostMouseEvent) { // Create two non-overlapping windows so we don't have to worry about which // is on top. - scoped_ptr<NonClientDelegate> delegate1(new NonClientDelegate()); - scoped_ptr<NonClientDelegate> delegate2(new NonClientDelegate()); + std::unique_ptr<NonClientDelegate> delegate1(new NonClientDelegate()); + std::unique_ptr<NonClientDelegate> delegate2(new NonClientDelegate()); const int kWindowWidth = 123; const int kWindowHeight = 45; gfx::Rect bounds1(100, 200, kWindowWidth, kWindowHeight); gfx::Rect bounds2(300, 400, kWindowWidth, kWindowHeight); - scoped_ptr<aura::Window> window1(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window1(CreateTestWindowWithDelegate( delegate1.get(), -1234, bounds1, root_window())); - scoped_ptr<aura::Window> window2(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window2(CreateTestWindowWithDelegate( delegate2.get(), -5678, bounds2, root_window())); // Send a mouse event to window1. @@ -166,7 +166,7 @@ TEST_F(WindowEventDispatcherTest, MouseButtonState) { EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); gfx::Point location; - scoped_ptr<ui::MouseEvent> event; + std::unique_ptr<ui::MouseEvent> event; // Press the left button. event.reset(new ui::MouseEvent( @@ -206,8 +206,8 @@ TEST_F(WindowEventDispatcherTest, MouseButtonState) { } TEST_F(WindowEventDispatcherTest, TranslatedEvent) { - scoped_ptr<Window> w1(test::CreateTestWindowWithDelegate(NULL, 1, - gfx::Rect(50, 50, 100, 100), root_window())); + std::unique_ptr<Window> w1(test::CreateTestWindowWithDelegate( + NULL, 1, gfx::Rect(50, 50, 100, 100), root_window())); gfx::Point origin(100, 100); ui::MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin, @@ -296,9 +296,8 @@ TEST_F(WindowEventDispatcherTest, CanProcessEventsWithinSubtree) { Window* w2 = test::CreateTestWindowWithBounds(gfx::Rect(30, 30, 20, 20), client.GetNonLockWindow()); w2->set_id(2); - scoped_ptr<Window> w3( - test::CreateTestWindowWithDelegate(&d, 3, gfx::Rect(30, 30, 20, 20), - client.GetLockWindow())); + std::unique_ptr<Window> w3(test::CreateTestWindowWithDelegate( + &d, 3, gfx::Rect(30, 30, 20, 20), client.GetLockWindow())); w1->Focus(); EXPECT_TRUE(IsFocusedWindow(w1)); @@ -370,7 +369,7 @@ TEST_F(WindowEventDispatcherTest, DontIgnoreUnknownKeys) { } TEST_F(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { - scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); + std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); w1->Show(); w1->Focus(); @@ -414,7 +413,7 @@ TEST_F(WindowEventDispatcherTest, ScrollEventDispatch) { root_window()->AddPreTargetHandler(&handler); test::TestWindowDelegate delegate; - scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); + std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); w1->SetBounds(gfx::Rect(20, 20, 40, 40)); // A scroll event on the root-window itself is dispatched. @@ -517,7 +516,7 @@ class EventFilterRecorder : public ui::EventHandler { } private: - scoped_ptr<base::RunLoop> run_loop_; + std::unique_ptr<base::RunLoop> run_loop_; ui::EventType wait_until_event_; Events events_; @@ -634,7 +633,7 @@ TEST_F(WindowEventDispatcherTest, MAYBE(RepostTargetsCaptureWindow)) { // capture). EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); EventFilterRecorder recorder; - scoped_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL)); + std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL)); window->SetBounds(gfx::Rect(20, 20, 40, 30)); window->AddPreTargetHandler(&recorder); window->SetCapture(); @@ -653,7 +652,7 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { root_window()->AddPreTargetHandler(&recorder); test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); ui::MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0), @@ -780,7 +779,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) { root_window()->AddPreTargetHandler(&recorder); test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); // Starting the touch and throwing out the first few events, since the system @@ -839,12 +838,12 @@ TEST_F(WindowEventDispatcherTest, MouseEventWithoutTargetWindow) { EventFilterRecorder recorder_second; test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(20, 10, 10, 20), root_window())); window_first->Show(); window_first->AddPreTargetHandler(&recorder_first); - scoped_ptr<aura::Window> window_second(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window_second(CreateTestWindowWithDelegate( &delegate, 2, gfx::Rect(20, 30, 10, 20), root_window())); window_second->Show(); window_second->AddPreTargetHandler(&recorder_second); @@ -868,7 +867,7 @@ TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenHidingWindow) { EventFilterRecorder recorder; test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(10, 10, 50, 50), root_window())); window->Show(); window->AddPreTargetHandler(&recorder); @@ -893,7 +892,7 @@ TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenHidingWindow) { // Verifies that a direct call to ProcessedTouchEvent() does not cause a crash. TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); host()->dispatcher()->ProcessedTouchEvent(0, window.get(), ui::ER_UNHANDLED); @@ -937,7 +936,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeldOnScroll) { root_window()->AddPreTargetHandler(&recorder); test::TestWindowDelegate delegate; HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); window->AddPreTargetHandler(&handler); @@ -1005,7 +1004,7 @@ TEST_F(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) { root_window()->AddPreTargetHandler(&recorder); test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); window->Show(); window->SetCapture(); @@ -1038,7 +1037,7 @@ TEST_F(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) { TEST_F(WindowEventDispatcherTest, DoNotSynthesizeWhileButtonDown) { EventFilterRecorder recorder; test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); window->Show(); @@ -1075,7 +1074,7 @@ TEST_F(WindowEventDispatcherTest, DoNotSynthesizeWhileButtonDown) { TEST_F(WindowEventDispatcherTest, MAYBE(SynthesizeMouseEventsOnWindowBoundsChanged)) { test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); window->Show(); window->SetCapture(); @@ -1132,7 +1131,7 @@ TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenCursorHidden) { test::TestWindowDelegate delegate; gfx::Point window_origin(7, 18); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1234, gfx::Rect(window_origin, gfx::Size(100, 100)), root_window())); window->Show(); @@ -1169,7 +1168,7 @@ TEST_F(WindowEventDispatcherTest, test::TestWindowDelegate delegate; gfx::Point window_origin(7, 18); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1234, gfx::Rect(window_origin, gfx::Size(100, 100)), root_window())); window->Show(); @@ -1273,7 +1272,7 @@ TEST_F(WindowEventDispatcherTest, DeleteWindowDuringDispatch) { // Verifies that we can delete a window during each phase of event handling. // Deleting the window should not cause a crash, only prevent further // processing from occurring. - scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); + std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); DeletingWindowDelegate d11; Window* w11 = CreateNormalWindow(11, w1.get(), &d11); WindowTracker tracker; @@ -1341,9 +1340,9 @@ class DetachesParentOnTapDelegate : public test::TestWindowDelegate { // window hides. No expectations, just checks that the test does not crash. TEST_F(WindowEventDispatcherTest, GestureRecognizerResetsTargetWhenParentHides) { - scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); + std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); DetachesParentOnTapDelegate delegate; - scoped_ptr<Window> parent(CreateNormalWindow(22, w1.get(), NULL)); + std::unique_ptr<Window> parent(CreateNormalWindow(22, w1.get(), NULL)); Window* child = CreateNormalWindow(11, parent.get(), &delegate); ui::test::EventGenerator generator(root_window(), child); generator.GestureTapAt(gfx::Point(40, 40)); @@ -1393,12 +1392,12 @@ class NestedGestureDelegate : public test::TestWindowDelegate { // Tests that gesture end is delivered after nested gesture processing. TEST_F(WindowEventDispatcherTest, GestureEndDeliveredAfterNestedGestures) { NestedGestureDelegate d1(NULL, gfx::Point()); - scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), &d1)); + std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &d1)); w1->SetBounds(gfx::Rect(0, 0, 100, 100)); ui::test::EventGenerator nested_generator(root_window(), w1.get()); NestedGestureDelegate d2(&nested_generator, w1->bounds().CenterPoint()); - scoped_ptr<Window> w2(CreateNormalWindow(1, root_window(), &d2)); + std::unique_ptr<Window> w2(CreateNormalWindow(1, root_window(), &d2)); w2->SetBounds(gfx::Rect(100, 0, 100, 100)); // Tap on w2 which triggers nested gestures for w1. @@ -1416,7 +1415,7 @@ TEST_F(WindowEventDispatcherTest, RepostTapdownGestureTest) { root_window()->AddPreTargetHandler(&recorder); test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); ui::GestureEventDetails details(ui::ET_GESTURE_TAP_DOWN); @@ -1507,10 +1506,10 @@ TEST_F(WindowEventDispatcherTest, GestureRepostEventOrder) { // We then generate the scroll sequence for repost_target and look for two // ET_GESTURE_TAP_DOWN events in the event list at the end. test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> repost_target(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> repost_target(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); - scoped_ptr<aura::Window> repost_source(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> repost_source(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(0, 0, 50, 50), root_window())); RepostGestureEventRecorder repost_event_recorder(repost_source.get(), @@ -1582,7 +1581,7 @@ class OnMouseExitDeletingEventFilter : public EventFilterRecorder { TEST_F(WindowEventDispatcherTest, DeleteWindowDuringMouseMovedDispatch) { // Create window 1 and set its event filter. Window 1 will take ownership of // the event filter. - scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); + std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); OnMouseExitDeletingEventFilter<Window> w1_filter; w1->AddPreTargetHandler(&w1_filter); w1->SetBounds(gfx::Rect(20, 20, 60, 60)); @@ -1697,7 +1696,7 @@ TEST_F(WindowEventDispatcherTest, ValidRootDuringDestruction) { ValidRootDuringDestructionWindowObserver observer(&got_destroying, &has_valid_root); { - scoped_ptr<WindowTreeHost> host( + std::unique_ptr<WindowTreeHost> host( WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100))); host->InitHost(); // Owned by WindowEventDispatcher. @@ -1747,7 +1746,7 @@ class DontResetHeldEventWindowDelegate : public test::TestWindowDelegate { // schedule another reposted event. TEST_F(WindowEventDispatcherTest, DontResetHeldEvent) { DontResetHeldEventWindowDelegate delegate(root_window()); - scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); + std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); w1->SetBounds(gfx::Rect(0, 0, 40, 40)); ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10), ui::EventTimeForNow(), @@ -1825,7 +1824,7 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) { root_window()->AddPreTargetHandler(&recorder); test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); gfx::Point position1 = root_window()->bounds().origin(); @@ -1850,7 +1849,7 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) { root_window()->AddPreTargetHandler(&recorder); test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); gfx::Point position1 = root_window()->bounds().origin(); @@ -1903,10 +1902,10 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) { TEST_F(WindowEventDispatcherTest, EndingEventDoesntRetarget) { EventFilterRecorder recorder1; EventFilterRecorder recorder2; - scoped_ptr<Window> window1(CreateNormalWindow(1, root_window(), NULL)); + std::unique_ptr<Window> window1(CreateNormalWindow(1, root_window(), NULL)); window1->SetBounds(gfx::Rect(0, 0, 40, 40)); - scoped_ptr<Window> window2(CreateNormalWindow(2, root_window(), NULL)); + std::unique_ptr<Window> window2(CreateNormalWindow(2, root_window(), NULL)); window2->SetBounds(gfx::Rect(40, 0, 40, 40)); window1->AddPreTargetHandler(&recorder1); @@ -1961,7 +1960,7 @@ class CaptureWindowTracker : public test::TestWindowDelegate { aura::Window* capture_window() { return capture_window_.get(); } private: - scoped_ptr<aura::Window> capture_window_; + std::unique_ptr<aura::Window> capture_window_; DISALLOW_COPY_AND_ASSIGN(CaptureWindowTracker); }; @@ -2014,7 +2013,7 @@ class WindowEventDispatcherTestWithMessageLoop // Start a nested message-loop, post an event to be dispatched, and then // terminate the message-loop. When the message-loop unwinds and gets back, // the reposted event should not have fired. - scoped_ptr<ui::MouseEvent> mouse(new ui::MouseEvent( + std::unique_ptr<ui::MouseEvent> mouse(new ui::MouseEvent( ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE)); message_loop()->PostTask( @@ -2052,11 +2051,11 @@ class WindowEventDispatcherTestWithMessageLoop private: // Used to avoid a copying |event| when binding to a closure. static void RepostEventHelper(WindowEventDispatcher* dispatcher, - scoped_ptr<ui::MouseEvent> event) { + std::unique_ptr<ui::MouseEvent> event) { dispatcher->RepostEvent(event.get()); } - scoped_ptr<Window> window_; + std::unique_ptr<Window> window_; ExitMessageLoopOnMousePress handler_; DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcherTestWithMessageLoop); @@ -2091,8 +2090,8 @@ class WindowEventDispatcherTestInHighDPI : public WindowEventDispatcherTest { TEST_F(WindowEventDispatcherTestInHighDPI, EventLocationTransform) { test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> child(test::CreateTestWindowWithDelegate(&delegate, - 1234, gfx::Rect(20, 20, 100, 100), root_window())); + std::unique_ptr<aura::Window> child(test::CreateTestWindowWithDelegate( + &delegate, 1234, gfx::Rect(20, 20, 100, 100), root_window())); child->Show(); ui::test::TestEventHandler handler_child; @@ -2130,7 +2129,7 @@ TEST_F(WindowEventDispatcherTestInHighDPI, TouchMovesHeldOnScroll) { root_window()->AddPreTargetHandler(&recorder); test::TestWindowDelegate delegate; HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); window->AddPreTargetHandler(&handler); @@ -2197,7 +2196,7 @@ class TriggerNestedLoopOnRightMousePress : public ui::test::TestEventHandler { // correctly. TEST_F(WindowEventDispatcherTestInHighDPI, EventsTransformedInRepostedEventTriggeredNestedLoop) { - scoped_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL)); + std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL)); // Make sure the window is visible. RunAllPendingInMessageLoop(); @@ -2210,7 +2209,7 @@ TEST_F(WindowEventDispatcherTestInHighDPI, TriggerNestedLoopOnRightMousePress handler(callback_on_right_click); window->AddPreTargetHandler(&handler); - scoped_ptr<ui::MouseEvent> mouse( + std::unique_ptr<ui::MouseEvent> mouse( new ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); @@ -2237,13 +2236,13 @@ class SelfDestructDelegate : public test::TestWindowDelegate { void OnMouseEvent(ui::MouseEvent* event) override { window_.reset(); } - void set_window(scoped_ptr<aura::Window> window) { + void set_window(std::unique_ptr<aura::Window> window) { window_ = std::move(window); } bool has_window() const { return !!window_.get(); } private: - scoped_ptr<aura::Window> window_; + std::unique_ptr<aura::Window> window_; DISALLOW_COPY_AND_ASSIGN(SelfDestructDelegate); }; @@ -2267,7 +2266,7 @@ TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) { // Make sure the location gets updated when a syntheiszed enter // event destroyed the window. SelfDestructDelegate delegate; - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); delegate.set_window(std::move(window)); EXPECT_TRUE(delegate.has_window()); @@ -2283,7 +2282,7 @@ TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) { // WindowEventDispatcher::UpdateCapture without causing a "use after free". TEST_F(WindowEventDispatcherTest, DestroyWindowOnCaptureChanged) { SelfDestructDelegate delegate; - scoped_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( + std::unique_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(20, 10, 10, 20), root_window())); Window* window_first_raw = window_first.get(); window_first->Show(); @@ -2291,7 +2290,7 @@ TEST_F(WindowEventDispatcherTest, DestroyWindowOnCaptureChanged) { delegate.set_window(std::move(window_first)); EXPECT_TRUE(delegate.has_window()); - scoped_ptr<aura::Window> window_second( + std::unique_ptr<aura::Window> window_second( test::CreateTestWindowWithId(2, root_window())); window_second->Show(); @@ -2323,8 +2322,8 @@ class StaticFocusClient : public client::FocusClient { // when the focused window does not live in the dispatcher's tree. TEST_F(WindowEventDispatcherTest, HostCancelModeWithFocusedWindowOutside) { test::TestWindowDelegate delegate; - scoped_ptr<Window> focused(CreateTestWindowWithDelegate(&delegate, 123, - gfx::Rect(20, 30, 100, 50), NULL)); + std::unique_ptr<Window> focused(CreateTestWindowWithDelegate( + &delegate, 123, gfx::Rect(20, 30, 100, 50), NULL)); StaticFocusClient focus_client(focused.get()); client::SetFocusClient(root_window(), &focus_client); EXPECT_FALSE(root_window()->Contains(focused.get())); @@ -2395,17 +2394,17 @@ class MoveWindowHandler : public ui::EventHandler { // event being dispatched is moved to a different dispatcher in response to an // event in the inner loop. TEST_F(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) { - scoped_ptr<WindowTreeHost> second_host( + std::unique_ptr<WindowTreeHost> second_host( WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); second_host->InitHost(); Window* second_root = second_host->window(); // Create two windows parented to |root_window()|. test::TestWindowDelegate delegate; - scoped_ptr<Window> first(CreateTestWindowWithDelegate(&delegate, 123, - gfx::Rect(20, 10, 10, 20), root_window())); - scoped_ptr<Window> second(CreateTestWindowWithDelegate(&delegate, 234, - gfx::Rect(40, 10, 50, 20), root_window())); + std::unique_ptr<Window> first(CreateTestWindowWithDelegate( + &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); + std::unique_ptr<Window> second(CreateTestWindowWithDelegate( + &delegate, 234, gfx::Rect(40, 10, 50, 20), root_window())); // Setup a handler on |first| so that it dispatches an event to |second| when // |first| receives an event. @@ -2453,19 +2452,20 @@ class AlwaysMouseDownInputStateLookup : public InputStateLookup { TEST_F(WindowEventDispatcherTest, CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) { test::EventCountDelegate delegate; - scoped_ptr<Window> window(CreateTestWindowWithDelegate(&delegate, 123, - gfx::Rect(20, 10, 10, 20), root_window())); + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( + &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); window->Show(); - scoped_ptr<WindowTreeHost> second_host( + std::unique_ptr<WindowTreeHost> second_host( WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); second_host->InitHost(); WindowEventDispatcher* second_dispatcher = second_host->dispatcher(); // Install an InputStateLookup on the Env that always claims that a // mouse-button is down. - test::EnvTestHelper(Env::GetInstance()).SetInputStateLookup( - scoped_ptr<InputStateLookup>(new AlwaysMouseDownInputStateLookup())); + test::EnvTestHelper(Env::GetInstance()) + .SetInputStateLookup(std::unique_ptr<InputStateLookup>( + new AlwaysMouseDownInputStateLookup())); window->SetCapture(); @@ -2496,19 +2496,19 @@ TEST_F(WindowEventDispatcherTest, TEST_F(WindowEventDispatcherTest, RedirectedEventToDifferentDispatcherLocation) { - scoped_ptr<WindowTreeHost> second_host( + std::unique_ptr<WindowTreeHost> second_host( WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); second_host->InitHost(); client::SetCaptureClient(second_host->window(), client::GetCaptureClient(root_window())); test::EventCountDelegate delegate; - scoped_ptr<Window> window_first(CreateTestWindowWithDelegate(&delegate, 123, - gfx::Rect(20, 10, 10, 20), root_window())); + std::unique_ptr<Window> window_first(CreateTestWindowWithDelegate( + &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); window_first->Show(); - scoped_ptr<Window> window_second(CreateTestWindowWithDelegate(&delegate, 12, - gfx::Rect(10, 10, 20, 30), second_host->window())); + std::unique_ptr<Window> window_second(CreateTestWindowWithDelegate( + &delegate, 12, gfx::Rect(10, 10, 20, 30), second_host->window())); window_second->Show(); window_second->SetCapture(); @@ -2568,10 +2568,8 @@ TEST_F(WindowEventDispatcherTest, GestureEventCoordinates) { root_window()->AddPreTargetHandler(&recorder); AsyncWindowDelegate delegate(host()->dispatcher()); HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); - scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( - &delegate, - 1, - gfx::Rect(kWindowOffset, kWindowOffset, 100, 100), + std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( + &delegate, 1, gfx::Rect(kWindowOffset, kWindowOffset, 100, 100), root_window())); window->AddPreTargetHandler(&handler); @@ -2647,7 +2645,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) { TEST_F(WindowEventDispatcherTest, OnCursorMovedToRootLocationUpdatesHover) { WindowEventDispatcher* dispatcher = host()->dispatcher(); - scoped_ptr<Window> w(CreateNormalWindow(1, root_window(), nullptr)); + std::unique_ptr<Window> w(CreateNormalWindow(1, root_window(), nullptr)); w->SetBounds(gfx::Rect(20, 20, 20, 20)); w->Show(); diff --git a/chromium/ui/aura/window_targeter.cc b/chromium/ui/aura/window_targeter.cc index 96413d02538..1364ab3fb83 100644 --- a/chromium/ui/aura/window_targeter.cc +++ b/chromium/ui/aura/window_targeter.cc @@ -168,7 +168,8 @@ Window* WindowTargeter::FindTargetInRootWindow(Window* root_window, Window* WindowTargeter::FindTargetForLocatedEventRecursively( Window* root_window, ui::LocatedEvent* event) { - scoped_ptr<ui::EventTargetIterator> iter = root_window->GetChildIterator(); + std::unique_ptr<ui::EventTargetIterator> iter = + root_window->GetChildIterator(); if (iter) { ui::EventTarget* target = root_window; for (ui::EventTarget* child = iter->GetNextTarget(); child; diff --git a/chromium/ui/aura/window_targeter_unittest.cc b/chromium/ui/aura/window_targeter_unittest.cc index 01893a8cb9f..c1f30ad8f99 100644 --- a/chromium/ui/aura/window_targeter_unittest.cc +++ b/chromium/ui/aura/window_targeter_unittest.cc @@ -57,7 +57,8 @@ gfx::RectF GetEffectiveVisibleBoundsInRootWindow(Window* window) { TEST_F(WindowTargeterTest, Basic) { test::TestWindowDelegate delegate; - scoped_ptr<Window> window(CreateNormalWindow(1, root_window(), &delegate)); + std::unique_ptr<Window> window( + CreateNormalWindow(1, root_window(), &delegate)); Window* one = CreateNormalWindow(2, window.get(), &delegate); Window* two = CreateNormalWindow(3, window.get(), &delegate); @@ -85,7 +86,8 @@ TEST_F(WindowTargeterTest, Basic) { TEST_F(WindowTargeterTest, ScopedWindowTargeter) { test::TestWindowDelegate delegate; - scoped_ptr<Window> window(CreateNormalWindow(1, root_window(), &delegate)); + std::unique_ptr<Window> window( + CreateNormalWindow(1, root_window(), &delegate)); Window* child = CreateNormalWindow(2, window.get(), &delegate); window->SetBounds(gfx::Rect(30, 30, 100, 100)); @@ -103,9 +105,10 @@ TEST_F(WindowTargeterTest, ScopedWindowTargeter) { } // Install a targeter on |window| so that the events never reach the child. - scoped_ptr<ScopedWindowTargeter> scoped_targeter( - new ScopedWindowTargeter(window.get(), scoped_ptr<ui::EventTargeter>( - new StaticWindowTargeter(window.get())))); + std::unique_ptr<ScopedWindowTargeter> scoped_targeter( + new ScopedWindowTargeter(window.get(), + std::unique_ptr<ui::EventTargeter>( + new StaticWindowTargeter(window.get())))); { ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); @@ -123,10 +126,12 @@ TEST_F(WindowTargeterTest, ScopedWindowTargeter) { // replaces the targeter gets destroyed before it does. TEST_F(WindowTargeterTest, ScopedWindowTargeterWindowDestroyed) { test::TestWindowDelegate delegate; - scoped_ptr<Window> window(CreateNormalWindow(1, root_window(), &delegate)); - scoped_ptr<ScopedWindowTargeter> scoped_targeter( - new ScopedWindowTargeter(window.get(), scoped_ptr<ui::EventTargeter>( - new StaticWindowTargeter(window.get())))); + std::unique_ptr<Window> window( + CreateNormalWindow(1, root_window(), &delegate)); + std::unique_ptr<ScopedWindowTargeter> scoped_targeter( + new ScopedWindowTargeter(window.get(), + std::unique_ptr<ui::EventTargeter>( + new StaticWindowTargeter(window.get())))); window.reset(); scoped_targeter.reset(); @@ -138,7 +143,8 @@ TEST_F(WindowTargeterTest, TargetTransformedWindow) { root_window()->Show(); test::TestWindowDelegate delegate; - scoped_ptr<Window> window(CreateNormalWindow(2, root_window(), &delegate)); + std::unique_ptr<Window> window( + CreateNormalWindow(2, root_window(), &delegate)); const gfx::Rect window_bounds(100, 20, 400, 80); window->SetBounds(window_bounds); @@ -197,9 +203,11 @@ class IdCheckingEventTargeter : public WindowTargeter { TEST_F(WindowTargeterTest, Bounds) { test::TestWindowDelegate delegate; - scoped_ptr<Window> parent(CreateNormalWindow(1, root_window(), &delegate)); - scoped_ptr<Window> child(CreateNormalWindow(1, parent.get(), &delegate)); - scoped_ptr<Window> grandchild(CreateNormalWindow(1, child.get(), &delegate)); + std::unique_ptr<Window> parent( + CreateNormalWindow(1, root_window(), &delegate)); + std::unique_ptr<Window> child(CreateNormalWindow(1, parent.get(), &delegate)); + std::unique_ptr<Window> grandchild( + CreateNormalWindow(1, child.get(), &delegate)); parent->SetBounds(gfx::Rect(0, 0, 30, 30)); child->SetBounds(gfx::Rect(5, 5, 20, 20)); @@ -229,8 +237,9 @@ TEST_F(WindowTargeterTest, Bounds) { // by |parent|. ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, gfx::Point(8, 8), gfx::Point(8, 8), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); - scoped_ptr<ui::EventTargeter> original_targeter = child_r->SetEventTargeter( - scoped_ptr<ui::EventTargeter>(new IdCheckingEventTargeter(2))); + std::unique_ptr<ui::EventTargeter> original_targeter = + child_r->SetEventTargeter( + std::unique_ptr<ui::EventTargeter>(new IdCheckingEventTargeter(2))); EXPECT_EQ(parent_r, targeter->FindTargetForEvent(root_target, &mouse2)); // Now install a targeter on the |child| that looks at the window id as well @@ -239,7 +248,7 @@ TEST_F(WindowTargeterTest, Bounds) { ui::MouseEvent mouse3(ui::ET_MOUSE_MOVED, gfx::Point(8, 8), gfx::Point(8, 8), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); child_r->SetEventTargeter( - scoped_ptr<ui::EventTargeter>(new IdCheckingEventTargeter(1))); + std::unique_ptr<ui::EventTargeter>(new IdCheckingEventTargeter(1))); EXPECT_EQ(child_r, targeter->FindTargetForEvent(root_target, &mouse3)); // restore original WindowTargeter for |child|. @@ -274,7 +283,8 @@ class IgnoreWindowTargeter : public WindowTargeter { // whether the target itself can process an event. TEST_F(WindowTargeterTest, TargeterChecksOwningEventTarget) { test::TestWindowDelegate delegate; - scoped_ptr<Window> child(CreateNormalWindow(1, root_window(), &delegate)); + std::unique_ptr<Window> child( + CreateNormalWindow(1, root_window(), &delegate)); ui::EventTarget* root_target = root_window(); ui::EventTargeter* targeter = root_target->GetEventTargeter(); @@ -287,7 +297,7 @@ TEST_F(WindowTargeterTest, TargeterChecksOwningEventTarget) { // Install an event targeter on |child| which always prevents the target from // receiving event. child->SetEventTargeter( - scoped_ptr<ui::EventTargeter>(new IgnoreWindowTargeter())); + std::unique_ptr<ui::EventTargeter>(new IgnoreWindowTargeter())); ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_NONE, diff --git a/chromium/ui/aura/window_tracker.cc b/chromium/ui/aura/window_tracker.cc deleted file mode 100644 index 522a1fc863f..00000000000 --- a/chromium/ui/aura/window_tracker.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/aura/window_tracker.h" - -#include "ui/aura/window.h" - -namespace aura { - -WindowTracker::WindowTracker() { -} - -WindowTracker::WindowTracker(const WindowList& windows) { - // |windows| may contain dups, so call Add() instead of insert(). - for (auto iter = windows.begin(); iter != windows.end(); iter++) - Add(*iter); -} - -WindowTracker::~WindowTracker() { - while (has_windows()) - Pop()->RemoveObserver(this); -} - -void WindowTracker::Add(Window* window) { - if (Contains(window)) - return; - - window->AddObserver(this); - windows_.push_back(window); -} - -void WindowTracker::Remove(Window* window) { - auto iter = std::find(windows_.begin(), windows_.end(), window); - if (iter != windows_.end()) { - windows_.erase(iter); - window->RemoveObserver(this); - } -} - -bool WindowTracker::Contains(Window* window) { - return std::find(windows_.begin(), windows_.end(), window) != windows_.end(); -} - -aura::Window* WindowTracker::Pop() { - DCHECK(!windows_.empty()); - aura::Window* window = *windows_.begin(); - Remove(window); - return window; -} - -void WindowTracker::OnWindowDestroying(Window* window) { - DCHECK(Contains(window)); - Remove(window); -} - -} // namespace aura diff --git a/chromium/ui/aura/window_tracker.h b/chromium/ui/aura/window_tracker.h index 65fcf684e5c..d44ec3f2e1c 100644 --- a/chromium/ui/aura/window_tracker.h +++ b/chromium/ui/aura/window_tracker.h @@ -9,47 +9,12 @@ #include "base/compiler_specific.h" #include "base/macros.h" -#include "ui/aura/aura_export.h" #include "ui/aura/window_observer.h" +#include "ui/base/window_tracker_template.h" namespace aura { -// This class keeps track of a set of windows. A Window is removed either -// explicitly by Remove() or Pop(), or implicitly when the window is destroyed. -class AURA_EXPORT WindowTracker : public WindowObserver { - public: - using WindowList = std::vector<Window*>; - - WindowTracker(); - explicit WindowTracker(const WindowList& windows); - ~WindowTracker() override; - - bool has_windows() const { return !windows_.empty(); } - - // Returns the set of windows being observed. - const std::vector<Window*>& windows() const { return windows_; } - - // Adds |window| to the set of Windows being tracked. - void Add(Window* window); - - // Removes |window| from the set of windows being tracked. - void Remove(Window* window); - - // Returns true if |window| was previously added and has not been removed or - // deleted. - bool Contains(Window* window); - - // Removes and returns the window object from the tracking windows. - aura::Window* Pop(); - - // WindowObserver overrides: - void OnWindowDestroying(Window* window) override; - - private: - WindowList windows_; - - DISALLOW_COPY_AND_ASSIGN(WindowTracker); -}; +using WindowTracker = ui::WindowTrackerTemplate<Window, WindowObserver>; } // namespace aura diff --git a/chromium/ui/aura/window_tree_host.cc b/chromium/ui/aura/window_tree_host.cc index aa6fb73ec12..d8f9940ceb4 100644 --- a/chromium/ui/aura/window_tree_host.cc +++ b/chromium/ui/aura/window_tree_host.cc @@ -4,7 +4,7 @@ #include "ui/aura/window_tree_host.h" -#include "base/thread_task_runner_handle.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "ui/aura/client/capture_client.h" #include "ui/aura/client/cursor_client.h" @@ -18,13 +18,13 @@ #include "ui/base/view_prop.h" #include "ui/compositor/dip_util.h" #include "ui/compositor/layer.h" -#include "ui/gfx/display.h" +#include "ui/display/display.h" +#include "ui/display/screen.h" #include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point3_f.h" #include "ui/gfx/geometry/point_conversions.h" #include "ui/gfx/geometry/size_conversions.h" -#include "ui/gfx/screen.h" namespace aura { @@ -32,8 +32,8 @@ const char kWindowTreeHostForAcceleratedWidget[] = "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__"; float GetDeviceScaleFactorFromDisplay(Window* window) { - gfx::Display display = - gfx::Screen::GetScreen()->GetDisplayNearestWindow(window); + display::Display display = + display::Screen::GetScreen()->GetDisplayNearestWindow(window); DCHECK(display.is_valid()); return display.device_scale_factor(); } @@ -250,7 +250,7 @@ void WindowTreeHost::CreateCompositor() { window()->set_host(this); window()->SetName("RootWindow"); window()->SetEventTargeter( - scoped_ptr<ui::EventTargeter>(new WindowTargeter())); + std::unique_ptr<ui::EventTargeter>(new WindowTargeter())); dispatcher_.reset(new WindowEventDispatcher(this)); } } @@ -285,6 +285,11 @@ void WindowTreeHost::OnHostResized(const gfx::Size& new_size) { FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_, OnHostResized(this)); } +void WindowTreeHost::OnHostWorkspaceChanged() { + FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_, + OnHostWorkspaceChanged(this)); +} + void WindowTreeHost::OnHostCloseRequested() { FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_, OnHostCloseRequested(this)); @@ -313,8 +318,8 @@ void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location, MoveCursorToNative(host_location); client::CursorClient* cursor_client = client::GetCursorClient(window()); if (cursor_client) { - const gfx::Display& display = - gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); + const display::Display& display = + display::Screen::GetScreen()->GetDisplayNearestWindow(window()); cursor_client->SetDisplay(display); } dispatcher()->OnCursorMovedToRootLocation(root_location); diff --git a/chromium/ui/aura/window_tree_host.h b/chromium/ui/aura/window_tree_host.h index 6821de4f185..03dcf1b91f1 100644 --- a/chromium/ui/aura/window_tree_host.h +++ b/chromium/ui/aura/window_tree_host.h @@ -194,6 +194,7 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate, void OnHostMoved(const gfx::Point& new_location); void OnHostResized(const gfx::Size& new_size); + void OnHostWorkspaceChanged(); void OnHostCloseRequested(); void OnHostActivated(); void OnHostLostWindowCapture(); @@ -224,23 +225,23 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate, void MoveCursorToInternal(const gfx::Point& root_location, const gfx::Point& host_location); - // We don't use a scoped_ptr for |window_| since we need this ptr to be valid - // during its deletion. (Window's dtor notifies observers that may attempt to - // reach back up to access this object which will be valid until the end of - // the dtor). + // We don't use a std::unique_ptr for |window_| since we need this ptr to be + // valid during its deletion. (Window's dtor notifies observers that may + // attempt to reach back up to access this object which will be valid until + // the end of the dtor). Window* window_; // Owning. base::ObserverList<WindowTreeHostObserver> observers_; - scoped_ptr<WindowEventDispatcher> dispatcher_; + std::unique_ptr<WindowEventDispatcher> dispatcher_; - scoped_ptr<ui::Compositor> compositor_; + std::unique_ptr<ui::Compositor> compositor_; // Last cursor set. Used for testing. gfx::NativeCursor last_cursor_; gfx::Point last_cursor_request_position_in_host_; - scoped_ptr<ui::ViewProp> prop_; + std::unique_ptr<ui::ViewProp> prop_; // The InputMethod instance used to process key events. // If owned it, it is created in GetInputMethod() method; diff --git a/chromium/ui/aura/window_tree_host_observer.h b/chromium/ui/aura/window_tree_host_observer.h index d96e9d3b24d..5c06dd111a7 100644 --- a/chromium/ui/aura/window_tree_host_observer.h +++ b/chromium/ui/aura/window_tree_host_observer.h @@ -24,6 +24,9 @@ class AURA_EXPORT WindowTreeHostObserver { virtual void OnHostMoved(const WindowTreeHost* host, const gfx::Point& new_origin) {} + // Called when the host is moved to a different workspace. + virtual void OnHostWorkspaceChanged(const WindowTreeHost* host) {} + // Called when the native window system sends the host request to close. virtual void OnHostCloseRequested(const WindowTreeHost* host) {} diff --git a/chromium/ui/aura/window_tree_host_platform.cc b/chromium/ui/aura/window_tree_host_platform.cc index 8dfa4d05327..7839643262e 100644 --- a/chromium/ui/aura/window_tree_host_platform.cc +++ b/chromium/ui/aura/window_tree_host_platform.cc @@ -10,8 +10,9 @@ #include "build/build_config.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/compositor/compositor.h" +#include "ui/display/display.h" +#include "ui/display/screen.h" #include "ui/events/event.h" -#include "ui/gfx/screen.h" #if defined(OS_ANDROID) #include "ui/platform_window/android/platform_window_android.h" @@ -57,7 +58,7 @@ WindowTreeHostPlatform::WindowTreeHostPlatform() } void WindowTreeHostPlatform::SetPlatformWindow( - scoped_ptr<ui::PlatformWindow> window) { + std::unique_ptr<ui::PlatformWindow> window) { window_ = std::move(window); } @@ -125,7 +126,7 @@ void WindowTreeHostPlatform::OnCursorVisibilityChangedNative(bool show) { void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) { float current_scale = compositor()->device_scale_factor(); - float new_scale = gfx::Screen::GetScreen() + float new_scale = display::Screen::GetScreen() ->GetDisplayNearestWindow(window()) .device_scale_factor(); gfx::Rect old_bounds = bounds_; diff --git a/chromium/ui/aura/window_tree_host_platform.h b/chromium/ui/aura/window_tree_host_platform.h index 111a1cd5257..eb25d349550 100644 --- a/chromium/ui/aura/window_tree_host_platform.h +++ b/chromium/ui/aura/window_tree_host_platform.h @@ -5,9 +5,10 @@ #ifndef UI_AURA_WINDOW_TREE_HOST_PLATFORM_H_ #define UI_AURA_WINDOW_TREE_HOST_PLATFORM_H_ +#include <memory> + #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "ui/aura/aura_export.h" #include "ui/aura/window_tree_host.h" #include "ui/gfx/native_widget_types.h" @@ -41,7 +42,7 @@ class AURA_EXPORT WindowTreeHostPlatform protected: WindowTreeHostPlatform(); - void SetPlatformWindow(scoped_ptr<ui::PlatformWindow> window); + void SetPlatformWindow(std::unique_ptr<ui::PlatformWindow> window); ui::PlatformWindow* platform_window() { return window_.get(); } // ui::PlatformWindowDelegate: @@ -59,7 +60,7 @@ class AURA_EXPORT WindowTreeHostPlatform private: gfx::AcceleratedWidget widget_; - scoped_ptr<ui::PlatformWindow> window_; + std::unique_ptr<ui::PlatformWindow> window_; gfx::NativeCursor current_cursor_; gfx::Rect bounds_; diff --git a/chromium/ui/aura/window_tree_host_x11.cc b/chromium/ui/aura/window_tree_host_x11.cc index a5675e9f3ce..0bbd0a0ce0e 100644 --- a/chromium/ui/aura/window_tree_host_x11.cc +++ b/chromium/ui/aura/window_tree_host_x11.cc @@ -37,6 +37,7 @@ #include "ui/compositor/compositor.h" #include "ui/compositor/dip_util.h" #include "ui/compositor/layer.h" +#include "ui/display/screen.h" #include "ui/events/devices/x11/device_data_manager_x11.h" #include "ui/events/devices/x11/device_list_cache_x11.h" #include "ui/events/devices/x11/touch_factory_x11.h" @@ -47,7 +48,6 @@ #include "ui/events/platform/platform_event_observer.h" #include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/x11/x11_event_source.h" -#include "ui/gfx/screen.h" using std::max; using std::min; @@ -257,8 +257,9 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) { client::CursorClient* cursor_client = client::GetCursorClient(root_window); if (cursor_client) { - const gfx::Display display = - gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_window); + const display::Display display = + display::Screen::GetScreen()->GetDisplayNearestWindow( + root_window); cursor_client->SetDisplay(display); } // EnterNotify creates ET_MOUSE_MOVE. Mark as synthesized as this is @@ -399,7 +400,7 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { // Even if the host window's size doesn't change, aura's root window // size, which is in DIP, changes when the scale changes. float current_scale = compositor()->device_scale_factor(); - float new_scale = gfx::Screen::GetScreen() + float new_scale = display::Screen::GetScreen() ->GetDisplayNearestWindow(window()) .device_scale_factor(); bool origin_changed = bounds_.origin() != bounds.origin(); diff --git a/chromium/ui/aura/window_tree_host_x11.h b/chromium/ui/aura/window_tree_host_x11.h index 0587bb6fa08..f209e10bdba 100644 --- a/chromium/ui/aura/window_tree_host_x11.h +++ b/chromium/ui/aura/window_tree_host_x11.h @@ -7,8 +7,9 @@ #include <stdint.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "ui/aura/aura_export.h" #include "ui/aura/window_tree_host.h" #include "ui/events/platform/platform_event_dispatcher.h" diff --git a/chromium/ui/aura/window_unittest.cc b/chromium/ui/aura/window_unittest.cc index f2699eb8b0e..3b647b560ef 100644 --- a/chromium/ui/aura/window_unittest.cc +++ b/chromium/ui/aura/window_unittest.cc @@ -21,6 +21,7 @@ #include "ui/aura/client/focus_change_observer.h" #include "ui/aura/client/visibility_client.h" #include "ui/aura/client/window_tree_client.h" +#include "ui/aura/layout_manager.h" #include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/aura_test_utils.h" #include "ui/aura/test/test_window_delegate.h" @@ -37,6 +38,7 @@ #include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/test/test_layers.h" +#include "ui/display/screen.h" #include "ui/events/event.h" #include "ui/events/event_utils.h" #include "ui/events/gesture_detection/gesture_configuration.h" @@ -44,13 +46,58 @@ #include "ui/events/test/event_generator.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/vector2d.h" -#include "ui/gfx/screen.h" #include "ui/gfx/skia_util.h" DECLARE_WINDOW_PROPERTY_TYPE(const char*) namespace { +enum class DeletionOrder { + LAYOUT_MANAGER_FIRST, + PROPERTY_FIRST, + UNKNOWN, +}; + +class DeletionTracker { + public: + DeletionTracker() {} + ~DeletionTracker() {} + + DeletionOrder order() const { return order_; } + bool property_deleted() const { return property_deleted_; } + bool layout_manager_deleted() const { return layout_manager_deleted_; } + + void PropertyDeleted() { + property_deleted_ = true; + if (order_ == DeletionOrder::UNKNOWN) + order_ = DeletionOrder::PROPERTY_FIRST; + } + + void LayoutManagerDeleted() { + layout_manager_deleted_ = true; + if (order_ == DeletionOrder::UNKNOWN) + order_ = DeletionOrder::LAYOUT_MANAGER_FIRST; + } + + private: + bool property_deleted_ = false; + bool layout_manager_deleted_ = false; + DeletionOrder order_ = DeletionOrder::UNKNOWN; + + DISALLOW_COPY_AND_ASSIGN(DeletionTracker); +}; + +class DeletionTestProperty { + public: + explicit DeletionTestProperty(DeletionTracker* tracker) : tracker_(tracker) {} + ~DeletionTestProperty() { tracker_->PropertyDeleted(); } + + private: + DeletionTracker* tracker_; + + DISALLOW_COPY_AND_ASSIGN(DeletionTestProperty); +}; + class TestProperty { public: TestProperty() {} @@ -67,11 +114,16 @@ class TestProperty { TestProperty* TestProperty::last_deleted_ = nullptr; DEFINE_OWNED_WINDOW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL); +DEFINE_OWNED_WINDOW_PROPERTY_KEY(DeletionTestProperty, + kDeletionTestPropertyKey, + nullptr); } // namespace DECLARE_WINDOW_PROPERTY_TYPE(TestProperty*); +DECLARE_WINDOW_PROPERTY_TYPE(DeletionTestProperty*); + namespace aura { namespace test { @@ -280,10 +332,10 @@ void OffsetBounds(Window* window, int horizontal, int vertical) { } // namespace TEST_F(WindowTest, GetChildById) { - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); - scoped_ptr<Window> w11(CreateTestWindowWithId(11, w1.get())); - scoped_ptr<Window> w111(CreateTestWindowWithId(111, w11.get())); - scoped_ptr<Window> w12(CreateTestWindowWithId(12, w1.get())); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w11(CreateTestWindowWithId(11, w1.get())); + 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_EQ(w12.get(), w1->GetChildById(12)); @@ -313,9 +365,8 @@ TEST_F(WindowTest, Contains) { } TEST_F(WindowTest, ContainsPointInRoot) { - scoped_ptr<Window> w( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 5, 5), - root_window())); + std::unique_ptr<Window> w(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(10, 10, 5, 5), root_window())); EXPECT_FALSE(w->ContainsPointInRoot(gfx::Point(9, 9))); EXPECT_TRUE(w->ContainsPointInRoot(gfx::Point(10, 10))); EXPECT_TRUE(w->ContainsPointInRoot(gfx::Point(14, 14))); @@ -324,9 +375,8 @@ TEST_F(WindowTest, ContainsPointInRoot) { } TEST_F(WindowTest, ContainsPoint) { - scoped_ptr<Window> w( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 5, 5), - root_window())); + std::unique_ptr<Window> w(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(10, 10, 5, 5), root_window())); EXPECT_TRUE(w->ContainsPoint(gfx::Point(0, 0))); EXPECT_TRUE(w->ContainsPoint(gfx::Point(4, 4))); EXPECT_FALSE(w->ContainsPoint(gfx::Point(5, 5))); @@ -337,7 +387,7 @@ TEST_F(WindowTest, ConvertPointToWindow) { // Window::ConvertPointToWindow is mostly identical to // Layer::ConvertPointToLayer, except NULL values for |source| are permitted, // in which case the function just returns. - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + 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); @@ -345,38 +395,36 @@ TEST_F(WindowTest, ConvertPointToWindow) { } TEST_F(WindowTest, MoveCursorTo) { - scoped_ptr<Window> w1( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), - root_window())); - scoped_ptr<Window> w11( + std::unique_ptr<Window> w1(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), root_window())); + std::unique_ptr<Window> w11( CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); - scoped_ptr<Window> w111( + std::unique_ptr<Window> w111( CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); - scoped_ptr<Window> w1111( + std::unique_ptr<Window> w1111( CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); Window* root = root_window(); root->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("10,10", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); w1->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("20,20", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); w11->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("25,25", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); w111->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("30,30", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); w1111->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("35,35", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); } TEST_F(WindowTest, ContainsMouse) { - scoped_ptr<Window> w( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), - root_window())); + std::unique_ptr<Window> w(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), root_window())); w->Show(); WindowTestApi w_test_api(w.get()); Window* root = root_window(); @@ -399,35 +447,34 @@ TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) { EXPECT_EQ("50,120", QueryLatestMousePositionRequestInHost(host()).ToString()); #endif EXPECT_EQ("10,10", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); } // Tests Window::ConvertPointToWindow() with transform to non-root windows. TEST_F(WindowTest, MoveCursorToWithTransformWindow) { - scoped_ptr<Window> w1( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), - root_window())); + std::unique_ptr<Window> w1(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), root_window())); gfx::Transform transform1; transform1.Scale(2, 2); w1->SetTransform(transform1); w1->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("30,30", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); gfx::Transform transform2; transform2.Translate(-10, 20); w1->SetTransform(transform2); w1->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("10,40", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); gfx::Transform transform3; transform3.Rotate(90.0); w1->SetTransform(transform3); w1->MoveCursorTo(gfx::Point(5, 5)); EXPECT_EQ("5,15", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); gfx::Transform transform4; transform4.Translate(100.0, 100.0); @@ -436,21 +483,20 @@ TEST_F(WindowTest, MoveCursorToWithTransformWindow) { w1->SetTransform(transform4); w1->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("60,130", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); } // Test Window::ConvertPointToWindow() with complex transforms to both root and // non-root windows. // Test Window::ConvertPointToWindow() with transform to root_window. TEST_F(WindowTest, MoveCursorToWithComplexTransform) { - scoped_ptr<Window> w1( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), - root_window())); - scoped_ptr<Window> w11( + std::unique_ptr<Window> w1(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), root_window())); + std::unique_ptr<Window> w11( CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); - scoped_ptr<Window> w111( + std::unique_ptr<Window> w111( CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); - scoped_ptr<Window> w1111( + std::unique_ptr<Window> w1111( CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); // The root window expects transforms that produce integer rects. @@ -477,33 +523,31 @@ TEST_F(WindowTest, MoveCursorToWithComplexTransform) { EXPECT_EQ("169,80", QueryLatestMousePositionRequestInHost(host()).ToString()); #endif EXPECT_EQ("20,53", - gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); + display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); } // Tests that we do not crash when a Window is destroyed by going out of // scope (as opposed to being explicitly deleted by its WindowDelegate). TEST_F(WindowTest, NoCrashOnWindowDelete) { CaptureWindowDelegateImpl delegate; - scoped_ptr<Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( &delegate, 0, gfx::Rect(0, 0, 20, 20), root_window())); } TEST_F(WindowTest, GetEventHandlerForPoint) { - scoped_ptr<Window> w1( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), - root_window())); - scoped_ptr<Window> w11( + std::unique_ptr<Window> w1(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), root_window())); + std::unique_ptr<Window> w11( CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); - scoped_ptr<Window> w111( + std::unique_ptr<Window> w111( CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); - scoped_ptr<Window> w1111( + std::unique_ptr<Window> w1111( CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); - scoped_ptr<Window> w12( - CreateTestWindow(SK_ColorMAGENTA, 12, gfx::Rect(10, 420, 25, 25), - w1.get())); - scoped_ptr<Window> w121( + std::unique_ptr<Window> w12(CreateTestWindow( + SK_ColorMAGENTA, 12, gfx::Rect(10, 420, 25, 25), w1.get())); + std::unique_ptr<Window> w121( CreateTestWindow(SK_ColorYELLOW, 121, gfx::Rect(5, 5, 5, 5), w12.get())); - scoped_ptr<Window> w13( + std::unique_ptr<Window> w13( CreateTestWindow(SK_ColorGRAY, 13, gfx::Rect(5, 470, 50, 50), w1.get())); Window* root = root_window(); @@ -521,10 +565,9 @@ TEST_F(WindowTest, GetEventHandlerForPoint) { TEST_F(WindowTest, GetEventHandlerForPointWithOverride) { // If our child is flush to our top-left corner he gets events just inside the // window edges. - scoped_ptr<Window> parent( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 20, 400, 500), - root_window())); - scoped_ptr<Window> child( + std::unique_ptr<Window> parent(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(10, 20, 400, 500), root_window())); + std::unique_ptr<Window> child( CreateTestWindow(SK_ColorRED, 2, gfx::Rect(0, 0, 60, 70), parent.get())); EXPECT_EQ(child.get(), parent->GetEventHandlerForPoint(gfx::Point(0, 0))); EXPECT_EQ(child.get(), parent->GetEventHandlerForPoint(gfx::Point(1, 1))); @@ -537,13 +580,12 @@ TEST_F(WindowTest, GetEventHandlerForPointWithOverride) { } TEST_F(WindowTest, GetEventHandlerForPointWithOverrideDescendingOrder) { - scoped_ptr<SelfEventHandlingWindowDelegate> parent_delegate( + std::unique_ptr<SelfEventHandlingWindowDelegate> parent_delegate( new SelfEventHandlingWindowDelegate); - scoped_ptr<Window> parent(CreateTestWindowWithDelegate( + std::unique_ptr<Window> parent(CreateTestWindowWithDelegate( parent_delegate.get(), 1, gfx::Rect(10, 20, 400, 500), root_window())); - scoped_ptr<Window> child( - CreateTestWindow(SK_ColorRED, 2, gfx::Rect(0, 0, 390, 480), - parent.get())); + std::unique_ptr<Window> child(CreateTestWindow( + SK_ColorRED, 2, gfx::Rect(0, 0, 390, 480), parent.get())); // We can override ShouldDescendIntoChildForEventHandling to make the parent // grab all events. @@ -555,22 +597,19 @@ TEST_F(WindowTest, GetTopWindowContainingPoint) { Window* root = root_window(); root->SetBounds(gfx::Rect(0, 0, 300, 300)); - scoped_ptr<Window> w1( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 100, 100), - root_window())); - scoped_ptr<Window> w11( + std::unique_ptr<Window> w1(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(10, 10, 100, 100), root_window())); + std::unique_ptr<Window> w11( CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(0, 0, 120, 120), w1.get())); - scoped_ptr<Window> w2( - CreateTestWindow(SK_ColorRED, 2, gfx::Rect(5, 5, 55, 55), - root_window())); + std::unique_ptr<Window> w2( + CreateTestWindow(SK_ColorRED, 2, gfx::Rect(5, 5, 55, 55), root_window())); - scoped_ptr<Window> w3( - CreateTestWindowWithDelegate( - NULL, 3, gfx::Rect(200, 200, 100, 100), root_window())); - scoped_ptr<Window> w31( + std::unique_ptr<Window> w3(CreateTestWindowWithDelegate( + NULL, 3, gfx::Rect(200, 200, 100, 100), root_window())); + std::unique_ptr<Window> w31( CreateTestWindow(SK_ColorCYAN, 31, gfx::Rect(0, 0, 50, 50), w3.get())); - scoped_ptr<Window> w311( + std::unique_ptr<Window> w311( CreateTestWindow(SK_ColorBLUE, 311, gfx::Rect(0, 0, 10, 10), w31.get())); EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(0, 0))); @@ -589,11 +628,11 @@ TEST_F(WindowTest, GetToplevelWindow) { const gfx::Rect kBounds(0, 0, 10, 10); TestWindowDelegate delegate; - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); - scoped_ptr<Window> w11( + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w11( CreateTestWindowWithDelegate(&delegate, 11, kBounds, w1.get())); - scoped_ptr<Window> w111(CreateTestWindowWithId(111, w11.get())); - scoped_ptr<Window> w1111( + std::unique_ptr<Window> w111(CreateTestWindowWithId(111, w11.get())); + std::unique_ptr<Window> w1111( CreateTestWindowWithDelegate(&delegate, 1111, kBounds, w111.get())); EXPECT_TRUE(root_window()->GetToplevelWindow() == NULL); @@ -620,8 +659,9 @@ class AddedToRootWindowObserver : public WindowObserver { TEST_F(WindowTest, WindowAddedToRootWindowShouldNotifyChildAndNotParent) { AddedToRootWindowObserver parent_observer; AddedToRootWindowObserver child_observer; - scoped_ptr<Window> parent_window(CreateTestWindowWithId(1, root_window())); - scoped_ptr<Window> child_window(new Window(NULL)); + std::unique_ptr<Window> parent_window( + CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> child_window(new Window(NULL)); child_window->Init(ui::LAYER_TEXTURED); child_window->Show(); @@ -642,9 +682,8 @@ TEST_F(WindowTest, DestroyTest) { DestroyTrackingDelegateImpl parent_delegate; ChildWindowDelegateImpl child_delegate(&parent_delegate); { - scoped_ptr<Window> parent( - CreateTestWindowWithDelegate(&parent_delegate, 0, gfx::Rect(), - root_window())); + std::unique_ptr<Window> parent(CreateTestWindowWithDelegate( + &parent_delegate, 0, gfx::Rect(), root_window())); CreateTestWindowWithDelegate(&child_delegate, 0, gfx::Rect(), parent.get()); } // Both the parent and child should have been destroyed. @@ -659,11 +698,10 @@ TEST_F(WindowTest, OrphanedBeforeOnDestroyed) { TestWindowDelegate parent_delegate; DestroyOrphanDelegate child_delegate; { - scoped_ptr<Window> parent( - CreateTestWindowWithDelegate(&parent_delegate, 0, gfx::Rect(), - root_window())); - scoped_ptr<Window> child(CreateTestWindowWithDelegate(&child_delegate, 0, - gfx::Rect(), parent.get())); + std::unique_ptr<Window> parent(CreateTestWindowWithDelegate( + &parent_delegate, 0, gfx::Rect(), root_window())); + std::unique_ptr<Window> child(CreateTestWindowWithDelegate( + &child_delegate, 0, gfx::Rect(), parent.get())); child_delegate.set_window(child.get()); } } @@ -789,7 +827,7 @@ TEST_F(WindowTest, StackChildAbove) { // Various capture assertions. TEST_F(WindowTest, CaptureTests) { CaptureWindowDelegateImpl delegate; - scoped_ptr<Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( &delegate, 0, gfx::Rect(0, 0, 20, 20), root_window())); EXPECT_FALSE(window->HasCapture()); @@ -840,10 +878,10 @@ TEST_F(WindowTest, CaptureTests) { TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) { CaptureWindowDelegateImpl delegate1; - scoped_ptr<Window> w1(CreateTestWindowWithDelegate( + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( &delegate1, 0, gfx::Rect(0, 0, 50, 50), root_window())); CaptureWindowDelegateImpl delegate2; - scoped_ptr<Window> w2(CreateTestWindowWithDelegate( + std::unique_ptr<Window> w2(CreateTestWindowWithDelegate( &delegate2, 0, gfx::Rect(50, 50, 50, 50), root_window())); // Press on w1. @@ -895,7 +933,7 @@ TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) { TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { CaptureWindowDelegateImpl delegate; - scoped_ptr<Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( &delegate, 0, gfx::Rect(0, 0, 50, 50), root_window())); base::TimeDelta time = getTime(); const int kTimeDelta = 100; @@ -951,7 +989,7 @@ TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { TEST_F(WindowTest, TransferCaptureTouchEvents) { // Touch on |w1|. CaptureWindowDelegateImpl d1; - scoped_ptr<Window> w1(CreateTestWindowWithDelegate( + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( &d1, 0, gfx::Rect(0, 0, 20, 20), root_window())); ui::TouchEvent p1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); DispatchEventUsingWindowDispatcher(&p1); @@ -962,7 +1000,7 @@ TEST_F(WindowTest, TransferCaptureTouchEvents) { // Touch on |w2| with a different id. CaptureWindowDelegateImpl d2; - scoped_ptr<Window> w2(CreateTestWindowWithDelegate( + std::unique_ptr<Window> w2(CreateTestWindowWithDelegate( &d2, 0, gfx::Rect(40, 0, 40, 20), root_window())); ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(41, 10), 1, getTime()); DispatchEventUsingWindowDispatcher(&p2); @@ -985,7 +1023,7 @@ TEST_F(WindowTest, TransferCaptureTouchEvents) { d2.ResetCounts(); CaptureWindowDelegateImpl d3; - scoped_ptr<Window> w3(CreateTestWindowWithDelegate( + std::unique_ptr<Window> w3(CreateTestWindowWithDelegate( &d3, 0, gfx::Rect(0, 0, 100, 101), root_window())); // Set capture on |w3|. All touches have already been cancelled. w3->SetCapture(); @@ -1031,10 +1069,10 @@ TEST_F(WindowTest, TransferCaptureTouchEvents) { // Changes capture while capture is already ongoing. TEST_F(WindowTest, ChangeCaptureWhileMouseDown) { CaptureWindowDelegateImpl delegate; - scoped_ptr<Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( &delegate, 0, gfx::Rect(0, 0, 20, 20), root_window())); CaptureWindowDelegateImpl delegate2; - scoped_ptr<Window> w2(CreateTestWindowWithDelegate( + std::unique_ptr<Window> w2(CreateTestWindowWithDelegate( &delegate2, 0, gfx::Rect(20, 20, 20, 20), root_window())); // Execute the scheduled draws so that mouse events are not @@ -1070,7 +1108,7 @@ TEST_F(WindowTest, ChangeCaptureWhileMouseDown) { // Verifies capture is reset when a window is destroyed. TEST_F(WindowTest, ReleaseCaptureOnDestroy) { CaptureWindowDelegateImpl delegate; - scoped_ptr<Window> window(CreateTestWindowWithDelegate( + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( &delegate, 0, gfx::Rect(0, 0, 20, 20), root_window())); EXPECT_FALSE(window->HasCapture()); @@ -1087,10 +1125,10 @@ TEST_F(WindowTest, ReleaseCaptureOnDestroy) { } TEST_F(WindowTest, GetBoundsInRootWindow) { - scoped_ptr<Window> viewport(CreateTestWindowWithBounds( - gfx::Rect(0, 0, 300, 300), root_window())); - scoped_ptr<Window> child(CreateTestWindowWithBounds( - gfx::Rect(0, 0, 100, 100), viewport.get())); + std::unique_ptr<Window> viewport( + CreateTestWindowWithBounds(gfx::Rect(0, 0, 300, 300), root_window())); + std::unique_ptr<Window> child( + CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), viewport.get())); // Sanity check. EXPECT_EQ("0,0 100x100", child->GetBoundsInRootWindow().ToString()); @@ -1105,13 +1143,13 @@ TEST_F(WindowTest, GetBoundsInRootWindow) { } TEST_F(WindowTest, GetBoundsInRootWindowWithLayers) { - scoped_ptr<Window> viewport( + std::unique_ptr<Window> viewport( CreateTestWindowWithBounds(gfx::Rect(0, 0, 300, 300), root_window())); - scoped_ptr<Window> widget( + std::unique_ptr<Window> widget( CreateTestWindowWithBounds(gfx::Rect(0, 0, 200, 200), viewport.get())); - scoped_ptr<Window> child( + std::unique_ptr<Window> child( CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), widget.get())); // Sanity check. @@ -1131,13 +1169,13 @@ TEST_F(WindowTest, GetBoundsInRootWindowWithLayers) { } TEST_F(WindowTest, GetBoundsInRootWindowWithLayersAndTranslations) { - scoped_ptr<Window> viewport( + std::unique_ptr<Window> viewport( CreateTestWindowWithBounds(gfx::Rect(0, 0, 300, 300), root_window())); - scoped_ptr<Window> widget( + std::unique_ptr<Window> widget( CreateTestWindowWithBounds(gfx::Rect(0, 0, 200, 200), viewport.get())); - scoped_ptr<Window> child( + std::unique_ptr<Window> child( CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), widget.get())); // Sanity check. @@ -1213,13 +1251,11 @@ class MouseEnterExitWindowDelegate : public TestWindowDelegate { // mouse transitions from window to window. TEST_F(WindowTest, MouseEnterExit) { MouseEnterExitWindowDelegate d1; - scoped_ptr<Window> w1( - CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + &d1, 1, gfx::Rect(10, 10, 50, 50), root_window())); MouseEnterExitWindowDelegate d2; - scoped_ptr<Window> w2( - CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50), - root_window())); + std::unique_ptr<Window> w2(CreateTestWindowWithDelegate( + &d2, 2, gfx::Rect(70, 70, 50, 50), root_window())); ui::test::EventGenerator generator(root_window()); generator.MoveMouseToCenterOf(w1.get()); @@ -1238,9 +1274,8 @@ TEST_F(WindowTest, MouseEnterExit) { // Verifies that the WindowDelegate receives MouseExit from ET_MOUSE_EXITED. TEST_F(WindowTest, WindowTreeHostExit) { MouseEnterExitWindowDelegate d1; - scoped_ptr<Window> w1( - CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + &d1, 1, gfx::Rect(10, 10, 50, 50), root_window())); ui::test::EventGenerator generator(root_window()); generator.MoveMouseToCenterOf(w1.get()); @@ -1260,13 +1295,11 @@ TEST_F(WindowTest, WindowTreeHostExit) { // and releases capture. TEST_F(WindowTest, MouseEnterExitWithClick) { MouseEnterExitWindowDelegate d1; - scoped_ptr<Window> w1( - CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + &d1, 1, gfx::Rect(10, 10, 50, 50), root_window())); MouseEnterExitWindowDelegate d2; - scoped_ptr<Window> w2( - CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50), - root_window())); + std::unique_ptr<Window> w2(CreateTestWindowWithDelegate( + &d2, 2, gfx::Rect(70, 70, 50, 50), root_window())); ui::test::EventGenerator generator(root_window()); generator.MoveMouseToCenterOf(w1.get()); @@ -1290,9 +1323,8 @@ TEST_F(WindowTest, MouseEnterExitWithClick) { TEST_F(WindowTest, MouseEnterExitWhenDeleteWithCapture) { MouseEnterExitWindowDelegate delegate; - scoped_ptr<Window> window( - CreateTestWindowWithDelegate(&delegate, 1, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( + &delegate, 1, gfx::Rect(10, 10, 50, 50), root_window())); ui::test::EventGenerator generator(root_window()); generator.MoveMouseToCenterOf(window.get()); @@ -1318,9 +1350,8 @@ TEST_F(WindowTest, MouseEnterExitWhenDeleteWithCapture) { // deleted under the current mouse position. TEST_F(WindowTest, MouseEnterExitWithWindowAppearAndDelete) { MouseEnterExitWindowDelegate d1; - scoped_ptr<Window> w1( - CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + &d1, 1, gfx::Rect(10, 10, 50, 50), root_window())); // The cursor is moved into the bounds of |w1|. We expect the delegate // of |w1| to see an ET_MOUSE_ENTERED event. @@ -1332,9 +1363,8 @@ TEST_F(WindowTest, MouseEnterExitWithWindowAppearAndDelete) { MouseEnterExitWindowDelegate d2; { - scoped_ptr<Window> w2( - CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> w2(CreateTestWindowWithDelegate( + &d2, 2, gfx::Rect(10, 10, 50, 50), root_window())); // Enters / exits can be sent asynchronously. RunAllPendingInMessageLoop(); @@ -1363,9 +1393,8 @@ TEST_F(WindowTest, MouseEnterExitWithWindowAppearAndDelete) { // under the current mouse position.. TEST_F(WindowTest, MouseEnterExitWithHide) { MouseEnterExitWindowDelegate d1; - scoped_ptr<Window> w1( - CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + &d1, 1, gfx::Rect(10, 10, 50, 50), root_window())); ui::test::EventGenerator generator(root_window()); generator.MoveMouseToCenterOf(w1.get()); @@ -1373,9 +1402,8 @@ TEST_F(WindowTest, MouseEnterExitWithHide) { EXPECT_FALSE(d1.exited()); MouseEnterExitWindowDelegate d2; - scoped_ptr<Window> w2( - CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> w2(CreateTestWindowWithDelegate( + &d2, 2, gfx::Rect(10, 10, 50, 50), root_window())); // Enters / exits can be send asynchronously. RunAllPendingInMessageLoop(); EXPECT_TRUE(d1.entered()); @@ -1393,9 +1421,8 @@ TEST_F(WindowTest, MouseEnterExitWithHide) { TEST_F(WindowTest, MouseEnterExitWithParentHide) { MouseEnterExitWindowDelegate d1; - scoped_ptr<Window> w1( - CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + &d1, 1, gfx::Rect(10, 10, 50, 50), root_window())); MouseEnterExitWindowDelegate d2; Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), w1.get()); @@ -1417,9 +1444,8 @@ TEST_F(WindowTest, MouseEnterExitWithParentHide) { TEST_F(WindowTest, MouseEnterExitWithParentDelete) { MouseEnterExitWindowDelegate d1; - scoped_ptr<Window> w1( - CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), - root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + &d1, 1, gfx::Rect(10, 10, 50, 50), root_window())); MouseEnterExitWindowDelegate d2; Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), w1.get()); @@ -1451,14 +1477,14 @@ TEST_F(WindowTest, MouseEnterExitWithParentDelete) { // allowing it to handle the event itself. TEST_F(WindowTest, GetEventHandlerForPoint_NoDelegate) { TestWindowDelegate d111; - scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, - gfx::Rect(0, 0, 500, 500), root_window())); - scoped_ptr<Window> w11(CreateTestWindowWithDelegate(NULL, 11, - gfx::Rect(0, 0, 500, 500), w1.get())); - scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111, - gfx::Rect(50, 50, 450, 450), w11.get())); - scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12, - gfx::Rect(0, 0, 500, 500), w1.get())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + NULL, 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())); + 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())); gfx::Point target_point = w111->bounds().CenterPoint(); EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(target_point)); @@ -1496,11 +1522,11 @@ class VisibilityWindowDelegate : public TestWindowDelegate { TEST_F(WindowTest, Visibility) { VisibilityWindowDelegate d; VisibilityWindowDelegate d2; - scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d, 1, gfx::Rect(), - root_window())); - scoped_ptr<Window> w2( - CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(), w1.get())); - scoped_ptr<Window> w3(CreateTestWindowWithId(3, w2.get())); + std::unique_ptr<Window> w1( + CreateTestWindowWithDelegate(&d, 1, gfx::Rect(), root_window())); + std::unique_ptr<Window> w2( + CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(), w1.get())); + std::unique_ptr<Window> w3(CreateTestWindowWithId(3, w2.get())); // Create shows all the windows. EXPECT_TRUE(w1->IsVisible()); @@ -1557,16 +1583,16 @@ TEST_F(WindowTest, IgnoreEventsTest) { TestWindowDelegate d12; TestWindowDelegate d111; TestWindowDelegate d121; - scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, - gfx::Rect(0, 0, 500, 500), root_window())); - scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11, - gfx::Rect(0, 0, 500, 500), w1.get())); - scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111, - gfx::Rect(50, 50, 450, 450), w11.get())); - scoped_ptr<Window> w12(CreateTestWindowWithDelegate(&d12, 12, - gfx::Rect(0, 0, 500, 500), w1.get())); - scoped_ptr<Window> w121(CreateTestWindowWithDelegate(&d121, 121, - gfx::Rect(150, 150, 50, 50), w12.get())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + NULL, 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( + &d111, 111, gfx::Rect(50, 50, 450, 450), w11.get())); + std::unique_ptr<Window> w12(CreateTestWindowWithDelegate( + &d12, 12, gfx::Rect(0, 0, 500, 500), w1.get())); + std::unique_ptr<Window> w121(CreateTestWindowWithDelegate( + &d121, 121, gfx::Rect(150, 150, 50, 50), w12.get())); EXPECT_EQ(w12.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10))); w12->set_ignore_events(true); @@ -1585,9 +1611,9 @@ TEST_F(WindowTest, IgnoreEventsTest) { // Tests transformation on the root window. TEST_F(WindowTest, Transform) { gfx::Size size = host()->GetBounds().size(); - EXPECT_EQ(gfx::Rect(size), - gfx::Screen::GetScreen()->GetDisplayNearestPoint( - gfx::Point()).bounds()); + EXPECT_EQ(gfx::Rect(size), display::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point()) + .bounds()); // Rotate it clock-wise 90 degrees. gfx::Transform transform; @@ -1599,10 +1625,11 @@ TEST_F(WindowTest, Transform) { gfx::Size transformed_size(size.height(), size.width()); EXPECT_EQ(transformed_size.ToString(), root_window()->bounds().size().ToString()); - EXPECT_EQ( - gfx::Rect(transformed_size).ToString(), - gfx::Screen::GetScreen()->GetDisplayNearestPoint( - gfx::Point()).bounds().ToString()); + EXPECT_EQ(gfx::Rect(transformed_size).ToString(), + display::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point()) + .bounds() + .ToString()); // Host size shouldn't change. EXPECT_EQ(size.ToString(), host()->GetBounds().size().ToString()); @@ -1611,10 +1638,10 @@ TEST_F(WindowTest, Transform) { TEST_F(WindowTest, TransformGesture) { gfx::Size size = host()->GetBounds().size(); - scoped_ptr<GestureTrackPositionDelegate> delegate( + std::unique_ptr<GestureTrackPositionDelegate> delegate( new GestureTrackPositionDelegate); - scoped_ptr<Window> window(CreateTestWindowWithDelegate(delegate.get(), -1234, - gfx::Rect(0, 0, 20, 20), root_window())); + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( + delegate.get(), -1234, gfx::Rect(0, 0, 20, 20), root_window())); // Rotate the root-window clock-wise 90 degrees. gfx::Transform transform; @@ -1634,7 +1661,7 @@ DEFINE_WINDOW_PROPERTY_KEY(const char*, kStringKey, "squeamish"); } TEST_F(WindowTest, Property) { - scoped_ptr<Window> w(CreateTestWindowWithId(0, root_window())); + std::unique_ptr<Window> w(CreateTestWindowWithId(0, root_window())); static const char native_prop_key[] = "fnord"; @@ -1672,7 +1699,7 @@ TEST_F(WindowTest, Property) { } TEST_F(WindowTest, OwnedProperty) { - scoped_ptr<Window> w(CreateTestWindowWithId(0, root_window())); + std::unique_ptr<Window> w(CreateTestWindowWithId(0, root_window())); EXPECT_EQ(NULL, w->GetProperty(kOwnedKey)); TestProperty* last_deleted = TestProperty::last_deleted(); TestProperty* p1 = new TestProperty(); @@ -1697,12 +1724,50 @@ TEST_F(WindowTest, OwnedProperty) { EXPECT_EQ(p3, TestProperty::last_deleted()); } +namespace { + +class DeletionTestLayoutManager : public LayoutManager { + public: + explicit DeletionTestLayoutManager(DeletionTracker* tracker) + : tracker_(tracker) {} + ~DeletionTestLayoutManager() override { tracker_->LayoutManagerDeleted(); } + + private: + // LayoutManager: + void OnWindowResized() override {} + void OnWindowAddedToLayout(Window* child) override {} + void OnWillRemoveWindowFromLayout(Window* child) override {} + void OnWindowRemovedFromLayout(Window* child) override {} + void OnChildWindowVisibilityChanged(Window* child, bool visible) override {} + void SetChildBounds(Window* child, + const gfx::Rect& requested_bounds) override {} + + DeletionTracker* tracker_; + + DISALLOW_COPY_AND_ASSIGN(DeletionTestLayoutManager); +}; + +} // namespace + +TEST_F(WindowTest, DeleteLayoutManagerBeforeOwnedProps) { + DeletionTracker tracker; + { + Window w(nullptr); + w.Init(ui::LAYER_NOT_DRAWN); + w.SetLayoutManager(new DeletionTestLayoutManager(&tracker)); + w.SetProperty(kDeletionTestPropertyKey, new DeletionTestProperty(&tracker)); + } + EXPECT_TRUE(tracker.property_deleted()); + EXPECT_TRUE(tracker.layout_manager_deleted()); + EXPECT_EQ(DeletionOrder::LAYOUT_MANAGER_FIRST, tracker.order()); +} + TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { // We cannot short-circuit animations in this test. ui::ScopedAnimationDurationScaleMode test_duration_mode( ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); - scoped_ptr<Window> w1( + std::unique_ptr<Window> w1( CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), root_window())); EXPECT_TRUE(w1->layer()); @@ -1841,7 +1906,7 @@ class WindowObserverTest : public WindowTest, int added_count_; int removed_count_; int destroyed_count_; - scoped_ptr<VisibilityInfo> visibility_info_; + std::unique_ptr<VisibilityInfo> visibility_info_; const void* property_key_; intptr_t old_property_value_; std::vector<std::pair<int, int> > transform_notifications_; @@ -1851,11 +1916,11 @@ class WindowObserverTest : public WindowTest, // Various assertions for WindowObserver. TEST_F(WindowObserverTest, WindowObserver) { - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); w1->AddObserver(this); // Create a new window as a child of w1, our observer should be notified. - scoped_ptr<Window> w2(CreateTestWindowWithId(2, w1.get())); + std::unique_ptr<Window> w2(CreateTestWindowWithId(2, w1.get())); EXPECT_EQ("added=1 removed=0", WindowObserverCountStateAndClear()); // Delete w2, which should result in the remove notification. @@ -1864,7 +1929,7 @@ TEST_F(WindowObserverTest, WindowObserver) { // Create a window that isn't parented to w1, we shouldn't get any // notification. - scoped_ptr<Window> w3(CreateTestWindowWithId(3, root_window())); + std::unique_ptr<Window> w3(CreateTestWindowWithId(3, root_window())); EXPECT_EQ("added=0 removed=0", WindowObserverCountStateAndClear()); // Similarly destroying w3 shouldn't notify us either. @@ -1876,8 +1941,8 @@ TEST_F(WindowObserverTest, WindowObserver) { // Test if OnWindowVisibilityChanged is invoked with expected // parameters. TEST_F(WindowObserverTest, WindowVisibility) { - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); - scoped_ptr<Window> w2(CreateTestWindowWithId(1, w1.get())); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w2(CreateTestWindowWithId(1, w1.get())); w2->AddObserver(this); // Hide should make the window invisible and the passed visible @@ -1929,13 +1994,13 @@ TEST_F(WindowObserverTest, WindowVisibility) { // Test if OnWindowDestroyed is invoked as expected. TEST_F(WindowObserverTest, WindowDestroyed) { // Delete a window should fire a destroyed notification. - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); w1->AddObserver(this); w1.reset(); EXPECT_EQ(1, DestroyedCountAndClear()); // Observe on child and delete parent window should fire a notification. - scoped_ptr<Window> parent(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> parent(CreateTestWindowWithId(1, root_window())); Window* child = CreateTestWindowWithId(1, parent.get()); // owned by parent child->AddObserver(this); parent.reset(); @@ -1944,7 +2009,7 @@ TEST_F(WindowObserverTest, WindowDestroyed) { TEST_F(WindowObserverTest, PropertyChanged) { // Setting property should fire a property change notification. - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); w1->AddObserver(this); static const WindowProperty<int> prop = {-2}; @@ -1981,13 +2046,13 @@ TEST_F(WindowObserverTest, AncestorTransformed) { // +-- w4 // Then, apply a transform to |w1| and ensure all its descendants are // notified. - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); w1->AddObserver(this); - scoped_ptr<Window> w2(CreateTestWindowWithId(2, w1.get())); + std::unique_ptr<Window> w2(CreateTestWindowWithId(2, w1.get())); w2->AddObserver(this); - scoped_ptr<Window> w3(CreateTestWindowWithId(3, w1.get())); + std::unique_ptr<Window> w3(CreateTestWindowWithId(3, w1.get())); w3->AddObserver(this); - scoped_ptr<Window> w4(CreateTestWindowWithId(4, w3.get())); + std::unique_ptr<Window> w4(CreateTestWindowWithId(4, w3.get())); w4->AddObserver(this); EXPECT_EQ(std::string(), TransformNotificationsAndClear()); @@ -2000,8 +2065,8 @@ TEST_F(WindowObserverTest, AncestorTransformed) { } TEST_F(WindowTest, AcquireLayer) { - scoped_ptr<Window> window1(CreateTestWindowWithId(1, root_window())); - scoped_ptr<Window> window2(CreateTestWindowWithId(2, root_window())); + std::unique_ptr<Window> window1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> window2(CreateTestWindowWithId(2, root_window())); ui::Layer* parent = window1->parent()->layer(); EXPECT_EQ(2U, parent->children().size()); @@ -2013,14 +2078,14 @@ TEST_F(WindowTest, AcquireLayer) { // After acquisition, window1 should not own its layer, but it should still // be available to the window. - scoped_ptr<ui::Layer> window1_layer(window1->AcquireLayer()); + std::unique_ptr<ui::Layer> window1_layer(window1->AcquireLayer()); EXPECT_FALSE(window1_test_api.OwnsLayer()); EXPECT_TRUE(window1_layer.get() == window1->layer()); // The acquired layer's owner should be set NULL and re-acquring // should return NULL. EXPECT_FALSE(window1_layer->owner()); - scoped_ptr<ui::Layer> window1_layer_reacquired(window1->AcquireLayer()); + std::unique_ptr<ui::Layer> window1_layer_reacquired(window1->AcquireLayer()); EXPECT_FALSE(window1_layer_reacquired.get()); // Upon destruction, window1's layer should still be valid, and in the layer @@ -2050,7 +2115,7 @@ TEST_F(WindowTest, RecreateLayer) { ui::Layer child_layer; layer->Add(&child_layer); - scoped_ptr<ui::Layer> old_layer(w.RecreateLayer()); + std::unique_ptr<ui::Layer> old_layer(w.RecreateLayer()); layer = w.layer(); EXPECT_EQ(ui::LAYER_SOLID_COLOR, layer->type()); EXPECT_FALSE(layer->visible()); @@ -2063,10 +2128,9 @@ TEST_F(WindowTest, RecreateLayer) { // Verify that RecreateLayer() stacks the old layer above the newly creatd // layer. TEST_F(WindowTest, RecreateLayerZOrder) { - scoped_ptr<Window> w( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(0, 0, 100, 100), - root_window())); - scoped_ptr<ui::Layer> old_layer(w->RecreateLayer()); + std::unique_ptr<Window> w(CreateTestWindow( + SK_ColorWHITE, 1, gfx::Rect(0, 0, 100, 100), root_window())); + std::unique_ptr<ui::Layer> old_layer(w->RecreateLayer()); const std::vector<ui::Layer*>& child_layers = root_window()->layer()->children(); @@ -2078,11 +2142,10 @@ TEST_F(WindowTest, RecreateLayerZOrder) { // Ensure that acquiring a layer then recreating a layer does not crash // and that RecreateLayer returns null. TEST_F(WindowTest, AcquireThenRecreateLayer) { - scoped_ptr<Window> w( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(0, 0, 100, 100), - root_window())); - scoped_ptr<ui::Layer> acquired_layer(w->AcquireLayer()); - scoped_ptr<ui::Layer> doubly_acquired_layer(w->RecreateLayer()); + std::unique_ptr<Window> w(CreateTestWindow( + 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()); // Destroy window before layer gets destroyed. @@ -2115,7 +2178,7 @@ class TestVisibilityClient : public client::VisibilityClient { TEST_F(WindowTest, VisibilityClientIsVisible) { TestVisibilityClient client(root_window()); - scoped_ptr<Window> window(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> window(CreateTestWindowWithId(1, root_window())); EXPECT_TRUE(window->IsVisible()); EXPECT_TRUE(window->layer()->visible()); @@ -2139,15 +2202,15 @@ TEST_F(WindowTest, MouseEventsOnLeafWindowChange) { generator.MoveMouseTo(50, 50); EventCountDelegate d1; - scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d1, 1, - gfx::Rect(0, 0, 100, 100), root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + &d1, 1, gfx::Rect(0, 0, 100, 100), root_window())); RunAllPendingInMessageLoop(); // The format of result is "Enter/Move/Leave". EXPECT_EQ("1 1 0", d1.GetMouseMotionCountsAndReset()); // Add new window |w11| on top of |w1| which contains the cursor. EventCountDelegate d11; - scoped_ptr<Window> w11(CreateTestWindowWithDelegate( + std::unique_ptr<Window> w11(CreateTestWindowWithDelegate( &d11, 1, gfx::Rect(0, 0, 100, 100), w1.get())); RunAllPendingInMessageLoop(); EXPECT_EQ("0 0 1", d1.GetMouseMotionCountsAndReset()); @@ -2240,15 +2303,15 @@ TEST_F(WindowTest, MouseEventsOnNonLeafWindowDelete) { generator.MoveMouseTo(50, 50); EventCountDelegate d1; - scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d1, 1, - gfx::Rect(0, 0, 100, 100), root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithDelegate( + &d1, 1, gfx::Rect(0, 0, 100, 100), root_window())); RunAllPendingInMessageLoop(); // The format of result is "Enter/Move/Leave". EXPECT_EQ("1 1 0", d1.GetMouseMotionCountsAndReset()); // Add new window |w2| on top of |w1| which contains the cursor. EventCountDelegate d2; - scoped_ptr<Window> w2(CreateTestWindowWithDelegate( + std::unique_ptr<Window> w2(CreateTestWindowWithDelegate( &d2, 1, gfx::Rect(0, 0, 100, 100), w1.get())); RunAllPendingInMessageLoop(); EXPECT_EQ("0 0 1", d1.GetMouseMotionCountsAndReset()); @@ -2304,7 +2367,7 @@ TEST_F(WindowTest, RootWindowAttachment) { RootWindowAttachmentObserver observer; // Test a direct add/remove from the RootWindow. - scoped_ptr<Window> w1(new Window(NULL)); + std::unique_ptr<Window> w1(new Window(NULL)); w1->Init(ui::LAYER_NOT_DRAWN); w1->AddObserver(&observer); @@ -2425,9 +2488,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. - scoped_ptr<Window> w1(new Window(NULL)); + std::unique_ptr<Window> w1(new Window(NULL)); w1->Init(ui::LAYER_NOT_DRAWN); - scoped_ptr<Window> w2(new Window(NULL)); + std::unique_ptr<Window> w2(new Window(NULL)); w2->set_owned_by_parent(false); w2->Init(ui::LAYER_NOT_DRAWN); w1->AddChild(w2.get()); @@ -2453,7 +2516,7 @@ class OwningWindowDelegate : public TestWindowDelegate { void OnWindowDestroyed(Window* window) override { owned_window_.reset(NULL); } private: - scoped_ptr<Window> owned_window_; + std::unique_ptr<Window> owned_window_; DISALLOW_COPY_AND_ASSIGN(OwningWindowDelegate); }; @@ -2466,7 +2529,7 @@ class OwningWindowDelegate : public TestWindowDelegate { // same parent and destroying BrowserView triggers it destroying the status // bubble. TEST_F(WindowTest, DeleteWindowFromOnWindowDestroyed) { - scoped_ptr<Window> parent(new Window(NULL)); + std::unique_ptr<Window> parent(new Window(NULL)); parent->Init(ui::LAYER_NOT_DRAWN); OwningWindowDelegate delegate; Window* c1 = new Window(&delegate); @@ -2516,9 +2579,8 @@ TEST_F(WindowTest, DelegateNotifiedAsBoundsChange) { ui::ScopedAnimationDurationScaleMode test_duration_mode( ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); - scoped_ptr<Window> window( - CreateTestWindowWithDelegate(&delegate, 1, - gfx::Rect(0, 0, 100, 100), root_window())); + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( + &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); window->layer()->GetAnimator()->set_disable_timer_for_test(true); delegate.clear_bounds_changed(); @@ -2551,9 +2613,8 @@ TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) { ui::ScopedAnimationDurationScaleMode test_duration_mode( ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); - scoped_ptr<Window> window( - CreateTestWindowWithDelegate(&delegate, 1, - gfx::Rect(0, 0, 100, 100), root_window())); + std::unique_ptr<Window> window(CreateTestWindowWithDelegate( + &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); window->layer()->GetAnimator()->set_disable_timer_for_test(true); delegate.clear_bounds_changed(); @@ -2620,8 +2681,8 @@ class AddChildNotificationsObserver : public WindowObserver { // Assertions around when root window notifications are sent. TEST_F(WindowTest, AddChildNotifications) { AddChildNotificationsObserver observer; - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); - scoped_ptr<Window> w2(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w2(CreateTestWindowWithId(1, root_window())); w2->AddObserver(&observer); w2->Focus(); EXPECT_TRUE(w2->HasFocus()); @@ -2637,11 +2698,9 @@ TEST_F(WindowTest, AddChildNotifications) { // Tests that a delegate that destroys itself when the window is destroyed does // not break. TEST_F(WindowTest, DelegateDestroysSelfOnWindowDestroy) { - scoped_ptr<Window> w1(CreateTestWindowWithDelegate( - new DestroyWindowDelegate(), - 0, - gfx::Rect(10, 20, 30, 40), - root_window())); + std::unique_ptr<Window> w1( + CreateTestWindowWithDelegate(new DestroyWindowDelegate(), 0, + gfx::Rect(10, 20, 30, 40), root_window())); } class HierarchyObserver : public WindowObserver { @@ -2691,7 +2750,7 @@ TEST_F(WindowTest, OnWindowHierarchyChange) { // Simple add & remove. HierarchyObserver oroot(root_window()); - scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); HierarchyObserver o1(w1.get()); // Add. @@ -2737,7 +2796,7 @@ TEST_F(WindowTest, OnWindowHierarchyChange) { // Add & remove of hierarchy. Tests notification order per documentation in // WindowObserver. HierarchyObserver o(root_window()); - scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); Window* w11 = CreateTestWindowWithId(11, w1.get()); w1->AddObserver(&o); w11->AddObserver(&o); @@ -2791,10 +2850,10 @@ TEST_F(WindowTest, OnWindowHierarchyChange) { { // Reparent. Tests notification order per documentation in WindowObserver. - scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); Window* w11 = CreateTestWindowWithId(11, w1.get()); Window* w111 = CreateTestWindowWithId(111, w11); - scoped_ptr<Window> w2(CreateTestWindowWithId(2, root_window())); + std::unique_ptr<Window> w2(CreateTestWindowWithId(2, root_window())); HierarchyObserver o(root_window()); w1->AddObserver(&o); @@ -2887,7 +2946,7 @@ TEST_F(WindowTest, WindowDestroyCompletesAnimations) { animator->AddObserver(&observer); // Make sure destroying a Window completes the animation. { - scoped_ptr<Window> window(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> window(CreateTestWindowWithId(1, root_window())); window->layer()->SetAnimator(animator.get()); gfx::Transform transform; @@ -2909,7 +2968,7 @@ TEST_F(WindowTest, WindowDestroyCompletesAnimations) { ui::Layer layer; layer.SetAnimator(animator.get()); { - scoped_ptr<Window> window(CreateTestWindowWithId(1, root_window())); + std::unique_ptr<Window> window(CreateTestWindowWithId(1, root_window())); window->layer()->Add(&layer); gfx::Transform transform; |