| 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 "ui/views/controls/link.h" | 5 #include "ui/views/controls/link.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 if (!enabled() || | 61 if (!enabled() || |
| 62 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) | 62 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) |
| 63 return false; | 63 return false; |
| 64 SetPressed(true); | 64 SetPressed(true); |
| 65 return true; | 65 return true; |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool Link::OnMouseDragged(const ui::MouseEvent& event) { | 68 bool Link::OnMouseDragged(const ui::MouseEvent& event) { |
| 69 SetPressed(enabled() && | 69 SetPressed(enabled() && |
| 70 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && | 70 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && |
| 71 HitTestPoint(event.location())); | 71 HitTestPoint(gfx::ToFlooredPoint(event.location()))); |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void Link::OnMouseReleased(const ui::MouseEvent& event) { | 75 void Link::OnMouseReleased(const ui::MouseEvent& event) { |
| 76 // Change the highlight first just in case this instance is deleted | 76 // Change the highlight first just in case this instance is deleted |
| 77 // while calling the controller | 77 // while calling the controller |
| 78 OnMouseCaptureLost(); | 78 OnMouseCaptureLost(); |
| 79 if (enabled() && | 79 if (enabled() && (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && |
| 80 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && | 80 HitTestPoint(gfx::ToFlooredPoint(event.location()))) { |
| 81 HitTestPoint(event.location())) { | |
| 82 // Focus the link on click. | 81 // Focus the link on click. |
| 83 RequestFocus(); | 82 RequestFocus(); |
| 84 | 83 |
| 85 if (listener_) | 84 if (listener_) |
| 86 listener_->LinkClicked(this, event.flags()); | 85 listener_->LinkClicked(this, event.flags()); |
| 87 } | 86 } |
| 88 } | 87 } |
| 89 | 88 |
| 90 void Link::OnMouseCaptureLost() { | 89 void Link::OnMouseCaptureLost() { |
| 91 SetPressed(false); | 90 SetPressed(false); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 void Link::RecalculateFont() { | 219 void Link::RecalculateFont() { |
| 221 // Underline the link iff it is enabled and |underline_| is true. | 220 // Underline the link iff it is enabled and |underline_| is true. |
| 222 const int style = font_list().GetFontStyle(); | 221 const int style = font_list().GetFontStyle(); |
| 223 const int intended_style = (enabled() && underline_) ? | 222 const int intended_style = (enabled() && underline_) ? |
| 224 (style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE); | 223 (style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE); |
| 225 if (style != intended_style) | 224 if (style != intended_style) |
| 226 Label::SetFontList(font_list().DeriveWithStyle(intended_style)); | 225 Label::SetFontList(font_list().DeriveWithStyle(intended_style)); |
| 227 } | 226 } |
| 228 | 227 |
| 229 } // namespace views | 228 } // namespace views |
| OLD | NEW |