Commit 74c26c73 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS Shelf: Remove more code from the non-scrollable shelf

Bug: 1009638
Change-Id: I6c712d615a113686e137c240bf5435bd20828869
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2096565Reviewed-by: default avatarAndrew Xu <andrewxu@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748896}
parent c6fd7f2d
......@@ -39,10 +39,6 @@
namespace ash {
namespace {
bool IsScrollableShelfEnabled() {
return chromeos::switches::ShouldShowScrollableShelf();
}
// Custom window targeter for the hotseat. Used so the hotseat only processes
// events that land on the visible portion of the hotseat, and only while the
// hotseat is not animating.
......@@ -219,9 +215,6 @@ void HotseatWidget::DelegateView::Init(
ui::AnimationMetricsReporter* background_metrics_reporter) {
SetLayoutManager(std::make_unique<views::FillLayout>());
if (!chromeos::switches::ShouldShowScrollableShelf())
return;
WallpaperControllerImpl* wallpaper_controller =
Shell::Get()->wallpaper_controller();
OverviewController* overview_controller = Shell::Get()->overview_controller();
......@@ -317,9 +310,6 @@ bool HotseatWidget::DelegateView::CanActivate() const {
}
void HotseatWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) {
if (!chromeos::switches::ShouldShowScrollableShelf())
return;
views::View::ReorderChildLayers(parent_layer);
parent_layer->StackAtBottom(&translucent_background_);
}
......@@ -375,18 +365,9 @@ void HotseatWidget::Initialize(aura::Window* container, Shelf* shelf) {
set_focus_on_creation(false);
GetFocusManager()->set_arrow_key_traversal_enabled_for_widget(true);
if (IsScrollableShelfEnabled()) {
scrollable_shelf_view_ = GetContentsView()->AddChildView(
std::make_unique<ScrollableShelfView>(ShelfModel::Get(), shelf));
scrollable_shelf_view_->Init();
} else {
// The shelf view observes the shelf model and creates icons as items are
// added to the model.
shelf_view_ = GetContentsView()->AddChildView(std::make_unique<ShelfView>(
ShelfModel::Get(), shelf, /*drag_and_drop_host=*/nullptr,
/*shelf_button_delegate=*/nullptr));
shelf_view_->Init();
}
scrollable_shelf_view_ = GetContentsView()->AddChildView(
std::make_unique<ScrollableShelfView>(ShelfModel::Get(), shelf));
scrollable_shelf_view_->Init();
traslucent_background_metrics_reporter_ =
std::make_unique<HotseatWidgetBackgroundAnimationMetricsReporter>(
state());
......@@ -418,11 +399,7 @@ bool HotseatWidget::OnNativeWidgetActivationChanged(bool active) {
if (!Widget::OnNativeWidgetActivationChanged(active))
return false;
if (IsScrollableShelfEnabled())
scrollable_shelf_view_->OnFocusRingActivationChanged(active);
else if (active)
GetShelfView()->SetPaneFocusAndFocusDefault();
scrollable_shelf_view_->OnFocusRingActivationChanged(active);
return true;
}
......@@ -597,13 +574,8 @@ void HotseatWidget::SetFocusCycler(FocusCycler* focus_cycler) {
}
ShelfView* HotseatWidget::GetShelfView() {
if (IsScrollableShelfEnabled()) {
DCHECK(scrollable_shelf_view_);
return scrollable_shelf_view_->shelf_view();
}
DCHECK(shelf_view_);
return shelf_view_;
DCHECK(scrollable_shelf_view_);
return scrollable_shelf_view_->shelf_view();
}
int HotseatWidget::GetHotseatBackgroundBlurForTest() const {
......@@ -625,9 +597,6 @@ void HotseatWidget::SetState(HotseatState state) {
state_ = state;
if (!IsScrollableShelfEnabled())
return;
// If the hotseat is not extended we can use the normal targeting as the
// hidden parts of the hotseat will not block non-shelf items from taking
if (state == HotseatState::kExtended) {
......
......@@ -144,7 +144,6 @@ class ASH_EXPORT HotseatWidget : public ShelfComponent,
// View containing the shelf items within an active user session. Owned by
// the views hierarchy.
ShelfView* shelf_view_ = nullptr;
ScrollableShelfView* scrollable_shelf_view_ = nullptr;
// The contents view of this widget. Contains |shelf_view_| and the background
......
......@@ -1237,7 +1237,6 @@ void ScrollableShelfView::DestroyDragIconProxy() {
}
const bool drag_originated_from_app_list =
chromeos::switches::ShouldShowScrollableShelf() &&
shelf_view_->IsShelfViewHandlingDragAndDrop();
// The drag proxy is the DragImageView created for the DragAndDropHost which
......
......@@ -76,13 +76,8 @@ void ShelfFocusCycler::FocusShelf(bool last_element) {
Shell::Get()->focus_cycler()->FocusWidget(shelf_widget);
} else {
HotseatWidget* hotseat_widget = shelf_->hotseat_widget();
if (chromeos::switches::ShouldShowScrollableShelf()) {
hotseat_widget->scrollable_shelf_view()->set_default_last_focusable_child(
last_element);
} else {
hotseat_widget->GetShelfView()->set_default_last_focusable_child(
last_element);
}
hotseat_widget->scrollable_shelf_view()->set_default_last_focusable_child(
last_element);
Shell::Get()->focus_cycler()->FocusWidget(hotseat_widget);
}
}
......
This diff is collapsed.
......@@ -317,11 +317,6 @@ class ASH_EXPORT ShelfView : public views::AccessiblePaneView,
NOT_REMOVABLE, // Item is fixed and can never be removed.
};
struct AppCenteringStrategy {
bool center_on_screen = false;
bool overflow = false;
};
// Minimum distance before drag starts.
static const int kMinimumDragDistance;
......@@ -348,11 +343,6 @@ class ASH_EXPORT ShelfView : public views::AccessiblePaneView,
// or -1 if no separator is required.
int GetSeparatorIndex() const;
// This method determines which centering strategy is adequate, returns that,
// and sets the |first_visible_index_| and |last_visible_index_| fields
// appropriately.
AppCenteringStrategy CalculateAppCenteringStrategy();
// Sets the bounds of each view to its ideal bounds.
void LayoutToIdealBounds();
......
......@@ -302,25 +302,6 @@ TEST_F(ShelfObserverIconTest, AddRemoveWithMultipleDisplays) {
second_observer.Reset();
}
TEST_F(ShelfObserverIconTest, BoundsChanged) {
// When scrollable shelf enabled, the shelf view's bounds are calculated in
// scrollable shelf and may remain unchanged when shelf widget's bounds are
// changed.
// TODO(https://crbug.com/1002576): revisit when scrollable shelf is launched.
if (chromeos::switches::ShouldShowScrollableShelf())
return;
views::Widget* widget =
GetPrimaryShelf()->GetShelfViewForTesting()->GetWidget();
gfx::Rect shelf_bounds = widget->GetWindowBoundsInScreen();
shelf_bounds.set_width(shelf_bounds.width() / 2);
ASSERT_GT(shelf_bounds.width(), 0);
widget->SetBounds(shelf_bounds);
// No animation happens for ShelfView bounds change.
EXPECT_TRUE(observer()->icon_positions_changed());
observer()->Reset();
}
////////////////////////////////////////////////////////////////////////////////
// ShelfView tests.
......@@ -1195,49 +1176,6 @@ TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) {
shelf_view_->GetMirroredXInView(center_point.x()), center_point.y())));
}
// Test that by moving the mouse cursor off the button onto the bubble it closes
// the bubble.
TEST_P(HotseatShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) {
if (chromeos::switches::ShouldShowShelfHotseat() ||
chromeos::switches::ShouldShowScrollableShelf()) {
return;
}
ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager();
tooltip_manager->set_timer_delay_for_test(0);
ui::test::EventGenerator* generator = GetEventGenerator();
// Move the mouse off any item and check that no tooltip is shown.
generator->MoveMouseTo(gfx::Point(0, 0));
EXPECT_FALSE(tooltip_manager->IsVisible());
// Move the mouse over the button and check that it is visible.
views::View* button = shelf_view_->first_visible_button_for_testing();
gfx::Rect bounds = button->GetBoundsInScreen();
generator->MoveMouseTo(bounds.CenterPoint());
// Wait for the timer to go off.
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(tooltip_manager->IsVisible());
// Move the mouse cursor slightly to the right of the item. The tooltip should
// now close.
generator->MoveMouseBy(bounds.width() / 2 + 5, 0);
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tooltip_manager->IsVisible());
// Move back - it should appear again.
generator->MoveMouseBy(-(bounds.width() / 2 + 5), 0);
// Make sure there is no delayed close.
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(tooltip_manager->IsVisible());
// Now move the mouse cursor slightly above the item - so that it is over the
// tooltip bubble. Now it should disappear.
generator->MoveMouseBy(0, -(bounds.height() / 2 + 5));
// Wait until the delayed close kicked in.
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tooltip_manager->IsVisible());
}
// Checks the rip an item off from left aligned shelf in secondary monitor.
TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) {
UpdateDisplay("800x600,800x600");
......@@ -1362,14 +1300,12 @@ TEST_F(ShelfViewTest, TestShelfItemsAnimations) {
observer.Reset();
Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true);
test_api_->RunMessageLoopUntilAnimationsDone();
EXPECT_EQ((chromeos::switches::ShouldShowScrollableShelf() ? 1 : 100),
observer.icon_positions_animation_duration().InMilliseconds());
EXPECT_EQ(1, observer.icon_positions_animation_duration().InMilliseconds());
observer.Reset();
Shell::Get()->tablet_mode_controller()->SetEnabledForTest(false);
test_api_->RunMessageLoopUntilAnimationsDone();
EXPECT_EQ((chromeos::switches::ShouldShowScrollableShelf() ? 1 : 100),
observer.icon_positions_animation_duration().InMilliseconds());
EXPECT_EQ(1, observer.icon_positions_animation_duration().InMilliseconds());
// The shelf items should not animate if we are entering or exiting tablet
// mode, and the shelf alignment is not bottom aligned.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment