From 48602c37b1f027823b7908080c8e026d5607807f Mon Sep 17 00:00:00 2001 From: andresantoso Date: Fri, 24 Oct 2014 16:54:10 -0700 Subject: [PATCH] MacViews: Get c/b/ui/views/tabs to build on Mac Isolate aura and ash dependencies since they are not included on Mac. Change GetLocalProcessWindowAtPoint to work with gfx::NativeWindow. Add window_finder_mac.mm BUG=425229 Review URL: https://codereview.chromium.org/669243002 Cr-Commit-Position: refs/heads/master@{#301235} --- .../browser/ui/views/tabs/tab_drag_controller.cc | 44 ++++++++++++++++------ chrome/browser/ui/views/tabs/window_finder.h | 4 +- chrome/browser/ui/views/tabs/window_finder_ash.cc | 12 +++--- .../ui/views/tabs/window_finder_chromeos.cc | 8 ++-- chrome/browser/ui/views/tabs/window_finder_mac.mm | 13 +++++++ chrome/browser/ui/views/tabs/window_finder_win.cc | 8 ++-- chrome/browser/ui/views/tabs/window_finder_x11.cc | 8 ++-- chrome/chrome_browser_ui.gypi | 35 ++++++++--------- 8 files changed, 83 insertions(+), 49 deletions(-) create mode 100644 chrome/browser/ui/views/tabs/window_finder_mac.mm diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc index 2d2b5506a210..7c737fd3426c 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc @@ -38,14 +38,17 @@ #include "ui/views/focus/view_storage.h" #include "ui/views/widget/root_view.h" #include "ui/views/widget/widget.h" -#include "ui/wm/core/coordinate_conversion.h" -#include "ui/wm/core/window_modality_controller.h" #if defined(USE_ASH) #include "ash/accelerators/accelerator_commands.h" #include "ash/shell.h" #include "ash/wm/maximize_mode/maximize_mode_controller.h" #include "ash/wm/window_state.h" +#include "ui/wm/core/coordinate_conversion.h" +#endif + +#if defined(USE_AURA) +#include "ui/wm/core/window_modality_controller.h" #endif using base::UserMetricsAction; @@ -94,6 +97,17 @@ bool IsDockedOrSnapped(const TabStrip* tab_strip) { } #endif +#if defined(USE_AURA) +gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { + return wm::GetModalTransient(window); +} +#else +gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { + NOTIMPLEMENTED(); + return NULL; +} +#endif + // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate // of |bounds| is adjusted by |vertical_adjustment|. bool DoesRectContainVerticalPointExpanded( @@ -123,7 +137,7 @@ class WindowPositionManagedUpdater : public views::WidgetObserver { public: virtual void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override { - SetWindowPositionManaged(widget->GetNativeView(), false); + SetWindowPositionManaged(widget->GetNativeWindow(), false); } }; @@ -217,7 +231,7 @@ TabDragController::~TabDragController() { if (move_loop_widget_) { move_loop_widget_->RemoveObserver(this); - SetWindowPositionManaged(move_loop_widget_->GetNativeView(), true); + SetWindowPositionManaged(move_loop_widget_->GetNativeWindow(), true); } if (source_tabstrip_) @@ -608,7 +622,7 @@ TabDragController::DragBrowserToNewTabStrip( // The window is going away. Since the drag is still on going we don't want // that to effect the position of any windows. - SetWindowPositionManaged(browser_widget->GetNativeView(), false); + SetWindowPositionManaged(browser_widget->GetNativeWindow(), false); #if !defined(OS_LINUX) || defined(OS_CHROMEOS) // EndMoveLoop is going to snap the window back to its original location. @@ -826,7 +840,7 @@ TabStrip* TabDragController::GetTargetTabStripForPoint( GetLocalProcessWindow(point_in_screen, is_dragging_window_); // Do not allow dragging into a window with a modal dialog, it causes a weird // behavior. See crbug.com/336691 - if (!wm::GetModalTransient(local_window)) { + if (!GetModalTransient(local_window)) { TabStrip* tab_strip = GetTabStripForWindow(local_window); if (tab_strip && DoesTabStripContain(tab_strip, point_in_screen)) return tab_strip; @@ -1337,7 +1351,7 @@ void TabDragController::EndDragImpl(EndDragType type) { waiting_for_run_loop_to_exit_ = true; if (type == NORMAL || (type == TAB_DESTROYED && drag_data_.size() > 1)) { - SetWindowPositionManaged(GetAttachedBrowserWidget()->GetNativeView(), + SetWindowPositionManaged(GetAttachedBrowserWidget()->GetNativeWindow(), true); } @@ -1553,7 +1567,7 @@ gfx::Rect TabDragController::GetViewScreenBounds( void TabDragController::BringWindowUnderPointToFront( const gfx::Point& point_in_screen) { - aura::Window* window = GetLocalProcessWindow(point_in_screen, true); + gfx::NativeWindow window = GetLocalProcessWindow(point_in_screen, true); // Only bring browser windows to front - only windows with a TabStrip can // be tab drag targets. @@ -1561,11 +1575,12 @@ void TabDragController::BringWindowUnderPointToFront( return; if (window) { - views::Widget* widget_window = views::Widget::GetWidgetForNativeView( + views::Widget* widget_window = views::Widget::GetWidgetForNativeWindow( window); if (!widget_window) return; +#if defined(USE_ASH) if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { // TODO(varkha): The code below ensures that the phantom drag widget // is shown on top of browser windows. The code should be moved to ash/ @@ -1597,6 +1612,9 @@ void TabDragController::BringWindowUnderPointToFront( } else { widget_window->StackAtTop(); } +#else + widget_window->StackAtTop(); +#endif // The previous call made the window appear on top of the dragged window, // move the dragged window to the front. @@ -1733,6 +1751,7 @@ Browser* TabDragController::CreateBrowserForDrag( } gfx::Point TabDragController::GetCursorScreenPoint() { +#if defined(USE_ASH) if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH && event_source_ == EVENT_SOURCE_TOUCH && aura::Env::GetInstance()->is_touch_down()) { @@ -1749,6 +1768,7 @@ gfx::Point TabDragController::GetCursorScreenPoint() { wm::ConvertPointToScreen(widget_window->GetRootWindow(), &touch_point); return touch_point; } +#endif return screen_->GetCursorScreenPoint(); } @@ -1767,10 +1787,10 @@ gfx::Vector2d TabDragController::GetWindowOffset( gfx::NativeWindow TabDragController::GetLocalProcessWindow( const gfx::Point& screen_point, bool exclude_dragged_view) { - std::set exclude; + std::set exclude; if (exclude_dragged_view) { - aura::Window* dragged_window = - attached_tabstrip_->GetWidget()->GetNativeView(); + gfx::NativeWindow dragged_window = + attached_tabstrip_->GetWidget()->GetNativeWindow(); if (dragged_window) exclude.insert(dragged_window); } diff --git a/chrome/browser/ui/views/tabs/window_finder.h b/chrome/browser/ui/views/tabs/window_finder.h index 246da081e965..91de6c161da5 100644 --- a/chrome/browser/ui/views/tabs/window_finder.h +++ b/chrome/browser/ui/views/tabs/window_finder.h @@ -18,9 +18,9 @@ class Point; } // Returns the Window at the specified point, ignoring the windows in |ignore|. -aura::Window* GetLocalProcessWindowAtPoint( +gfx::NativeWindow GetLocalProcessWindowAtPoint( chrome::HostDesktopType host_desktop_type, const gfx::Point& screen_point, - const std::set& ignore); + const std::set& ignore); #endif // CHROME_BROWSER_UI_VIEWS_TABS_WINDOW_FINDER_H_ diff --git a/chrome/browser/ui/views/tabs/window_finder_ash.cc b/chrome/browser/ui/views/tabs/window_finder_ash.cc index 049888821fa2..a0cbe04768e3 100644 --- a/chrome/browser/ui/views/tabs/window_finder_ash.cc +++ b/chrome/browser/ui/views/tabs/window_finder_ash.cc @@ -11,10 +11,10 @@ namespace { -aura::Window* GetLocalProcessWindowAtPointImpl( +gfx::NativeWindow GetLocalProcessWindowAtPointImpl( const gfx::Point& screen_point, - const std::set& ignore, - aura::Window* window) { + const std::set& ignore, + gfx::NativeWindow window) { if (ignore.find(window) != ignore.end()) return NULL; @@ -31,7 +31,7 @@ aura::Window* GetLocalProcessWindowAtPointImpl( for (aura::Window::Windows::const_reverse_iterator i = window->children().rbegin(); i != window->children().rend(); ++i) { - aura::Window* result = + gfx::NativeWindow result = GetLocalProcessWindowAtPointImpl(screen_point, ignore, *i); if (result) return result; @@ -41,9 +41,9 @@ aura::Window* GetLocalProcessWindowAtPointImpl( } // namespace -aura::Window* GetLocalProcessWindowAtPointAsh( +gfx::NativeWindow GetLocalProcessWindowAtPointAsh( const gfx::Point& screen_point, - const std::set& ignore) { + const std::set& ignore) { return GetLocalProcessWindowAtPointImpl( screen_point, ignore, ::ash::wm::GetRootWindowAt(screen_point)); } diff --git a/chrome/browser/ui/views/tabs/window_finder_chromeos.cc b/chrome/browser/ui/views/tabs/window_finder_chromeos.cc index c84a727935b4..175615cf6035 100644 --- a/chrome/browser/ui/views/tabs/window_finder_chromeos.cc +++ b/chrome/browser/ui/views/tabs/window_finder_chromeos.cc @@ -7,13 +7,13 @@ #include "chrome/browser/ui/host_desktop.h" #include "ui/aura/window.h" -aura::Window* GetLocalProcessWindowAtPointAsh( +gfx::NativeWindow GetLocalProcessWindowAtPointAsh( const gfx::Point& screen_point, - const std::set& ignore); + const std::set& ignore); -aura::Window* GetLocalProcessWindowAtPoint( +gfx::NativeWindow GetLocalProcessWindowAtPoint( chrome::HostDesktopType host_desktop_type, const gfx::Point& screen_point, - const std::set& ignore) { + const std::set& ignore) { return GetLocalProcessWindowAtPointAsh(screen_point, ignore); } diff --git a/chrome/browser/ui/views/tabs/window_finder_mac.mm b/chrome/browser/ui/views/tabs/window_finder_mac.mm new file mode 100644 index 000000000000..b2307da35507 --- /dev/null +++ b/chrome/browser/ui/views/tabs/window_finder_mac.mm @@ -0,0 +1,13 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/views/tabs/window_finder.h" + +gfx::NativeWindow GetLocalProcessWindowAtPoint( + chrome::HostDesktopType host_desktop_type, + const gfx::Point& screen_point, + const std::set& ignore) { + NOTIMPLEMENTED(); + return NULL; +} diff --git a/chrome/browser/ui/views/tabs/window_finder_win.cc b/chrome/browser/ui/views/tabs/window_finder_win.cc index 6d365bdc7e5d..33d401f01df2 100644 --- a/chrome/browser/ui/views/tabs/window_finder_win.cc +++ b/chrome/browser/ui/views/tabs/window_finder_win.cc @@ -13,9 +13,9 @@ #include "ui/views/win/hwnd_util.h" #if defined(USE_ASH) -aura::Window* GetLocalProcessWindowAtPointAsh( +gfx::NativeWindow GetLocalProcessWindowAtPointAsh( const gfx::Point& screen_point, - const std::set& ignore); + const std::set& ignore); #endif namespace { @@ -218,10 +218,10 @@ std::set RemapIgnoreSet(const std::set& ignore) { } // namespace -aura::Window* GetLocalProcessWindowAtPoint( +gfx::NativeWindow GetLocalProcessWindowAtPoint( chrome::HostDesktopType host_desktop_type, const gfx::Point& screen_point, - const std::set& ignore) { + const std::set& ignore) { #if defined(USE_ASH) if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) return GetLocalProcessWindowAtPointAsh(screen_point, ignore); diff --git a/chrome/browser/ui/views/tabs/window_finder_x11.cc b/chrome/browser/ui/views/tabs/window_finder_x11.cc index 6d9e50e9c8af..f7511233d856 100644 --- a/chrome/browser/ui/views/tabs/window_finder_x11.cc +++ b/chrome/browser/ui/views/tabs/window_finder_x11.cc @@ -7,15 +7,15 @@ #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" #if defined(USE_ASH) -aura::Window* GetLocalProcessWindowAtPointAsh( +gfx::NativeWindow GetLocalProcessWindowAtPointAsh( const gfx::Point& screen_point, - const std::set& ignore); + const std::set& ignore); #endif -aura::Window* GetLocalProcessWindowAtPoint( +gfx::NativeWindow GetLocalProcessWindowAtPoint( chrome::HostDesktopType host_desktop_type, const gfx::Point& screen_point, - const std::set& ignore) { + const std::set& ignore) { #if defined(USE_ASH) if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) return GetLocalProcessWindowAtPointAsh(screen_point, ignore); diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index cf9693fbb1e3..ca24a8850b10 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -2194,23 +2194,6 @@ 'browser/ui/views/tab_icon_view.h', 'browser/ui/views/tab_modal_confirm_dialog_views.cc', 'browser/ui/views/tab_modal_confirm_dialog_views.h', - 'browser/ui/views/tabs/browser_tab_strip_controller.cc', - 'browser/ui/views/tabs/browser_tab_strip_controller.h', - 'browser/ui/views/tabs/media_indicator_button.cc', - 'browser/ui/views/tabs/media_indicator_button.h', - 'browser/ui/views/tabs/stacked_tab_strip_layout.cc', - 'browser/ui/views/tabs/stacked_tab_strip_layout.h', - 'browser/ui/views/tabs/tab.cc', - 'browser/ui/views/tabs/tab_controller.h', - 'browser/ui/views/tabs/tab_drag_controller.cc', - 'browser/ui/views/tabs/tab_drag_controller.h', - 'browser/ui/views/tabs/tab.h', - 'browser/ui/views/tabs/tab_strip.cc', - 'browser/ui/views/tabs/tab_strip_controller.h', - 'browser/ui/views/tabs/tab_strip.h', - 'browser/ui/views/tabs/window_finder_chromeos.cc', - 'browser/ui/views/tabs/window_finder.h', - 'browser/ui/views/tabs/window_finder_win.cc', 'browser/ui/views/theme_image_mapper.cc', 'browser/ui/views/theme_image_mapper.h', 'browser/ui/views/touch_uma/touch_uma.h', @@ -2248,6 +2231,24 @@ 'browser/ui/views/find_bar_host.h', 'browser/ui/views/find_bar_view.cc', 'browser/ui/views/find_bar_view.h', + 'browser/ui/views/tabs/browser_tab_strip_controller.cc', + 'browser/ui/views/tabs/browser_tab_strip_controller.h', + 'browser/ui/views/tabs/media_indicator_button.cc', + 'browser/ui/views/tabs/media_indicator_button.h', + 'browser/ui/views/tabs/stacked_tab_strip_layout.cc', + 'browser/ui/views/tabs/stacked_tab_strip_layout.h', + 'browser/ui/views/tabs/tab.cc', + 'browser/ui/views/tabs/tab_controller.h', + 'browser/ui/views/tabs/tab_drag_controller.cc', + 'browser/ui/views/tabs/tab_drag_controller.h', + 'browser/ui/views/tabs/tab.h', + 'browser/ui/views/tabs/tab_strip.cc', + 'browser/ui/views/tabs/tab_strip_controller.h', + 'browser/ui/views/tabs/tab_strip.h', + 'browser/ui/views/tabs/window_finder_chromeos.cc', + 'browser/ui/views/tabs/window_finder.h', + 'browser/ui/views/tabs/window_finder_mac.mm', + 'browser/ui/views/tabs/window_finder_win.cc', 'browser/ui/views/toolbar/back_button.cc', 'browser/ui/views/toolbar/back_button.h', 'browser/ui/views/toolbar/browser_actions_container.cc', -- 2.11.4.GIT