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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 const char* Link::GetClassName() const { | 44 const char* Link::GetClassName() const { |
45 return kViewClassName; | 45 return kViewClassName; |
46 } | 46 } |
47 | 47 |
48 gfx::NativeCursor Link::GetCursor(const ui::MouseEvent& event) { | 48 gfx::NativeCursor Link::GetCursor(const ui::MouseEvent& event) { |
49 if (!enabled()) | 49 if (!enabled()) |
50 return gfx::kNullCursor; | 50 return gfx::kNullCursor; |
51 return GetNativeHandCursor(); | 51 return GetNativeHandCursor(); |
52 } | 52 } |
53 | 53 |
54 bool Link::HitTestRect(const gfx::Rect& rect) const { | 54 bool Link::CanProcessEventsWithinSubtree() const { |
55 // We need to allow clicks on the link. So we override the implementation in | 55 // Links need to be able to accept events (e.g., clicking) even though |
56 // Label and use the default implementation of View. | 56 // in general Labels do not. |
57 return View::HitTestRect(rect); | 57 return View::CanProcessEventsWithinSubtree(); |
58 } | 58 } |
59 | 59 |
60 bool Link::OnMousePressed(const ui::MouseEvent& event) { | 60 bool Link::OnMousePressed(const ui::MouseEvent& event) { |
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 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 void Link::RecalculateFont() { | 220 void Link::RecalculateFont() { |
221 // Underline the link iff it is enabled and |underline_| is true. | 221 // Underline the link iff it is enabled and |underline_| is true. |
222 const int style = font_list().GetFontStyle(); | 222 const int style = font_list().GetFontStyle(); |
223 const int intended_style = (enabled() && underline_) ? | 223 const int intended_style = (enabled() && underline_) ? |
224 (style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE); | 224 (style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE); |
225 if (style != intended_style) | 225 if (style != intended_style) |
226 Label::SetFontList(font_list().DeriveWithStyle(intended_style)); | 226 Label::SetFontList(font_list().DeriveWithStyle(intended_style)); |
227 } | 227 } |
228 | 228 |
229 } // namespace views | 229 } // namespace views |
OLD | NEW |