Skip to content

Commit

Permalink
ash: Clean up classic-view tablet tab dragging feature - part 4
Browse files Browse the repository at this point in the history
In this CL:
- TabletModeBrowserWindowDragSessionWindowsHider is moved from
  ash/wm/tablet_mode to ash/drag_drop and renamed to
  TabDragDropWindowsHider since it's now only used by the webui tab drag
  code.
- Clean up the unused parameter of DropTargetView
- Remove the unused vector icon

Bug: b/270442617
Change-Id: Idf0a0607aadca17ba749eab78c6d4e86f5f70783
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288655
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1118857}
  • Loading branch information
Xiaoqian Dai authored and Chromium LUCI CQ committed Mar 17, 2023
1 parent 5092586 commit ce2f784
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 259 deletions.
8 changes: 3 additions & 5 deletions ash/BUILD.gn
Expand Up @@ -527,6 +527,8 @@ component("ash") {
"drag_drop/scoped_drag_drop_observer.h",
"drag_drop/tab_drag_drop_delegate.cc",
"drag_drop/tab_drag_drop_delegate.h",
"drag_drop/tab_drag_drop_windows_hider.cc",
"drag_drop/tab_drag_drop_windows_hider.h",
"drag_drop/toplevel_window_drag_delegate.h",
"events/accessibility_event_rewriter.cc",
"events/accessibility_event_rewriter.h",
Expand Down Expand Up @@ -2287,8 +2289,6 @@ component("ash") {
"wm/overview/delayed_animation_observer.h",
"wm/overview/delayed_animation_observer_impl.cc",
"wm/overview/delayed_animation_observer_impl.h",
"wm/overview/drop_target_view.cc",
"wm/overview/drop_target_view.h",
"wm/overview/overview_animation_state_waiter.cc",
"wm/overview/overview_animation_state_waiter.h",
"wm/overview/overview_constants.h",
Expand Down Expand Up @@ -2390,8 +2390,6 @@ component("ash") {
"wm/tablet_mode/internal_input_devices_event_blocker.h",
"wm/tablet_mode/scoped_skip_user_session_blocked_check.cc",
"wm/tablet_mode/scoped_skip_user_session_blocked_check.h",
"wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.cc",
"wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h",
"wm/tablet_mode/tablet_mode_controller.cc",
"wm/tablet_mode/tablet_mode_controller.h",
"wm/tablet_mode/tablet_mode_multitask_cue.cc",
Expand Down Expand Up @@ -2945,6 +2943,7 @@ test("ash_unittests") {
"drag_drop/drag_drop_unittest.cc",
"drag_drop/drag_image_view_unittest.cc",
"drag_drop/tab_drag_drop_delegate_unittest.cc",
"drag_drop/tab_drag_drop_windows_hider_unittest.cc",
"events/accessibility_event_rewriter_unittest.cc",
"events/keyboard_capability_unittest.cc",
"events/keyboard_driven_event_rewriter_unittest.cc",
Expand Down Expand Up @@ -3419,7 +3418,6 @@ test("ash_unittests") {
"wm/system_gesture_event_filter_unittest.cc",
"wm/system_modal_container_layout_manager_unittest.cc",
"wm/tablet_mode/accelerometer_test_data_literals.cc",
"wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider_unittest.cc",
"wm/tablet_mode/tablet_mode_controller_unittest.cc",
"wm/tablet_mode/tablet_mode_multitask_cue_unittest.cc",
"wm/tablet_mode/tablet_mode_multitask_menu_event_handler_unittest.cc",
Expand Down
6 changes: 2 additions & 4 deletions ash/drag_drop/tab_drag_drop_delegate.cc
Expand Up @@ -6,6 +6,7 @@

#include "ash/constants/app_types.h"
#include "ash/constants/ash_features.h"
#include "ash/drag_drop/tab_drag_drop_windows_hider.h"
#include "ash/public/cpp/new_window_delegate.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/screen_util.h"
Expand All @@ -17,7 +18,6 @@
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/splitview/split_view_drag_indicators.h"
#include "ash/wm/splitview/split_view_utils.h"
#include "ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h"
#include "ash/wm/wm_metrics.h"
#include "base/pickle.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -300,9 +300,7 @@ void TabDragDropDelegate::UpdateSourceWindowBoundsIfNecessary(
return;

if (!windows_hider_) {
windows_hider_ =
std::make_unique<TabletModeBrowserWindowDragSessionWindowsHider>(
source_window_, nullptr);
windows_hider_ = std::make_unique<TabDragDropWindowsHider>(source_window_);
}

gfx::Rect new_source_window_bounds;
Expand Down
8 changes: 4 additions & 4 deletions ash/drag_drop/tab_drag_drop_delegate.h
Expand Up @@ -9,6 +9,7 @@

#include "ash/ash_export.h"
#include "ash/drag_drop/drag_drop_capture_delegate.h"
#include "ash/drag_drop/tab_drag_drop_windows_hider.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ui/aura/window_observer.h"
#include "ui/gfx/geometry/point.h"
Expand All @@ -20,12 +21,12 @@ class Window;
namespace ui {
class OSExchangeData;
class PresentationTimeRecorder;
}
} // namespace ui

namespace ash {

class SplitViewDragIndicators;
class TabletModeBrowserWindowDragSessionWindowsHider;
class TabDragDropWindowsHider;

// Provides special handling for Chrome tab drags on behalf of
// DragDropController. This must be created at the beginning of a tab drag and
Expand Down Expand Up @@ -105,8 +106,7 @@ class ASH_EXPORT TabDragDropDelegate : public DragDropCaptureDelegate,
const gfx::Point start_location_in_screen_;

std::unique_ptr<SplitViewDragIndicators> split_view_drag_indicators_;
std::unique_ptr<TabletModeBrowserWindowDragSessionWindowsHider>
windows_hider_;
std::unique_ptr<TabDragDropWindowsHider> windows_hider_;

// Presentation time recorder for tab dragging in tablet mode with webui
// tab strip enable.
Expand Down
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h"
#include "ash/drag_drop/tab_drag_drop_windows_hider.h"

#include <vector>

Expand All @@ -21,15 +21,9 @@

namespace ash {

TabletModeBrowserWindowDragSessionWindowsHider::
TabletModeBrowserWindowDragSessionWindowsHider(aura::Window* source_window,
aura::Window* dragged_window)
: source_window_(source_window), dragged_window_(dragged_window) {
TabDragDropWindowsHider::TabDragDropWindowsHider(aura::Window* source_window)
: source_window_(source_window) {
DCHECK(source_window_);
if (dragged_window_) {
DCHECK_EQ(source_window_,
dragged_window_->GetProperty(kTabDraggingSourceWindowKey));
}

root_window_ = source_window_->GetRootWindow();

Expand All @@ -41,8 +35,7 @@ TabletModeBrowserWindowDragSessionWindowsHider::
std::vector<aura::Window*> windows =
Shell::Get()->mru_window_tracker()->BuildMruWindowList(kActiveDesk);
for (aura::Window* window : windows) {
if (window == dragged_window_ || window == source_window_ ||
window->GetRootWindow() != root_window_) {
if (window == source_window_ || window->GetRootWindow() != root_window_) {
continue;
}

Expand All @@ -63,11 +56,11 @@ TabletModeBrowserWindowDragSessionWindowsHider::
->SetWallpaperBlur(wallpaper_constants::kOverviewBlur);
}

TabletModeBrowserWindowDragSessionWindowsHider::
~TabletModeBrowserWindowDragSessionWindowsHider() {
TabDragDropWindowsHider::~TabDragDropWindowsHider() {
// It might be possible that |source_window_| is destroyed during dragging.
if (source_window_)
if (source_window_) {
WindowBackdrop::Get(source_window_)->RestoreBackdrop();
}

for (auto iter = window_visibility_map_.begin();
iter != window_visibility_map_.end(); ++iter) {
Expand All @@ -90,8 +83,7 @@ TabletModeBrowserWindowDragSessionWindowsHider::
->SetWallpaperBlur(wallpaper_constants::kClear);
}

void TabletModeBrowserWindowDragSessionWindowsHider::OnWindowDestroying(
aura::Window* window) {
void TabDragDropWindowsHider::OnWindowDestroying(aura::Window* window) {
if (window == source_window_) {
source_window_ = nullptr;
return;
Expand All @@ -100,13 +92,13 @@ void TabletModeBrowserWindowDragSessionWindowsHider::OnWindowDestroying(
window->RemoveObserver(this);
window_visibility_map_.erase(window);
}
void TabletModeBrowserWindowDragSessionWindowsHider::OnWindowVisibilityChanged(
aura::Window* window,
bool visible) {
void TabDragDropWindowsHider::OnWindowVisibilityChanged(aura::Window* window,
bool visible) {
// The window object is not necessarily the one that is being observed.
// So we only take action if the window is currently being observed.
if (window_visibility_map_.count(window) == 0)
if (window_visibility_map_.count(window) == 0) {
return;
}

if (visible) {
// Do not let |window| change to visible during the lifetime of |this|.
Expand All @@ -119,8 +111,7 @@ void TabletModeBrowserWindowDragSessionWindowsHider::OnWindowVisibilityChanged(
// ignored.
}

int TabletModeBrowserWindowDragSessionWindowsHider::
GetWindowVisibilityMapSizeForTesting() const {
int TabDragDropWindowsHider::GetWindowVisibilityMapSizeForTesting() const {
return window_visibility_map_.size();
}

Expand Down
52 changes: 52 additions & 0 deletions ash/drag_drop/tab_drag_drop_windows_hider.h
@@ -0,0 +1,52 @@
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_DRAG_DROP_TAB_DRAG_DROP_WINDOWS_HIDER_H_
#define ASH_DRAG_DROP_TAB_DRAG_DROP_WINDOWS_HIDER_H_

#include <map>

#include "ash/ash_export.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"

namespace ash {

// Hides all visible windows except the source window from which the webui tab
// drag originates, and restores the windows' visibility upon its destruction.
// It also blurs and darkens the background, hides the home launcher if home
// launcher is enabled. Only need to do so if we need to scale up and down the
// source window when dragging a web ui tab out of it.
class ASH_EXPORT TabDragDropWindowsHider : public aura::WindowObserver {
public:
explicit TabDragDropWindowsHider(aura::Window* source_window);

TabDragDropWindowsHider(const TabDragDropWindowsHider&) = delete;
TabDragDropWindowsHider& operator=(const TabDragDropWindowsHider&) = delete;

~TabDragDropWindowsHider() override;

// aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override;
void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;

int GetWindowVisibilityMapSizeForTesting() const;

private:
// The window from which the drag originated.
aura::Window* source_window_;

// The root window the drag is taking place within. Guaranteed to be
// non-null during the lifetime of |this|.
aura::Window* root_window_;

// Maintains the map between windows and their visibilities. All windows
// except the dragged window and the source window should stay hidden during
// dragging.
std::map<aura::Window*, bool> window_visibility_map_;
};

} // namespace ash

#endif // ASH_DRAG_DROP_TAB_DRAG_DROP_WINDOWS_HIDER_H_
Expand Up @@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h"
#include "ash/drag_drop/tab_drag_drop_windows_hider.h"

#include "ash/test/ash_test_base.h"

namespace ash {

class TabletModeBrowserWindowDragSessionWindowsHiderTest : public AshTestBase {
class TabDragDropWindowsHiderTest : public AshTestBase {
public:
// AshTestBase:
void SetUp() override {
Expand All @@ -26,16 +26,14 @@ class TabletModeBrowserWindowDragSessionWindowsHiderTest : public AshTestBase {
};

// Test for crbug.com/1330038 .
TEST_F(TabletModeBrowserWindowDragSessionWindowsHiderTest,
WindowVisibilityChangedDuringDrag) {
TEST_F(TabDragDropWindowsHiderTest, WindowVisibilityChangedDuringDrag) {
std::unique_ptr<aura::Window> source_window = CreateToplevelTestWindow();

// Create a sub window and hide it.
std::unique_ptr<aura::Window> sub_window = CreateTestWindow();
dummy_window_->AddChild(sub_window.get());
sub_window->Hide();
auto hider = std::make_unique<TabletModeBrowserWindowDragSessionWindowsHider>(
source_window.get(), nullptr);
auto hider = std::make_unique<TabDragDropWindowsHider>(source_window.get());
int size = hider->GetWindowVisibilityMapSizeForTesting();

// Show the sub window. Make sure the window observer list size remains the
Expand Down
1 change: 0 additions & 1 deletion ash/resources/vector_icons/BUILD.gn
Expand Up @@ -222,7 +222,6 @@ aggregate_vector_icons("ash_vector_icons") {
"notification_timer.icon",
"overflow_shelf_left.icon",
"overflow_shelf_right.icon",
"overview_drop_target_plus.icon",
"overview_window_close.icon",
"paint_brush.icon",
"palette_action_create_note.icon",
Expand Down
19 changes: 0 additions & 19 deletions ash/resources/vector_icons/overview_drop_target_plus.icon

This file was deleted.

89 changes: 0 additions & 89 deletions ash/wm/overview/drop_target_view.cc

This file was deleted.

0 comments on commit ce2f784

Please sign in to comment.