| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 if (!profile->GetExtensionService()->IsInstalledApp(url)) | 242 if (!profile->GetExtensionService()->IsInstalledApp(url)) |
| 243 return; | 243 return; |
| 244 | 244 |
| 245 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, | 245 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, |
| 246 extension_misc::APP_LAUNCH_BOOKMARK_BAR, | 246 extension_misc::APP_LAUNCH_BOOKMARK_BAR, |
| 247 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); | 247 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); |
| 248 } | 248 } |
| 249 | 249 |
| 250 } // namespace | 250 } // namespace |
| 251 | 251 |
| 252 // DropLocation --------------------------------------------------------------- |
| 253 |
| 254 struct BookmarkBarView::DropLocation { |
| 255 DropLocation() |
| 256 : index(-1), |
| 257 operation(ui::DragDropTypes::DRAG_NONE), |
| 258 on(false), |
| 259 button_type(DROP_BOOKMARK) { |
| 260 } |
| 261 |
| 262 bool Equals(const DropLocation& other) { |
| 263 return ((other.index == index) && (other.on == on) && |
| 264 (other.button_type == button_type)); |
| 265 } |
| 266 |
| 267 // Index into the model the drop is over. This is relative to the root node. |
| 268 int index; |
| 269 |
| 270 // Drop constants. |
| 271 int operation; |
| 272 |
| 273 // If true, the user is dropping on a folder. |
| 274 bool on; |
| 275 |
| 276 // Type of button. |
| 277 DropButtonType button_type; |
| 278 }; |
| 279 |
| 252 // DropInfo ------------------------------------------------------------------- | 280 // DropInfo ------------------------------------------------------------------- |
| 253 | 281 |
| 254 // Tracks drops on the BookmarkBarView. | 282 // Tracks drops on the BookmarkBarView. |
| 255 | 283 |
| 256 struct BookmarkBarView::DropInfo { | 284 struct BookmarkBarView::DropInfo { |
| 257 DropInfo() | 285 DropInfo() |
| 258 : valid(false), | 286 : valid(false), |
| 259 drop_index(-1), | |
| 260 is_menu_showing(false), | 287 is_menu_showing(false), |
| 261 drop_on(false), | |
| 262 is_over_overflow(false), | |
| 263 is_over_other(false), | |
| 264 x(0), | 288 x(0), |
| 265 y(0), | 289 y(0) { |
| 266 drag_operation(0) { | |
| 267 } | 290 } |
| 268 | 291 |
| 269 // Whether the data is valid. | 292 // Whether the data is valid. |
| 270 bool valid; | 293 bool valid; |
| 271 | 294 |
| 272 // Index into the model the drop is over. This is relative to the root node. | |
| 273 int drop_index; | |
| 274 | |
| 275 // If true, the menu is being shown. | 295 // If true, the menu is being shown. |
| 276 bool is_menu_showing; | 296 bool is_menu_showing; |
| 277 | 297 |
| 278 // If true, the user is dropping on a node. This is only used for folder | |
| 279 // nodes. | |
| 280 bool drop_on; | |
| 281 | |
| 282 // If true, the user is over the overflow button. | |
| 283 bool is_over_overflow; | |
| 284 | |
| 285 // If true, the user is over the other button. | |
| 286 bool is_over_other; | |
| 287 | |
| 288 // Coordinates of the drag (in terms of the BookmarkBarView). | 298 // Coordinates of the drag (in terms of the BookmarkBarView). |
| 289 int x; | 299 int x; |
| 290 int y; | 300 int y; |
| 291 | 301 |
| 292 // The current drag operation. | |
| 293 int drag_operation; | |
| 294 | |
| 295 // DropData for the drop. | 302 // DropData for the drop. |
| 296 BookmarkNodeData data; | 303 BookmarkNodeData data; |
| 304 |
| 305 DropLocation location; |
| 297 }; | 306 }; |
| 298 | 307 |
| 299 // ButtonSeparatorView -------------------------------------------------------- | 308 // ButtonSeparatorView -------------------------------------------------------- |
| 300 | 309 |
| 301 class BookmarkBarView::ButtonSeparatorView : public views::View { | 310 class BookmarkBarView::ButtonSeparatorView : public views::View { |
| 302 public: | 311 public: |
| 303 ButtonSeparatorView() {} | 312 ButtonSeparatorView() {} |
| 304 virtual ~ButtonSeparatorView() {} | 313 virtual ~ButtonSeparatorView() {} |
| 305 | 314 |
| 306 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 315 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 // layout. Therefore we always force a layout when added. | 668 // layout. Therefore we always force a layout when added. |
| 660 Layout(); | 669 Layout(); |
| 661 } | 670 } |
| 662 } | 671 } |
| 663 } | 672 } |
| 664 | 673 |
| 665 void BookmarkBarView::PaintChildren(gfx::Canvas* canvas) { | 674 void BookmarkBarView::PaintChildren(gfx::Canvas* canvas) { |
| 666 View::PaintChildren(canvas); | 675 View::PaintChildren(canvas); |
| 667 | 676 |
| 668 if (drop_info_.get() && drop_info_->valid && | 677 if (drop_info_.get() && drop_info_->valid && |
| 669 drop_info_->drag_operation != 0 && drop_info_->drop_index != -1 && | 678 drop_info_->location.operation != 0 && drop_info_->location.index != -1 && |
| 670 !drop_info_->is_over_overflow && !drop_info_->drop_on) { | 679 drop_info_->location.button_type != DROP_OVERFLOW && |
| 671 int index = drop_info_->drop_index; | 680 !drop_info_->location.on) { |
| 681 int index = drop_info_->location.index; |
| 672 DCHECK(index <= GetBookmarkButtonCount()); | 682 DCHECK(index <= GetBookmarkButtonCount()); |
| 673 int x = 0; | 683 int x = 0; |
| 674 int y = 0; | 684 int y = 0; |
| 675 int h = height(); | 685 int h = height(); |
| 676 if (index == GetBookmarkButtonCount()) { | 686 if (index == GetBookmarkButtonCount()) { |
| 677 if (index == 0) { | 687 if (index == 0) { |
| 678 x = kLeftMargin; | 688 x = kLeftMargin; |
| 679 } else { | 689 } else { |
| 680 x = GetBookmarkButton(index - 1)->x() + | 690 x = GetBookmarkButton(index - 1)->x() + |
| 681 GetBookmarkButton(index - 1)->width(); | 691 GetBookmarkButton(index - 1)->width(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 void BookmarkBarView::OnDragEntered(const DropTargetEvent& event) { | 743 void BookmarkBarView::OnDragEntered(const DropTargetEvent& event) { |
| 734 } | 744 } |
| 735 | 745 |
| 736 int BookmarkBarView::OnDragUpdated(const DropTargetEvent& event) { | 746 int BookmarkBarView::OnDragUpdated(const DropTargetEvent& event) { |
| 737 if (!drop_info_.get()) | 747 if (!drop_info_.get()) |
| 738 return 0; | 748 return 0; |
| 739 | 749 |
| 740 if (drop_info_->valid && | 750 if (drop_info_->valid && |
| 741 (drop_info_->x == event.x() && drop_info_->y == event.y())) { | 751 (drop_info_->x == event.x() && drop_info_->y == event.y())) { |
| 742 // The location of the mouse didn't change, return the last operation. | 752 // The location of the mouse didn't change, return the last operation. |
| 743 return drop_info_->drag_operation; | 753 return drop_info_->location.operation; |
| 744 } | 754 } |
| 745 | 755 |
| 746 drop_info_->x = event.x(); | 756 drop_info_->x = event.x(); |
| 747 drop_info_->y = event.y(); | 757 drop_info_->y = event.y(); |
| 748 | 758 |
| 749 int drop_index; | 759 DropLocation location; |
| 750 bool drop_on; | 760 CalculateDropLocation(event, drop_info_->data, &location); |
| 751 bool is_over_overflow; | |
| 752 bool is_over_other; | |
| 753 | 761 |
| 754 drop_info_->drag_operation = CalculateDropOperation( | 762 if (drop_info_->valid && drop_info_->location.Equals(location)) { |
| 755 event, drop_info_->data, &drop_index, &drop_on, &is_over_overflow, | |
| 756 &is_over_other); | |
| 757 | |
| 758 if (drop_info_->valid && drop_info_->drop_index == drop_index && | |
| 759 drop_info_->drop_on == drop_on && | |
| 760 drop_info_->is_over_overflow == is_over_overflow && | |
| 761 drop_info_->is_over_other == is_over_other) { | |
| 762 // The position we're going to drop didn't change, return the last drag | 763 // The position we're going to drop didn't change, return the last drag |
| 763 // operation we calculated. | 764 // operation we calculated. Copy of the operation in case it changed. |
| 764 return drop_info_->drag_operation; | 765 drop_info_->location.operation = location.operation; |
| 766 return drop_info_->location.operation; |
| 765 } | 767 } |
| 766 | 768 |
| 767 drop_info_->valid = true; | |
| 768 | |
| 769 StopShowFolderDropMenuTimer(); | 769 StopShowFolderDropMenuTimer(); |
| 770 | 770 |
| 771 // TODO(sky): Optimize paint region. | 771 // TODO(sky): Optimize paint region. |
| 772 SchedulePaint(); | 772 SchedulePaint(); |
| 773 drop_info_->drop_index = drop_index; | 773 |
| 774 drop_info_->drop_on = drop_on; | 774 drop_info_->location = location; |
| 775 drop_info_->is_over_overflow = is_over_overflow; | 775 drop_info_->valid = true; |
| 776 drop_info_->is_over_other = is_over_other; | |
| 777 | 776 |
| 778 if (drop_info_->is_menu_showing) { | 777 if (drop_info_->is_menu_showing) { |
| 779 if (bookmark_drop_menu_) | 778 if (bookmark_drop_menu_) |
| 780 bookmark_drop_menu_->Cancel(); | 779 bookmark_drop_menu_->Cancel(); |
| 781 drop_info_->is_menu_showing = false; | 780 drop_info_->is_menu_showing = false; |
| 782 } | 781 } |
| 783 | 782 |
| 784 if (drop_on || is_over_overflow || is_over_other) { | 783 if (location.on || location.button_type == DROP_OVERFLOW || |
| 784 location.button_type == DROP_OTHER_FOLDER) { |
| 785 const BookmarkNode* node; | 785 const BookmarkNode* node; |
| 786 if (is_over_other) | 786 if (location.button_type == DROP_OTHER_FOLDER) |
| 787 node = model_->other_node(); | 787 node = model_->other_node(); |
| 788 else if (is_over_overflow) | 788 else if (location.button_type == DROP_OVERFLOW) |
| 789 node = model_->GetBookmarkBarNode(); | 789 node = model_->GetBookmarkBarNode(); |
| 790 else | 790 else |
| 791 node = model_->GetBookmarkBarNode()->GetChild(drop_index); | 791 node = model_->GetBookmarkBarNode()->GetChild(location.index); |
| 792 StartShowFolderDropMenuTimer(node); | 792 StartShowFolderDropMenuTimer(node); |
| 793 } | 793 } |
| 794 | 794 |
| 795 return drop_info_->drag_operation; | 795 return drop_info_->location.operation; |
| 796 } | 796 } |
| 797 | 797 |
| 798 void BookmarkBarView::OnDragExited() { | 798 void BookmarkBarView::OnDragExited() { |
| 799 StopShowFolderDropMenuTimer(); | 799 StopShowFolderDropMenuTimer(); |
| 800 | 800 |
| 801 // NOTE: we don't hide the menu on exit as it's possible the user moved the | 801 // NOTE: we don't hide the menu on exit as it's possible the user moved the |
| 802 // mouse over the menu, which triggers an exit on us. | 802 // mouse over the menu, which triggers an exit on us. |
| 803 | 803 |
| 804 drop_info_->valid = false; | 804 drop_info_->valid = false; |
| 805 | 805 |
| 806 if (drop_info_->drop_index != -1) { | 806 if (drop_info_->location.index != -1) { |
| 807 // TODO(sky): optimize the paint region. | 807 // TODO(sky): optimize the paint region. |
| 808 SchedulePaint(); | 808 SchedulePaint(); |
| 809 } | 809 } |
| 810 drop_info_.reset(); | 810 drop_info_.reset(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) { | 813 int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) { |
| 814 StopShowFolderDropMenuTimer(); | 814 StopShowFolderDropMenuTimer(); |
| 815 | 815 |
| 816 if (bookmark_drop_menu_) | 816 if (bookmark_drop_menu_) |
| 817 bookmark_drop_menu_->Cancel(); | 817 bookmark_drop_menu_->Cancel(); |
| 818 | 818 |
| 819 if (!drop_info_.get() || !drop_info_->drag_operation) | 819 if (!drop_info_.get() || !drop_info_->location.operation) |
| 820 return ui::DragDropTypes::DRAG_NONE; | 820 return ui::DragDropTypes::DRAG_NONE; |
| 821 | 821 |
| 822 const BookmarkNode* root = | 822 const BookmarkNode* root = |
| 823 drop_info_->is_over_other ? model_->other_node() : | 823 (drop_info_->location.button_type == DROP_OTHER_FOLDER) ? |
| 824 model_->GetBookmarkBarNode(); | 824 model_->other_node() : model_->GetBookmarkBarNode(); |
| 825 int index = drop_info_->drop_index; | 825 int index = drop_info_->location.index; |
| 826 const bool drop_on = drop_info_->drop_on; | |
| 827 const BookmarkNodeData data = drop_info_->data; | |
| 828 const bool is_over_other = drop_info_->is_over_other; | |
| 829 DCHECK(data.is_valid()); | |
| 830 | 826 |
| 831 if (drop_info_->drop_index != -1) { | 827 if (index != -1) { |
| 832 // TODO(sky): optimize the SchedulePaint region. | 828 // TODO(sky): optimize the SchedulePaint region. |
| 833 SchedulePaint(); | 829 SchedulePaint(); |
| 834 } | 830 } |
| 835 drop_info_.reset(); | |
| 836 | |
| 837 const BookmarkNode* parent_node; | 831 const BookmarkNode* parent_node; |
| 838 if (is_over_other) { | 832 if (drop_info_->location.button_type == DROP_OTHER_FOLDER) { |
| 839 parent_node = root; | 833 parent_node = root; |
| 840 index = parent_node->child_count(); | 834 index = parent_node->child_count(); |
| 841 } else if (drop_on) { | 835 } else if (drop_info_->location.on) { |
| 842 parent_node = root->GetChild(index); | 836 parent_node = root->GetChild(index); |
| 843 index = parent_node->child_count(); | 837 index = parent_node->child_count(); |
| 844 } else { | 838 } else { |
| 845 parent_node = root; | 839 parent_node = root; |
| 846 } | 840 } |
| 841 const BookmarkNodeData data = drop_info_->data; |
| 842 DCHECK(data.is_valid()); |
| 843 drop_info_.reset(); |
| 847 return bookmark_utils::PerformBookmarkDrop(profile_, data, parent_node, | 844 return bookmark_utils::PerformBookmarkDrop(profile_, data, parent_node, |
| 848 index); | 845 index); |
| 849 } | 846 } |
| 850 | 847 |
| 851 void BookmarkBarView::ShowContextMenu(const gfx::Point& p, | 848 void BookmarkBarView::ShowContextMenu(const gfx::Point& p, |
| 852 bool is_mouse_gesture) { | 849 bool is_mouse_gesture) { |
| 853 ShowContextMenuForView(this, p, is_mouse_gesture); | 850 ShowContextMenuForView(this, p, is_mouse_gesture); |
| 854 } | 851 } |
| 855 | 852 |
| 856 void BookmarkBarView::OnThemeChanged() { | 853 void BookmarkBarView::OnThemeChanged() { |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 return; | 1424 return; |
| 1428 } | 1425 } |
| 1429 show_folder_method_factory_.RevokeAll(); | 1426 show_folder_method_factory_.RevokeAll(); |
| 1430 MessageLoop::current()->PostDelayedTask( | 1427 MessageLoop::current()->PostDelayedTask( |
| 1431 FROM_HERE, | 1428 FROM_HERE, |
| 1432 show_folder_method_factory_.NewRunnableMethod( | 1429 show_folder_method_factory_.NewRunnableMethod( |
| 1433 &BookmarkBarView::ShowDropFolderForNode, node), | 1430 &BookmarkBarView::ShowDropFolderForNode, node), |
| 1434 views::GetMenuShowDelay()); | 1431 views::GetMenuShowDelay()); |
| 1435 } | 1432 } |
| 1436 | 1433 |
| 1437 int BookmarkBarView::CalculateDropOperation(const DropTargetEvent& event, | 1434 void BookmarkBarView::CalculateDropLocation(const DropTargetEvent& event, |
| 1438 const BookmarkNodeData& data, | 1435 const BookmarkNodeData& data, |
| 1439 int* index, | 1436 DropLocation* location) { |
| 1440 bool* drop_on, | |
| 1441 bool* is_over_overflow, | |
| 1442 bool* is_over_other) { | |
| 1443 DCHECK(model_); | 1437 DCHECK(model_); |
| 1444 DCHECK(model_->IsLoaded()); | 1438 DCHECK(model_->IsLoaded()); |
| 1445 DCHECK(data.is_valid()); | 1439 DCHECK(data.is_valid()); |
| 1446 | 1440 |
| 1441 *location = DropLocation(); |
| 1442 |
| 1447 // The drop event uses the screen coordinates while the child Views are | 1443 // The drop event uses the screen coordinates while the child Views are |
| 1448 // always laid out from left to right (even though they are rendered from | 1444 // always laid out from left to right (even though they are rendered from |
| 1449 // right-to-left on RTL locales). Thus, in order to make sure the drop | 1445 // right-to-left on RTL locales). Thus, in order to make sure the drop |
| 1450 // coordinates calculation works, we mirror the event's X coordinate if the | 1446 // coordinates calculation works, we mirror the event's X coordinate if the |
| 1451 // locale is RTL. | 1447 // locale is RTL. |
| 1452 int mirrored_x = GetMirroredXInView(event.x()); | 1448 int mirrored_x = GetMirroredXInView(event.x()); |
| 1453 | 1449 |
| 1454 *index = -1; | |
| 1455 *drop_on = false; | |
| 1456 *is_over_other = *is_over_overflow = false; | |
| 1457 | |
| 1458 bool found = false; | 1450 bool found = false; |
| 1459 const int other_delta_x = mirrored_x - other_bookmarked_button_->x(); | 1451 const int other_delta_x = mirrored_x - other_bookmarked_button_->x(); |
| 1460 if (other_bookmarked_button_->IsVisible() && other_delta_x >= 0 && | 1452 if (other_bookmarked_button_->IsVisible() && other_delta_x >= 0 && |
| 1461 other_delta_x < other_bookmarked_button_->width()) { | 1453 other_delta_x < other_bookmarked_button_->width()) { |
| 1462 // Mouse is over 'other' folder. | 1454 // Mouse is over 'other' folder. |
| 1463 *is_over_other = true; | 1455 location->button_type = DROP_OTHER_FOLDER; |
| 1464 *drop_on = true; | 1456 location->on = true; |
| 1465 found = true; | 1457 found = true; |
| 1466 } else if (!GetBookmarkButtonCount()) { | 1458 } else if (!GetBookmarkButtonCount()) { |
| 1467 // No bookmarks, accept the drop. | 1459 // No bookmarks, accept the drop. |
| 1468 *index = 0; | 1460 location->index = 0; |
| 1469 int ops = data.GetFirstNode(profile_) | 1461 int ops = data.GetFirstNode(profile_) |
| 1470 ? ui::DragDropTypes::DRAG_MOVE | 1462 ? ui::DragDropTypes::DRAG_MOVE |
| 1471 : ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK; | 1463 : ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK; |
| 1472 return bookmark_utils::PreferredDropOperation(event.source_operations(), | 1464 location->operation = |
| 1473 ops); | 1465 bookmark_utils::PreferredDropOperation(event.source_operations(), ops); |
| 1466 return; |
| 1474 } | 1467 } |
| 1475 | 1468 |
| 1476 for (int i = 0; i < GetBookmarkButtonCount() && | 1469 for (int i = 0; i < GetBookmarkButtonCount() && |
| 1477 GetBookmarkButton(i)->IsVisible() && !found; i++) { | 1470 GetBookmarkButton(i)->IsVisible() && !found; i++) { |
| 1478 views::TextButton* button = GetBookmarkButton(i); | 1471 views::TextButton* button = GetBookmarkButton(i); |
| 1479 int button_x = mirrored_x - button->x(); | 1472 int button_x = mirrored_x - button->x(); |
| 1480 int button_w = button->width(); | 1473 int button_w = button->width(); |
| 1481 if (button_x < button_w) { | 1474 if (button_x < button_w) { |
| 1482 found = true; | 1475 found = true; |
| 1483 const BookmarkNode* node = model_->GetBookmarkBarNode()->GetChild(i); | 1476 const BookmarkNode* node = model_->GetBookmarkBarNode()->GetChild(i); |
| 1484 if (node->is_folder()) { | 1477 if (node->is_folder()) { |
| 1485 if (button_x <= views::kDropBetweenPixels) { | 1478 if (button_x <= views::kDropBetweenPixels) { |
| 1486 *index = i; | 1479 location->index = i; |
| 1487 } else if (button_x < button_w - views::kDropBetweenPixels) { | 1480 } else if (button_x < button_w - views::kDropBetweenPixels) { |
| 1488 *index = i; | 1481 location->index = i; |
| 1489 *drop_on = true; | 1482 location->on = true; |
| 1490 } else { | 1483 } else { |
| 1491 *index = i + 1; | 1484 location->index = i + 1; |
| 1492 } | 1485 } |
| 1493 } else if (button_x < button_w / 2) { | 1486 } else if (button_x < button_w / 2) { |
| 1494 *index = i; | 1487 location->index = i; |
| 1495 } else { | 1488 } else { |
| 1496 *index = i + 1; | 1489 location->index = i + 1; |
| 1497 } | 1490 } |
| 1498 break; | 1491 break; |
| 1499 } | 1492 } |
| 1500 } | 1493 } |
| 1501 | 1494 |
| 1502 if (!found) { | 1495 if (!found) { |
| 1503 if (overflow_button_->IsVisible()) { | 1496 if (overflow_button_->IsVisible()) { |
| 1504 // Are we over the overflow button? | 1497 // Are we over the overflow button? |
| 1505 int overflow_delta_x = mirrored_x - overflow_button_->x(); | 1498 int overflow_delta_x = mirrored_x - overflow_button_->x(); |
| 1506 if (overflow_delta_x >= 0 && | 1499 if (overflow_delta_x >= 0 && |
| 1507 overflow_delta_x < overflow_button_->width()) { | 1500 overflow_delta_x < overflow_button_->width()) { |
| 1508 // Mouse is over overflow button. | 1501 // Mouse is over overflow button. |
| 1509 *index = GetFirstHiddenNodeIndex(); | 1502 location->index = GetFirstHiddenNodeIndex(); |
| 1510 *is_over_overflow = true; | 1503 location->button_type = DROP_OVERFLOW; |
| 1511 } else if (overflow_delta_x < 0) { | 1504 } else if (overflow_delta_x < 0) { |
| 1512 // Mouse is after the last visible button but before overflow button; | 1505 // Mouse is after the last visible button but before overflow button; |
| 1513 // use the last visible index. | 1506 // use the last visible index. |
| 1514 *index = GetFirstHiddenNodeIndex(); | 1507 location->index = GetFirstHiddenNodeIndex(); |
| 1515 } else { | 1508 } else { |
| 1516 return ui::DragDropTypes::DRAG_NONE; | 1509 return; |
| 1517 } | 1510 } |
| 1518 } else if (!other_bookmarked_button_->IsVisible() || | 1511 } else if (!other_bookmarked_button_->IsVisible() || |
| 1519 mirrored_x < other_bookmarked_button_->x()) { | 1512 mirrored_x < other_bookmarked_button_->x()) { |
| 1520 // Mouse is after the last visible button but before more recently | 1513 // Mouse is after the last visible button but before more recently |
| 1521 // bookmarked; use the last visible index. | 1514 // bookmarked; use the last visible index. |
| 1522 *index = GetFirstHiddenNodeIndex(); | 1515 location->index = GetFirstHiddenNodeIndex(); |
| 1523 } else { | 1516 } else { |
| 1524 return ui::DragDropTypes::DRAG_NONE; | 1517 return; |
| 1525 } | 1518 } |
| 1526 } | 1519 } |
| 1527 | 1520 |
| 1528 if (*drop_on) { | 1521 if (location->on) { |
| 1529 const BookmarkNode* parent = | 1522 const BookmarkNode* parent = (location->button_type == DROP_OTHER_FOLDER) ? |
| 1530 *is_over_other ? model_->other_node() : | 1523 model_->other_node() : |
| 1531 model_->GetBookmarkBarNode()->GetChild(*index); | 1524 model_->GetBookmarkBarNode()->GetChild(location->index); |
| 1532 int operation = | 1525 location->operation = |
| 1533 bookmark_utils::BookmarkDropOperation(profile_, event, data, parent, | 1526 bookmark_utils::BookmarkDropOperation(profile_, event, data, parent, |
| 1534 parent->child_count()); | 1527 parent->child_count()); |
| 1535 if (!operation && !data.has_single_url() && | 1528 if (!location->operation && !data.has_single_url() && |
| 1536 data.GetFirstNode(profile_) == parent) { | 1529 data.GetFirstNode(profile_) == parent) { |
| 1537 // Don't open a menu if the node being dragged is the the menu to | 1530 // Don't open a menu if the node being dragged is the menu to open. |
| 1538 // open. | 1531 location->on = false; |
| 1539 *drop_on = false; | |
| 1540 } | 1532 } |
| 1541 return operation; | 1533 } else { |
| 1534 location->operation = |
| 1535 bookmark_utils::BookmarkDropOperation(profile_, event, data, |
| 1536 model_->GetBookmarkBarNode(), |
| 1537 location->index); |
| 1542 } | 1538 } |
| 1543 return bookmark_utils::BookmarkDropOperation(profile_, event, data, | |
| 1544 model_->GetBookmarkBarNode(), | |
| 1545 *index); | |
| 1546 } | 1539 } |
| 1547 | 1540 |
| 1548 void BookmarkBarView::WriteBookmarkDragData(const BookmarkNode* node, | 1541 void BookmarkBarView::WriteBookmarkDragData(const BookmarkNode* node, |
| 1549 ui::OSExchangeData* data) { | 1542 ui::OSExchangeData* data) { |
| 1550 DCHECK(node && data); | 1543 DCHECK(node && data); |
| 1551 BookmarkNodeData drag_data(node); | 1544 BookmarkNodeData drag_data(node); |
| 1552 drag_data.Write(profile_, data); | 1545 drag_data.Write(profile_, data); |
| 1553 } | 1546 } |
| 1554 | 1547 |
| 1555 void BookmarkBarView::StartThrobbing(const BookmarkNode* node, | 1548 void BookmarkBarView::StartThrobbing(const BookmarkNode* node, |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 (1 - size_animation_->GetCurrentValue()))); | 1766 (1 - size_animation_->GetCurrentValue()))); |
| 1774 } else { | 1767 } else { |
| 1775 prefsize.set_height( | 1768 prefsize.set_height( |
| 1776 static_cast<int>( | 1769 static_cast<int>( |
| 1777 browser_defaults::kBookmarkBarHeight * | 1770 browser_defaults::kBookmarkBarHeight * |
| 1778 size_animation_->GetCurrentValue())); | 1771 size_animation_->GetCurrentValue())); |
| 1779 } | 1772 } |
| 1780 } | 1773 } |
| 1781 return prefsize; | 1774 return prefsize; |
| 1782 } | 1775 } |
| OLD | NEW |