| 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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 } | 805 } |
| 806 | 806 |
| 807 bool TabStrip::IsTabStripCloseable() const { | 807 bool TabStrip::IsTabStripCloseable() const { |
| 808 return !IsDragSessionActive(); | 808 return !IsDragSessionActive(); |
| 809 } | 809 } |
| 810 | 810 |
| 811 void TabStrip::UpdateLoadingAnimations() { | 811 void TabStrip::UpdateLoadingAnimations() { |
| 812 controller_->UpdateLoadingAnimations(); | 812 controller_->UpdateLoadingAnimations(); |
| 813 } | 813 } |
| 814 | 814 |
| 815 bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) { | 815 bool TabStrip::IsPositionInWindowCaption(const gfx::PointF& point) { |
| 816 return IsRectInWindowCaption(gfx::Rect(point, gfx::Size(1, 1))); | 816 return IsRectInWindowCaption(gfx::RectF(point, gfx::Size(1, 1))); |
| 817 } | 817 } |
| 818 | 818 |
| 819 bool TabStrip::IsRectInWindowCaption(const gfx::Rect& rect) { | 819 bool TabStrip::IsRectInWindowCaption(const gfx::RectF& rect) { |
| 820 views::View* v = GetEventHandlerForRect(rect); | 820 views::View* v = GetEventHandlerForRect(rect); |
| 821 | 821 |
| 822 // If there is no control at this location, claim the hit was in the title | 822 // If there is no control at this location, claim the hit was in the title |
| 823 // bar to get a move action. | 823 // bar to get a move action. |
| 824 if (v == this) | 824 if (v == this) |
| 825 return true; | 825 return true; |
| 826 | 826 |
| 827 // Check to see if the rect intersects the non-button parts of the new tab | 827 // Check to see if the rect intersects the non-button parts of the new tab |
| 828 // button. The button has a non-rectangular shape, so if it's not in the | 828 // button. The button has a non-rectangular shape, so if it's not in the |
| 829 // visual portions of the button we treat it as a click to the caption. | 829 // visual portions of the button we treat it as a click to the caption. |
| 830 gfx::RectF rect_in_newtab_coords_f(rect); | 830 gfx::RectF rect_in_newtab_coords(rect); |
| 831 View::ConvertRectToTarget(this, newtab_button_, &rect_in_newtab_coords_f); | 831 View::ConvertRectToTarget(this, newtab_button_, &rect_in_newtab_coords); |
| 832 gfx::Rect rect_in_newtab_coords = gfx::ToEnclosingRect( | 832 gfx::RectF newtab_bounds(newtab_button_->GetLocalBounds()); |
| 833 rect_in_newtab_coords_f); | 833 if (newtab_bounds.Intersects(rect_in_newtab_coords) && |
| 834 if (newtab_button_->GetLocalBounds().Intersects(rect_in_newtab_coords) && | |
| 835 !newtab_button_->HitTestRect(rect_in_newtab_coords)) | 834 !newtab_button_->HitTestRect(rect_in_newtab_coords)) |
| 836 return true; | 835 return true; |
| 837 | 836 |
| 838 // All other regions, including the new Tab button, should be considered part | 837 // All other regions, including the new Tab button, should be considered part |
| 839 // of the containing Window's client area so that regular events can be | 838 // of the containing Window's client area so that regular events can be |
| 840 // processed for them. | 839 // processed for them. |
| 841 return false; | 840 return false; |
| 842 } | 841 } |
| 843 | 842 |
| 844 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { | 843 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 | 1329 |
| 1331 controller()->PerformDrop(drop_before, drop_index, url); | 1330 controller()->PerformDrop(drop_before, drop_index, url); |
| 1332 | 1331 |
| 1333 return GetDropEffect(event); | 1332 return GetDropEffect(event); |
| 1334 } | 1333 } |
| 1335 | 1334 |
| 1336 void TabStrip::GetAccessibleState(ui::AXViewState* state) { | 1335 void TabStrip::GetAccessibleState(ui::AXViewState* state) { |
| 1337 state->role = ui::AX_ROLE_TAB_LIST; | 1336 state->role = ui::AX_ROLE_TAB_LIST; |
| 1338 } | 1337 } |
| 1339 | 1338 |
| 1340 views::View* TabStrip::GetEventHandlerForRect(const gfx::Rect& rect) { | 1339 views::View* TabStrip::GetEventHandlerForRect(const gfx::RectF& rect) { |
| 1341 if (!views::UsePointBasedTargeting(rect)) | 1340 if (!views::UsePointBasedTargeting(rect)) |
| 1342 return View::GetEventHandlerForRect(rect); | 1341 return View::GetEventHandlerForRect(rect); |
| 1343 const gfx::Point point(rect.CenterPoint()); | 1342 const gfx::Point point(gfx::ToFlooredPoint(rect.CenterPoint())); |
| 1344 | 1343 |
| 1345 if (!touch_layout_.get()) { | 1344 if (!touch_layout_.get()) { |
| 1346 // Return any view that isn't a Tab or this TabStrip immediately. We don't | 1345 // Return any view that isn't a Tab or this TabStrip immediately. We don't |
| 1347 // want to interfere. | 1346 // want to interfere. |
| 1348 views::View* v = View::GetEventHandlerForRect(rect); | 1347 views::View* v = View::GetEventHandlerForRect(rect); |
| 1349 if (v && v != this && strcmp(v->GetClassName(), Tab::kViewClassName)) | 1348 if (v && v != this && strcmp(v->GetClassName(), Tab::kViewClassName)) |
| 1350 return v; | 1349 return v; |
| 1351 | 1350 |
| 1352 views::View* tab = FindTabHitByPoint(point); | 1351 views::View* tab = FindTabHitByPoint(point); |
| 1353 if (tab) | 1352 if (tab) |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2643 else | 2642 else |
| 2644 RemoveMessageLoopObserver(); | 2643 RemoveMessageLoopObserver(); |
| 2645 } | 2644 } |
| 2646 | 2645 |
| 2647 bool TabStrip::GetAdjustLayout() const { | 2646 bool TabStrip::GetAdjustLayout() const { |
| 2648 if (!adjust_layout_) | 2647 if (!adjust_layout_) |
| 2649 return false; | 2648 return false; |
| 2650 return chrome::GetHostDesktopTypeForNativeView( | 2649 return chrome::GetHostDesktopTypeForNativeView( |
| 2651 GetWidget()->GetNativeView()) == chrome::HOST_DESKTOP_TYPE_ASH; | 2650 GetWidget()->GetNativeView()) == chrome::HOST_DESKTOP_TYPE_ASH; |
| 2652 } | 2651 } |
| OLD | NEW |