Index: ui/views/view.cc |
diff --git a/ui/views/view.cc b/ui/views/view.cc |
index 45467ab23dbfc0fdbf68fdd9ad1ef9532bd20e64..9232987ea608bec2b6b593c9d2da9977f4d11dbb 100644 |
--- a/ui/views/view.cc |
+++ b/ui/views/view.cc |
@@ -1146,7 +1146,21 @@ bool View::AcceleratorPressed(const ui::Accelerator& accelerator) { |
} |
bool View::CanHandleAccelerators() const { |
- return enabled() && IsDrawn() && GetWidget() && GetWidget()->IsVisible(); |
+ const Widget* widget = GetWidget(); |
+ if (!enabled() || !IsDrawn() || !widget || !widget->IsVisible()) { |
+ return false; |
+ } |
+ #if !defined(OS_CHROMEOS) |
+ // Should only handle accelerators when active. However, only top level |
+ // widgets can be active, so for child widgets check if they are focused |
+ // instead. This check is disabled on ChromeOS as ChromeOS already handles |
+ // this logic properly. |
+ if ((IsChildWidget() && !FocusInChildWidget()) || |
sky
2016/01/28 16:23:45
I wouldn't bother with the new functions, instead:
meacer
2016/01/28 18:39:26
This was so that I could override them in unit tes
meacer
2016/01/29 00:37:36
Done now.
|
+ (!IsChildWidget() && !widget->IsActive())) { |
+ return false; |
+ } |
+ #endif |
sadrul
2016/01/28 08:11:00
I don't think this behaviour should be OS specific
meacer
2016/01/28 18:39:26
Sure, but ChromeOS seems to handle accelerators fi
sky
2016/01/28 21:18:38
What I don't understand is how this works in chrom
meacer
2016/01/29 00:14:22
For the original bug (https://crbug.com/541415): t
|
+ return true; |
} |
// Focus ----------------------------------------------------------------------- |
@@ -2410,4 +2424,14 @@ bool View::DoDrag(const ui::LocatedEvent& event, |
return true; |
} |
+bool View::IsChildWidget() const { |
+ return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); |
+} |
+ |
+bool View::FocusInChildWidget() const { |
+ return GetWidget() && |
+ GetWidget()->GetRootView()->Contains( |
+ GetFocusManager()->GetFocusedView()); |
+} |
+ |
} // namespace views |