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

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

Issue 10827198: Change View::HitTest to View::HitTestRect (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed errors reported by trybots Created 8 years, 4 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
« no previous file with comments | « ui/views/controls/link.h ('k') | ui/views/view.h » ('j') | 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/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if (!enabled()) 47 if (!enabled())
48 return gfx::kNullCursor; 48 return gfx::kNullCursor;
49 #if defined(USE_AURA) 49 #if defined(USE_AURA)
50 return ui::kCursorHand; 50 return ui::kCursorHand;
51 #elif defined(OS_WIN) 51 #elif defined(OS_WIN)
52 static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND); 52 static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND);
53 return g_hand_cursor; 53 return g_hand_cursor;
54 #endif 54 #endif
55 } 55 }
56 56
57 bool Link::HitTest(const gfx::Point& l) const { 57 bool Link::HitTestRect(const gfx::Rect& rect) const {
58 // We need to allow clicks on the link. So we override the implementation in 58 // We need to allow clicks on the link. So we override the implementation in
59 // Label and use the default implementation of View. 59 // Label and use the default implementation of View.
60 return View::HitTest(l); 60 return View::HitTestRect(rect);
61 } 61 }
62 62
63 bool Link::OnMousePressed(const MouseEvent& event) { 63 bool Link::OnMousePressed(const MouseEvent& event) {
64 if (!enabled() || 64 if (!enabled() ||
65 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) 65 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton()))
66 return false; 66 return false;
67 SetPressed(true); 67 SetPressed(true);
68 return true; 68 return true;
69 } 69 }
70 70
71 bool Link::OnMouseDragged(const MouseEvent& event) { 71 bool Link::OnMouseDragged(const MouseEvent& event) {
72 SetPressed(enabled() && 72 SetPressed(enabled() &&
73 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && 73 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
74 HitTest(event.location())); 74 HitTestPoint(event.location()));
75 return true; 75 return true;
76 } 76 }
77 77
78 void Link::OnMouseReleased(const MouseEvent& event) { 78 void Link::OnMouseReleased(const MouseEvent& event) {
79 // Change the highlight first just in case this instance is deleted 79 // Change the highlight first just in case this instance is deleted
80 // while calling the controller 80 // while calling the controller
81 OnMouseCaptureLost(); 81 OnMouseCaptureLost();
82 if (enabled() && 82 if (enabled() &&
83 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && 83 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
84 HitTest(event.location())) { 84 HitTestPoint(event.location())) {
85 // Focus the link on click. 85 // Focus the link on click.
86 RequestFocus(); 86 RequestFocus();
87 87
88 if (listener_) 88 if (listener_)
89 listener_->LinkClicked(this, event.flags()); 89 listener_->LinkClicked(this, event.flags());
90 } 90 }
91 } 91 }
92 92
93 void Link::OnMouseCaptureLost() { 93 void Link::OnMouseCaptureLost() {
94 SetPressed(false); 94 SetPressed(false);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void Link::RecalculateFont() { 198 void Link::RecalculateFont() {
199 // The font should be underlined iff the link is enabled. 199 // The font should be underlined iff the link is enabled.
200 if (enabled() == !(font().GetStyle() & gfx::Font::UNDERLINED)) { 200 if (enabled() == !(font().GetStyle() & gfx::Font::UNDERLINED)) {
201 Label::SetFont(font().DeriveFont(0, enabled() ? 201 Label::SetFont(font().DeriveFont(0, enabled() ?
202 (font().GetStyle() | gfx::Font::UNDERLINED) : 202 (font().GetStyle() | gfx::Font::UNDERLINED) :
203 (font().GetStyle() & ~gfx::Font::UNDERLINED))); 203 (font().GetStyle() & ~gfx::Font::UNDERLINED)));
204 } 204 }
205 } 205 }
206 206
207 } // namespace views 207 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/link.h ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698