Commit 624eb0c0 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Don't toggle caret browsing on Mac unless web contents has focus.

Pressing F7 to toggle caret browsing was interfering with a Japanese
IME on Mac, but only when the omnibox has focus. There were no
conflicts when focus is in a web page. So to work around this issue,
ignore the F7 shortcut when focus is

It turns out Firefox has the same behavior: it ignores the F7 toggle
when focus is in its address bar. So that's good motivation that this
is the right fix.

There hasn't been any feedback about a similar issue on other
platforms, so scoping the fix to just Mac.

Bug: 1138475
Change-Id: I19b5ccaf9aec0b46c76e241887af60b0180a7338
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2472897Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817162}
parent 45e45556
...@@ -1536,6 +1536,20 @@ bool CanViewSource(const Browser* browser) { ...@@ -1536,6 +1536,20 @@ bool CanViewSource(const Browser* browser) {
} }
void ToggleCaretBrowsing(Browser* browser) { void ToggleCaretBrowsing(Browser* browser) {
#if defined(OS_MAC)
// On Mac, ignore the keyboard shortcut unless web contents is focused,
// because the keyboard shortcut interferes with a Japenese IME when the
// omnibox is focused. See https://crbug.com/1138475
WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
if (!web_contents)
return;
content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
if (!rwhv || !rwhv->HasFocus())
return;
#endif // defined(OS_MAC)
PrefService* prefService = browser->profile()->GetPrefs(); PrefService* prefService = browser->profile()->GetPrefs();
bool enabled = prefService->GetBoolean(prefs::kCaretBrowsingEnabled); bool enabled = prefService->GetBoolean(prefs::kCaretBrowsingEnabled);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment