Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: ui/views/controls/link.cc

Issue 287193002: Remove overrides of HitTestRect() which just return false (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/link.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 {
55 // We need to allow clicks on the link. So we override the implementation in
56 // Label and use the default implementation of View.
57 return View::HitTestRect(rect);
58 }
59
60 bool Link::OnMousePressed(const ui::MouseEvent& event) { 54 bool Link::OnMousePressed(const ui::MouseEvent& event) {
61 if (!enabled() || 55 if (!enabled() ||
62 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) 56 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton()))
63 return false; 57 return false;
64 SetPressed(true); 58 SetPressed(true);
65 return true; 59 return true;
66 } 60 }
67 61
68 bool Link::OnMouseDragged(const ui::MouseEvent& event) { 62 bool Link::OnMouseDragged(const ui::MouseEvent& event) {
69 SetPressed(enabled() && 63 SetPressed(enabled() &&
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // border, when in this case we probably wanted zero width. 159 // border, when in this case we probably wanted zero width.
166 SetFocusable(!text.empty()); 160 SetFocusable(!text.empty());
167 } 161 }
168 162
169 void Link::SetEnabledColor(SkColor color) { 163 void Link::SetEnabledColor(SkColor color) {
170 requested_enabled_color_ = color; 164 requested_enabled_color_ = color;
171 if (!pressed_) 165 if (!pressed_)
172 Label::SetEnabledColor(requested_enabled_color_); 166 Label::SetEnabledColor(requested_enabled_color_);
173 } 167 }
174 168
169 bool Link::CanAcceptEvent(const ui::Event& event) {
170 // Links need to be able to accept events (e.g., clicking) even though
171 // in general Labels do not.
172 return true;
sadrul 2014/05/21 15:44:59 I think this should return View::CanAcceptEvent(ev
tdanderson 2014/05/21 21:03:26 Done.
173 }
174
175 void Link::SetPressedColor(SkColor color) { 175 void Link::SetPressedColor(SkColor color) {
176 requested_pressed_color_ = color; 176 requested_pressed_color_ = color;
177 if (pressed_) 177 if (pressed_)
178 Label::SetEnabledColor(requested_pressed_color_); 178 Label::SetEnabledColor(requested_pressed_color_);
179 } 179 }
180 180
181 void Link::SetUnderline(bool underline) { 181 void Link::SetUnderline(bool underline) {
182 if (underline_ == underline) 182 if (underline_ == underline)
183 return; 183 return;
184 underline_ = underline; 184 underline_ = underline;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « ui/views/controls/link.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698