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.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 25 matching lines...) Expand all Loading... |
36 #include "ui/gfx/canvas.h" | 36 #include "ui/gfx/canvas.h" |
37 #include "ui/gfx/color_analysis.h" | 37 #include "ui/gfx/color_analysis.h" |
38 #include "ui/gfx/favicon_size.h" | 38 #include "ui/gfx/favicon_size.h" |
39 #include "ui/gfx/font.h" | 39 #include "ui/gfx/font.h" |
40 #include "ui/gfx/image/image_skia_operations.h" | 40 #include "ui/gfx/image/image_skia_operations.h" |
41 #include "ui/gfx/path.h" | 41 #include "ui/gfx/path.h" |
42 #include "ui/gfx/rect_conversions.h" | 42 #include "ui/gfx/rect_conversions.h" |
43 #include "ui/gfx/skia_util.h" | 43 #include "ui/gfx/skia_util.h" |
44 #include "ui/gfx/text_elider.h" | 44 #include "ui/gfx/text_elider.h" |
45 #include "ui/views/controls/button/image_button.h" | 45 #include "ui/views/controls/button/image_button.h" |
| 46 #include "ui/views/rect_based_targeting_utils.h" |
46 #include "ui/views/widget/tooltip_manager.h" | 47 #include "ui/views/widget/tooltip_manager.h" |
47 #include "ui/views/widget/widget.h" | 48 #include "ui/views/widget/widget.h" |
48 #include "ui/views/window/non_client_view.h" | 49 #include "ui/views/window/non_client_view.h" |
49 | 50 |
50 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
51 #include "win8/util/win8_util.h" | 52 #include "win8/util/win8_util.h" |
52 #endif | 53 #endif |
53 | 54 |
54 #if defined(USE_ASH) | 55 #if defined(USE_ASH) |
55 #include "ui/aura/env.h" | 56 #include "ui/aura/env.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 // TabCloseButton | 349 // TabCloseButton |
349 // | 350 // |
350 // This is a Button subclass that causes middle clicks to be forwarded to the | 351 // This is a Button subclass that causes middle clicks to be forwarded to the |
351 // parent View by explicitly not handling them in OnMousePressed. | 352 // parent View by explicitly not handling them in OnMousePressed. |
352 class Tab::TabCloseButton : public views::ImageButton { | 353 class Tab::TabCloseButton : public views::ImageButton { |
353 public: | 354 public: |
354 explicit TabCloseButton(Tab* tab) : views::ImageButton(tab), tab_(tab) {} | 355 explicit TabCloseButton(Tab* tab) : views::ImageButton(tab), tab_(tab) {} |
355 virtual ~TabCloseButton() {} | 356 virtual ~TabCloseButton() {} |
356 | 357 |
357 // Overridden from views::View. | 358 // Overridden from views::View. |
358 virtual View* GetEventHandlerForPoint(const gfx::Point& point) OVERRIDE { | 359 virtual View* GetEventHandlerForRect(const gfx::Rect& rect) OVERRIDE { |
| 360 if (!views::UsePointBasedTargeting(rect)) |
| 361 return View::GetEventHandlerForRect(rect); |
| 362 |
359 // Ignore the padding set on the button. | 363 // Ignore the padding set on the button. |
360 gfx::Rect rect = GetContentsBounds(); | 364 gfx::Rect contents_bounds = GetContentsBounds(); |
361 rect.set_x(GetMirroredXForRect(rect)); | 365 contents_bounds.set_x(GetMirroredXForRect(contents_bounds)); |
362 | 366 |
| 367 // TODO(tdanderson): Remove this ifdef if rect-based targeting |
| 368 // is turned on by default. |
363 #if defined(USE_ASH) | 369 #if defined(USE_ASH) |
364 // Include the padding in hit-test for touch events. | 370 // Include the padding in hit-test for touch events. |
365 if (aura::Env::GetInstance()->is_touch_down()) | 371 if (aura::Env::GetInstance()->is_touch_down()) |
366 rect = GetLocalBounds(); | 372 contents_bounds = GetLocalBounds(); |
367 #elif defined(OS_WIN) | 373 #elif defined(OS_WIN) |
368 // TODO(sky): Use local-bounds if a touch-point is active. | 374 // TODO(sky): Use local-bounds if a touch-point is active. |
369 // http://crbug.com/145258 | 375 // http://crbug.com/145258 |
370 #endif | 376 #endif |
371 | 377 |
372 return rect.Contains(point) ? this : parent(); | 378 return contents_bounds.Intersects(rect) ? this : parent(); |
373 } | 379 } |
374 | 380 |
375 // Overridden from views::View. | 381 // Overridden from views::View. |
376 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) OVERRIDE { | 382 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) OVERRIDE { |
377 // Tab close button has no children, so tooltip handler should be the same | 383 // Tab close button has no children, so tooltip handler should be the same |
378 // as the event handler. | 384 // as the event handler. |
379 // In addition, a hit test has to be performed for the point (as | 385 // In addition, a hit test has to be performed for the point (as |
380 // GetTooltipHandlerForPoint() is responsible for it). | 386 // GetTooltipHandlerForPoint() is responsible for it). |
381 if (!HitTestPoint(point)) | 387 if (!HitTestPoint(point)) |
382 return NULL; | 388 return NULL; |
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 const gfx::ImageSkia& image) { | 1786 const gfx::ImageSkia& image) { |
1781 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1787 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
1782 ImageCacheEntry entry; | 1788 ImageCacheEntry entry; |
1783 entry.resource_id = resource_id; | 1789 entry.resource_id = resource_id; |
1784 entry.scale_factor = scale_factor; | 1790 entry.scale_factor = scale_factor; |
1785 entry.image = image; | 1791 entry.image = image; |
1786 image_cache_->push_front(entry); | 1792 image_cache_->push_front(entry); |
1787 if (image_cache_->size() > kMaxImageCacheSize) | 1793 if (image_cache_->size() > kMaxImageCacheSize) |
1788 image_cache_->pop_back(); | 1794 image_cache_->pop_back(); |
1789 } | 1795 } |
OLD | NEW |