| 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/base_tab.h" | 5 #include "chrome/browser/ui/views/tabs/base_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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // TabCloseButton | 45 // TabCloseButton |
| 46 // | 46 // |
| 47 // This is a Button subclass that causes middle clicks to be forwarded to the | 47 // This is a Button subclass that causes middle clicks to be forwarded to the |
| 48 // parent View by explicitly not handling them in OnMousePressed. | 48 // parent View by explicitly not handling them in OnMousePressed. |
| 49 class BaseTab::TabCloseButton : public views::ImageButton { | 49 class BaseTab::TabCloseButton : public views::ImageButton { |
| 50 public: | 50 public: |
| 51 explicit TabCloseButton(BaseTab* tab) : views::ImageButton(tab), tab_(tab) {} | 51 explicit TabCloseButton(BaseTab* tab) : views::ImageButton(tab), tab_(tab) {} |
| 52 virtual ~TabCloseButton() {} | 52 virtual ~TabCloseButton() {} |
| 53 | 53 |
| 54 // Overridden from views::View. | 54 // Overridden from views::View. |
| 55 virtual View* GetEventHandlerForPoint(const gfx::Point& point) OVERRIDE { | 55 virtual View* GetEventHandler(const gfx::Rect& rect, EventType type) |
| 56 OVERRIDE { |
| 56 // Ignore the padding set on the button. | 57 // Ignore the padding set on the button. |
| 57 gfx::Rect rect = GetContentsBounds(); | 58 gfx::Rect contents_rect = GetContentsBounds(); |
| 58 rect.set_x(GetMirroredXForRect(rect)); | 59 contents_rect.set_x(GetMirroredXForRect(contents_rect)); |
| 59 | 60 |
| 60 #if defined(USE_ASH) | 61 #if defined(USE_ASH) |
| 61 // Include the padding in hit-test for touch events. | 62 // Include the padding in hit-test for touch events. |
| 62 if (aura::Env::GetInstance()->is_touch_down()) | 63 if (aura::Env::GetInstance()->is_touch_down()) |
| 63 rect = GetLocalBounds(); | 64 contents_rect = GetLocalBounds(); |
| 64 #elif defined(OS_WIN) | 65 #elif defined(OS_WIN) |
| 65 // TODO(sky): Use local-bounds if a touch-point is active. | 66 // TODO(sky): Use local-bounds if a touch-point is active. |
| 66 // http://crbug.com/145258 | 67 // http://crbug.com/145258 |
| 67 #endif | 68 #endif |
| 68 | 69 |
| 69 return rect.Contains(point) ? this : parent(); | 70 return contents_rect.Intersects(rect) ? this : parent(); |
| 70 } | 71 } |
| 71 | 72 |
| 72 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { | 73 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { |
| 73 if (tab_->controller()) | 74 if (tab_->controller()) |
| 74 tab_->controller()->OnMouseEventInTab(this, event); | 75 tab_->controller()->OnMouseEventInTab(this, event); |
| 75 | 76 |
| 76 bool handled = ImageButton::OnMousePressed(event); | 77 bool handled = ImageButton::OnMousePressed(event); |
| 77 // Explicitly mark midle-mouse clicks as non-handled to ensure the tab | 78 // Explicitly mark midle-mouse clicks as non-handled to ensure the tab |
| 78 // sees them. | 79 // sees them. |
| 79 return event.IsOnlyMiddleMouseButton() ? false : handled; | 80 return event.IsOnlyMiddleMouseButton() ? false : handled; |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 // static | 657 // static |
| 657 void BaseTab::InitResources() { | 658 void BaseTab::InitResources() { |
| 658 static bool initialized = false; | 659 static bool initialized = false; |
| 659 if (!initialized) { | 660 if (!initialized) { |
| 660 initialized = true; | 661 initialized = true; |
| 661 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 662 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 662 font_ = new gfx::Font(rb.GetFont(ui::ResourceBundle::BaseFont)); | 663 font_ = new gfx::Font(rb.GetFont(ui::ResourceBundle::BaseFont)); |
| 663 font_height_ = font_->GetHeight(); | 664 font_height_ = font_->GetHeight(); |
| 664 } | 665 } |
| 665 } | 666 } |
| OLD | NEW |