Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1088)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 2899133004: Reduce overdraw on bookmark bar (Closed)
Patch Set: Reduce overdraw on bookmark bar Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 browser_(browser), 594 browser_(browser),
595 browser_view_(browser_view), 595 browser_view_(browser_view),
596 infobar_visible_(false), 596 infobar_visible_(false),
597 size_animation_(this), 597 size_animation_(this),
598 throbbing_view_(nullptr), 598 throbbing_view_(nullptr),
599 bookmark_bar_state_(BookmarkBar::SHOW), 599 bookmark_bar_state_(BookmarkBar::SHOW),
600 animating_detached_(false), 600 animating_detached_(false),
601 show_folder_method_factory_(this) { 601 show_folder_method_factory_(this) {
602 set_id(VIEW_ID_BOOKMARK_BAR); 602 set_id(VIEW_ID_BOOKMARK_BAR);
603 Init(); 603 Init();
604
605 // Don't let the bookmarks show on top of the location bar while animating.
606 SetPaintToLayer();
607 layer()->SetMasksToBounds(true);
608 layer()->SetFillsBoundsOpaquely(false);
609
610 size_animation_.Reset(1); 604 size_animation_.Reset(1);
611 } 605 }
612 606
613 BookmarkBarView::~BookmarkBarView() { 607 BookmarkBarView::~BookmarkBarView() {
614 if (model_) 608 if (model_)
615 model_->RemoveObserver(this); 609 model_->RemoveObserver(this);
616 610
617 // It's possible for the menu to outlive us, reset the observer to make sure 611 // It's possible for the menu to outlive us, reset the observer to make sure
618 // it doesn't have a reference to us. 612 // it doesn't have a reference to us.
619 if (bookmark_menu_) { 613 if (bookmark_menu_) {
(...skipping 26 matching lines...) Expand all
646 bookmark_menu_->SetPageNavigator(navigator); 640 bookmark_menu_->SetPageNavigator(navigator);
647 if (context_menu_.get()) 641 if (context_menu_.get())
648 context_menu_->SetPageNavigator(navigator); 642 context_menu_->SetPageNavigator(navigator);
649 } 643 }
650 644
651 void BookmarkBarView::SetBookmarkBarState( 645 void BookmarkBarView::SetBookmarkBarState(
652 BookmarkBar::State state, 646 BookmarkBar::State state,
653 BookmarkBar::AnimateChangeType animate_type) { 647 BookmarkBar::AnimateChangeType animate_type) {
654 if (animate_type == BookmarkBar::ANIMATE_STATE_CHANGE && 648 if (animate_type == BookmarkBar::ANIMATE_STATE_CHANGE &&
655 animations_enabled) { 649 animations_enabled) {
650 if (!layer()) {
651 SetPaintToLayer();
652 layer()->SetMasksToBounds(true);
653 layer()->SetFillsBoundsOpaquely(false);
654 }
656 animating_detached_ = (state == BookmarkBar::DETACHED || 655 animating_detached_ = (state == BookmarkBar::DETACHED ||
657 bookmark_bar_state_ == BookmarkBar::DETACHED); 656 bookmark_bar_state_ == BookmarkBar::DETACHED);
658 if (state == BookmarkBar::SHOW) 657 if (state == BookmarkBar::SHOW)
659 size_animation_.Show(); 658 size_animation_.Show();
660 else 659 else
661 size_animation_.Hide(); 660 size_animation_.Hide();
661 if (layer())
662 DestroyLayer();
Evan Stade 2017/05/24 17:34:30 I am surprised this works. You're destroying the l
sky 2017/05/24 21:32:05 I think it would be better to key off whether any
662 } else { 663 } else {
663 size_animation_.Reset(state == BookmarkBar::SHOW ? 1 : 0); 664 size_animation_.Reset(state == BookmarkBar::SHOW ? 1 : 0);
664 } 665 }
665 bookmark_bar_state_ = state; 666 bookmark_bar_state_ = state;
666 } 667 }
667 668
668 const BookmarkNode* BookmarkBarView::GetNodeForButtonAtModelIndex( 669 const BookmarkNode* BookmarkBarView::GetNodeForButtonAtModelIndex(
669 const gfx::Point& loc, 670 const gfx::Point& loc,
670 int* model_start_index) { 671 int* model_start_index) {
671 *model_start_index = 0; 672 *model_start_index = 0;
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 return; 2166 return;
2166 apps_page_shortcut_->SetVisible(visible); 2167 apps_page_shortcut_->SetVisible(visible);
2167 UpdateBookmarksSeparatorVisibility(); 2168 UpdateBookmarksSeparatorVisibility();
2168 LayoutAndPaint(); 2169 LayoutAndPaint();
2169 } 2170 }
2170 2171
2171 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2172 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2172 if (UpdateOtherAndManagedButtonsVisibility()) 2173 if (UpdateOtherAndManagedButtonsVisibility())
2173 LayoutAndPaint(); 2174 LayoutAndPaint();
2174 } 2175 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698