diff options
author | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 00:38:27 +0000 |
---|---|---|
committer | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 00:38:27 +0000 |
commit | 7f05552488f8f9ea5000512fd1972894aee7ee82 (patch) | |
tree | 0e2ed5a562335907e44307a1d99e9c6ab8d8a3ec /views | |
parent | 9d7e8fd4a448491817b816585d6f375d71c0a97a (diff) | |
download | chromium_src-7f05552488f8f9ea5000512fd1972894aee7ee82.zip chromium_src-7f05552488f8f9ea5000512fd1972894aee7ee82.tar.gz chromium_src-7f05552488f8f9ea5000512fd1972894aee7ee82.tar.bz2 |
Re-lands 58186:
Original message:
"""
Move the keyboard files from base/ to app/.
Also moves the associated classes/enums from base:: to app::.
TEST=try bots compile
BUG=NONE
Review URL: http://codereview.chromium.org/3165064
"""
TBR=phajdan.jr@chromium.org
Review URL: http://codereview.chromium.org/3354005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58438 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
44 files changed, 215 insertions, 210 deletions
diff --git a/views/accelerator.cc b/views/accelerator.cc index 730191d..6b80cc4 100644 --- a/views/accelerator.cc +++ b/views/accelerator.cc @@ -22,46 +22,46 @@ namespace views { std::wstring Accelerator::GetShortcutText() const { int string_id = 0; switch(key_code_) { - case base::VKEY_TAB: + case app::VKEY_TAB: string_id = IDS_APP_TAB_KEY; break; - case base::VKEY_RETURN: + case app::VKEY_RETURN: string_id = IDS_APP_ENTER_KEY; break; - case base::VKEY_ESCAPE: + case app::VKEY_ESCAPE: string_id = IDS_APP_ESC_KEY; break; - case base::VKEY_PRIOR: + case app::VKEY_PRIOR: string_id = IDS_APP_PAGEUP_KEY; break; - case base::VKEY_NEXT: + case app::VKEY_NEXT: string_id = IDS_APP_PAGEDOWN_KEY; break; - case base::VKEY_END: + case app::VKEY_END: string_id = IDS_APP_END_KEY; break; - case base::VKEY_HOME: + case app::VKEY_HOME: string_id = IDS_APP_HOME_KEY; break; - case base::VKEY_INSERT: + case app::VKEY_INSERT: string_id = IDS_APP_INSERT_KEY; break; - case base::VKEY_DELETE: + case app::VKEY_DELETE: string_id = IDS_APP_DELETE_KEY; break; - case base::VKEY_LEFT: + case app::VKEY_LEFT: string_id = IDS_APP_LEFT_ARROW_KEY; break; - case base::VKEY_RIGHT: + case app::VKEY_RIGHT: string_id = IDS_APP_RIGHT_ARROW_KEY; break; - case base::VKEY_BACK: + case app::VKEY_BACK: string_id = IDS_APP_BACKSPACE_KEY; break; - case base::VKEY_F1: + case app::VKEY_F1: string_id = IDS_APP_F1_KEY; break; - case base::VKEY_F11: + case app::VKEY_F11: string_id = IDS_APP_F11_KEY; break; default: diff --git a/views/accelerator.h b/views/accelerator.h index 08dc201..5cf68f1 100644 --- a/views/accelerator.h +++ b/views/accelerator.h @@ -23,10 +23,10 @@ class Accelerator : public menus::Accelerator { public: Accelerator() : menus::Accelerator() {} - Accelerator(base::KeyboardCode keycode, int modifiers) + Accelerator(app::KeyboardCode keycode, int modifiers) : menus::Accelerator(keycode, modifiers) {} - Accelerator(base::KeyboardCode keycode, + Accelerator(app::KeyboardCode keycode, bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { key_code_ = keycode; modifiers_ = 0; diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index 04ff856..bc949c1 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 "app/throb_animation.h" -#include "base/keyboard_codes.h" #include "views/screen.h" namespace views { @@ -192,9 +192,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() == base::VKEY_SPACE) { + if (e.GetKeyCode() == app::VKEY_SPACE) { SetState(BS_PUSHED); - } else if (e.GetKeyCode() == base::VKEY_RETURN) { + } else if (e.GetKeyCode() == app::VKEY_RETURN) { SetState(BS_NORMAL); NotifyClick(e); } else { @@ -204,7 +204,7 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) { } bool CustomButton::OnKeyReleased(const KeyEvent& e) { - if ((state_ == BS_DISABLED) || (e.GetKeyCode() != base::VKEY_SPACE)) + if ((state_ == BS_DISABLED) || (e.GetKeyCode() != app::VKEY_SPACE)) return false; SetState(BS_NORMAL); diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index f09b2d4..4973ea2 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -219,10 +219,10 @@ void MenuButton::OnMouseReleased(const MouseEvent& e, } bool MenuButton::OnKeyPressed(const KeyEvent& e) { - if (e.GetKeyCode() == base::VKEY_SPACE || - e.GetKeyCode() == base::VKEY_RETURN || - e.GetKeyCode() == base::VKEY_UP || - e.GetKeyCode() == base::VKEY_DOWN) { + if (e.GetKeyCode() == app::VKEY_SPACE || + e.GetKeyCode() == app::VKEY_RETURN || + e.GetKeyCode() == app::VKEY_UP || + e.GetKeyCode() == app::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 4c66b9f..89dae9c 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 "base/keyboard_codes.h" #include "views/controls/native/native_view_host.h" #if defined(OS_WIN) @@ -90,9 +90,9 @@ void NativeButton::SetIsDefault(bool is_default) { if (is_default == is_default_) return; if (is_default) - AddAccelerator(Accelerator(base::VKEY_RETURN, false, false, false)); + AddAccelerator(Accelerator(app::VKEY_RETURN, false, false, false)); else - RemoveAccelerator(Accelerator(base::VKEY_RETURN, false, false, false)); + RemoveAccelerator(Accelerator(app::VKEY_RETURN, false, false, false)); SetAppearsAsDefault(is_default); } diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc index 0c24a0d..3eed917 100644 --- a/views/controls/combobox/combobox.cc +++ b/views/controls/combobox/combobox.cc @@ -5,7 +5,7 @@ #include "views/controls/combobox/combobox.h" #include "app/combobox_model.h" -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/logging.h" #include "base/utf_string_conversions.h" #include "views/controls/combobox/native_combobox_wrapper.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() != base::VKEY_ESCAPE || + if (e.GetKeyCode() != app::VKEY_ESCAPE || e.IsShiftDown() || e.IsControlDown() || e.IsAltDown()) { return false; } diff --git a/views/controls/link.cc b/views/controls/link.cc index 97dc01f..6cf81d3 100644 --- a/views/controls/link.cc +++ b/views/controls/link.cc @@ -8,7 +8,7 @@ #include <gdk/gdk.h> #endif -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/logging.h" #include "gfx/color_utils.h" #include "gfx/font.h" @@ -122,8 +122,8 @@ void Link::OnMouseReleased(const MouseEvent& e, bool canceled) { } bool Link::OnKeyPressed(const KeyEvent& e) { - bool activate = ((e.GetKeyCode() == base::VKEY_SPACE) || - (e.GetKeyCode() == base::VKEY_RETURN)); + bool activate = ((e.GetKeyCode() == app::VKEY_SPACE) || + (e.GetKeyCode() == app::VKEY_RETURN)); if (!activate) return false; @@ -140,8 +140,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() == base::VKEY_SPACE) || - (e.GetKeyCode() == base::VKEY_RETURN); + return (e.GetKeyCode() == app::VKEY_SPACE) || + (e.GetKeyCode() == app::VKEY_RETURN); } bool Link::GetAccessibleRole(AccessibilityTypes::Role* role) { diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index d5abe50..276226c 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -4,10 +4,10 @@ #include "views/controls/menu/menu_controller.h" +#include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "app/os_exchange_data.h" #include "base/i18n/rtl.h" -#include "base/keyboard_codes.h" #include "base/time.h" #include "base/utf_string_conversions.h" #include "gfx/canvas_skia.h" @@ -22,7 +22,7 @@ #include "views/widget/widget.h" #if defined(OS_LINUX) -#include "base/keyboard_code_conversion_gtk.h" +#include "app/keyboard_code_conversion_gtk.h" #endif using base::Time; @@ -813,8 +813,8 @@ bool MenuController::Dispatch(GdkEvent* event) { switch (event->type) { case GDK_KEY_PRESS: { - base::KeyboardCode win_keycode = - base::WindowsKeyCodeForGdkKeyCode(event->key.keyval); + app::KeyboardCode win_keycode = + app::WindowsKeyCodeForGdkKeyCode(event->key.keyval); if (!OnKeyDown(win_keycode)) return false; @@ -853,35 +853,35 @@ bool MenuController::OnKeyDown(int key_code DCHECK(blocking_run_); switch (key_code) { - case base::VKEY_UP: + case app::VKEY_UP: IncrementSelection(-1); break; - case base::VKEY_DOWN: + case app::VKEY_DOWN: IncrementSelection(1); break; // Handling of VK_RIGHT and VK_LEFT is different depending on the UI // layout. - case base::VKEY_RIGHT: + case app::VKEY_RIGHT: if (base::i18n::IsRTL()) CloseSubmenu(); else OpenSubmenuChangeSelectionIfCan(); break; - case base::VKEY_LEFT: + case app::VKEY_LEFT: if (base::i18n::IsRTL()) OpenSubmenuChangeSelectionIfCan(); else CloseSubmenu(); break; - case base::VKEY_SPACE: + case app::VKEY_SPACE: SendAcceleratorToHotTrackedView(); break; - case base::VKEY_RETURN: + case app::VKEY_RETURN: if (pending_state_.item) { if (pending_state_.item->HasSubmenu()) { OpenSubmenuChangeSelectionIfCan(); @@ -893,7 +893,7 @@ bool MenuController::OnKeyDown(int key_code } break; - case base::VKEY_ESCAPE: + case app::VKEY_ESCAPE: if (!state_.item->GetParentMenuItem() || (!state_.item->GetParentMenuItem()->GetParentMenuItem() && (!state_.item->HasSubmenu() || @@ -956,7 +956,7 @@ bool MenuController::SendAcceleratorToHotTrackedView() { if (!hot_view) return false; - Accelerator accelerator(base::VKEY_RETURN, false, false, false); + Accelerator accelerator(app::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 90637a0..0c75743 100644 --- a/views/controls/menu/menu_win.cc +++ b/views/controls/menu/menu_win.cc @@ -6,9 +6,9 @@ #include <string> +#include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" -#include "base/keyboard_codes.h" #include "base/logging.h" #include "base/stl_util-inl.h" #include "base/string_util.h" @@ -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(base::VKEY_UNKNOWN, false, false, false); + views::Accelerator accelerator(app::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 2ddf336..7954d20 100644 --- a/views/controls/menu/native_menu_gtk.cc +++ b/views/controls/menu/native_menu_gtk.cc @@ -8,11 +8,11 @@ #include <map> #include <string> +#include "app/keyboard_code_conversion_gtk.h" +#include "app/keyboard_codes.h" #include "app/menus/menu_model.h" #include "base/gtk_util.h" #include "base/i18n/rtl.h" -#include "base/keyboard_code_conversion_gtk.h" -#include "base/keyboard_codes.h" #include "base/message_loop.h" #include "base/time.h" #include "base/utf_string_conversions.h" @@ -329,7 +329,7 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index, submenu->GetNativeMenu()); } - views::Accelerator accelerator(base::VKEY_UNKNOWN, false, false, false); + views::Accelerator accelerator(app::VKEY_UNKNOWN, false, false, false); if (accel_group && model_->GetAcceleratorAt(index, &accelerator)) { int gdk_modifiers = 0; if (accelerator.IsShiftDown()) @@ -339,7 +339,7 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index, if (accelerator.IsAltDown()) gdk_modifiers |= GDK_MOD1_MASK; gtk_widget_add_accelerator(menu_item, "activate", accel_group, - base::GdkKeyCodeForWindowsKeyCode(accelerator.GetKeyCode(), false), + app::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 f65cfcd..665b15e 100644 --- a/views/controls/menu/native_menu_win.cc +++ b/views/controls/menu/native_menu_win.cc @@ -4,9 +4,9 @@ #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 "base/keyboard_codes.h" #include "base/logging.h" #include "base/stl_util-inl.h" #include "gfx/canvas_skia.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(base::VKEY_UNKNOWN, false, false, false); + views::Accelerator accelerator(app::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 942a093..a0ff1b0 100644 --- a/views/controls/native_control.cc +++ b/views/controls/native_control.cc @@ -10,8 +10,9 @@ #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 "base/keyboard_codes.h" #include "base/logging.h" #include "base/win_util.h" #include "gfx/native_theme_win.h" @@ -359,7 +360,7 @@ LRESULT CALLBACK NativeControl::NativeControlWndProc(HWND window, UINT message, DCHECK(native_control); if (message == WM_KEYDOWN && - native_control->OnKeyDown(win_util::WinToKeyboardCode(w_param))) { + native_control->OnKeyDown(app::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 a01ed83..5a180d2 100644 --- a/views/controls/native_control.h +++ b/views/controls/native_control.h @@ -8,7 +8,7 @@ #include <windows.h> -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "views/view.h" namespace views { @@ -81,7 +81,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(base::KeyboardCode virtual_key_code) { return false; } + virtual bool OnKeyDown(app::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 d5ac40c..d170b50 100644 --- a/views/controls/scrollbar/bitmap_scroll_bar.cc +++ b/views/controls/scrollbar/bitmap_scroll_bar.cc @@ -8,10 +8,10 @@ #include "views/screen.h" #endif +#include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "base/callback.h" #include "base/compiler_specific.h" -#include "base/keyboard_codes.h" #include "base/message_loop.h" #include "gfx/canvas.h" #include "grit/app_strings.h" @@ -496,32 +496,32 @@ bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) { bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) { ScrollAmount amount = SCROLL_NONE; switch (event.GetKeyCode()) { - case base::VKEY_UP: + case app::VKEY_UP: if (!IsHorizontal()) amount = SCROLL_PREV_LINE; break; - case base::VKEY_DOWN: + case app::VKEY_DOWN: if (!IsHorizontal()) amount = SCROLL_NEXT_LINE; break; - case base::VKEY_LEFT: + case app::VKEY_LEFT: if (IsHorizontal()) amount = SCROLL_PREV_LINE; break; - case base::VKEY_RIGHT: + case app::VKEY_RIGHT: if (IsHorizontal()) amount = SCROLL_NEXT_LINE; break; - case base::VKEY_PRIOR: + case app::VKEY_PRIOR: amount = SCROLL_PREV_PAGE; break; - case base::VKEY_NEXT: + case app::VKEY_NEXT: amount = SCROLL_NEXT_PAGE; break; - case base::VKEY_HOME: + case app::VKEY_HOME: amount = SCROLL_START; break; - case base::VKEY_END: + case app::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 c5d75c8..6f318ec 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 "base/keyboard_codes_posix.h" +#include "app/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 base::VKEY_UP: + case app::VKEY_UP: if (!native_scroll_bar_->IsHorizontal()) MoveStep(false /* negative */); break; - case base::VKEY_DOWN: + case app::VKEY_DOWN: if (!native_scroll_bar_->IsHorizontal()) MoveStep(true /* positive */); break; - case base::VKEY_LEFT: + case app::VKEY_LEFT: if (native_scroll_bar_->IsHorizontal()) MoveStep(false /* negative */); break; - case base::VKEY_RIGHT: + case app::VKEY_RIGHT: if (native_scroll_bar_->IsHorizontal()) MoveStep(true /* positive */); break; - case base::VKEY_PRIOR: + case app::VKEY_PRIOR: MovePage(false /* negative */); break; - case base::VKEY_NEXT: + case app::VKEY_NEXT: MovePage(true /* positive */); break; - case base::VKEY_HOME: + case app::VKEY_HOME: MoveTo(0); break; - case base::VKEY_END: + case app::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 65350e0..55592a8a 100644 --- a/views/controls/scrollbar/native_scroll_bar_win.cc +++ b/views/controls/scrollbar/native_scroll_bar_win.cc @@ -7,7 +7,7 @@ #include <algorithm> #include <string> -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/message_loop.h" #include "gfx/window_impl.h" #include "views/controls/scrollbar/native_scroll_bar.h" @@ -231,31 +231,31 @@ bool NativeScrollBarWin::OnKeyPressed(const KeyEvent& event) { return false; int code = -1; switch (event.GetKeyCode()) { - case base::VKEY_UP: + case app::VKEY_UP: if (!native_scroll_bar_->IsHorizontal()) code = SB_LINEUP; break; - case base::VKEY_PRIOR: + case app::VKEY_PRIOR: code = SB_PAGEUP; break; - case base::VKEY_NEXT: + case app::VKEY_NEXT: code = SB_PAGEDOWN; break; - case base::VKEY_DOWN: + case app::VKEY_DOWN: if (!native_scroll_bar_->IsHorizontal()) code = SB_LINEDOWN; break; - case base::VKEY_HOME: + case app::VKEY_HOME: code = SB_TOP; break; - case base::VKEY_END: + case app::VKEY_END: code = SB_BOTTOM; break; - case base::VKEY_LEFT: + case app::VKEY_LEFT: if (native_scroll_bar_->IsHorizontal()) code = SB_LINELEFT; break; - case base::VKEY_RIGHT: + case app::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 110b134..8061821 100644 --- a/views/controls/tabbed_pane/tabbed_pane.cc +++ b/views/controls/tabbed_pane/tabbed_pane.cc @@ -4,7 +4,7 @@ #include "views/controls/tabbed_pane/tabbed_pane.h" -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/logging.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() == - base::VKEY_TAB && accelerator.IsCtrlDown()); + app::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(base::VKEY_TAB, true, true, false)); + AddAccelerator(views::Accelerator(app::VKEY_TAB, true, true, false)); // Ctrl+Tab - AddAccelerator(views::Accelerator(base::VKEY_TAB, false, true, false)); + AddAccelerator(views::Accelerator(app::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 14a5eae..efef1a5 100644 --- a/views/controls/table/group_table_view.cc +++ b/views/controls/table/group_table_view.cc @@ -61,7 +61,7 @@ void GroupTableView::SyncSelection() { } } -bool GroupTableView::OnKeyDown(base::KeyboardCode virtual_keycode) { +bool GroupTableView::OnKeyDown(app::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: @@ -87,8 +87,8 @@ bool GroupTableView::OnKeyDown(base::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 != base::VKEY_UP) && - (virtual_keycode != base::VKEY_DOWN)) { + if ((virtual_keycode != app::VKEY_UP) && + (virtual_keycode != app::VKEY_DOWN)) { return TableView::OnKeyDown(virtual_keycode); } @@ -116,10 +116,10 @@ bool GroupTableView::OnKeyDown(base::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 == base::VKEY_UP) { + if (virtual_keycode == app::VKEY_UP) { SetFocusOnItem(group_range.start); } else { - DCHECK_EQ(virtual_keycode, base::VKEY_DOWN); + DCHECK_EQ(virtual_keycode, app::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 0e9f1ee..d4853cb 100644 --- a/views/controls/table/group_table_view.h +++ b/views/controls/table/group_table_view.h @@ -56,7 +56,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(base::KeyboardCode virtual_keycode); + virtual bool OnKeyDown(app::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 f0b0659..82561e1 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(base::KeyboardCode virtual_keycode) { +bool NativeTableWin::OnKeyDown(app::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 d23a961..dcbc087 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(base::KeyboardCode virtual_keycode); + virtual bool OnKeyDown(app::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 510d536..e397ce9 100644 --- a/views/controls/table/table_view.cc +++ b/views/controls/table/table_view.cc @@ -1488,7 +1488,7 @@ void TableView::OnSelectedStateChanged() { } } -bool TableView::OnKeyDown(base::KeyboardCode virtual_keycode) { +bool TableView::OnKeyDown(app::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 2799c62..9444d96b 100644 --- a/views/controls/table/table_view.h +++ b/views/controls/table/table_view.h @@ -16,8 +16,8 @@ typedef struct tagNMLVCUSTOMDRAW NMLVCUSTOMDRAW; #include <map> #include <vector> +#include "app/keyboard_codes.h" #include "app/table_model_observer.h" -#include "base/keyboard_codes.h" #include "third_party/skia/include/core/SkColor.h" #if defined(OS_WIN) // TODO(port): remove the ifdef when native_control.h is ported. @@ -257,7 +257,7 @@ class TableView : public NativeControl, virtual void OnMiddleClick(); // Overridden from NativeControl. Notifies the observer. - virtual bool OnKeyDown(base::KeyboardCode virtual_keycode); + virtual bool OnKeyDown(app::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 07a1e86..86fff7a 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 "base/keyboard_codes.h" +#include "app/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(base::KeyboardCode virtual_keycode) {} + virtual void OnKeyDown(app::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_win.cc b/views/controls/textfield/native_textfield_win.cc index fc4ad8b..c91dcdf 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -8,11 +8,11 @@ #include "app/clipboard/clipboard.h" #include "app/clipboard/scoped_clipboard_writer.h" +#include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/win_util.h" #include "base/i18n/rtl.h" -#include "base/keyboard_codes.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/win_util.h" @@ -313,13 +313,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(base::VKEY_X, false, true, false); + *accelerator = views::Accelerator(app::VKEY_X, false, true, false); return true; case IDS_APP_COPY: - *accelerator = views::Accelerator(base::VKEY_C, false, true, false); + *accelerator = views::Accelerator(app::VKEY_C, false, true, false); return true; case IDS_APP_PASTE: - *accelerator = views::Accelerator(base::VKEY_V, false, true, false); + *accelerator = views::Accelerator(app::VKEY_V, false, true, false); return true; } return container_view_->GetWidget()->GetAccelerator(command_id, accelerator); @@ -868,7 +868,7 @@ void NativeTextfieldWin::HandleKeystroke(UINT message, if (!handled) { OnBeforePossibleChange(); - if (key == base::VKEY_HOME || key == base::VKEY_END) { + if (key == app::VKEY_HOME || key == app::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 43f0897..fc8d081 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -10,7 +10,7 @@ #include <string> -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "gfx/insets.h" @@ -19,7 +19,7 @@ #include "views/widget/widget.h" #if defined(OS_LINUX) -#include "base/keyboard_code_conversion_gtk.h" +#include "app/keyboard_code_conversion_gtk.h" #elif defined(OS_WIN) #include "app/win_util.h" #include "base/win_util.h" @@ -239,14 +239,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. - base::KeyboardCode key = e.GetKeyCode(); - if (key == base::VKEY_BACK) + app::KeyboardCode key = e.GetKeyCode(); + if (key == app::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 != base::VKEY_HOME) && + if (e.IsAltDown() && (key != app::VKEY_HOME) && win_util::IsNumPadDigit(key, e.IsExtendedKey())) return true; #endif @@ -332,12 +332,12 @@ std::string Textfield::GetClassName() const { return kViewClassName; } -base::KeyboardCode Textfield::Keystroke::GetKeyboardCode() const { +app::KeyboardCode Textfield::Keystroke::GetKeyboardCode() const { #if defined(OS_WIN) - return static_cast<base::KeyboardCode>(key_); + return static_cast<app::KeyboardCode>(key_); #else - return static_cast<base::KeyboardCode>( - base::WindowsKeyCodeForGdkKeyCode(event_.keyval)); + return static_cast<app::KeyboardCode>( + app::WindowsKeyCodeForGdkKeyCode(event_.keyval)); #endif } diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h index 564243e..3bd6c31 100644 --- a/views/controls/textfield/textfield.h +++ b/views/controls/textfield/textfield.h @@ -14,8 +14,8 @@ #include <string> +#include "app/keyboard_codes.h" #include "base/basictypes.h" -#include "base/keyboard_codes.h" #if !defined(OS_LINUX) #include "base/logging.h" #endif @@ -65,7 +65,7 @@ class Textfield : public View { } const GdkEventKey* event() const { return &event_; } #endif - base::KeyboardCode GetKeyboardCode() const; + app::KeyboardCode GetKeyboardCode() const; bool IsControlHeld() const; bool IsShiftHeld() const; diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc index eba1a31..27edeaf 100644 --- a/views/controls/tree/tree_view.cc +++ b/views/controls/tree/tree_view.cc @@ -6,10 +6,11 @@ #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 "base/i18n/rtl.h" -#include "base/keyboard_codes.h" #include "base/logging.h" #include "base/stl_util-inl.h" #include "base/win_util.h" @@ -448,7 +449,7 @@ LRESULT TreeView::OnNotify(int w_param, LPNMHDR l_param) { NMTVKEYDOWN* key_down_message = reinterpret_cast<NMTVKEYDOWN*>(l_param); controller_->OnTreeViewKeyDown( - win_util::WinToKeyboardCode(key_down_message->wVKey)); + app::KeyboardCodeForWindowsKeyCode(key_down_message->wVKey)); } break; @@ -458,7 +459,7 @@ LRESULT TreeView::OnNotify(int w_param, LPNMHDR l_param) { return 0; } -bool TreeView::OnKeyDown(base::KeyboardCode virtual_key_code) { +bool TreeView::OnKeyDown(app::KeyboardCode virtual_key_code) { if (virtual_key_code == VK_F2) { if (!GetEditingNode()) { TreeModelNode* selected_node = GetSelectedNode(); @@ -466,7 +467,7 @@ bool TreeView::OnKeyDown(base::KeyboardCode virtual_key_code) { StartEditing(selected_node); } return true; - } else if (virtual_key_code == base::VKEY_RETURN && !process_enter_) { + } else if (virtual_key_code == app::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 cbcfbe7..593219c 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 "base/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(base::KeyboardCode keycode) {} + virtual void OnTreeViewKeyDown(app::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(base::KeyboardCode virtual_key_code); + virtual bool OnKeyDown(app::KeyboardCode virtual_key_code); virtual void OnContextMenu(const POINT& location); diff --git a/views/event.cc b/views/event.cc index ba05875..e047004 100644 --- a/views/event.cc +++ b/views/event.cc @@ -25,7 +25,7 @@ LocatedEvent::LocatedEvent(const LocatedEvent& model, View* from, View* to) View::ConvertPointToView(from, to, &location_); } -KeyEvent::KeyEvent(EventType type, base::KeyboardCode key_code, +KeyEvent::KeyEvent(EventType type, app::KeyboardCode key_code, int event_flags, int repeat_count, int message_flags) : Event(type, event_flags), key_code_(key_code), diff --git a/views/event.h b/views/event.h index aa1905c..14a6af7 100644 --- a/views/event.h +++ b/views/event.h @@ -6,8 +6,8 @@ #define VIEWS_EVENT_H_ #pragma once +#include "app/keyboard_codes.h" #include "base/basictypes.h" -#include "base/keyboard_codes.h" #include "gfx/point.h" #if defined(OS_LINUX) @@ -309,7 +309,7 @@ class KeyEvent : public Event { public: // Create a new key event KeyEvent(EventType type, - base::KeyboardCode key_code, + app::KeyboardCode key_code, int event_flags, int repeat_count, int message_flags); @@ -317,11 +317,11 @@ class KeyEvent : public Event { explicit KeyEvent(GdkEventKey* event); #endif - // This returns a VKEY_ value as defined in base/keyboard_codes.h which is + // This returns a VKEY_ value as defined in app/keyboard_codes.h which is // the Windows value. // On GTK, you can use the methods in keyboard_code_conversion_gtk.cc to // convert this value back to a GDK value if needed. - base::KeyboardCode GetKeyCode() const { + app::KeyboardCode GetKeyCode() const { return key_code_; } @@ -340,7 +340,7 @@ class KeyEvent : public Event { private: - base::KeyboardCode key_code_; + app::KeyboardCode key_code_; int repeat_count_; int message_flags_; diff --git a/views/event_gtk.cc b/views/event_gtk.cc index cb76e76..6ffd449 100644 --- a/views/event_gtk.cc +++ b/views/event_gtk.cc @@ -6,7 +6,7 @@ #include <gdk/gdk.h> -#include "base/keyboard_code_conversion_gtk.h" +#include "app/keyboard_code_conversion_gtk.h" namespace views { @@ -15,7 +15,7 @@ KeyEvent::KeyEvent(GdkEventKey* event) Event::ET_KEY_PRESSED : Event::ET_KEY_RELEASED, GetFlagsFromGdkState(event->state)), // TODO(erg): All these values are iffy. - key_code_(base::WindowsKeyCodeForGdkKeyCode(event->keyval)), + key_code_(app::WindowsKeyCodeForGdkKeyCode(event->keyval)), repeat_count_(0), message_flags_(0) { } diff --git a/views/examples/table2_example.h b/views/examples/table2_example.h index 9e2f22f..c58b073 100644 --- a/views/examples/table2_example.h +++ b/views/examples/table2_example.h @@ -130,7 +130,7 @@ class Table2Example virtual void OnMiddleClick() {} - virtual void OnKeyDown(base::KeyboardCode virtual_keycode) {} + virtual void OnKeyDown(app::KeyboardCode virtual_keycode) {} virtual void OnTableViewDelete(views::TableView* table_view) {} diff --git a/views/examples/table_example.h b/views/examples/table_example.h index 1a447f4..c71b2c8 100644 --- a/views/examples/table_example.h +++ b/views/examples/table_example.h @@ -124,7 +124,7 @@ class TableExample virtual void OnMiddleClick() {} - virtual void OnKeyDown(base::KeyboardCode virtual_keycode) {} + virtual void OnKeyDown(app::KeyboardCode virtual_keycode) {} virtual void OnTableViewDelete(views::TableView* table_view) {} diff --git a/views/focus/accelerator_handler_gtk_unittest.cc b/views/focus/accelerator_handler_gtk_unittest.cc index 78e9110..baa11bc 100644 --- a/views/focus/accelerator_handler_gtk_unittest.cc +++ b/views/focus/accelerator_handler_gtk_unittest.cc @@ -19,8 +19,8 @@ class AcceleratorHandlerGtkTest public AcceleratorTarget { public: AcceleratorHandlerGtkTest() - : kMenuAccelerator(base::VKEY_MENU, false, false, false), - kHomepageAccelerator(base::VKEY_HOME, false, false, true), + : kMenuAccelerator(app::VKEY_MENU, false, false, false), + kHomepageAccelerator(app::VKEY_HOME, false, false, true), content_view_(NULL) { } diff --git a/views/focus/accelerator_handler_win.cc b/views/focus/accelerator_handler_win.cc index 64b51f4..496acd4 100644 --- a/views/focus/accelerator_handler_win.cc +++ b/views/focus/accelerator_handler_win.cc @@ -4,7 +4,8 @@ #include "views/focus/accelerator_handler.h" -#include "base/keyboard_codes.h" +#include "app/keyboard_code_conversion_win.h" +#include "app/keyboard_codes.h" #include "base/win_util.h" #include "views/event.h" #include "views/focus/focus_manager.h" @@ -25,7 +26,7 @@ bool AcceleratorHandler::Dispatch(const MSG& msg) { case WM_KEYDOWN: case WM_SYSKEYDOWN: { KeyEvent event(Event::ET_KEY_PRESSED, - win_util::WinToKeyboardCode(msg.wParam), + app::KeyboardCodeForWindowsKeyCode(msg.wParam), KeyEvent::GetKeyStateFlags(), msg.lParam & 0xFFFF, (msg.lParam & 0xFFFF0000) >> 16); diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc index f0f5f99..3751ace 100644 --- a/views/focus/focus_manager.cc +++ b/views/focus/focus_manager.cc @@ -12,7 +12,7 @@ #include <gtk/gtk.h> #endif -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/logging.h" #include "views/accelerator.h" #include "views/focus/focus_search.h" @@ -109,11 +109,11 @@ bool FocusManager::OnKeyEvent(const KeyEvent& event) { #endif // Intercept arrow key messages to switch between grouped views. - base::KeyboardCode key_code = event.GetKeyCode(); + app::KeyboardCode key_code = event.GetKeyCode(); if (focused_view_ && focused_view_->GetGroup() != -1 && - (key_code == base::VKEY_UP || key_code == base::VKEY_DOWN || - key_code == base::VKEY_LEFT || key_code == base::VKEY_RIGHT)) { - bool next = (key_code == base::VKEY_RIGHT || key_code == base::VKEY_DOWN); + (key_code == app::VKEY_UP || key_code == app::VKEY_DOWN || + key_code == app::VKEY_LEFT || key_code == app::VKEY_RIGHT)) { + bool next = (key_code == app::VKEY_RIGHT || key_code == app::VKEY_DOWN); std::vector<View*> views; focused_view_->GetParent()->GetViewsWithGroup(focused_view_->GetGroup(), &views); @@ -494,7 +494,7 @@ AcceleratorTarget* FocusManager::GetCurrentTargetForAccelerator( // static bool FocusManager::IsTabTraversalKeyEvent(const KeyEvent& key_event) { - return key_event.GetKeyCode() == base::VKEY_TAB && + return key_event.GetKeyCode() == app::VKEY_TAB && !key_event.IsControlDown(); } diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc index a711538..c7a3cf4 100644 --- a/views/focus/focus_manager_unittest.cc +++ b/views/focus/focus_manager_unittest.cc @@ -5,7 +5,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "app/combobox_model.h" -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/logging.h" #include "base/string16.h" #include "base/string_number_conversions.h" @@ -36,7 +36,7 @@ #include "views/widget/widget_win.h" #include "views/window/window_win.h" #elif defined(OS_LINUX) -#include "base/keyboard_code_conversion_gtk.h" +#include "app/keyboard_code_conversion_gtk.h" #include "views/window/window_gtk.h" #endif @@ -209,23 +209,23 @@ class FocusManagerTest : public testing::Test, public WindowDelegate { } #if defined(OS_WIN) - void PostKeyDown(base::KeyboardCode key_code) { + void PostKeyDown(app::KeyboardCode key_code) { ::PostMessage(window_->GetNativeWindow(), WM_KEYDOWN, key_code, 0); } - void PostKeyUp(base::KeyboardCode key_code) { + void PostKeyUp(app::KeyboardCode key_code) { ::PostMessage(window_->GetNativeWindow(), WM_KEYUP, key_code, 0); } #elif defined(OS_LINUX) - void PostKeyDown(base::KeyboardCode key_code) { + void PostKeyDown(app::KeyboardCode key_code) { PostKeyEvent(key_code, true); } - void PostKeyUp(base::KeyboardCode key_code) { + void PostKeyUp(app::KeyboardCode key_code) { PostKeyEvent(key_code, false); } - void PostKeyEvent(base::KeyboardCode key_code, bool pressed) { + void PostKeyEvent(app::KeyboardCode key_code, bool pressed) { int keyval = GdkKeyCodeForWindowsKeyCode(key_code, false); GdkKeymapKey* keys; gint n_keys; @@ -1300,8 +1300,8 @@ class TestAcceleratorTarget : public AcceleratorTarget { TEST_F(FocusManagerTest, CallsNormalAcceleratorTarget) { FocusManager* focus_manager = GetFocusManager(); - Accelerator return_accelerator(base::VKEY_RETURN, false, false, false); - Accelerator escape_accelerator(base::VKEY_ESCAPE, false, false, false); + Accelerator return_accelerator(app::VKEY_RETURN, false, false, false); + Accelerator escape_accelerator(app::VKEY_ESCAPE, false, false, false); TestAcceleratorTarget return_target(true); TestAcceleratorTarget escape_target(true); @@ -1418,7 +1418,7 @@ class SelfUnregisteringAcceleratorTarget : public AcceleratorTarget { TEST_F(FocusManagerTest, CallsSelfDeletingAcceleratorTarget) { FocusManager* focus_manager = GetFocusManager(); - Accelerator return_accelerator(base::VKEY_RETURN, false, false, false); + Accelerator return_accelerator(app::VKEY_RETURN, false, false, false); SelfUnregisteringAcceleratorTarget target(return_accelerator, focus_manager); EXPECT_EQ(target.accelerator_count(), 0); EXPECT_EQ(NULL, @@ -1466,11 +1466,11 @@ class MessageTrackingView : public View { keys_released_.clear(); } - const std::vector<base::KeyboardCode>& keys_pressed() const { + const std::vector<app::KeyboardCode>& keys_pressed() const { return keys_pressed_; } - const std::vector<base::KeyboardCode>& keys_released() const { + const std::vector<app::KeyboardCode>& keys_released() const { return keys_released_; } @@ -1480,8 +1480,8 @@ class MessageTrackingView : public View { private: bool accelerator_pressed_; - std::vector<base::KeyboardCode> keys_pressed_; - std::vector<base::KeyboardCode> keys_released_; + std::vector<app::KeyboardCode> keys_pressed_; + std::vector<app::KeyboardCode> keys_released_; DISALLOW_COPY_AND_ASSIGN(MessageTrackingView); }; @@ -1494,53 +1494,53 @@ class MessageTrackingView : public View { TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { FocusManager* focus_manager = GetFocusManager(); MessageTrackingView* mtv = new MessageTrackingView(); - mtv->AddAccelerator(Accelerator(base::VKEY_0, false, false, false)); - mtv->AddAccelerator(Accelerator(base::VKEY_1, false, false, false)); + mtv->AddAccelerator(Accelerator(app::VKEY_0, false, false, false)); + mtv->AddAccelerator(Accelerator(app::VKEY_1, false, false, false)); content_view_->AddChildView(mtv); focus_manager->SetFocusedView(mtv); // First send a non-accelerator key sequence. - PostKeyDown(base::VKEY_9); - PostKeyUp(base::VKEY_9); + PostKeyDown(app::VKEY_9); + PostKeyUp(app::VKEY_9); AcceleratorHandler accelerator_handler; MessageLoopForUI::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); MessageLoopForUI::current()->Run(&accelerator_handler); // Make sure we get a key-up and key-down. ASSERT_EQ(1U, mtv->keys_pressed().size()); - EXPECT_EQ(base::VKEY_9, mtv->keys_pressed().at(0)); + EXPECT_EQ(app::VKEY_9, mtv->keys_pressed().at(0)); ASSERT_EQ(1U, mtv->keys_released().size()); - EXPECT_EQ(base::VKEY_9, mtv->keys_released().at(0)); + EXPECT_EQ(app::VKEY_9, mtv->keys_released().at(0)); EXPECT_FALSE(mtv->accelerator_pressed()); mtv->Reset(); // Same thing with repeat and more than one key at once. - PostKeyDown(base::VKEY_9); - PostKeyDown(base::VKEY_9); - PostKeyDown(base::VKEY_8); - PostKeyDown(base::VKEY_9); - PostKeyDown(base::VKEY_7); - PostKeyUp(base::VKEY_9); - PostKeyUp(base::VKEY_7); - PostKeyUp(base::VKEY_8); + PostKeyDown(app::VKEY_9); + PostKeyDown(app::VKEY_9); + PostKeyDown(app::VKEY_8); + PostKeyDown(app::VKEY_9); + PostKeyDown(app::VKEY_7); + PostKeyUp(app::VKEY_9); + PostKeyUp(app::VKEY_7); + PostKeyUp(app::VKEY_8); MessageLoopForUI::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); MessageLoopForUI::current()->Run(&accelerator_handler); // Make sure we get a key-up and key-down. ASSERT_EQ(5U, mtv->keys_pressed().size()); - EXPECT_EQ(base::VKEY_9, mtv->keys_pressed().at(0)); - EXPECT_EQ(base::VKEY_9, mtv->keys_pressed().at(1)); - EXPECT_EQ(base::VKEY_8, mtv->keys_pressed().at(2)); - EXPECT_EQ(base::VKEY_9, mtv->keys_pressed().at(3)); - EXPECT_EQ(base::VKEY_7, mtv->keys_pressed().at(4)); + EXPECT_EQ(app::VKEY_9, mtv->keys_pressed().at(0)); + EXPECT_EQ(app::VKEY_9, mtv->keys_pressed().at(1)); + EXPECT_EQ(app::VKEY_8, mtv->keys_pressed().at(2)); + EXPECT_EQ(app::VKEY_9, mtv->keys_pressed().at(3)); + EXPECT_EQ(app::VKEY_7, mtv->keys_pressed().at(4)); ASSERT_EQ(3U, mtv->keys_released().size()); - EXPECT_EQ(base::VKEY_9, mtv->keys_released().at(0)); - EXPECT_EQ(base::VKEY_7, mtv->keys_released().at(1)); - EXPECT_EQ(base::VKEY_8, mtv->keys_released().at(2)); + EXPECT_EQ(app::VKEY_9, mtv->keys_released().at(0)); + EXPECT_EQ(app::VKEY_7, mtv->keys_released().at(1)); + EXPECT_EQ(app::VKEY_8, mtv->keys_released().at(2)); EXPECT_FALSE(mtv->accelerator_pressed()); mtv->Reset(); // Now send an accelerator key sequence. - PostKeyDown(base::VKEY_0); - PostKeyUp(base::VKEY_0); + PostKeyDown(app::VKEY_0); + PostKeyUp(app::VKEY_0); MessageLoopForUI::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); MessageLoopForUI::current()->Run(&accelerator_handler); EXPECT_TRUE(mtv->keys_pressed().empty()); @@ -1549,13 +1549,13 @@ TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { mtv->Reset(); // Same thing with repeat and more than one key at once. - PostKeyDown(base::VKEY_0); - PostKeyDown(base::VKEY_1); - PostKeyDown(base::VKEY_1); - PostKeyDown(base::VKEY_0); - PostKeyDown(base::VKEY_0); - PostKeyUp(base::VKEY_1); - PostKeyUp(base::VKEY_0); + PostKeyDown(app::VKEY_0); + PostKeyDown(app::VKEY_1); + PostKeyDown(app::VKEY_1); + PostKeyDown(app::VKEY_0); + PostKeyDown(app::VKEY_0); + PostKeyUp(app::VKEY_1); + PostKeyUp(app::VKEY_0); MessageLoopForUI::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); MessageLoopForUI::current()->Run(&accelerator_handler); EXPECT_TRUE(mtv->keys_pressed().empty()); diff --git a/views/view_unittest.cc b/views/view_unittest.cc index 870273e..a44ce6f 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -5,7 +5,7 @@ #include <map> #include "app/clipboard/clipboard.h" -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -828,7 +828,7 @@ bool TestView::AcceleratorPressed(const Accelerator& accelerator) { #if defined(OS_WIN) TEST_F(ViewTest, ActivateAccelerator) { // Register a keyboard accelerator before the view is added to a window. - views::Accelerator return_accelerator(base::VKEY_RETURN, false, false, false); + views::Accelerator return_accelerator(app::VKEY_RETURN, false, false, false); TestView* view = new TestView(); view->Reset(); view->AddAccelerator(return_accelerator); @@ -852,7 +852,7 @@ TEST_F(ViewTest, ActivateAccelerator) { EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1); // Hit the escape key. Nothing should happen. - views::Accelerator escape_accelerator(base::VKEY_ESCAPE, false, false, false); + views::Accelerator escape_accelerator(app::VKEY_ESCAPE, false, false, false); EXPECT_FALSE(focus_manager->ProcessAccelerator(escape_accelerator)); EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1); EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 0); @@ -1108,7 +1108,7 @@ class DefaultButtonTest : public ViewTest { } void SimularePressingEnterAndCheckDefaultButton(ButtonID button_id) { - KeyEvent event(Event::ET_KEY_PRESSED, base::VKEY_RETURN, 0, 0, 0); + KeyEvent event(Event::ET_KEY_PRESSED, app::VKEY_RETURN, 0, 0, 0); focus_manager_->OnKeyEvent(event); switch (button_id) { case OK: diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index a56ec99..20464cc 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -7,7 +7,7 @@ #include <algorithm> #include "app/drag_drop_types.h" -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/logging.h" #include "base/message_loop.h" #include "gfx/canvas_skia.h" @@ -581,8 +581,8 @@ bool RootView::ProcessKeyEvent(const KeyEvent& event) { View* v = GetFocusedView(); // Special case to handle right-click context menus triggered by the // keyboard. - if (v && v->IsEnabled() && ((event.GetKeyCode() == base::VKEY_APPS) || - (event.GetKeyCode() == base::VKEY_F10 && event.IsShiftDown()))) { + if (v && v->IsEnabled() && ((event.GetKeyCode() == app::VKEY_APPS) || + (event.GetKeyCode() == app::VKEY_F10 && event.IsShiftDown()))) { v->ShowContextMenu(v->GetKeyboardContextMenuLocation(), false); return true; } diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 0a129f6..67d542f 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -884,21 +884,21 @@ bool WidgetGtk::HandleKeyboardEvent(GdkEventKey* event) { // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only // be activated when handling a VKEY_MENU key release event which is preceded // by an unhandled VKEY_MENU key press event. - if (key_code != base::VKEY_MENU || event->type != GDK_KEY_RELEASE) + if (key_code != app::VKEY_MENU || event->type != GDK_KEY_RELEASE) should_handle_menu_key_release_ = false; if (event->type == GDK_KEY_PRESS) { // VKEY_MENU is triggered by key release event. // FocusManager::OnKeyEvent() returns false when the key has been consumed. - if (key_code != base::VKEY_MENU) + if (key_code != app::VKEY_MENU) handled = !focus_manager_->OnKeyEvent(key); else should_handle_menu_key_release_ = true; - } else if (key_code == base::VKEY_MENU && should_handle_menu_key_release_ && + } else if (key_code == app::VKEY_MENU && should_handle_menu_key_release_ && (key.GetFlags() & ~Event::EF_ALT_DOWN) == 0) { // Trigger VKEY_MENU when only this key is pressed and released, and both // press and release events are not handled by others. - Accelerator accelerator(base::VKEY_MENU, false, false, false); + Accelerator accelerator(app::VKEY_MENU, false, false, false); handled = focus_manager_->ProcessAccelerator(accelerator); } @@ -1167,7 +1167,7 @@ gboolean WidgetGtk::OnKeyEvent(GtkWidget* widget, GdkEventKey* event) { // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only // be activated when handling a VKEY_MENU key release event which is preceded // by an unhandled VKEY_MENU key press event. See also HandleKeyboardEvent(). - if (key.GetKeyCode() != base::VKEY_MENU || event->type != GDK_KEY_RELEASE) + if (key.GetKeyCode() != app::VKEY_MENU || event->type != GDK_KEY_RELEASE) should_handle_menu_key_release_ = false; bool handled = false; diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index f11031c..ec0121a 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -4,6 +4,7 @@ #include "views/widget/widget_win.h" +#include "app/keyboard_code_conversion_win.h" #include "app/l10n_util_win.h" #include "app/system_monitor.h" #include "app/win_util.h" @@ -672,7 +673,7 @@ void WidgetWin::OnInitMenuPopup(HMENU menu, } void WidgetWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) { - KeyEvent event(Event::ET_KEY_PRESSED, win_util::WinToKeyboardCode(c), + KeyEvent event(Event::ET_KEY_PRESSED, app::KeyboardCodeForWindowsKeyCode(c), KeyEvent::GetKeyStateFlags(), rep_cnt, flags); RootView* root_view = GetFocusedViewRootView(); if (!root_view) @@ -682,7 +683,7 @@ void WidgetWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) { } void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { - KeyEvent event(Event::ET_KEY_RELEASED, win_util::WinToKeyboardCode(c), + KeyEvent event(Event::ET_KEY_RELEASED, app::KeyboardCodeForWindowsKeyCode(c), KeyEvent::GetKeyStateFlags(), rep_cnt, flags); RootView* root_view = GetFocusedViewRootView(); if (!root_view) diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index bbc7672..9dd45ac 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -14,9 +14,9 @@ #include <algorithm> +#include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/keyboard_codes.h" #include "gfx/canvas_skia.h" #include "gfx/font.h" #include "grit/app_strings.h" @@ -139,7 +139,7 @@ void DialogClientView::ShowDialogButtons() { if (is_default_button) default_button_ = ok_button_; if (!(buttons & MessageBoxFlags::DIALOGBUTTON_CANCEL)) - ok_button_->AddAccelerator(Accelerator(base::VKEY_ESCAPE, + ok_button_->AddAccelerator(Accelerator(app::VKEY_ESCAPE, false, false, false)); AddChildView(ok_button_); } @@ -160,7 +160,7 @@ void DialogClientView::ShowDialogButtons() { MessageBoxFlags::DIALOGBUTTON_CANCEL, label, is_default_button); cancel_button_->SetGroup(kButtonGroup); - cancel_button_->AddAccelerator(Accelerator(base::VKEY_ESCAPE, + cancel_button_->AddAccelerator(Accelerator(app::VKEY_ESCAPE, false, false, false)); if (is_default_button) default_button_ = ok_button_; @@ -169,7 +169,7 @@ void DialogClientView::ShowDialogButtons() { if (!buttons) { // Register the escape key as an accelerator which will close the window // if there are no dialog buttons. - AddAccelerator(Accelerator(base::VKEY_ESCAPE, false, false, false)); + AddAccelerator(Accelerator(app::VKEY_ESCAPE, false, false, false)); } } @@ -387,7 +387,7 @@ gfx::Size DialogClientView::GetPreferredSize() { bool DialogClientView::AcceleratorPressed(const Accelerator& accelerator) { // We only expect Escape key. - DCHECK(accelerator.GetKeyCode() == base::VKEY_ESCAPE); + DCHECK(accelerator.GetKeyCode() == app::VKEY_ESCAPE); Close(); return true; } diff --git a/views/window/window_win.cc b/views/window/window_win.cc index af03463..6aa5224 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -7,6 +7,7 @@ #include <dwmapi.h> #include <shellapi.h> +#include "app/keyboard_code_conversion_win.h" #include "app/theme_provider.h" #include "app/win_util.h" #include "base/i18n/rtl.h" @@ -1120,7 +1121,7 @@ void WindowWin::OnSysCommand(UINT notification_code, CPoint click) { // Handle SC_KEYMENU, which means that the user has pressed the ALT // key and released it, so we should focus the menu bar. if ((notification_code & sc_mask) == SC_KEYMENU && click.x == 0) { - Accelerator accelerator(win_util::WinToKeyboardCode(VK_MENU), + Accelerator accelerator(app::KeyboardCodeForWindowsKeyCode(VK_MENU), false, false, false); GetFocusManager()->ProcessAccelerator(accelerator); return; |