| OLD | NEW |
| 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/tabs/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windowsx.h> | 8 #include <windowsx.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "ui/base/layout.h" | 36 #include "ui/base/layout.h" |
| 37 #include "ui/base/models/list_selection_model.h" | 37 #include "ui/base/models/list_selection_model.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/gfx/animation/animation_container.h" | 39 #include "ui/gfx/animation/animation_container.h" |
| 40 #include "ui/gfx/animation/throb_animation.h" | 40 #include "ui/gfx/animation/throb_animation.h" |
| 41 #include "ui/gfx/canvas.h" | 41 #include "ui/gfx/canvas.h" |
| 42 #include "ui/gfx/display.h" | 42 #include "ui/gfx/display.h" |
| 43 #include "ui/gfx/image/image_skia.h" | 43 #include "ui/gfx/image/image_skia.h" |
| 44 #include "ui/gfx/image/image_skia_operations.h" | 44 #include "ui/gfx/image/image_skia_operations.h" |
| 45 #include "ui/gfx/path.h" | 45 #include "ui/gfx/path.h" |
| 46 #include "ui/gfx/rect_conversions.h" |
| 46 #include "ui/gfx/screen.h" | 47 #include "ui/gfx/screen.h" |
| 47 #include "ui/gfx/size.h" | 48 #include "ui/gfx/size.h" |
| 48 #include "ui/views/controls/image_view.h" | 49 #include "ui/views/controls/image_view.h" |
| 49 #include "ui/views/mouse_watcher_view_host.h" | 50 #include "ui/views/mouse_watcher_view_host.h" |
| 51 #include "ui/views/rect_based_targeting_utils.h" |
| 50 #include "ui/views/view_model_utils.h" | 52 #include "ui/views/view_model_utils.h" |
| 51 #include "ui/views/widget/root_view.h" | 53 #include "ui/views/widget/root_view.h" |
| 52 #include "ui/views/widget/widget.h" | 54 #include "ui/views/widget/widget.h" |
| 53 #include "ui/views/window/non_client_view.h" | 55 #include "ui/views/window/non_client_view.h" |
| 54 | 56 |
| 55 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 56 #include "ui/gfx/win/hwnd_util.h" | 58 #include "ui/gfx/win/hwnd_util.h" |
| 57 #include "ui/views/widget/monitor_win.h" | 59 #include "ui/views/widget/monitor_win.h" |
| 58 #include "ui/views/win/hwnd_util.h" | 60 #include "ui/views/win/hwnd_util.h" |
| 59 #include "win8/util/win8_util.h" | 61 #include "win8/util/win8_util.h" |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 | 910 |
| 909 bool TabStrip::IsTabStripCloseable() const { | 911 bool TabStrip::IsTabStripCloseable() const { |
| 910 return !IsDragSessionActive(); | 912 return !IsDragSessionActive(); |
| 911 } | 913 } |
| 912 | 914 |
| 913 void TabStrip::UpdateLoadingAnimations() { | 915 void TabStrip::UpdateLoadingAnimations() { |
| 914 controller_->UpdateLoadingAnimations(); | 916 controller_->UpdateLoadingAnimations(); |
| 915 } | 917 } |
| 916 | 918 |
| 917 bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) { | 919 bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) { |
| 918 views::View* v = GetEventHandlerForPoint(point); | 920 return IsRectInWindowCaption(gfx::Rect(point, gfx::Size(1, 1))); |
| 921 } |
| 922 |
| 923 bool TabStrip::IsRectInWindowCaption(const gfx::Rect& rect) { |
| 924 views::View* v = GetEventHandlerForRect(rect); |
| 919 | 925 |
| 920 // If there is no control at this location, claim the hit was in the title | 926 // If there is no control at this location, claim the hit was in the title |
| 921 // bar to get a move action. | 927 // bar to get a move action. |
| 922 if (v == this) | 928 if (v == this) |
| 923 return true; | 929 return true; |
| 924 | 930 |
| 925 // Check to see if the point is within the non-button parts of the new tab | 931 // Check to see if the rect intersects the non-button parts of the new tab |
| 926 // button. The button has a non-rectangular shape, so if it's not in the | 932 // button. The button has a non-rectangular shape, so if it's not in the |
| 927 // visual portions of the button we treat it as a click to the caption. | 933 // visual portions of the button we treat it as a click to the caption. |
| 928 gfx::Point point_in_newtab_coords(point); | 934 gfx::RectF rect_in_newtab_coords_f(rect); |
| 929 View::ConvertPointToTarget(this, newtab_button_, &point_in_newtab_coords); | 935 View::ConvertRectToTarget(this, newtab_button_, &rect_in_newtab_coords_f); |
| 930 if (newtab_button_->GetLocalBounds().Contains(point_in_newtab_coords) && | 936 gfx::Rect rect_in_newtab_coords = gfx::ToEnclosingRect( |
| 931 !newtab_button_->HitTestPoint(point_in_newtab_coords)) { | 937 rect_in_newtab_coords_f); |
| 938 if (newtab_button_->GetLocalBounds().Intersects(rect_in_newtab_coords) && |
| 939 !newtab_button_->HitTestRect(rect_in_newtab_coords)) |
| 932 return true; | 940 return true; |
| 933 } | |
| 934 | 941 |
| 935 // All other regions, including the new Tab button, should be considered part | 942 // All other regions, including the new Tab button, should be considered part |
| 936 // of the containing Window's client area so that regular events can be | 943 // of the containing Window's client area so that regular events can be |
| 937 // processed for them. | 944 // processed for them. |
| 938 return false; | 945 return false; |
| 939 } | 946 } |
| 940 | 947 |
| 941 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { | 948 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { |
| 942 for (int i = 0; i < tab_count(); ++i) | 949 for (int i = 0; i < tab_count(); ++i) |
| 943 tab_at(i)->set_background_offset(offset); | 950 tab_at(i)->set_background_offset(offset); |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 | 1426 |
| 1420 controller()->PerformDrop(drop_before, drop_index, url); | 1427 controller()->PerformDrop(drop_before, drop_index, url); |
| 1421 | 1428 |
| 1422 return GetDropEffect(event); | 1429 return GetDropEffect(event); |
| 1423 } | 1430 } |
| 1424 | 1431 |
| 1425 void TabStrip::GetAccessibleState(ui::AccessibleViewState* state) { | 1432 void TabStrip::GetAccessibleState(ui::AccessibleViewState* state) { |
| 1426 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST; | 1433 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST; |
| 1427 } | 1434 } |
| 1428 | 1435 |
| 1429 views::View* TabStrip::GetEventHandlerForPoint(const gfx::Point& point) { | 1436 views::View* TabStrip::GetEventHandlerForRect(const gfx::Rect& rect) { |
| 1437 if (!views::UsePointBasedTargeting(rect)) |
| 1438 return View::GetEventHandlerForRect(rect); |
| 1439 const gfx::Point point(rect.CenterPoint()); |
| 1440 |
| 1430 if (!touch_layout_.get()) { | 1441 if (!touch_layout_.get()) { |
| 1431 // Return any view that isn't a Tab or this TabStrip immediately. We don't | 1442 // Return any view that isn't a Tab or this TabStrip immediately. We don't |
| 1432 // want to interfere. | 1443 // want to interfere. |
| 1433 views::View* v = View::GetEventHandlerForPoint(point); | 1444 views::View* v = View::GetEventHandlerForRect(rect); |
| 1434 if (v && v != this && strcmp(v->GetClassName(), Tab::kViewClassName)) | 1445 if (v && v != this && strcmp(v->GetClassName(), Tab::kViewClassName)) |
| 1435 return v; | 1446 return v; |
| 1436 | 1447 |
| 1437 views::View* tab = FindTabHitByPoint(point); | 1448 views::View* tab = FindTabHitByPoint(point); |
| 1438 if (tab) | 1449 if (tab) |
| 1439 return tab; | 1450 return tab; |
| 1440 } else { | 1451 } else { |
| 1441 if (newtab_button_->visible()) { | 1452 if (newtab_button_->visible()) { |
| 1442 views::View* view = | 1453 views::View* view = |
| 1443 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); | 1454 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2716 if (!adjust_layout_) | 2727 if (!adjust_layout_) |
| 2717 return false; | 2728 return false; |
| 2718 | 2729 |
| 2719 #if !defined(OS_CHROMEOS) | 2730 #if !defined(OS_CHROMEOS) |
| 2720 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) | 2731 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) |
| 2721 return false; | 2732 return false; |
| 2722 #endif | 2733 #endif |
| 2723 | 2734 |
| 2724 return true; | 2735 return true; |
| 2725 } | 2736 } |
| OLD | NEW |