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

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

Issue 10825254: Remove views::KeyEvent, replacing uses of it with ui::KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/link.h ('k') | ui/views/controls/menu/submenu_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"
11 #include "ui/base/accessibility/accessible_view_state.h" 11 #include "ui/base/accessibility/accessible_view_state.h"
12 #include "ui/base/event.h"
12 #include "ui/base/keycodes/keyboard_codes.h" 13 #include "ui/base/keycodes/keyboard_codes.h"
13 #include "ui/gfx/color_utils.h" 14 #include "ui/gfx/color_utils.h"
14 #include "ui/gfx/font.h" 15 #include "ui/gfx/font.h"
15 #include "ui/views/controls/link_listener.h" 16 #include "ui/views/controls/link_listener.h"
16 #include "ui/views/events/event.h" 17 #include "ui/views/events/event.h"
17 18
18 #if defined(USE_AURA) 19 #if defined(USE_AURA)
19 #include "ui/base/cursor/cursor.h" 20 #include "ui/base/cursor/cursor.h"
20 #endif 21 #endif
21 22
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 88
88 if (listener_) 89 if (listener_)
89 listener_->LinkClicked(this, event.flags()); 90 listener_->LinkClicked(this, event.flags());
90 } 91 }
91 } 92 }
92 93
93 void Link::OnMouseCaptureLost() { 94 void Link::OnMouseCaptureLost() {
94 SetPressed(false); 95 SetPressed(false);
95 } 96 }
96 97
97 bool Link::OnKeyPressed(const KeyEvent& event) { 98 bool Link::OnKeyPressed(const ui::KeyEvent& event) {
98 bool activate = ((event.key_code() == ui::VKEY_SPACE) || 99 bool activate = ((event.key_code() == ui::VKEY_SPACE) ||
99 (event.key_code() == ui::VKEY_RETURN)); 100 (event.key_code() == ui::VKEY_RETURN));
100 if (!activate) 101 if (!activate)
101 return false; 102 return false;
102 103
103 SetPressed(false); 104 SetPressed(false);
104 105
105 // Focus the link on key pressed. 106 // Focus the link on key pressed.
106 RequestFocus(); 107 RequestFocus();
107 108
(...skipping 13 matching lines...) Expand all
121 RequestFocus(); 122 RequestFocus();
122 if (listener_) 123 if (listener_)
123 listener_->LinkClicked(this, event.flags()); 124 listener_->LinkClicked(this, event.flags());
124 } else { 125 } else {
125 SetPressed(false); 126 SetPressed(false);
126 return ui::GESTURE_STATUS_UNKNOWN; 127 return ui::GESTURE_STATUS_UNKNOWN;
127 } 128 }
128 return ui::GESTURE_STATUS_CONSUMED; 129 return ui::GESTURE_STATUS_CONSUMED;
129 } 130 }
130 131
131 bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& event) { 132 bool Link::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) {
132 // Make sure we don't process space or enter as accelerators. 133 // Make sure we don't process space or enter as accelerators.
133 return (event.key_code() == ui::VKEY_SPACE) || 134 return (event.key_code() == ui::VKEY_SPACE) ||
134 (event.key_code() == ui::VKEY_RETURN); 135 (event.key_code() == ui::VKEY_RETURN);
135 } 136 }
136 137
137 void Link::GetAccessibleState(ui::AccessibleViewState* state) { 138 void Link::GetAccessibleState(ui::AccessibleViewState* state) {
138 Label::GetAccessibleState(state); 139 Label::GetAccessibleState(state);
139 state->role = ui::AccessibilityTypes::ROLE_LINK; 140 state->role = ui::AccessibilityTypes::ROLE_LINK;
140 } 141 }
141 142
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void Link::RecalculateFont() { 199 void Link::RecalculateFont() {
199 // The font should be underlined iff the link is enabled. 200 // The font should be underlined iff the link is enabled.
200 if (enabled() == !(font().GetStyle() & gfx::Font::UNDERLINED)) { 201 if (enabled() == !(font().GetStyle() & gfx::Font::UNDERLINED)) {
201 Label::SetFont(font().DeriveFont(0, enabled() ? 202 Label::SetFont(font().DeriveFont(0, enabled() ?
202 (font().GetStyle() | gfx::Font::UNDERLINED) : 203 (font().GetStyle() | gfx::Font::UNDERLINED) :
203 (font().GetStyle() & ~gfx::Font::UNDERLINED))); 204 (font().GetStyle() & ~gfx::Font::UNDERLINED)));
204 } 205 }
205 } 206 }
206 207
207 } // namespace views 208 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/link.h ('k') | ui/views/controls/menu/submenu_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698