| Index: chrome/browser/ui/views/tabs/tab_strip.cc
|
| diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
|
| index 6841fd93fa618f6d749327c9241325a1900fb213..28c9cc2f1a603ffcd6e9b4c063f7f6f490128fbd 100644
|
| --- a/chrome/browser/ui/views/tabs/tab_strip.cc
|
| +++ b/chrome/browser/ui/views/tabs/tab_strip.cc
|
| @@ -254,16 +254,16 @@ class ResetDraggingStateDelegate
|
| DISALLOW_COPY_AND_ASSIGN(ResetDraggingStateDelegate);
|
| };
|
|
|
| -// If |dest| contains the point |point_in_source| the event handler from |dest|
|
| +// If |dest| intersects the rect |rect_in_source| the event handler from |dest|
|
| // is returned. Otherwise NULL is returned.
|
| -views::View* ConvertPointToViewAndGetEventHandler(
|
| +views::View* ConvertRectToViewAndGetEventHandler(
|
| views::View* source,
|
| views::View* dest,
|
| - const gfx::Point& point_in_source) {
|
| - gfx::Point dest_point(point_in_source);
|
| - views::View::ConvertPointToTarget(source, dest, &dest_point);
|
| - return dest->HitTestPoint(dest_point) ?
|
| - dest->GetEventHandlerForPoint(dest_point) : NULL;
|
| + const gfx::Rect& rect_in_source) {
|
| + gfx::Rect dest_rect(rect_in_source);
|
| + views::View::ConvertRectToTarget(source, dest, &dest_rect);
|
| + return dest->HitTestRect(dest_rect) ?
|
| + dest->GetEventHandlerForRect(dest_rect) : NULL;
|
| }
|
|
|
| // Gets a tooltip handler for |point_in_source| from |dest|. Note that |dest|
|
| @@ -907,22 +907,25 @@ void TabStrip::UpdateLoadingAnimations() {
|
| }
|
|
|
| bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) {
|
| - views::View* v = GetEventHandlerForPoint(point);
|
| + return IsRectInWindowCaption(gfx::Rect(point, gfx::Size(1, 1)));
|
| +}
|
| +
|
| +bool TabStrip::IsRectInWindowCaption(const gfx::Rect& rect) {
|
| + views::View* v = GetEventHandlerForRect(rect);
|
|
|
| // If there is no control at this location, claim the hit was in the title
|
| // bar to get a move action.
|
| if (v == this)
|
| return true;
|
|
|
| - // Check to see if the point is within the non-button parts of the new tab
|
| + // Check to see if the rect intersects the non-button parts of the new tab
|
| // button. The button has a non-rectangular shape, so if it's not in the
|
| // visual portions of the button we treat it as a click to the caption.
|
| - gfx::Point point_in_newtab_coords(point);
|
| - View::ConvertPointToTarget(this, newtab_button_, &point_in_newtab_coords);
|
| - if (newtab_button_->GetLocalBounds().Contains(point_in_newtab_coords) &&
|
| - !newtab_button_->HitTestPoint(point_in_newtab_coords)) {
|
| + gfx::Rect rect_in_newtab_coords(rect);
|
| + View::ConvertRectToTarget(this, newtab_button_, &rect_in_newtab_coords);
|
| + if (newtab_button_->GetLocalBounds().Intersects(rect_in_newtab_coords) &&
|
| + !newtab_button_->HitTestRect(rect_in_newtab_coords))
|
| return true;
|
| - }
|
|
|
| // All other regions, including the new Tab button, should be considered part
|
| // of the containing Window's client area so that regular events can be
|
| @@ -1428,27 +1431,30 @@ void TabStrip::GetAccessibleState(ui::AccessibleViewState* state) {
|
| state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST;
|
| }
|
|
|
| -views::View* TabStrip::GetEventHandlerForPoint(const gfx::Point& point) {
|
| +views::View* TabStrip::GetEventHandlerForRect(const gfx::Rect& rect) {
|
| + if (!View::UsePointBasedTargeting(rect))
|
| + return View::GetEventHandlerForRect(rect);
|
| +
|
| if (!touch_layout_.get()) {
|
| // Return any view that isn't a Tab or this TabStrip immediately. We don't
|
| // want to interfere.
|
| - views::View* v = View::GetEventHandlerForPoint(point);
|
| + views::View* v = View::GetEventHandlerForRect(rect);
|
| if (v && v != this && strcmp(v->GetClassName(), Tab::kViewClassName))
|
| return v;
|
|
|
| - views::View* tab = FindTabHitByPoint(point);
|
| + views::View* tab = FindTabHitByPoint(rect.CenterPoint());
|
| if (tab)
|
| return tab;
|
| } else {
|
| if (newtab_button_->visible()) {
|
| views::View* view =
|
| - ConvertPointToViewAndGetEventHandler(this, newtab_button_, point);
|
| + ConvertRectToViewAndGetEventHandler(this, newtab_button_, rect);
|
| if (view)
|
| return view;
|
| }
|
| - Tab* tab = FindTabForEvent(point);
|
| + Tab* tab = FindTabForEvent(rect.CenterPoint());
|
| if (tab)
|
| - return ConvertPointToViewAndGetEventHandler(this, tab, point);
|
| + return ConvertRectToViewAndGetEventHandler(this, tab, rect);
|
| }
|
| return this;
|
| }
|
| @@ -2591,6 +2597,13 @@ bool TabStrip::IsPointInTab(Tab* tab,
|
| return tab->HitTestPoint(point_in_tab_coords);
|
| }
|
|
|
| +bool TabStrip::IsRectInTab(Tab* tab,
|
| + const gfx::Rect& rect_in_tabstrip_coords) {
|
| + gfx::Rect rect_in_tab_coords(rect_in_tabstrip_coords);
|
| + View::ConvertRectToTarget(this, tab, &rect_in_tab_coords);
|
| + return tab->HitTestRect(rect_in_tab_coords);
|
| +}
|
| +
|
| int TabStrip::GetStartXForNormalTabs() const {
|
| int mini_tab_count = GetMiniTabCount();
|
| if (mini_tab_count == 0)
|
|
|