Commit 629a2eb2 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Remove redundant layer transforms code from system tray

The implementation to use layer transforms to resize the bubble
is no longer used due to recent optimizations. Removing this code
and the extra view containers that were required for it.

Bug: 1024530
Change-Id: I71e5cecbc51011b16c0b7d0da09464ea4562eacd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2318693
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791989}
parent 46e8cdd2
...@@ -50,10 +50,7 @@ class ContainerView : public views::View { ...@@ -50,10 +50,7 @@ class ContainerView : public views::View {
// Note that transforms are currently only supported when there are not // Note that transforms are currently only supported when there are not
// notifications, so we only consider the system tray height (excluding the // notifications, so we only consider the system tray height (excluding the
// message center) for now. // message center) for now.
return gfx::Size(kTrayMenuWidth, return gfx::Size(kTrayMenuWidth, unified_view_->GetCurrentHeight());
unified_view_->IsTransformEnabled()
? unified_view_->GetExpandedSystemTrayHeight()
: unified_view_->GetCurrentHeight());
} }
void ChildPreferredSizeChanged(views::View* child) override { void ChildPreferredSizeChanged(views::View* child) override {
...@@ -101,7 +98,7 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray, ...@@ -101,7 +98,7 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray,
unified_view_->SetMaxHeight(max_height); unified_view_->SetMaxHeight(max_height);
bubble_view_->SetMaxHeight(max_height); bubble_view_->SetMaxHeight(max_height);
controller_->ResetToCollapsedIfRequired(); controller_->ResetToCollapsedIfRequired();
bubble_view_->AddChildView(new ContainerView(unified_view_)); bubble_view_->AddChildView(unified_view_);
bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_view_); bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_view_);
bubble_widget_->AddObserver(this); bubble_widget_->AddObserver(this);
...@@ -221,36 +218,6 @@ void UnifiedSystemTrayBubble::UpdateBubble() { ...@@ -221,36 +218,6 @@ void UnifiedSystemTrayBubble::UpdateBubble() {
bubble_view_->UpdateBubble(); bubble_view_->UpdateBubble();
} }
void UnifiedSystemTrayBubble::UpdateTransform() {
if (!bubble_widget_)
return;
DCHECK(unified_view_);
if (!unified_view_->IsTransformEnabled()) {
unified_view_->SetTransform(gfx::Transform());
OnAnimationFinished();
SetFrameVisible(true);
return;
}
SetFrameVisible(false);
// Note: currently transforms are only enabled when there are no
// notifications, so we can consider only the system tray height (excluding
// the message center) for now.
const int y_offset = unified_view_->GetExpandedSystemTrayHeight() -
unified_view_->GetCurrentHeight();
gfx::Transform transform;
transform.Translate(0, y_offset);
unified_view_->SetTransform(transform);
gfx::Rect blur_bounds = bubble_view_->bounds();
blur_bounds.Inset(gfx::Insets(y_offset, 0, 0, 0));
bubble_view_->layer()->SetClipRect(blur_bounds);
}
TrayBackgroundView* UnifiedSystemTrayBubble::GetTray() const { TrayBackgroundView* UnifiedSystemTrayBubble::GetTray() const {
return tray_; return tray_;
} }
......
...@@ -82,12 +82,6 @@ class ASH_EXPORT UnifiedSystemTrayBubble ...@@ -82,12 +82,6 @@ class ASH_EXPORT UnifiedSystemTrayBubble
// Update bubble bounds and focus if necessary. // Update bubble bounds and focus if necessary.
void UpdateBubble(); void UpdateBubble();
// Update layer transform during expand / collapse animation. During
// animation, the height of the view changes, but resizing of the bubble is
// performance bottleneck. This method makes use of layer transform to avoid
// resizing of the bubble during animation.
void UpdateTransform();
// Return the maximum height available for both the system tray and // Return the maximum height available for both the system tray and
// the message center. // the message center.
int CalculateMaxHeight() const; int CalculateMaxHeight() const;
......
...@@ -204,11 +204,6 @@ void UnifiedSystemTrayController::ToggleExpanded() { ...@@ -204,11 +204,6 @@ void UnifiedSystemTrayController::ToggleExpanded() {
} }
} }
void UnifiedSystemTrayController::OnMessageCenterVisibilityUpdated() {
if (bubble_)
bubble_->UpdateTransform();
}
void UnifiedSystemTrayController::BeginDrag(const gfx::PointF& location) { void UnifiedSystemTrayController::BeginDrag(const gfx::PointF& location) {
UpdateDragThreshold(); UpdateDragThreshold();
// Ignore swipe collapsing when a detailed view is shown as it's confusing. // Ignore swipe collapsing when a detailed view is shown as it's confusing.
...@@ -468,9 +463,7 @@ void UnifiedSystemTrayController::ShowDetailedView( ...@@ -468,9 +463,7 @@ void UnifiedSystemTrayController::ShowDetailedView(
void UnifiedSystemTrayController::UpdateExpandedAmount() { void UnifiedSystemTrayController::UpdateExpandedAmount() {
double expanded_amount = animation_->GetCurrentValue(); double expanded_amount = animation_->GetCurrentValue();
unified_view_->SetExpandedAmount(expanded_amount); unified_view_->SetExpandedAmount(expanded_amount);
// Can be null in unit tests.
if (bubble_)
bubble_->UpdateTransform();
if (expanded_amount == 0.0 || expanded_amount == 1.0) if (expanded_amount == 0.0 || expanded_amount == 1.0)
model_->set_expanded_on_open( model_->set_expanded_on_open(
expanded_amount == 1.0 expanded_amount == 1.0
......
...@@ -59,9 +59,6 @@ class ASH_EXPORT UnifiedSystemTrayController ...@@ -59,9 +59,6 @@ class ASH_EXPORT UnifiedSystemTrayController
void HandleEnterpriseInfoAction(); void HandleEnterpriseInfoAction();
// Toggle expanded state of UnifiedSystemTrayView. Called from the view. // Toggle expanded state of UnifiedSystemTrayView. Called from the view.
void ToggleExpanded(); void ToggleExpanded();
// Called when message center visibility is changed. Called from the
// view.
void OnMessageCenterVisibilityUpdated();
// Handle finger dragging and expand/collapse the view. Called from view. // Handle finger dragging and expand/collapse the view. Called from view.
void BeginDrag(const gfx::PointF& location); void BeginDrag(const gfx::PointF& location);
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/focus/focus_search.h" #include "ui/views/focus/focus_search.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/painter.h" #include "ui/views/painter.h"
namespace ash { namespace ash {
...@@ -219,7 +218,6 @@ UnifiedSystemTrayView::UnifiedSystemTrayView( ...@@ -219,7 +218,6 @@ UnifiedSystemTrayView::UnifiedSystemTrayView(
std::make_unique<InteractedByTapRecorder>(this)) { std::make_unique<InteractedByTapRecorder>(this)) {
DCHECK(controller_); DCHECK(controller_);
SetLayoutManager(std::make_unique<views::FillLayout>());
auto add_layered_child = [](views::View* parent, views::View* child) { auto add_layered_child = [](views::View* parent, views::View* child) {
parent->AddChildView(child); parent->AddChildView(child);
child->SetPaintToLayer(); child->SetPaintToLayer();
...@@ -333,18 +331,9 @@ void UnifiedSystemTrayView::SetExpandedAmount(double expanded_amount) { ...@@ -333,18 +331,9 @@ void UnifiedSystemTrayView::SetExpandedAmount(double expanded_amount) {
page_indicator_view_->SetExpandedAmount(expanded_amount); page_indicator_view_->SetExpandedAmount(expanded_amount);
sliders_container_->SetExpandedAmount(expanded_amount); sliders_container_->SetExpandedAmount(expanded_amount);
if (!IsTransformEnabled()) { PreferredSizeChanged();
PreferredSizeChanged(); // It is possible that the ratio between |message_center_view_| and others
// It is possible that the ratio between |message_center_view_| and others // can change while the bubble size remain unchanged.
// can change while the bubble size remain unchanged.
Layout();
return;
}
// Note: currently transforms are only enabled when there are no
// notifications, so we can consider only the system tray height.
if (height() != GetExpandedSystemTrayHeight())
PreferredSizeChanged();
Layout(); Layout();
} }
...@@ -380,14 +369,6 @@ int UnifiedSystemTrayView::GetCurrentHeight() const { ...@@ -380,14 +369,6 @@ int UnifiedSystemTrayView::GetCurrentHeight() const {
return GetPreferredSize().height(); return GetPreferredSize().height();
} }
bool UnifiedSystemTrayView::IsTransformEnabled() const {
// TODO(amehfooz): Remove transform code completely, the code does not work
// and isn't needed after Oshima's performance improvement changes for the
// tray.
return false;
}
int UnifiedSystemTrayView::GetVisibleFeaturePodCount() const { int UnifiedSystemTrayView::GetVisibleFeaturePodCount() const {
return feature_pods_container_->GetVisibleCount(); return feature_pods_container_->GetVisibleCount();
} }
...@@ -461,10 +442,11 @@ void UnifiedSystemTrayView::OnGestureEvent(ui::GestureEvent* event) { ...@@ -461,10 +442,11 @@ void UnifiedSystemTrayView::OnGestureEvent(ui::GestureEvent* event) {
} }
} }
void UnifiedSystemTrayView::ChildPreferredSizeChanged(views::View* child) { void UnifiedSystemTrayView::Layout() {
// The size change is not caused by SetExpandedAmount(), because they don't if (system_tray_container_->GetVisible())
// trigger PreferredSizeChanged(). system_tray_container_->SetBoundsRect(GetContentsBounds());
PreferredSizeChanged(); else if (detailed_view_container_->GetVisible())
detailed_view_container_->SetBoundsRect(GetContentsBounds());
} }
const char* UnifiedSystemTrayView::GetClassName() const { const char* UnifiedSystemTrayView::GetClassName() const {
......
...@@ -122,12 +122,6 @@ class ASH_EXPORT UnifiedSystemTrayView : public views::View, ...@@ -122,12 +122,6 @@ class ASH_EXPORT UnifiedSystemTrayView : public views::View,
// Get current height of the view (including the message center). // Get current height of the view (including the message center).
int GetCurrentHeight() const; int GetCurrentHeight() const;
// Return true if layer transform can be used against the view. During
// animation, the height of the view changes, but resizing of the bubble
// is performance bottleneck. If this method returns true, the embedder can
// call SetTransform() to move this view in order to avoid resizing.
bool IsTransformEnabled() const;
// Returns the number of visible feature pods. // Returns the number of visible feature pods.
int GetVisibleFeaturePodCount() const; int GetVisibleFeaturePodCount() const;
...@@ -141,7 +135,7 @@ class ASH_EXPORT UnifiedSystemTrayView : public views::View, ...@@ -141,7 +135,7 @@ class ASH_EXPORT UnifiedSystemTrayView : public views::View,
// views::View: // views::View:
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void OnGestureEvent(ui::GestureEvent* event) override; void OnGestureEvent(ui::GestureEvent* event) override;
void ChildPreferredSizeChanged(views::View* child) override; void Layout() override;
const char* GetClassName() const override; const char* GetClassName() const override;
views::FocusTraversable* GetFocusTraversable() override; views::FocusTraversable* GetFocusTraversable() override;
void AddedToWidget() override; void AddedToWidget() override;
......
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