summaryrefslogtreecommitdiffstats
path: root/chrome/views
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-30 19:54:31 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-30 19:54:31 +0000
commitad6da855e4860f681b90e83eaa2da721e7f6011d (patch)
tree89805ab55ff7d9b9419161fc79622a46f5d991df /chrome/views
parent7e487d1d77e8e28c3a25daa25fc56a3e9c108023 (diff)
downloadchromium_src-ad6da855e4860f681b90e83eaa2da721e7f6011d.zip
chromium_src-ad6da855e4860f681b90e83eaa2da721e7f6011d.tar.gz
chromium_src-ad6da855e4860f681b90e83eaa2da721e7f6011d.tar.bz2
Patch for accelerator clean-up from Hamaji.
See http://codereview.chromium.org/99161 TBR=hamami Review URL: http://codereview.chromium.org/99228 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r--chrome/views/controls/tree/tree_view.cc2
-rw-r--r--chrome/views/focus/focus_manager.cc55
-rw-r--r--chrome/views/focus/focus_manager.h10
3 files changed, 21 insertions, 46 deletions
diff --git a/chrome/views/controls/tree/tree_view.cc b/chrome/views/controls/tree/tree_view.cc
index 8c130bd..7677828 100644
--- a/chrome/views/controls/tree/tree_view.cc
+++ b/chrome/views/controls/tree/tree_view.cc
@@ -475,7 +475,7 @@ bool TreeView::OnKeyDown(int virtual_key_code) {
win_util::IsShiftPressed(),
win_util::IsCtrlPressed(),
win_util::IsAltPressed()));
- fm->ProcessAccelerator(accelerator, true);
+ fm->ProcessAccelerator(accelerator);
return true;
}
return false;
diff --git a/chrome/views/focus/focus_manager.cc b/chrome/views/focus/focus_manager.cc
index 8d22506..4b4120f 100644
--- a/chrome/views/focus/focus_manager.cc
+++ b/chrome/views/focus/focus_manager.cc
@@ -307,18 +307,11 @@ bool FocusManager::OnKeyDown(HWND window, UINT message, WPARAM wparam,
// really processed a key event. If the key combination matches an
// accelerator, the accelerator is triggered, otherwise we forward the
// event to the HWND.
- int modifiers = 0;
- if (win_util::IsShiftPressed())
- modifiers |= Event::EF_SHIFT_DOWN;
- if (win_util::IsCtrlPressed())
- modifiers |= Event::EF_CONTROL_DOWN;
- if (win_util::IsAltPressed())
- modifiers |= Event::EF_ALT_DOWN;
Accelerator accelerator(Accelerator(static_cast<int>(virtual_key_code),
win_util::IsShiftPressed(),
win_util::IsCtrlPressed(),
win_util::IsAltPressed()));
- if (ProcessAccelerator(accelerator, true)) {
+ if (ProcessAccelerator(accelerator)) {
// If a shortcut was activated for this keydown message, do not
// propagate the message further.
return false;
@@ -649,36 +642,26 @@ void FocusManager::UnregisterAccelerators(AcceleratorTarget* target) {
}
}
-bool FocusManager::ProcessAccelerator(const Accelerator& accelerator,
- bool prioritary_accelerators_only) {
- if (!prioritary_accelerators_only ||
- accelerator.IsCtrlDown() || accelerator.IsAltDown() ||
- accelerator.GetKeyCode() == VK_ESCAPE ||
- accelerator.GetKeyCode() == VK_RETURN ||
- (accelerator.GetKeyCode() >= VK_F1 &&
- accelerator.GetKeyCode() <= VK_F24) ||
- (accelerator.GetKeyCode() >= VK_BROWSER_BACK &&
- accelerator.GetKeyCode() <= VK_BROWSER_HOME)) {
- FocusManager* focus_manager = this;
- do {
- AcceleratorTarget* target =
- focus_manager->GetTargetForAccelerator(accelerator);
- if (target) {
- // If there is focused view, we give it a chance to process that
- // accelerator.
- if (!focused_view_ ||
- !focused_view_->OverrideAccelerator(accelerator)) {
- if (target->AcceleratorPressed(accelerator))
- return true;
- }
+bool FocusManager::ProcessAccelerator(const Accelerator& accelerator) {
+ FocusManager* focus_manager = this;
+ do {
+ AcceleratorTarget* target =
+ focus_manager->GetTargetForAccelerator(accelerator);
+ if (target) {
+ // If there is focused view, we give it a chance to process that
+ // accelerator.
+ if (!focused_view_ ||
+ !focused_view_->OverrideAccelerator(accelerator)) {
+ if (target->AcceleratorPressed(accelerator))
+ return true;
}
+ }
- // When dealing with child windows that have their own FocusManager (such
- // as ConstrainedWindow), we still want the parent FocusManager to process
- // the accelerator if the child window did not process it.
- focus_manager = focus_manager->GetParentFocusManager();
- } while (focus_manager);
- }
+ // When dealing with child windows that have their own FocusManager (such
+ // as ConstrainedWindow), we still want the parent FocusManager to process
+ // the accelerator if the child window did not process it.
+ focus_manager = focus_manager->GetParentFocusManager();
+ } while (focus_manager);
return false;
}
diff --git a/chrome/views/focus/focus_manager.h b/chrome/views/focus/focus_manager.h
index 491cbbb..f9e8d2d 100644
--- a/chrome/views/focus/focus_manager.h
+++ b/chrome/views/focus/focus_manager.h
@@ -257,16 +257,8 @@ class FocusManager : public NotificationObserver {
void UnregisterAccelerators(AcceleratorTarget* target);
// Activate the target associated with the specified accelerator if any.
- // If |prioritary_accelerators_only| is true, only the following accelerators
- // are allowed:
- // - a key combination including Ctrl or Alt
- // - the escape key
- // - the enter key
- // - any F key (F1, F2, F3 ...)
- // - any browser specific keys (as available on special keyboards)
// Returns true if an accelerator was activated.
- bool ProcessAccelerator(const Accelerator& accelerator,
- bool prioritary_accelerators_only);
+ bool ProcessAccelerator(const Accelerator& accelerator);
// NotificationObserver method.
void Observe(NotificationType type,