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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container.cc

Issue 399173004: Adjust BrowserActionsContainer drag and drop to work for overflow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finnurs + RTL fix Created 6 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/toolbar/browser_actions_container.h" 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return border.Pass(); 93 return border.Pass();
94 } 94 }
95 95
96 private: 96 private:
97 DISALLOW_COPY_AND_ASSIGN(ChevronMenuButton); 97 DISALLOW_COPY_AND_ASSIGN(ChevronMenuButton);
98 }; 98 };
99 99
100 } // namespace 100 } // namespace
101 101
102 // static 102 // static
103 bool BrowserActionsContainer::disable_animations_during_testing_ = false; 103 bool BrowserActionsContainer::disable_animations_during_testing_ = false;
Peter Kasting 2014/07/21 20:24:08 Nit: Put this below the "BrowserActionsContainer"
Devlin 2014/07/22 17:30:46 Done.
104 104
105 struct BrowserActionsContainer::DropPosition {
Peter Kasting 2014/07/21 20:24:08 Nit: Consider a "// BrowserActionsContainer::DropP
Devlin 2014/07/22 17:30:46 SGTM. Done.
106 DropPosition(size_t row, size_t icon_in_row);
107 ~DropPosition();
Peter Kasting 2014/07/21 20:24:08 Nit: Is declaring this destructor necessary?
Devlin 2014/07/22 17:30:47 For some reason, I thought it was chrome/google st
108
109 // The (0-indexed) row into which the action will be dropped.
110 size_t row;
111
112 // The (0-indexed) icon in the row before the action will be dropped.
113 size_t icon_in_row;
114 };
115
116 BrowserActionsContainer::DropPosition::DropPosition(
117 size_t row, size_t icon_in_row)
118 : row(row), icon_in_row(icon_in_row) {
119 }
120
121 BrowserActionsContainer::DropPosition::~DropPosition() {
122 }
123
105 //////////////////////////////////////////////////////////////////////////////// 124 ////////////////////////////////////////////////////////////////////////////////
106 // BrowserActionsContainer 125 // BrowserActionsContainer
107 126
108 BrowserActionsContainer::BrowserActionsContainer( 127 BrowserActionsContainer::BrowserActionsContainer(
109 Browser* browser, 128 Browser* browser,
110 View* owner_view, 129 View* owner_view,
111 BrowserActionsContainer* main_container) 130 BrowserActionsContainer* main_container)
112 : profile_(browser->profile()), 131 : profile_(browser->profile()),
113 browser_(browser), 132 browser_(browser),
114 owner_view_(owner_view), 133 owner_view_(owner_view),
115 main_container_(main_container), 134 main_container_(main_container),
116 popup_(NULL), 135 popup_(NULL),
117 popup_button_(NULL), 136 popup_button_(NULL),
118 model_(NULL), 137 model_(NULL),
119 container_width_(0), 138 container_width_(0),
120 resize_area_(NULL), 139 resize_area_(NULL),
121 chevron_(NULL), 140 chevron_(NULL),
122 overflow_menu_(NULL), 141 overflow_menu_(NULL),
123 suppress_chevron_(false), 142 suppress_chevron_(false),
124 resize_amount_(0), 143 resize_amount_(0),
125 animation_target_size_(0), 144 animation_target_size_(0),
126 drop_indicator_position_(-1),
127 task_factory_(this), 145 task_factory_(this),
128 show_menu_task_factory_(this) { 146 show_menu_task_factory_(this) {
129 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR); 147 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR);
130 148
131 model_ = extensions::ExtensionToolbarModel::Get(browser->profile()); 149 model_ = extensions::ExtensionToolbarModel::Get(browser->profile());
132 if (model_) 150 if (model_)
133 model_->AddObserver(this); 151 model_->AddObserver(this);
134 152
135 bool overflow_experiment = 153 bool overflow_experiment =
136 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled(); 154 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // Ensure that any browser actions shown in the main view are hidden in 370 // Ensure that any browser actions shown in the main view are hidden in
353 // the overflow view. 371 // the overflow view.
354 browser_action_views_[i]->SetVisible(false); 372 browser_action_views_[i]->SetVisible(false);
355 } 373 }
356 374
357 for (size_t i = main_container_->VisibleBrowserActionsAfterAnimation(); 375 for (size_t i = main_container_->VisibleBrowserActionsAfterAnimation();
358 i < browser_action_views_.size(); ++i) { 376 i < browser_action_views_.size(); ++i) {
359 BrowserActionView* view = browser_action_views_[i]; 377 BrowserActionView* view = browser_action_views_[i];
360 size_t index = i - main_container_->VisibleBrowserActionsAfterAnimation(); 378 size_t index = i - main_container_->VisibleBrowserActionsAfterAnimation();
361 int row_index = static_cast<int>(index) / kIconsPerMenuRow; 379 int row_index = static_cast<int>(index) / kIconsPerMenuRow;
362 int x = (index * IconWidth(true)) - 380 int x = kItemSpacing + (index * IconWidth(true)) -
Peter Kasting 2014/07/21 20:24:08 So, we have kItemSpacing to the left of all the ic
Devlin 2014/07/22 17:30:46 We do have it between each pair of icons, but Icon
363 (row_index * IconWidth(true) * kIconsPerMenuRow); 381 (row_index * IconWidth(true) * kIconsPerMenuRow);
364 gfx::Rect rect_bounds( 382 gfx::Rect rect_bounds(
365 x, IconHeight() * row_index, icon_width, IconHeight()); 383 x, IconHeight() * row_index, icon_width, IconHeight());
366 view->SetBoundsRect(rect_bounds); 384 view->SetBoundsRect(rect_bounds);
367 view->SetVisible(true); 385 view->SetVisible(true);
368 } 386 }
369 } else { 387 } else {
370 for (BrowserActionViews::const_iterator it = browser_action_views_.begin(); 388 for (BrowserActionViews::const_iterator it = browser_action_views_.begin();
371 it < browser_action_views_.end(); ++it) { 389 it < browser_action_views_.end(); ++it) {
372 BrowserActionView* view = *it; 390 BrowserActionView* view = *it;
(...skipping 27 matching lines...) Expand all
400 int BrowserActionsContainer::OnDragUpdated( 418 int BrowserActionsContainer::OnDragUpdated(
401 const ui::DropTargetEvent& event) { 419 const ui::DropTargetEvent& event) {
402 // First check if we are above the chevron (overflow) menu. 420 // First check if we are above the chevron (overflow) menu.
403 if (GetEventHandlerForPoint(event.location()) == chevron_) { 421 if (GetEventHandlerForPoint(event.location()) == chevron_) {
404 if (!show_menu_task_factory_.HasWeakPtrs() && !overflow_menu_) 422 if (!show_menu_task_factory_.HasWeakPtrs() && !overflow_menu_)
405 StartShowFolderDropMenuTimer(); 423 StartShowFolderDropMenuTimer();
406 return ui::DragDropTypes::DRAG_MOVE; 424 return ui::DragDropTypes::DRAG_MOVE;
407 } 425 }
408 StopShowFolderDropMenuTimer(); 426 StopShowFolderDropMenuTimer();
409 427
410 // TODO(devlin): This calculation needs to take 'overflow' mode into account
411 // once the wrench menu becomes a drag target for browser action icons.
412
413 // Figure out where to display the indicator. This is a complex calculation: 428 // Figure out where to display the indicator. This is a complex calculation:
414 429
415 // First, we figure out how much space is to the left of the icon area, so we 430 // First, we figure out how much space is to the left of the icon area, so we
416 // can calculate the true offset into the icon area. 431 // can calculate the true offset into the icon area. The easiest way to do
417 int width_before_icons = ToolbarView::kStandardSpacing; 432 // this is to just find where the first icon starts.
418 if (chevron_ && base::i18n::IsRTL()) { 433 int width_before_icons =
419 width_before_icons += 434 browser_action_views_[GetFirstVisibleIconIndex()]->x();
420 chevron_->GetPreferredSize().width() + kChevronSpacing; 435
421 } 436 // If we're right-to-left, we flip the mirror the event.x() so that our
422 int offset_into_icon_area = event.x() - width_before_icons; 437 // calculations are consistent with left-to-right.
438 int offset_into_icon_area =
439 (base::i18n::IsRTL() ? width() - event.x() : event.x()) -
Peter Kasting 2014/07/21 20:24:08 Nit: Use "GetMirroredXInView(event.x())"; indent 2
Devlin 2014/07/22 17:30:46 Done.
440 width_before_icons;
441
442 // Next, figure out what row we're on. This only matters for overflow mode,
443 // but the calculation is the same for both.
444 int row_index = event.y() / IconHeight();
445
446 // Sanity check - we should never be on a different row in the main container.
447 DCHECK(in_overflow_mode() || row_index == 0);
423 448
424 // Next, we determine which icon to place the indicator in front of. We want 449 // Next, we determine which icon to place the indicator in front of. We want
425 // to place the indicator in front of icon n when the cursor is between the 450 // to place the indicator in front of icon n when the cursor is between the
426 // midpoints of icons (n - 1) and n. To do this we take the offset into the 451 // midpoints of icons (n - 1) and n. To do this we take the offset into the
427 // icon area and transform it as follows: 452 // icon area and transform it as follows:
428 // 453 //
429 // Real icon area: 454 // Real icon area:
430 // 0 a * b c 455 // 0 a * b c
431 // | | | | 456 // | | | |
432 // |[IC|ON] [IC|ON] [IC|ON] 457 // |[IC|ON] [IC|ON] [IC|ON]
433 // We want to be before icon 0 for 0 < x <= a, icon 1 for a < x <= b, etc. 458 // We want to be before icon 0 for 0 < x <= a, icon 1 for a < x <= b, etc.
434 // Here the "*" represents the offset into the icon area, and since it's 459 // Here the "*" represents the offset into the icon area, and since it's
435 // between a and b, we want to return "1". 460 // between a and b, we want to return "1".
436 // 461 //
437 // Transformed "icon area": 462 // Transformed "icon area":
438 // 0 a * b c 463 // 0 a * b c
439 // | | | | 464 // | | | |
440 // |[ICON] |[ICON] |[ICON] | 465 // |[ICON] |[ICON] |[ICON] |
441 // If we shift both our offset and our divider points later by half an icon 466 // If we shift both our offset and our divider points later by half an icon
442 // plus one spacing unit, then it becomes very easy to calculate how many 467 // plus one spacing unit, then it becomes very easy to calculate how many
443 // divider points we've passed, because they're the multiples of "one icon 468 // divider points we've passed, because they're the multiples of "one icon
444 // plus padding". 469 // plus padding".
445 int before_icon_unclamped = (offset_into_icon_area + (IconWidth(false) / 2) + 470 int before_icon_unclamped = (offset_into_icon_area + (IconWidth(false) / 2) +
446 kItemSpacing) / IconWidth(true); 471 kItemSpacing) / IconWidth(true);
447 472
473 // We need to figure out how many icons are visible on the relevant row.
474 // In the main container, this will just be the visible actions.
475 int visible_icons_on_row = VisibleBrowserActionsAfterAnimation();
476 if (in_overflow_mode()) {
477 // If this is the final row of the overflow, then this is the remainder of
478 // visible icons. Otherwise, it's a full row (kIconsPerRow).
479 visible_icons_on_row =
480 row_index == (visible_icons_on_row / kIconsPerMenuRow) ?
481 visible_icons_on_row % kIconsPerMenuRow :
482 kIconsPerMenuRow;
483 }
484
448 // Because the user can drag outside the container bounds, we need to clamp to 485 // Because the user can drag outside the container bounds, we need to clamp to
449 // the valid range. Note that the maximum allowable value is (num icons), not 486 // the valid range. Note that the maximum allowable value is (num icons), not
450 // (num icons - 1), because we represent the indicator being past the last 487 // (num icons - 1), because we represent the indicator being past the last
451 // icon as being "before the (last + 1) icon". 488 // icon as being "before the (last + 1) icon".
452 int before_icon = std::min(std::max(before_icon_unclamped, 0), 489 int before_icon_in_row =
453 static_cast<int>(VisibleBrowserActions())); 490 std::min(std::max(before_icon_unclamped, 0), visible_icons_on_row);
454 491
455 // Now we convert back to a pixel offset into the container. We want to place 492 SetDropPosition(row_index, before_icon_in_row);
456 // the center of the drop indicator at the midpoint of the space before our
457 // chosen icon.
458 SetDropIndicator(width_before_icons + (before_icon * IconWidth(true)) -
459 (kItemSpacing / 2));
460 493
461 return ui::DragDropTypes::DRAG_MOVE; 494 return ui::DragDropTypes::DRAG_MOVE;
462 } 495 }
463 496
464 void BrowserActionsContainer::OnDragExited() { 497 void BrowserActionsContainer::OnDragExited() {
465 StopShowFolderDropMenuTimer(); 498 StopShowFolderDropMenuTimer();
466 drop_indicator_position_ = -1; 499 ResetDropPosition();
467 SchedulePaint(); 500 SchedulePaint();
468 } 501 }
469 502
470 int BrowserActionsContainer::OnPerformDrop( 503 int BrowserActionsContainer::OnPerformDrop(
471 const ui::DropTargetEvent& event) { 504 const ui::DropTargetEvent& event) {
472 BrowserActionDragData data; 505 BrowserActionDragData data;
473 if (!data.Read(event.data())) 506 if (!data.Read(event.data()))
474 return ui::DragDropTypes::DRAG_NONE; 507 return ui::DragDropTypes::DRAG_NONE;
475 508
476 // Make sure we have the same view as we started with. 509 // Make sure we have the same view as we started with.
477 DCHECK_EQ(browser_action_views_[data.index()]->button()->extension()->id(), 510 DCHECK_EQ(browser_action_views_[data.index()]->button()->extension()->id(),
478 data.id()); 511 data.id());
479 DCHECK(model_); 512 DCHECK(model_);
480 513
481 size_t i = 0; 514 size_t i =
482 for (; i < browser_action_views_.size(); ++i) { 515 drop_position_->row * kIconsPerMenuRow + drop_position_->icon_in_row;
483 int view_x = browser_action_views_[i]->GetMirroredBounds().x(); 516 if (in_overflow_mode())
484 if (!browser_action_views_[i]->visible() || 517 i += GetFirstVisibleIconIndex();
485 (base::i18n::IsRTL() ? (view_x < drop_indicator_position_) :
486 (view_x >= drop_indicator_position_))) {
487 // We have reached the end of the visible icons or found one that has a
488 // higher x position than the drop point.
489 break;
490 }
491 }
492
493 // |i| now points to the item to the right of the drop indicator*, which is 518 // |i| now points to the item to the right of the drop indicator*, which is
494 // correct when dragging an icon to the left. When dragging to the right, 519 // correct when dragging an icon to the left. When dragging to the right,
495 // however, we want the icon being dragged to get the index of the item to 520 // however, we want the icon being dragged to get the index of the item to
496 // the left of the drop indicator, so we subtract one. 521 // the left of the drop indicator, so we subtract one.
497 // * Well, it can also point to the end, but not when dragging to the left. :) 522 // * Well, it can also point to the end, but not when dragging to the left. :)
498 if (i > data.index()) 523 if (i > data.index())
499 --i; 524 --i;
500 525
501 if (profile_->IsOffTheRecord()) 526 if (profile_->IsOffTheRecord())
502 i = model_->IncognitoIndexToOriginal(i); 527 i = model_->IncognitoIndexToOriginal(i);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 708
684 for (BrowserActionViews::iterator it = browser_action_views_.begin(); 709 for (BrowserActionViews::iterator it = browser_action_views_.begin();
685 it != browser_action_views_.end(); ++it) { 710 it != browser_action_views_.end(); ++it) {
686 BrowserActionButton* button = (*it)->button(); 711 BrowserActionButton* button = (*it)->button();
687 if (button && button->extension() == extension) 712 if (button && button->extension() == extension)
688 return ShowPopup(button, ExtensionPopup::SHOW, should_grant); 713 return ShowPopup(button, ExtensionPopup::SHOW, should_grant);
689 } 714 }
690 return false; 715 return false;
691 } 716 }
692 717
718 size_t BrowserActionsContainer::GetFirstVisibleIconIndex() const {
719 return in_overflow_mode() ? model_->GetVisibleIconCount() : 0;
720 }
721
693 void BrowserActionsContainer::HidePopup() { 722 void BrowserActionsContainer::HidePopup() {
694 // Remove this as an observer and clear |popup_| and |popup_button_| here, 723 // Remove this as an observer and clear |popup_| and |popup_button_| here,
695 // since we might change them before OnWidgetDestroying() gets called. 724 // since we might change them before OnWidgetDestroying() gets called.
696 if (popup_) { 725 if (popup_) {
697 popup_->GetWidget()->RemoveObserver(this); 726 popup_->GetWidget()->RemoveObserver(this);
698 popup_->GetWidget()->Close(); 727 popup_->GetWidget()->Close();
699 popup_ = NULL; 728 popup_ = NULL;
700 } 729 }
701 if (popup_button_) { 730 if (popup_button_) {
702 popup_button_->SetButtonNotPushed(); 731 popup_button_->SetButtonNotPushed();
(...skipping 17 matching lines...) Expand all
720 void BrowserActionsContainer::OnPaint(gfx::Canvas* canvas) { 749 void BrowserActionsContainer::OnPaint(gfx::Canvas* canvas) {
721 // If the views haven't been initialized yet, wait for the next call to 750 // If the views haven't been initialized yet, wait for the next call to
722 // paint (one will be triggered by entering highlight mode). 751 // paint (one will be triggered by entering highlight mode).
723 if (model_->is_highlighting() && !browser_action_views_.empty()) { 752 if (model_->is_highlighting() && !browser_action_views_.empty()) {
724 views::Painter::PaintPainterAt( 753 views::Painter::PaintPainterAt(
725 canvas, highlight_painter_.get(), GetLocalBounds()); 754 canvas, highlight_painter_.get(), GetLocalBounds());
726 } 755 }
727 756
728 // TODO(sky/glen): Instead of using a drop indicator, animate the icons while 757 // TODO(sky/glen): Instead of using a drop indicator, animate the icons while
729 // dragging (like we do for tab dragging). 758 // dragging (like we do for tab dragging).
730 if (drop_indicator_position_ > -1) { 759 if (drop_position_.get()) {
731 // The two-pixel width drop indicator. 760 // The two-pixel width drop indicator.
732 static const int kDropIndicatorWidth = 2; 761 static const int kDropIndicatorWidth = 2;
733 gfx::Rect indicator_bounds( 762
734 drop_indicator_position_ - (kDropIndicatorWidth / 2), 763 // Convert back to a pixel offset into the container. We want to place
735 0, 764 // the center of the drop indicator at the midpoint of the space before
736 kDropIndicatorWidth, 765 // the drop position's referenced icon.
737 height()); 766 // This is:
767 // The width before the first icon, plus
768 // The width of all icons before the target icon in the row, minus
769 // Half the spacing between the target icon and the previous icon, minus
770 // Half the width of the drop indicator, so it's centered.
771 int drop_indicator_x =
772 browser_action_views_[GetFirstVisibleIconIndex()]->x() +
773 drop_position_->icon_in_row * IconWidth(true) -
774 kItemSpacing / 2 -
775 kDropIndicatorWidth / 2;
776
777 // Mirror the x if it's RTL. Why the extra -1? Because kItemSpacing is 3,
778 // so kItemSpacing / 2 = 1. In order to draw the drop indicator at the same
779 // point in RTL, we have to subtract the extra difference (otherwise it
780 // draws to far to the right).
Peter Kasting 2014/07/21 20:24:08 Nit: to far -> too far This logic doesn't really
Devlin 2014/07/22 17:30:46 Yeah, it's confusing. :) So, in LTR, we shift thi
Peter Kasting 2014/07/22 18:21:11 The screenshots are pretty clear that what you're
Devlin 2014/07/22 20:29:32 Ah! You're quite right, there's a couple things w
781 if (base::i18n::IsRTL())
782 drop_indicator_x = width() - drop_indicator_x - 1;
Peter Kasting 2014/07/21 20:24:08 Nit: MirroredXInView()
Devlin 2014/07/22 17:30:46 Done.
783
784 // The y is simply the start of the row (which for the main container is
785 // always 0).
786 int drop_indicator_y = IconHeight() * drop_position_->row;
787
788 gfx::Rect indicator_bounds(drop_indicator_x,
789 drop_indicator_y,
790 kDropIndicatorWidth,
791 IconHeight());
738 792
739 // Color of the drop indicator. 793 // Color of the drop indicator.
740 static const SkColor kDropIndicatorColor = SK_ColorBLACK; 794 static const SkColor kDropIndicatorColor = SK_ColorBLACK;
741 canvas->FillRect(indicator_bounds, kDropIndicatorColor); 795 canvas->FillRect(indicator_bounds, kDropIndicatorColor);
742 } 796 }
743 } 797 }
744 798
745 void BrowserActionsContainer::OnThemeChanged() { 799 void BrowserActionsContainer::OnThemeChanged() {
746 LoadImages(); 800 LoadImages();
747 } 801 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 void BrowserActionsContainer::StartShowFolderDropMenuTimer() { 992 void BrowserActionsContainer::StartShowFolderDropMenuTimer() {
939 base::MessageLoop::current()->PostDelayedTask( 993 base::MessageLoop::current()->PostDelayedTask(
940 FROM_HERE, 994 FROM_HERE,
941 base::Bind(&BrowserActionsContainer::ShowDropFolder, 995 base::Bind(&BrowserActionsContainer::ShowDropFolder,
942 show_menu_task_factory_.GetWeakPtr()), 996 show_menu_task_factory_.GetWeakPtr()),
943 base::TimeDelta::FromMilliseconds(views::GetMenuShowDelay())); 997 base::TimeDelta::FromMilliseconds(views::GetMenuShowDelay()));
944 } 998 }
945 999
946 void BrowserActionsContainer::ShowDropFolder() { 1000 void BrowserActionsContainer::ShowDropFolder() {
947 DCHECK(!overflow_menu_); 1001 DCHECK(!overflow_menu_);
948 SetDropIndicator(-1); 1002 ResetDropPosition();
949 overflow_menu_ = 1003 overflow_menu_ =
950 new BrowserActionOverflowMenuController(this, 1004 new BrowserActionOverflowMenuController(this,
951 browser_, 1005 browser_,
952 chevron_, 1006 chevron_,
953 browser_action_views_, 1007 browser_action_views_,
954 VisibleBrowserActions(), 1008 VisibleBrowserActions(),
955 true); 1009 true);
956 overflow_menu_->set_observer(this); 1010 overflow_menu_->set_observer(this);
957 overflow_menu_->RunMenu(GetWidget()); 1011 overflow_menu_->RunMenu(GetWidget());
958 } 1012 }
959 1013
960 void BrowserActionsContainer::SetDropIndicator(int x_pos) { 1014 void BrowserActionsContainer::SetDropPosition(size_t row, size_t icon_in_row) {
Peter Kasting 2014/07/21 20:24:08 Nit: This is only called once. It might be cleare
Devlin 2014/07/22 17:30:46 Inlined. See comment in the .h about the rest.
961 if (drop_indicator_position_ != x_pos) { 1015 if (!drop_position_.get() ||
962 drop_indicator_position_ = x_pos; 1016 !(drop_position_->row == row &&
1017 drop_position_->icon_in_row == icon_in_row)) {
1018 drop_position_.reset(new DropPosition(row, icon_in_row));
963 SchedulePaint(); 1019 SchedulePaint();
964 } 1020 }
965 } 1021 }
966 1022
1023 void BrowserActionsContainer::ResetDropPosition() {
Peter Kasting 2014/07/21 20:24:08 I'm not convinced having this is preferable to jus
Devlin 2014/07/22 17:30:46 Agreed - I put this in for parity with SetDropPosi
1024 drop_position_.reset();
1025 }
1026
967 int BrowserActionsContainer::IconCountToWidth(int icons, 1027 int BrowserActionsContainer::IconCountToWidth(int icons,
968 bool display_chevron) const { 1028 bool display_chevron) const {
969 if (icons < 0) 1029 if (icons < 0)
970 icons = browser_action_views_.size(); 1030 icons = browser_action_views_.size();
971 if ((icons == 0) && !display_chevron) 1031 if ((icons == 0) && !display_chevron)
972 return ToolbarView::kStandardSpacing; 1032 return ToolbarView::kStandardSpacing;
973 int icons_size = 1033 int icons_size =
974 (icons == 0) ? 0 : ((icons * IconWidth(true)) - kItemSpacing); 1034 (icons == 0) ? 0 : ((icons * IconWidth(true)) - kItemSpacing);
975 int chevron_size = chevron_ && display_chevron ? 1035 int chevron_size = chevron_ && display_chevron ?
976 (kChevronSpacing + chevron_->GetPreferredSize().width()) : 0; 1036 (kChevronSpacing + chevron_->GetPreferredSize().width()) : 0;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 views::BubbleBorder::TOP_RIGHT, 1124 views::BubbleBorder::TOP_RIGHT,
1065 show_action); 1125 show_action);
1066 popup_->GetWidget()->AddObserver(this); 1126 popup_->GetWidget()->AddObserver(this);
1067 popup_button_ = button; 1127 popup_button_ = button;
1068 1128
1069 // Only set button as pushed if it was triggered by a user click. 1129 // Only set button as pushed if it was triggered by a user click.
1070 if (should_grant) 1130 if (should_grant)
1071 popup_button_->SetButtonPushed(); 1131 popup_button_->SetButtonPushed();
1072 return true; 1132 return true;
1073 } 1133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698