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

Side by Side Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 147623004: Tab close buttons can only be targeted with touch if the whole button is visible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "chrome/browser/ui/views/tabs/tab.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // button is hidden behind another tab. 415 // button is hidden behind another tab.
416 gfx::Path tab_mask; 416 gfx::Path tab_mask;
417 tab_->GetHitTestMask(source, &tab_mask); 417 tab_->GetHitTestMask(source, &tab_mask);
418 418
419 gfx::Rect button_bounds(GetContentsBounds()); 419 gfx::Rect button_bounds(GetContentsBounds());
420 button_bounds.set_x(GetMirroredXForRect(button_bounds)); 420 button_bounds.set_x(GetMirroredXForRect(button_bounds));
421 gfx::RectF tab_bounds_f(gfx::SkRectToRectF(tab_mask.getBounds())); 421 gfx::RectF tab_bounds_f(gfx::SkRectToRectF(tab_mask.getBounds()));
422 views::View::ConvertRectToTarget(tab_, this, &tab_bounds_f); 422 views::View::ConvertRectToTarget(tab_, this, &tab_bounds_f);
423 gfx::Rect tab_bounds = gfx::ToEnclosingRect(tab_bounds_f); 423 gfx::Rect tab_bounds = gfx::ToEnclosingRect(tab_bounds_f);
424 424
425 // If the button is hidden behind another tab, the hit test mask is empty. 425 // If the hit test request is in response to a gesture, |path| should be
426 // Otherwise set the hit test mask to be the contents bounds. 426 // empty unless the entire tab close button is visible to the user. Hit
427 // test requests in response to a mouse event should always set |path|
428 // to be the visible portion of the tab close button, even if it is
429 // partially hidden behind another tab.
427 path->reset(); 430 path->reset();
428 if (tab_bounds.Intersects(button_bounds)) { 431 gfx::Rect intersection(gfx::IntersectRects(tab_bounds, button_bounds));
429 // Include the padding in the hit test mask for touch events. 432 if (!intersection.IsEmpty()) {
430 if (source == HIT_TEST_SOURCE_TOUCH) 433 #if !defined(OS_WIN)
sky 2014/02/03 20:55:47 Why the ifdef? I also don't understand why we can
tdanderson 2014/02/03 23:08:13 If we always return the intersection, then tabs wi
431 button_bounds = GetLocalBounds(); 434 // TODO(tdanderson): Enforce this constraint on Windows once the issue
432 435 // described in crbug.com/337850 is resolved; the
433 // TODO: this isn't quite right, really need to intersect the two regions. 436 // improper layout/clipping of the tab close button
434 path->addRect(RectToSkRect(button_bounds)); 437 // causes Contains() to always return false.
438 if (source == HIT_TEST_SOURCE_TOUCH &&
439 !tab_bounds.Contains(button_bounds))
440 return;
441 #endif
442 path->addRect(RectToSkRect(intersection));
435 } 443 }
436 } 444 }
437 445
438 virtual const char* GetClassName() const OVERRIDE { 446 virtual const char* GetClassName() const OVERRIDE {
439 return kTabCloseButtonName; 447 return kTabCloseButtonName;
440 } 448 }
441 449
442 private: 450 private:
443 Tab* tab_; 451 Tab* tab_;
444 452
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 const gfx::ImageSkia& image) { 1773 const gfx::ImageSkia& image) {
1766 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); 1774 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE);
1767 ImageCacheEntry entry; 1775 ImageCacheEntry entry;
1768 entry.resource_id = resource_id; 1776 entry.resource_id = resource_id;
1769 entry.scale_factor = scale_factor; 1777 entry.scale_factor = scale_factor;
1770 entry.image = image; 1778 entry.image = image;
1771 image_cache_->push_front(entry); 1779 image_cache_->push_front(entry);
1772 if (image_cache_->size() > kMaxImageCacheSize) 1780 if (image_cache_->size() > kMaxImageCacheSize)
1773 image_cache_->pop_back(); 1781 image_cache_->pop_back();
1774 } 1782 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698