Skip to content

Commit

Permalink
Update shadow layer bounds when tab's layer bounds changes (uplift to…
Browse files Browse the repository at this point in the history
… 1.51.x) (#18140)

Uplift of #18111 (squashed) to beta
  • Loading branch information
brave-builds committed Apr 21, 2023
1 parent 8768697 commit fed077b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 14 additions & 8 deletions browser/ui/views/tabs/brave_tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ void BraveTab::UpdateIconVisibility() {
}
}

void BraveTab::OnLayerBoundsChanged(const gfx::Rect& old_bounds,
ui::PropertyChangeReason reason) {
Tab::OnLayerBoundsChanged(old_bounds, reason);

if (!base::FeatureList::IsEnabled(tabs::features::kBraveVerticalTabs)) {
return;
}

if (shadow_layer_ && shadow_layer_->parent() &&
shadow_layer_->parent() == layer()->parent()) {
LayoutShadowLayer();
}
}

void BraveTab::Layout() {
Tab::Layout();
if (IsAtMinWidthForVerticalTabStrip()) {
Expand Down Expand Up @@ -223,14 +237,6 @@ void BraveTab::ReorderChildLayers(ui::Layer* parent_layer) {
layer()->parent()->StackBelow(shadow_layer_.get(), layer());
}

void BraveTab::OnBoundsChanged(const gfx::Rect& previous_bounds) {
Tab::OnBoundsChanged(previous_bounds);

if (shadow_layer_ && shadow_layer_->parent()) {
LayoutShadowLayer();
}
}

void BraveTab::MaybeAdjustLeftForPinnedTab(gfx::Rect* bounds,
int visual_width) const {
if (!base::FeatureList::IsEnabled(tabs::features::kBraveVerticalTabs) ||
Expand Down
4 changes: 3 additions & 1 deletion browser/ui/views/tabs/brave_tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ class BraveTab : public Tab {
bool ShouldRenderAsNormalTab() const override;
void Layout() override;
void ReorderChildLayers(ui::Layer* parent_layer) override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
void MaybeAdjustLeftForPinnedTab(gfx::Rect* bounds,
int visual_width) const override;

void OnLayerBoundsChanged(const gfx::Rect& old_bounds,
ui::PropertyChangeReason reason) override;

private:
bool IsAtMinWidthForVerticalTabStrip() const;

Expand Down

0 comments on commit fed077b

Please sign in to comment.