| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // TabCloseButton | 233 // TabCloseButton |
| 234 // | 234 // |
| 235 // This is a Button subclass that causes middle clicks to be forwarded to the | 235 // This is a Button subclass that causes middle clicks to be forwarded to the |
| 236 // parent View by explicitly not handling them in OnMousePressed. | 236 // parent View by explicitly not handling them in OnMousePressed. |
| 237 class Tab::TabCloseButton : public views::ImageButton { | 237 class Tab::TabCloseButton : public views::ImageButton { |
| 238 public: | 238 public: |
| 239 explicit TabCloseButton(Tab* tab) : views::ImageButton(tab), tab_(tab) {} | 239 explicit TabCloseButton(Tab* tab) : views::ImageButton(tab), tab_(tab) {} |
| 240 virtual ~TabCloseButton() {} | 240 virtual ~TabCloseButton() {} |
| 241 | 241 |
| 242 // Overridden from views::View. | 242 // Overridden from views::View. |
| 243 virtual View* GetEventHandlerForRect(const gfx::Rect& rect) OVERRIDE { | 243 virtual View* GetEventHandlerForRect(const gfx::RectF& rect) OVERRIDE { |
| 244 if (!views::UsePointBasedTargeting(rect)) | 244 if (!views::UsePointBasedTargeting(rect)) |
| 245 return View::GetEventHandlerForRect(rect); | 245 return View::GetEventHandlerForRect(rect); |
| 246 | 246 |
| 247 // Ignore the padding set on the button. | 247 // Ignore the padding set on the button. |
| 248 gfx::Rect contents_bounds = GetContentsBounds(); | 248 gfx::Rect contents_bounds = GetContentsBounds(); |
| 249 contents_bounds.set_x(GetMirroredXForRect(contents_bounds)); | 249 contents_bounds.set_x(GetMirroredXForRect(contents_bounds)); |
| 250 | 250 |
| 251 // TODO(tdanderson): Remove this ifdef if rect-based targeting | 251 // TODO(tdanderson): Remove this ifdef if rect-based targeting |
| 252 // is turned on by default. | 252 // is turned on by default. |
| 253 #if defined(USE_ASH) | 253 #if defined(USE_ASH) |
| 254 // Include the padding in hit-test for touch events. | 254 // Include the padding in hit-test for touch events. |
| 255 if (aura::Env::GetInstance()->is_touch_down()) | 255 if (aura::Env::GetInstance()->is_touch_down()) |
| 256 contents_bounds = GetLocalBounds(); | 256 contents_bounds = GetLocalBounds(); |
| 257 #elif defined(OS_WIN) | 257 #elif defined(OS_WIN) |
| 258 // TODO(sky): Use local-bounds if a touch-point is active. | 258 // TODO(sky): Use local-bounds if a touch-point is active. |
| 259 // http://crbug.com/145258 | 259 // http://crbug.com/145258 |
| 260 #endif | 260 #endif |
| 261 | 261 |
| 262 return contents_bounds.Intersects(rect) ? this : parent(); | 262 return gfx::RectF(contents_bounds).Intersects(rect) ? this : parent(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 // Overridden from views::View. | 265 // Overridden from views::View. |
| 266 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) OVERRIDE { | 266 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) OVERRIDE { |
| 267 // Tab close button has no children, so tooltip handler should be the same | 267 // Tab close button has no children, so tooltip handler should be the same |
| 268 // as the event handler. | 268 // as the event handler. |
| 269 // In addition, a hit test has to be performed for the point (as | 269 // In addition, a hit test has to be performed for the point (as |
| 270 // GetTooltipHandlerForPoint() is responsible for it). | 270 // GetTooltipHandlerForPoint() is responsible for it). |
| 271 if (!HitTestPoint(point)) | 271 if (!HitTestPoint(point)) |
| 272 return NULL; | 272 return NULL; |
| (...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 const gfx::ImageSkia& image) { | 1647 const gfx::ImageSkia& image) { |
| 1648 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1648 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
| 1649 ImageCacheEntry entry; | 1649 ImageCacheEntry entry; |
| 1650 entry.resource_id = resource_id; | 1650 entry.resource_id = resource_id; |
| 1651 entry.scale_factor = scale_factor; | 1651 entry.scale_factor = scale_factor; |
| 1652 entry.image = image; | 1652 entry.image = image; |
| 1653 image_cache_->push_front(entry); | 1653 image_cache_->push_front(entry); |
| 1654 if (image_cache_->size() > kMaxImageCacheSize) | 1654 if (image_cache_->size() > kMaxImageCacheSize) |
| 1655 image_cache_->pop_back(); | 1655 image_cache_->pop_back(); |
| 1656 } | 1656 } |
| OLD | NEW |