diff options
Diffstat (limited to 'views/controls')
29 files changed, 250 insertions, 249 deletions
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index baf0209..56abaeb 100644 --- a/views/controls/button/custom_button.cc +++ b/views/controls/button/custom_button.cc @@ -4,8 +4,8 @@ #include "views/controls/button/custom_button.h" -#include "app/keyboard_codes.h" #include "ui/base/animation/throb_animation.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/screen.h" namespace views { @@ -203,9 +203,9 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) { // Space sets button state to pushed. Enter clicks the button. This matches // the Windows native behavior of buttons, where Space clicks the button on // KeyRelease and Enter clicks the button on KeyPressed. - if (e.GetKeyCode() == app::VKEY_SPACE) { + if (e.GetKeyCode() == ui::VKEY_SPACE) { SetState(BS_PUSHED); - } else if (e.GetKeyCode() == app::VKEY_RETURN) { + } else if (e.GetKeyCode() == ui::VKEY_RETURN) { SetState(BS_NORMAL); NotifyClick(e); } else { @@ -215,7 +215,7 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) { } bool CustomButton::OnKeyReleased(const KeyEvent& e) { - if ((state_ == BS_DISABLED) || (e.GetKeyCode() != app::VKEY_SPACE)) + if ((state_ == BS_DISABLED) || (e.GetKeyCode() != ui::VKEY_SPACE)) return false; SetState(BS_NORMAL); diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index e7d746a..ad51681 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -220,10 +220,10 @@ void MenuButton::OnMouseReleased(const MouseEvent& e, } bool MenuButton::OnKeyPressed(const KeyEvent& e) { - if (e.GetKeyCode() == app::VKEY_SPACE || - e.GetKeyCode() == app::VKEY_RETURN || - e.GetKeyCode() == app::VKEY_UP || - e.GetKeyCode() == app::VKEY_DOWN) { + if (e.GetKeyCode() == ui::VKEY_SPACE || + e.GetKeyCode() == ui::VKEY_RETURN || + e.GetKeyCode() == ui::VKEY_UP || + e.GetKeyCode() == ui::VKEY_DOWN) { bool result = Activate(); if (GetFocusManager()->GetFocusedView() == NULL) RequestFocus(); diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc index 84eee12..650bf0f 100644 --- a/views/controls/button/native_button.cc +++ b/views/controls/button/native_button.cc @@ -4,8 +4,8 @@ #include "views/controls/button/native_button.h" -#include "app/keyboard_codes.h" #include "base/i18n/rtl.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/native/native_view_host.h" #if defined(OS_WIN) @@ -88,9 +88,9 @@ void NativeButton::SetIsDefault(bool is_default) { if (is_default == is_default_) return; if (is_default) - AddAccelerator(Accelerator(app::VKEY_RETURN, false, false, false)); + AddAccelerator(Accelerator(ui::VKEY_RETURN, false, false, false)); else - RemoveAccelerator(Accelerator(app::VKEY_RETURN, false, false, false)); + RemoveAccelerator(Accelerator(ui::VKEY_RETURN, false, false, false)); SetAppearsAsDefault(is_default); } diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc index 9d1b1f0..49dd4d3 100644 --- a/views/controls/combobox/combobox.cc +++ b/views/controls/combobox/combobox.cc @@ -5,9 +5,9 @@ #include "views/controls/combobox/combobox.h" #include "app/combobox_model.h" -#include "app/keyboard_codes.h" #include "base/logging.h" #include "base/utf_string_conversions.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/combobox/native_combobox_wrapper.h" #include "views/controls/native/native_view_host.h" @@ -75,7 +75,7 @@ void Combobox::SetEnabled(bool flag) { // VKEY_ESCAPE should be handled by this view when the drop down list is active. // In other words, the list should be closed instead of the dialog. bool Combobox::SkipDefaultKeyEventProcessing(const KeyEvent& e) { - if (e.GetKeyCode() != app::VKEY_ESCAPE || + if (e.GetKeyCode() != ui::VKEY_ESCAPE || e.IsShiftDown() || e.IsControlDown() || e.IsAltDown()) { return false; } diff --git a/views/controls/link.cc b/views/controls/link.cc index 6101e49..e83411e 100644 --- a/views/controls/link.cc +++ b/views/controls/link.cc @@ -8,10 +8,10 @@ #include <gdk/gdk.h> #endif -#include "app/keyboard_codes.h" #include "base/logging.h" #include "gfx/color_utils.h" #include "gfx/font.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/event.h" #if defined(OS_LINUX) @@ -126,8 +126,8 @@ void Link::OnMouseReleased(const MouseEvent& e, bool canceled) { } bool Link::OnKeyPressed(const KeyEvent& e) { - bool activate = ((e.GetKeyCode() == app::VKEY_SPACE) || - (e.GetKeyCode() == app::VKEY_RETURN)); + bool activate = ((e.GetKeyCode() == ui::VKEY_SPACE) || + (e.GetKeyCode() == ui::VKEY_RETURN)); if (!activate) return false; @@ -144,8 +144,8 @@ bool Link::OnKeyPressed(const KeyEvent& e) { bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { // Make sure we don't process space or enter as accelerators. - return (e.GetKeyCode() == app::VKEY_SPACE) || - (e.GetKeyCode() == app::VKEY_RETURN); + return (e.GetKeyCode() == ui::VKEY_SPACE) || + (e.GetKeyCode() == ui::VKEY_RETURN); } AccessibilityTypes::Role Link::GetAccessibleRole() { diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index 31d21f0..27b059e 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -4,13 +4,13 @@ #include "views/controls/menu/menu_controller.h" -#include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "base/i18n/rtl.h" #include "base/time.h" #include "base/utf_string_conversions.h" #include "gfx/canvas_skia.h" #include "ui/base/dragdrop/os_exchange_data.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/button/menu_button.h" #include "views/controls/menu/menu_scroll_view_container.h" #include "views/controls/menu/submenu_view.h" @@ -22,7 +22,7 @@ #include "views/widget/widget.h" #if defined(OS_LINUX) -#include "app/keyboard_code_conversion_gtk.h" +#include "ui/base/keycodes/keyboard_code_conversion_gtk.h" #endif #if defined(TOUCH_UI) @@ -830,8 +830,8 @@ bool MenuController::Dispatch(GdkEvent* event) { switch (event->type) { case GDK_KEY_PRESS: { - app::KeyboardCode win_keycode = - app::WindowsKeyCodeForGdkKeyCode(event->key.keyval); + ui::KeyboardCode win_keycode = + ui::WindowsKeyCodeForGdkKeyCode(event->key.keyval); if (!OnKeyDown(win_keycode)) return false; @@ -883,35 +883,35 @@ bool MenuController::OnKeyDown(int key_code DCHECK(blocking_run_); switch (key_code) { - case app::VKEY_UP: + case ui::VKEY_UP: IncrementSelection(-1); break; - case app::VKEY_DOWN: + case ui::VKEY_DOWN: IncrementSelection(1); break; // Handling of VK_RIGHT and VK_LEFT is different depending on the UI // layout. - case app::VKEY_RIGHT: + case ui::VKEY_RIGHT: if (base::i18n::IsRTL()) CloseSubmenu(); else OpenSubmenuChangeSelectionIfCan(); break; - case app::VKEY_LEFT: + case ui::VKEY_LEFT: if (base::i18n::IsRTL()) OpenSubmenuChangeSelectionIfCan(); else CloseSubmenu(); break; - case app::VKEY_SPACE: + case ui::VKEY_SPACE: SendAcceleratorToHotTrackedView(); break; - case app::VKEY_RETURN: + case ui::VKEY_RETURN: if (pending_state_.item) { if (pending_state_.item->HasSubmenu()) { OpenSubmenuChangeSelectionIfCan(); @@ -923,7 +923,7 @@ bool MenuController::OnKeyDown(int key_code } break; - case app::VKEY_ESCAPE: + case ui::VKEY_ESCAPE: if (!state_.item->GetParentMenuItem() || (!state_.item->GetParentMenuItem()->GetParentMenuItem() && (!state_.item->HasSubmenu() || @@ -978,7 +978,7 @@ bool MenuController::SendAcceleratorToHotTrackedView() { if (!hot_view) return false; - Accelerator accelerator(app::VKEY_RETURN, false, false, false); + Accelerator accelerator(ui::VKEY_RETURN, false, false, false); hot_view->AcceleratorPressed(accelerator); hot_view->SetHotTracked(true); return true; diff --git a/views/controls/menu/menu_win.cc b/views/controls/menu/menu_win.cc index b2ade18..6776a8b 100644 --- a/views/controls/menu/menu_win.cc +++ b/views/controls/menu/menu_win.cc @@ -6,7 +6,6 @@ #include <string> -#include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/win/window_impl.h" @@ -16,6 +15,7 @@ #include "gfx/canvas_skia.h" #include "gfx/font.h" #include "gfx/rect.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/accelerator.h" namespace views { @@ -443,7 +443,7 @@ void MenuWin::AddMenuItemInternal(int index, delegate()->GetLabel(item_id) : label); // Find out if there is a shortcut we need to append to the label. - views::Accelerator accelerator(app::VKEY_UNKNOWN, false, false, false); + views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); if (delegate() && delegate()->GetAcceleratorInfo(item_id, &accelerator)) { actual_label += L'\t'; actual_label += accelerator.GetShortcutText(); diff --git a/views/controls/menu/native_menu_gtk.cc b/views/controls/menu/native_menu_gtk.cc index 3aa6c3e..3aecff8 100644 --- a/views/controls/menu/native_menu_gtk.cc +++ b/views/controls/menu/native_menu_gtk.cc @@ -8,8 +8,6 @@ #include <map> #include <string> -#include "app/keyboard_code_conversion_gtk.h" -#include "app/keyboard_codes.h" #include "app/menus/menu_model.h" #include "base/i18n/rtl.h" #include "base/message_loop.h" @@ -18,6 +16,8 @@ #include "gfx/font.h" #include "gfx/gtk_util.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/keycodes/keyboard_codes.h" +#include "ui/base/keycodes/keyboard_code_conversion_gtk.h" #include "views/accelerator.h" #include "views/controls/menu/menu_2.h" #include "views/controls/menu/nested_dispatcher_gtk.h" @@ -388,7 +388,7 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index, submenu->GetNativeMenu()); } - views::Accelerator accelerator(app::VKEY_UNKNOWN, false, false, false); + views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); if (accel_group && model_->GetAcceleratorAt(index, &accelerator)) { int gdk_modifiers = 0; if (accelerator.IsShiftDown()) @@ -398,7 +398,7 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index, if (accelerator.IsAltDown()) gdk_modifiers |= GDK_MOD1_MASK; gtk_widget_add_accelerator(menu_item, "activate", accel_group, - app::GdkKeyCodeForWindowsKeyCode(accelerator.GetKeyCode(), false), + ui::GdkKeyCodeForWindowsKeyCode(accelerator.GetKeyCode(), false), static_cast<GdkModifierType>(gdk_modifiers), GTK_ACCEL_VISIBLE); } diff --git a/views/controls/menu/native_menu_win.cc b/views/controls/menu/native_menu_win.cc index cf36c8e..efdaa67 100644 --- a/views/controls/menu/native_menu_win.cc +++ b/views/controls/menu/native_menu_win.cc @@ -4,7 +4,6 @@ #include "views/controls/menu/native_menu_win.h" -#include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/win/hwnd_util.h" @@ -13,6 +12,7 @@ #include "gfx/canvas_skia.h" #include "gfx/font.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/accelerator.h" #include "views/controls/menu/menu_2.h" @@ -554,7 +554,7 @@ void NativeMenuWin::UpdateMenuItemInfoForString( menus::MenuModel::ItemType type = model_->GetTypeAt(model_index); if (type != menus::MenuModel::TYPE_SUBMENU) { // Add accelerator details to the label if provided. - views::Accelerator accelerator(app::VKEY_UNKNOWN, false, false, false); + views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); if (model_->GetAcceleratorAt(model_index, &accelerator)) { formatted += L"\t"; formatted += accelerator.GetShortcutText(); diff --git a/views/controls/native_control.cc b/views/controls/native_control.cc index 9434a50..b684a82 100644 --- a/views/controls/native_control.cc +++ b/views/controls/native_control.cc @@ -10,14 +10,14 @@ #include <atlframe.h> #include <atlmisc.h> -#include "app/keyboard_code_conversion_win.h" -#include "app/keyboard_codes.h" #include "app/l10n_util_win.h" #include "app/win/hwnd_util.h" #include "app/view_prop.h" #include "base/logging.h" #include "base/scoped_ptr.h" #include "gfx/native_theme_win.h" +#include "ui/base/keycodes/keyboard_codes.h" +#include "ui/base/keycodes/keyboard_code_conversion_win.h" #include "views/background.h" #include "views/border.h" #include "views/controls/native/native_view_host.h" @@ -371,7 +371,7 @@ LRESULT CALLBACK NativeControl::NativeControlWndProc(HWND window, DCHECK(original_handler); if (message == WM_KEYDOWN && - native_control->OnKeyDown(app::KeyboardCodeForWindowsKeyCode(w_param))) { + native_control->OnKeyDown(ui::KeyboardCodeForWindowsKeyCode(w_param))) { return 0; } else if (message == WM_SETFOCUS) { // Let the focus manager know that the focus changed. diff --git a/views/controls/native_control.h b/views/controls/native_control.h index 75a2a49..60f447c 100644 --- a/views/controls/native_control.h +++ b/views/controls/native_control.h @@ -8,7 +8,7 @@ #include <windows.h> -#include "app/keyboard_codes.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/view.h" namespace views { @@ -82,7 +82,7 @@ class NativeControl : public View { // Invoked when a key is pressed on the control. // Should return true if the key message was processed, false otherwise. - virtual bool OnKeyDown(app::KeyboardCode virtual_key_code) { return false; } + virtual bool OnKeyDown(ui::KeyboardCode virtual_key_code) { return false; } // Returns additional extended style flags. When subclasses call // CreateWindowEx in order to create the underlying control, they must OR the diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc index 12f98c1..5a426e1 100644 --- a/views/controls/scrollbar/bitmap_scroll_bar.cc +++ b/views/controls/scrollbar/bitmap_scroll_bar.cc @@ -8,7 +8,6 @@ #include "views/screen.h" #endif -#include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "base/callback.h" #include "base/compiler_specific.h" @@ -18,6 +17,7 @@ #include "gfx/canvas.h" #include "grit/app_strings.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/menu/menu.h" #include "views/controls/scroll_view.h" #include "views/widget/widget.h" @@ -498,32 +498,32 @@ bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) { bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) { ScrollAmount amount = SCROLL_NONE; switch (event.GetKeyCode()) { - case app::VKEY_UP: + case ui::VKEY_UP: if (!IsHorizontal()) amount = SCROLL_PREV_LINE; break; - case app::VKEY_DOWN: + case ui::VKEY_DOWN: if (!IsHorizontal()) amount = SCROLL_NEXT_LINE; break; - case app::VKEY_LEFT: + case ui::VKEY_LEFT: if (IsHorizontal()) amount = SCROLL_PREV_LINE; break; - case app::VKEY_RIGHT: + case ui::VKEY_RIGHT: if (IsHorizontal()) amount = SCROLL_NEXT_LINE; break; - case app::VKEY_PRIOR: + case ui::VKEY_PRIOR: amount = SCROLL_PREV_PAGE; break; - case app::VKEY_NEXT: + case ui::VKEY_NEXT: amount = SCROLL_NEXT_PAGE; break; - case app::VKEY_HOME: + case ui::VKEY_HOME: amount = SCROLL_START; break; - case app::VKEY_END: + case ui::VKEY_END: amount = SCROLL_END; break; } diff --git a/views/controls/scrollbar/native_scroll_bar_gtk.cc b/views/controls/scrollbar/native_scroll_bar_gtk.cc index 6f318ec..0a1bc73 100644 --- a/views/controls/scrollbar/native_scroll_bar_gtk.cc +++ b/views/controls/scrollbar/native_scroll_bar_gtk.cc @@ -6,7 +6,7 @@ #include <gtk/gtk.h> -#include "app/keyboard_codes_posix.h" +#include "ui/base/keycodes/keyboard_codes_posix.h" #include "views/controls/scrollbar/native_scroll_bar.h" #include "views/controls/scrollbar/scroll_bar.h" @@ -45,32 +45,32 @@ bool NativeScrollBarGtk::OnKeyPressed(const KeyEvent& event) { if (!native_view()) return false; switch (event.GetKeyCode()) { - case app::VKEY_UP: + case ui::VKEY_UP: if (!native_scroll_bar_->IsHorizontal()) MoveStep(false /* negative */); break; - case app::VKEY_DOWN: + case ui::VKEY_DOWN: if (!native_scroll_bar_->IsHorizontal()) MoveStep(true /* positive */); break; - case app::VKEY_LEFT: + case ui::VKEY_LEFT: if (native_scroll_bar_->IsHorizontal()) MoveStep(false /* negative */); break; - case app::VKEY_RIGHT: + case ui::VKEY_RIGHT: if (native_scroll_bar_->IsHorizontal()) MoveStep(true /* positive */); break; - case app::VKEY_PRIOR: + case ui::VKEY_PRIOR: MovePage(false /* negative */); break; - case app::VKEY_NEXT: + case ui::VKEY_NEXT: MovePage(true /* positive */); break; - case app::VKEY_HOME: + case ui::VKEY_HOME: MoveTo(0); break; - case app::VKEY_END: + case ui::VKEY_END: MoveToBottom(); break; default: diff --git a/views/controls/scrollbar/native_scroll_bar_win.cc b/views/controls/scrollbar/native_scroll_bar_win.cc index 0aea447c..6286305 100644 --- a/views/controls/scrollbar/native_scroll_bar_win.cc +++ b/views/controls/scrollbar/native_scroll_bar_win.cc @@ -7,9 +7,9 @@ #include <algorithm> #include <string> -#include "app/keyboard_codes.h" #include "app/win/window_impl.h" #include "base/message_loop.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/scrollbar/native_scroll_bar.h" #include "views/controls/scrollbar/scroll_bar.h" #include "views/widget/widget.h" @@ -231,31 +231,31 @@ bool NativeScrollBarWin::OnKeyPressed(const KeyEvent& event) { return false; int code = -1; switch (event.GetKeyCode()) { - case app::VKEY_UP: + case ui::VKEY_UP: if (!native_scroll_bar_->IsHorizontal()) code = SB_LINEUP; break; - case app::VKEY_PRIOR: + case ui::VKEY_PRIOR: code = SB_PAGEUP; break; - case app::VKEY_NEXT: + case ui::VKEY_NEXT: code = SB_PAGEDOWN; break; - case app::VKEY_DOWN: + case ui::VKEY_DOWN: if (!native_scroll_bar_->IsHorizontal()) code = SB_LINEDOWN; break; - case app::VKEY_HOME: + case ui::VKEY_HOME: code = SB_TOP; break; - case app::VKEY_END: + case ui::VKEY_END: code = SB_BOTTOM; break; - case app::VKEY_LEFT: + case ui::VKEY_LEFT: if (native_scroll_bar_->IsHorizontal()) code = SB_LINELEFT; break; - case app::VKEY_RIGHT: + case ui::VKEY_RIGHT: if (native_scroll_bar_->IsHorizontal()) code = SB_LINERIGHT; break; diff --git a/views/controls/tabbed_pane/tabbed_pane.cc b/views/controls/tabbed_pane/tabbed_pane.cc index 429e4c4..6fb07ea 100644 --- a/views/controls/tabbed_pane/tabbed_pane.cc +++ b/views/controls/tabbed_pane/tabbed_pane.cc @@ -4,8 +4,8 @@ #include "views/controls/tabbed_pane/tabbed_pane.h" -#include "app/keyboard_codes.h" #include "base/logging.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/native/native_view_host.h" #include "views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" @@ -82,7 +82,7 @@ void TabbedPane::ViewHierarchyChanged(bool is_add, View* parent, View* child) { bool TabbedPane::AcceleratorPressed(const views::Accelerator& accelerator) { // We only accept Ctrl+Tab keyboard events. DCHECK(accelerator.GetKeyCode() == - app::VKEY_TAB && accelerator.IsCtrlDown()); + ui::VKEY_TAB && accelerator.IsCtrlDown()); int tab_count = GetTabCount(); if (tab_count <= 1) @@ -100,9 +100,9 @@ bool TabbedPane::AcceleratorPressed(const views::Accelerator& accelerator) { void TabbedPane::LoadAccelerators() { // Ctrl+Shift+Tab - AddAccelerator(views::Accelerator(app::VKEY_TAB, true, true, false)); + AddAccelerator(views::Accelerator(ui::VKEY_TAB, true, true, false)); // Ctrl+Tab - AddAccelerator(views::Accelerator(app::VKEY_TAB, false, true, false)); + AddAccelerator(views::Accelerator(ui::VKEY_TAB, false, true, false)); } void TabbedPane::Layout() { diff --git a/views/controls/table/group_table_view.cc b/views/controls/table/group_table_view.cc index 4d34c56..cf35d73 100644 --- a/views/controls/table/group_table_view.cc +++ b/views/controls/table/group_table_view.cc @@ -63,7 +63,7 @@ void GroupTableView::SyncSelection() { } } -bool GroupTableView::OnKeyDown(app::KeyboardCode virtual_keycode) { +bool GroupTableView::OnKeyDown(ui::KeyboardCode virtual_keycode) { // In a list view, multiple items can be selected but only one item has the // focus. This creates a problem when the arrow keys are used for navigating // between items in the list view. An example will make this more clear: @@ -89,8 +89,8 @@ bool GroupTableView::OnKeyDown(app::KeyboardCode virtual_keycode) { // detect that one of the arrow keys is pressed. Thus, when it comes time // for the list view control to actually switch the focus, the right item // will be selected. - if ((virtual_keycode != app::VKEY_UP) && - (virtual_keycode != app::VKEY_DOWN)) { + if ((virtual_keycode != ui::VKEY_UP) && + (virtual_keycode != ui::VKEY_DOWN)) { return TableView::OnKeyDown(virtual_keycode); } @@ -118,10 +118,10 @@ bool GroupTableView::OnKeyDown(app::KeyboardCode virtual_keycode) { // If the user pressed the UP key, then the focus should be set to the // topmost element in the group. If the user pressed the DOWN key, the focus // should be set to the bottommost element. - if (virtual_keycode == app::VKEY_UP) { + if (virtual_keycode == ui::VKEY_UP) { SetFocusOnItem(group_range.start); } else { - DCHECK_EQ(virtual_keycode, app::VKEY_DOWN); + DCHECK_EQ(virtual_keycode, ui::VKEY_DOWN); SetFocusOnItem(group_range.start + group_range.length - 1); } diff --git a/views/controls/table/group_table_view.h b/views/controls/table/group_table_view.h index adf0bac..8ce6270 100644 --- a/views/controls/table/group_table_view.h +++ b/views/controls/table/group_table_view.h @@ -57,7 +57,7 @@ class GroupTableView : public TableView { // keys), we must take action when an arrow key is pressed. The reason we // need to process this message has to do with the manner in which the focus // needs to be set on a group item when a group is selected. - virtual bool OnKeyDown(app::KeyboardCode virtual_keycode); + virtual bool OnKeyDown(ui::KeyboardCode virtual_keycode); // Overriden to make sure rows in the same group stay grouped together. virtual int CompareRows(int model_row1, int model_row2); diff --git a/views/controls/table/native_table_win.cc b/views/controls/table/native_table_win.cc index 35769c6..d660dbb 100644 --- a/views/controls/table/native_table_win.cc +++ b/views/controls/table/native_table_win.cc @@ -463,7 +463,7 @@ void NativeTableWin::OnMiddleClick() { table_->observer()->OnMiddleClick(); } -bool NativeTableWin::OnKeyDown(app::KeyboardCode virtual_keycode) { +bool NativeTableWin::OnKeyDown(ui::KeyboardCode virtual_keycode) { if (!ignore_listview_change_ && table_->observer()) table_->observer()->OnKeyDown(virtual_keycode); return false; // Let the key event be processed as ususal. diff --git a/views/controls/table/native_table_win.h b/views/controls/table/native_table_win.h index dcbc087..548f070 100644 --- a/views/controls/table/native_table_win.h +++ b/views/controls/table/native_table_win.h @@ -74,7 +74,7 @@ class NativeTableWin : public NativeControlWin, public NativeTableWrapper { virtual void OnMiddleClick(); // Overridden from NativeControl. Notifies the observer. - virtual bool OnKeyDown(app::KeyboardCode virtual_keycode); + virtual bool OnKeyDown(ui::KeyboardCode virtual_keycode); // Custom drawing of our icons. LRESULT OnCustomDraw(NMLVCUSTOMDRAW* draw_info); diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc index d35b074..45b0bf1 100644 --- a/views/controls/table/table_view.cc +++ b/views/controls/table/table_view.cc @@ -1503,7 +1503,7 @@ void TableView::OnSelectedStateChanged() { } } -bool TableView::OnKeyDown(app::KeyboardCode virtual_keycode) { +bool TableView::OnKeyDown(ui::KeyboardCode virtual_keycode) { if (!ignore_listview_change_ && table_view_observer_) { table_view_observer_->OnKeyDown(virtual_keycode); } diff --git a/views/controls/table/table_view.h b/views/controls/table/table_view.h index 83ac85a..cae1a64b 100644 --- a/views/controls/table/table_view.h +++ b/views/controls/table/table_view.h @@ -16,10 +16,11 @@ typedef struct tagNMLVCUSTOMDRAW NMLVCUSTOMDRAW; #include <map> #include <vector> -#include "app/keyboard_codes.h" #include "app/table_model_observer.h" #include "base/gtest_prod_util.h" #include "third_party/skia/include/core/SkColor.h" +#include "ui/base/keycodes/keyboard_codes.h" + #if defined(OS_WIN) // TODO(port): remove the ifdef when native_control.h is ported. #include "views/controls/native_control.h" @@ -258,7 +259,7 @@ class TableView : public NativeControl, virtual void OnMiddleClick(); // Overridden from NativeControl. Notifies the observer. - virtual bool OnKeyDown(app::KeyboardCode virtual_keycode); + virtual bool OnKeyDown(ui::KeyboardCode virtual_keycode); // Invoked to customize the colors or font at a particular cell. If you // change the colors or font, return true. This is only invoked if diff --git a/views/controls/table/table_view_observer.h b/views/controls/table/table_view_observer.h index 86fff7a..3444118 100644 --- a/views/controls/table/table_view_observer.h +++ b/views/controls/table/table_view_observer.h @@ -6,7 +6,7 @@ #define VIEWS_CONTROLS_TABLE_TABLE_VIEW_OBSERVER_H_ #pragma once -#include "app/keyboard_codes.h" +#include "ui/base/keycodes/keyboard_codes.h" namespace views { @@ -28,7 +28,7 @@ class TableViewObserver { virtual void OnMiddleClick() {} // Optional method invoked when the user hits a key with the table in focus. - virtual void OnKeyDown(app::KeyboardCode virtual_keycode) {} + virtual void OnKeyDown(ui::KeyboardCode virtual_keycode) {} // Invoked when the user presses the delete key. virtual void OnTableViewDelete(TableView* table_view) {} diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc index 06ceb82..39677a7 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -427,52 +427,52 @@ void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) { // TODO(oshima): handle IME. if (key_event.GetType() == views::Event::ET_KEY_PRESSED) { - app::KeyboardCode key_code = key_event.GetKeyCode(); + ui::KeyboardCode key_code = key_event.GetKeyCode(); // TODO(oshima): shift-tab does not work. Figure out why and fix. - if (key_code == app::VKEY_TAB) + if (key_code == ui::VKEY_TAB) return false; bool selection = key_event.IsShiftDown(); bool control = key_event.IsControlDown(); bool text_changed = false; bool cursor_changed = false; switch (key_code) { - case app::VKEY_A: + case ui::VKEY_A: if (control) { model_->SelectAll(); cursor_changed = true; } break; - case app::VKEY_X: + case ui::VKEY_X: if (control) text_changed = model_->Cut(); break; - case app::VKEY_C: + case ui::VKEY_C: if (control) model_->Copy(); break; - case app::VKEY_V: + case ui::VKEY_V: if (control) text_changed = model_->Paste(); break; - case app::VKEY_RIGHT: + case ui::VKEY_RIGHT: control ? model_->MoveCursorToNextWord(selection) : model_->MoveCursorRight(selection); cursor_changed = true; break; - case app::VKEY_LEFT: + case ui::VKEY_LEFT: control ? model_->MoveCursorToPreviousWord(selection) : model_->MoveCursorLeft(selection); cursor_changed = true; break; - case app::VKEY_END: + case ui::VKEY_END: model_->MoveCursorToEnd(selection); cursor_changed = true; break; - case app::VKEY_HOME: + case ui::VKEY_HOME: model_->MoveCursorToStart(selection); cursor_changed = true; break; - case app::VKEY_BACK: + case ui::VKEY_BACK: if (!model_->HasSelection()) { if (selection && control) { // If both shift and control are pressed, then erase upto the @@ -490,7 +490,7 @@ bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) { text_changed = model_->Backspace(); cursor_changed = true; break; - case app::VKEY_DELETE: + case ui::VKEY_DELETE: if (!model_->HasSelection()) { if (selection && control) { // If both shift and control are pressed, then erase upto the @@ -507,7 +507,7 @@ bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) { } text_changed = model_->Delete(); break; - case app::VKEY_INSERT: + case ui::VKEY_INSERT: insert_ = !insert_; cursor_changed = true; break; @@ -544,114 +544,114 @@ bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) { char16 NativeTextfieldViews::GetPrintableChar(const KeyEvent& key_event) { // TODO(oshima): IME, i18n support. // This only works for UCS-2 characters. - app::KeyboardCode key_code = key_event.GetKeyCode(); + ui::KeyboardCode key_code = key_event.GetKeyCode(); bool shift = key_event.IsShiftDown(); bool upper = shift ^ key_event.IsCapsLockDown(); // TODO(oshima): We should have a utility function // under app to convert a KeyboardCode to a printable character, // probably in keyboard_code_conversion{.h, _x switch (key_code) { - case app::VKEY_NUMPAD0: + case ui::VKEY_NUMPAD0: return '0'; - case app::VKEY_NUMPAD1: + case ui::VKEY_NUMPAD1: return '1'; - case app::VKEY_NUMPAD2: + case ui::VKEY_NUMPAD2: return '2'; - case app::VKEY_NUMPAD3: + case ui::VKEY_NUMPAD3: return '3'; - case app::VKEY_NUMPAD4: + case ui::VKEY_NUMPAD4: return '4'; - case app::VKEY_NUMPAD5: + case ui::VKEY_NUMPAD5: return '5'; - case app::VKEY_NUMPAD6: + case ui::VKEY_NUMPAD6: return '6'; - case app::VKEY_NUMPAD7: + case ui::VKEY_NUMPAD7: return '7'; - case app::VKEY_NUMPAD8: + case ui::VKEY_NUMPAD8: return '8'; - case app::VKEY_NUMPAD9: + case ui::VKEY_NUMPAD9: return '9'; - case app::VKEY_MULTIPLY: + case ui::VKEY_MULTIPLY: return '*'; - case app::VKEY_ADD: + case ui::VKEY_ADD: return '+'; - case app::VKEY_SUBTRACT: + case ui::VKEY_SUBTRACT: return '-'; - case app::VKEY_DECIMAL: + case ui::VKEY_DECIMAL: return '.'; - case app::VKEY_DIVIDE: + case ui::VKEY_DIVIDE: return '/'; - case app::VKEY_SPACE: + case ui::VKEY_SPACE: return ' '; - case app::VKEY_0: + case ui::VKEY_0: return shift ? ')' : '0'; - case app::VKEY_1: + case ui::VKEY_1: return shift ? '!' : '1'; - case app::VKEY_2: + case ui::VKEY_2: return shift ? '@' : '2'; - case app::VKEY_3: + case ui::VKEY_3: return shift ? '#' : '3'; - case app::VKEY_4: + case ui::VKEY_4: return shift ? '$' : '4'; - case app::VKEY_5: + case ui::VKEY_5: return shift ? '%' : '5'; - case app::VKEY_6: + case ui::VKEY_6: return shift ? '^' : '6'; - case app::VKEY_7: + case ui::VKEY_7: return shift ? '&' : '7'; - case app::VKEY_8: + case ui::VKEY_8: return shift ? '*' : '8'; - case app::VKEY_9: + case ui::VKEY_9: return shift ? '(' : '9'; - case app::VKEY_A: - case app::VKEY_B: - case app::VKEY_C: - case app::VKEY_D: - case app::VKEY_E: - case app::VKEY_F: - case app::VKEY_G: - case app::VKEY_H: - case app::VKEY_I: - case app::VKEY_J: - case app::VKEY_K: - case app::VKEY_L: - case app::VKEY_M: - case app::VKEY_N: - case app::VKEY_O: - case app::VKEY_P: - case app::VKEY_Q: - case app::VKEY_R: - case app::VKEY_S: - case app::VKEY_T: - case app::VKEY_U: - case app::VKEY_V: - case app::VKEY_W: - case app::VKEY_X: - case app::VKEY_Y: - case app::VKEY_Z: - return (upper ? 'A' : 'a') + (key_code - app::VKEY_A); - case app::VKEY_OEM_1: + case ui::VKEY_A: + case ui::VKEY_B: + case ui::VKEY_C: + case ui::VKEY_D: + case ui::VKEY_E: + case ui::VKEY_F: + case ui::VKEY_G: + case ui::VKEY_H: + case ui::VKEY_I: + case ui::VKEY_J: + case ui::VKEY_K: + case ui::VKEY_L: + case ui::VKEY_M: + case ui::VKEY_N: + case ui::VKEY_O: + case ui::VKEY_P: + case ui::VKEY_Q: + case ui::VKEY_R: + case ui::VKEY_S: + case ui::VKEY_T: + case ui::VKEY_U: + case ui::VKEY_V: + case ui::VKEY_W: + case ui::VKEY_X: + case ui::VKEY_Y: + case ui::VKEY_Z: + return (upper ? 'A' : 'a') + (key_code - ui::VKEY_A); + case ui::VKEY_OEM_1: return shift ? ':' : ';'; - case app::VKEY_OEM_PLUS: + case ui::VKEY_OEM_PLUS: return shift ? '+' : '='; - case app::VKEY_OEM_COMMA: + case ui::VKEY_OEM_COMMA: return shift ? '<' : ','; - case app::VKEY_OEM_MINUS: + case ui::VKEY_OEM_MINUS: return shift ? '_' : '-'; - case app::VKEY_OEM_PERIOD: + case ui::VKEY_OEM_PERIOD: return shift ? '>' : '.'; - case app::VKEY_OEM_2: + case ui::VKEY_OEM_2: return shift ? '?' : '/'; - case app::VKEY_OEM_3: + case ui::VKEY_OEM_3: return shift ? '~' : '`'; - case app::VKEY_OEM_4: + case ui::VKEY_OEM_4: return shift ? '}' : ']'; - case app::VKEY_OEM_5: + case ui::VKEY_OEM_5: return shift ? '|' : '\\'; - case app::VKEY_OEM_6: + case ui::VKEY_OEM_6: return shift ? '{' : '['; - case app::VKEY_OEM_7: + case ui::VKEY_OEM_7: return shift ? '"' : '\''; default: return 0; diff --git a/views/controls/textfield/native_textfield_views_unittest.cc b/views/controls/textfield/native_textfield_views_unittest.cc index 05775f2..9b6eb0a 100644 --- a/views/controls/textfield/native_textfield_views_unittest.cc +++ b/views/controls/textfield/native_textfield_views_unittest.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "app/keyboard_codes.h" #include "base/utf_string_conversions.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/textfield/native_textfield_views.h" #include "views/controls/textfield/textfield.h" #include "views/controls/textfield/textfield_views_model.h" @@ -88,7 +88,7 @@ class NativeTextfieldViewsTest : public ViewsTestBase, } protected: - bool SendKeyEventToTextfieldViews(app::KeyboardCode key_code, + bool SendKeyEventToTextfieldViews(ui::KeyboardCode key_code, bool shift, bool control, bool capslock) { @@ -99,13 +99,13 @@ class NativeTextfieldViewsTest : public ViewsTestBase, return textfield_->OnKeyPressed(event); } - bool SendKeyEventToTextfieldViews(app::KeyboardCode key_code, + bool SendKeyEventToTextfieldViews(ui::KeyboardCode key_code, bool shift, bool control) { return SendKeyEventToTextfieldViews(key_code, shift, control, false); } - bool SendKeyEventToTextfieldViews(app::KeyboardCode key_code) { + bool SendKeyEventToTextfieldViews(ui::KeyboardCode key_code) { return SendKeyEventToTextfieldViews(key_code, false, false); } @@ -157,21 +157,21 @@ TEST_F(NativeTextfieldViewsTest, ModelChangesTeset) { TEST_F(NativeTextfieldViewsTest, KeyTest) { InitTextfield(Textfield::STYLE_DEFAULT); - SendKeyEventToTextfieldViews(app::VKEY_C, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_C, true, false); EXPECT_STR_EQ("C", textfield_->text()); EXPECT_STR_EQ("C", last_contents_); last_contents_.clear(); - SendKeyEventToTextfieldViews(app::VKEY_R, false, false); + SendKeyEventToTextfieldViews(ui::VKEY_R, false, false); EXPECT_STR_EQ("Cr", textfield_->text()); EXPECT_STR_EQ("Cr", last_contents_); textfield_->SetText(ASCIIToUTF16("")); - SendKeyEventToTextfieldViews(app::VKEY_C, true, false, true); - SendKeyEventToTextfieldViews(app::VKEY_C, false, false, true); - SendKeyEventToTextfieldViews(app::VKEY_1, false, false, true); - SendKeyEventToTextfieldViews(app::VKEY_1, true, false, true); - SendKeyEventToTextfieldViews(app::VKEY_1, true, false, false); + SendKeyEventToTextfieldViews(ui::VKEY_C, true, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_C, false, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_1, false, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_1, true, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_1, true, false, false); EXPECT_STR_EQ("cC1!!", textfield_->text()); EXPECT_STR_EQ("cC1!!", last_contents_); } @@ -180,34 +180,34 @@ TEST_F(NativeTextfieldViewsTest, ControlAndSelectTest) { // Insert a test string in a textfield. InitTextfield(Textfield::STYLE_DEFAULT); textfield_->SetText(ASCIIToUTF16("one two three")); - SendKeyEventToTextfieldViews(app::VKEY_RIGHT, + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, true /* shift */, false /* control */); - SendKeyEventToTextfieldViews(app::VKEY_RIGHT, true, false); - SendKeyEventToTextfieldViews(app::VKEY_RIGHT, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, true, false); EXPECT_STR_EQ("one", textfield_->GetSelectedText()); // Test word select. - SendKeyEventToTextfieldViews(app::VKEY_RIGHT, true, true); + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, true, true); EXPECT_STR_EQ("one two", textfield_->GetSelectedText()); - SendKeyEventToTextfieldViews(app::VKEY_RIGHT, true, true); + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, true, true); EXPECT_STR_EQ("one two three", textfield_->GetSelectedText()); - SendKeyEventToTextfieldViews(app::VKEY_LEFT, true, true); + SendKeyEventToTextfieldViews(ui::VKEY_LEFT, true, true); EXPECT_STR_EQ("one two ", textfield_->GetSelectedText()); - SendKeyEventToTextfieldViews(app::VKEY_LEFT, true, true); + SendKeyEventToTextfieldViews(ui::VKEY_LEFT, true, true); EXPECT_STR_EQ("one ", textfield_->GetSelectedText()); // Replace the selected text. - SendKeyEventToTextfieldViews(app::VKEY_Z, true, false); - SendKeyEventToTextfieldViews(app::VKEY_E, true, false); - SendKeyEventToTextfieldViews(app::VKEY_R, true, false); - SendKeyEventToTextfieldViews(app::VKEY_O, true, false); - SendKeyEventToTextfieldViews(app::VKEY_SPACE, false, false); + SendKeyEventToTextfieldViews(ui::VKEY_Z, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_E, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_R, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_O, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_SPACE, false, false); EXPECT_STR_EQ("ZERO two three", textfield_->text()); - SendKeyEventToTextfieldViews(app::VKEY_END, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_END, true, false); EXPECT_STR_EQ("two three", textfield_->GetSelectedText()); - SendKeyEventToTextfieldViews(app::VKEY_HOME, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_HOME, true, false); EXPECT_STR_EQ("ZERO ", textfield_->GetSelectedText()); } @@ -219,44 +219,44 @@ TEST_F(NativeTextfieldViewsTest, InsertionDeletionTest) { // This is ugly and should be replaced by a utility standard function. // See comment in NativeTextfieldViews::GetPrintableChar. char c = test_str[i]; - app::KeyboardCode code = - c == ' ' ? app::VKEY_SPACE : - static_cast<app::KeyboardCode>(app::VKEY_A + c - 'a'); + ui::KeyboardCode code = + c == ' ' ? ui::VKEY_SPACE : + static_cast<ui::KeyboardCode>(ui::VKEY_A + c - 'a'); SendKeyEventToTextfieldViews(code); } EXPECT_STR_EQ(test_str, textfield_->text()); // Move the cursor around. for (int i = 0; i < 6; i++) { - SendKeyEventToTextfieldViews(app::VKEY_LEFT); + SendKeyEventToTextfieldViews(ui::VKEY_LEFT); } - SendKeyEventToTextfieldViews(app::VKEY_RIGHT); + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT); // Delete using backspace and check resulting string. - SendKeyEventToTextfieldViews(app::VKEY_BACK); + SendKeyEventToTextfieldViews(ui::VKEY_BACK); EXPECT_STR_EQ("this is test", textfield_->text()); // Delete using delete key and check resulting string. for (int i = 0; i < 5; i++) { - SendKeyEventToTextfieldViews(app::VKEY_DELETE); + SendKeyEventToTextfieldViews(ui::VKEY_DELETE); } EXPECT_STR_EQ("this is ", textfield_->text()); // Select all and replace with "k". textfield_->SelectAll(); - SendKeyEventToTextfieldViews(app::VKEY_K); + SendKeyEventToTextfieldViews(ui::VKEY_K); EXPECT_STR_EQ("k", textfield_->text()); // Delete the previous word from cursor. textfield_->SetText(ASCIIToUTF16("one two three four")); - SendKeyEventToTextfieldViews(app::VKEY_END); - SendKeyEventToTextfieldViews(app::VKEY_BACK, false, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_END); + SendKeyEventToTextfieldViews(ui::VKEY_BACK, false, true, false); EXPECT_STR_EQ("one two three ", textfield_->text()); // Delete upto the beginning of the buffer from cursor in chromeos, do nothing // in windows. - SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true, false); - SendKeyEventToTextfieldViews(app::VKEY_BACK, true, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_BACK, true, true, false); #if defined(OS_WIN) EXPECT_STR_EQ("one two three ", textfield_->text()); #else @@ -265,14 +265,14 @@ TEST_F(NativeTextfieldViewsTest, InsertionDeletionTest) { // Delete the next word from cursor. textfield_->SetText(ASCIIToUTF16("one two three four")); - SendKeyEventToTextfieldViews(app::VKEY_HOME); - SendKeyEventToTextfieldViews(app::VKEY_DELETE, false, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_HOME); + SendKeyEventToTextfieldViews(ui::VKEY_DELETE, false, true, false); EXPECT_STR_EQ(" two three four", textfield_->text()); // Delete upto the end of the buffer from cursor in chromeos, do nothing // in windows. - SendKeyEventToTextfieldViews(app::VKEY_RIGHT, false, true, false); - SendKeyEventToTextfieldViews(app::VKEY_DELETE, true, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, false, true, false); + SendKeyEventToTextfieldViews(ui::VKEY_DELETE, true, true, false); #if defined(OS_WIN) EXPECT_STR_EQ(" two three four", textfield_->text()); #else @@ -291,11 +291,11 @@ TEST_F(NativeTextfieldViewsTest, PasswordTest) { TEST_F(NativeTextfieldViewsTest, OnKeyPressReturnValueTest) { InitTextfield(Textfield::STYLE_DEFAULT); - EXPECT_TRUE(SendKeyEventToTextfieldViews(app::VKEY_A)); + EXPECT_TRUE(SendKeyEventToTextfieldViews(ui::VKEY_A)); // F24, up/down key won't be handled. - EXPECT_FALSE(SendKeyEventToTextfieldViews(app::VKEY_F24)); - EXPECT_FALSE(SendKeyEventToTextfieldViews(app::VKEY_UP)); - EXPECT_FALSE(SendKeyEventToTextfieldViews(app::VKEY_DOWN)); + EXPECT_FALSE(SendKeyEventToTextfieldViews(ui::VKEY_F24)); + EXPECT_FALSE(SendKeyEventToTextfieldViews(ui::VKEY_UP)); + EXPECT_FALSE(SendKeyEventToTextfieldViews(ui::VKEY_DOWN)); } TEST_F(NativeTextfieldViewsTest, CursorMovement) { @@ -305,23 +305,23 @@ TEST_F(NativeTextfieldViewsTest, CursorMovement) { textfield_->SetText(ASCIIToUTF16("one two hre ")); // Send the cursor at the end. - SendKeyEventToTextfieldViews(app::VKEY_END); + SendKeyEventToTextfieldViews(ui::VKEY_END); // Ctrl+Left should move the cursor just before the last word. - SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true); - SendKeyEventToTextfieldViews(app::VKEY_T); + SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_T); EXPECT_STR_EQ("one two thre ", textfield_->text()); EXPECT_STR_EQ("one two thre ", last_contents_); // Ctrl+Right should move the cursor to the end of the last word. - SendKeyEventToTextfieldViews(app::VKEY_RIGHT, false, true); - SendKeyEventToTextfieldViews(app::VKEY_E); + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_E); EXPECT_STR_EQ("one two three ", textfield_->text()); EXPECT_STR_EQ("one two three ", last_contents_); // Ctrl+Right again should move the cursor to the end. - SendKeyEventToTextfieldViews(app::VKEY_RIGHT, false, true); - SendKeyEventToTextfieldViews(app::VKEY_BACK); + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_BACK); EXPECT_STR_EQ("one two three", textfield_->text()); EXPECT_STR_EQ("one two three", last_contents_); @@ -329,21 +329,21 @@ TEST_F(NativeTextfieldViewsTest, CursorMovement) { textfield_->SetText(ASCIIToUTF16(" ne two")); // Send the cursor at the beginning. - SendKeyEventToTextfieldViews(app::VKEY_HOME); + SendKeyEventToTextfieldViews(ui::VKEY_HOME); // Ctrl+Right, then Ctrl+Left should move the cursor to the beginning of the // first word. - SendKeyEventToTextfieldViews(app::VKEY_RIGHT, false, true); - SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true); - SendKeyEventToTextfieldViews(app::VKEY_O); + SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_O); EXPECT_STR_EQ(" one two", textfield_->text()); EXPECT_STR_EQ(" one two", last_contents_); // Ctrl+Left to move the cursor to the beginning of the first word. - SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true); // Ctrl+Left again should move the cursor back to the very beginning. - SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true); - SendKeyEventToTextfieldViews(app::VKEY_DELETE); + SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true); + SendKeyEventToTextfieldViews(ui::VKEY_DELETE); EXPECT_STR_EQ("one two", textfield_->text()); EXPECT_STR_EQ("one two", last_contents_); } diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index 279777f..e719f1f 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -6,8 +6,6 @@ #include <algorithm> -#include "app/keyboard_codes.h" -#include "app/keyboard_code_conversion_win.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/win/win_util.h" @@ -20,6 +18,8 @@ #include "skia/ext/skia_utils_win.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" +#include "ui/base/keycodes/keyboard_codes.h" +#include "ui/base/keycodes/keyboard_code_conversion_win.h" #include "views/controls/label.h" #include "views/controls/menu/menu_win.h" #include "views/controls/menu/menu_2.h" @@ -348,13 +348,13 @@ bool NativeTextfieldWin::GetAcceleratorForCommandId(int command_id, // anywhere so we need to check for them explicitly here. switch (command_id) { case IDS_APP_CUT: - *accelerator = views::Accelerator(app::VKEY_X, false, true, false); + *accelerator = views::Accelerator(ui::VKEY_X, false, true, false); return true; case IDS_APP_COPY: - *accelerator = views::Accelerator(app::VKEY_C, false, true, false); + *accelerator = views::Accelerator(ui::VKEY_C, false, true, false); return true; case IDS_APP_PASTE: - *accelerator = views::Accelerator(app::VKEY_V, false, true, false); + *accelerator = views::Accelerator(ui::VKEY_V, false, true, false); return true; } return container_view_->GetWidget()->GetAccelerator(command_id, accelerator); @@ -915,7 +915,7 @@ void NativeTextfieldWin::HandleKeystroke(UINT message, type = Event::ET_KEY_PRESSED; } KeyEvent key_event(type, - app::KeyboardCodeForWindowsKeyCode(key), + ui::KeyboardCodeForWindowsKeyCode(key), KeyEvent::GetKeyStateFlags(), repeat_count, flags, @@ -926,7 +926,7 @@ void NativeTextfieldWin::HandleKeystroke(UINT message, if (!handled) { OnBeforePossibleChange(); - if (key == app::VKEY_HOME || key == app::VKEY_END) { + if (key == ui::VKEY_HOME || key == ui::VKEY_END) { // DefWindowProc() might reset the keyboard layout when it receives a // keydown event for VKEY_HOME or VKEY_END. When the window was created // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc index 53d3695..66f7489 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -10,16 +10,16 @@ #include <string> -#include "app/keyboard_codes.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "gfx/insets.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/native/native_view_host.h" #include "views/controls/textfield/native_textfield_wrapper.h" #include "views/widget/widget.h" #if defined(OS_LINUX) -#include "app/keyboard_code_conversion_gtk.h" +#include "ui/base/keycodes/keyboard_code_conversion_gtk.h" #elif defined(OS_WIN) #include "app/win/win_util.h" #include "base/win/win_util.h" @@ -272,14 +272,14 @@ void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { // TODO(hamaji): Figure out which keyboard combinations we need to add here, // similar to LocationBarView::SkipDefaultKeyEventProcessing. - app::KeyboardCode key = e.GetKeyCode(); - if (key == app::VKEY_BACK) + ui::KeyboardCode key = e.GetKeyCode(); + if (key == ui::VKEY_BACK) return true; // We'll handle BackSpace ourselves. #if defined(OS_WIN) // We don't translate accelerators for ALT + NumPad digit on Windows, they are // used for entering special characters. We do translate alt-home. - if (e.IsAltDown() && (key != app::VKEY_HOME) && + if (e.IsAltDown() && (key != ui::VKEY_HOME) && app::win::IsNumPadDigit(key, e.IsExtendedKey())) return true; #endif diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h index fd9174e..afcc441 100644 --- a/views/controls/textfield/textfield.h +++ b/views/controls/textfield/textfield.h @@ -14,16 +14,16 @@ #include <string> -#include "app/keyboard_codes.h" #include "base/basictypes.h" -#if !defined(OS_LINUX) -#include "base/logging.h" -#endif #include "base/string16.h" #include "gfx/font.h" -#include "views/view.h" #include "third_party/skia/include/core/SkColor.h" +#include "ui/base/keycodes/keyboard_codes.h" +#include "views/view.h" +#if !defined(OS_LINUX) +#include "base/logging.h" +#endif #ifdef UNIT_TEST #include "gfx/native_widget_types.h" #include "views/controls/textfield/native_textfield_wrapper.h" diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc index 746330d..b45ff45 100644 --- a/views/controls/tree/tree_view.cc +++ b/views/controls/tree/tree_view.cc @@ -6,8 +6,6 @@ #include <vector> -#include "app/keyboard_code_conversion_win.h" -#include "app/keyboard_codes.h" #include "app/l10n_util_win.h" #include "app/resource_bundle.h" #include "app/win/hwnd_util.h" @@ -21,6 +19,8 @@ #include "gfx/icon_util.h" #include "gfx/point.h" #include "grit/app_resources.h" +#include "ui/base/keycodes/keyboard_codes.h" +#include "ui/base/keycodes/keyboard_code_conversion_win.h" #include "views/focus/focus_manager.h" #include "views/widget/widget.h" @@ -441,7 +441,7 @@ LRESULT TreeView::OnNotify(int w_param, LPNMHDR l_param) { NMTVKEYDOWN* key_down_message = reinterpret_cast<NMTVKEYDOWN*>(l_param); controller_->OnTreeViewKeyDown( - app::KeyboardCodeForWindowsKeyCode(key_down_message->wVKey)); + ui::KeyboardCodeForWindowsKeyCode(key_down_message->wVKey)); } break; @@ -451,7 +451,7 @@ LRESULT TreeView::OnNotify(int w_param, LPNMHDR l_param) { return 0; } -bool TreeView::OnKeyDown(app::KeyboardCode virtual_key_code) { +bool TreeView::OnKeyDown(ui::KeyboardCode virtual_key_code) { if (virtual_key_code == VK_F2) { if (!GetEditingNode()) { TreeModelNode* selected_node = GetSelectedNode(); @@ -459,7 +459,7 @@ bool TreeView::OnKeyDown(app::KeyboardCode virtual_key_code) { StartEditing(selected_node); } return true; - } else if (virtual_key_code == app::VKEY_RETURN && !process_enter_) { + } else if (virtual_key_code == ui::VKEY_RETURN && !process_enter_) { Widget* widget = GetWidget(); DCHECK(widget); Accelerator accelerator(Accelerator(virtual_key_code, diff --git a/views/controls/tree/tree_view.h b/views/controls/tree/tree_view.h index 61c6001..463a8bc 100644 --- a/views/controls/tree/tree_view.h +++ b/views/controls/tree/tree_view.h @@ -11,9 +11,9 @@ #include <map> -#include "app/keyboard_codes.h" #include "app/tree_model.h" #include "base/basictypes.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/native_control.h" namespace views { @@ -36,7 +36,7 @@ class TreeViewController { } // Invoked when a key is pressed on the tree view. - virtual void OnTreeViewKeyDown(app::KeyboardCode keycode) {} + virtual void OnTreeViewKeyDown(ui::KeyboardCode keycode) {} }; // TreeView ------------------------------------------------------------------- @@ -181,7 +181,7 @@ class TreeView : public NativeControl, TreeModelObserver { // We pay attention to key down for two reasons: to circumvent VK_ENTER from // toggling the expaned state when processes_enter_ is false, and to have F2 // start editting. - virtual bool OnKeyDown(app::KeyboardCode virtual_key_code); + virtual bool OnKeyDown(ui::KeyboardCode virtual_key_code); virtual void OnContextMenu(const POINT& location); |