HandleKeyboardEvent returns bool
https://chromium-review.googlesource.com/c/chromium/src/+/1262404
This commit is contained in:
parent
fd7b49b32b
commit
30e5e993c1
7 changed files with 26 additions and 17 deletions
|
@ -617,15 +617,15 @@ void WebContents::UpdateTargetURL(content::WebContents* source,
|
||||||
Emit("update-target-url", url);
|
Emit("update-target-url", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::HandleKeyboardEvent(
|
bool WebContents::HandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::NativeWebKeyboardEvent& event) {
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
if (type_ == WEB_VIEW && embedder_) {
|
if (type_ == WEB_VIEW && embedder_) {
|
||||||
// Send the unhandled keyboard events back to the embedder.
|
// Send the unhandled keyboard events back to the embedder.
|
||||||
embedder_->HandleKeyboardEvent(source, event);
|
return embedder_->HandleKeyboardEvent(source, event);
|
||||||
} else {
|
} else {
|
||||||
// Go to the default keyboard handling.
|
// Go to the default keyboard handling.
|
||||||
CommonWebContentsDelegate::HandleKeyboardEvent(source, event);
|
return CommonWebContentsDelegate::HandleKeyboardEvent(source, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
void CloseContents(content::WebContents* source) override;
|
void CloseContents(content::WebContents* source) override;
|
||||||
void ActivateContents(content::WebContents* contents) override;
|
void ActivateContents(content::WebContents* contents) override;
|
||||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||||
void HandleKeyboardEvent(
|
bool HandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::NativeWebKeyboardEvent& event) override;
|
const content::NativeWebKeyboardEvent& event) override;
|
||||||
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
||||||
|
|
|
@ -100,7 +100,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
content::SecurityStyleExplanations* explanations) override;
|
content::SecurityStyleExplanations* explanations) override;
|
||||||
bool TakeFocus(content::WebContents* source, bool reverse) override;
|
bool TakeFocus(content::WebContents* source, bool reverse) override;
|
||||||
void HandleKeyboardEvent(
|
bool HandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::NativeWebKeyboardEvent& event) override;
|
const content::NativeWebKeyboardEvent& event) override;
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
void CommonWebContentsDelegate::HandleKeyboardEvent(
|
bool CommonWebContentsDelegate::HandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::NativeWebKeyboardEvent& event) {
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
if (event.skip_in_browser ||
|
if (event.skip_in_browser ||
|
||||||
event.GetType() == content::NativeWebKeyboardEvent::kChar)
|
event.GetType() == content::NativeWebKeyboardEvent::kChar)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// Escape exits tabbed fullscreen mode.
|
// Escape exits tabbed fullscreen mode.
|
||||||
if (event.windows_key_code == ui::VKEY_ESCAPE && is_html_fullscreen()) {
|
if (event.windows_key_code == ui::VKEY_ESCAPE && is_html_fullscreen()) {
|
||||||
|
@ -34,16 +34,23 @@ void CommonWebContentsDelegate::HandleKeyboardEvent(
|
||||||
auto* web_preferences = WebContentsPreferences::From(source);
|
auto* web_preferences = WebContentsPreferences::From(source);
|
||||||
if (web_preferences &&
|
if (web_preferences &&
|
||||||
web_preferences->IsEnabled("ignoreMenuShortcuts", false))
|
web_preferences->IsEnabled("ignoreMenuShortcuts", false))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// Send the event to the menu before sending it to the window
|
// Send the event to the menu before sending it to the window
|
||||||
if (event.os_event.type == NSKeyDown &&
|
if (event.os_event.type == NSKeyDown &&
|
||||||
[[NSApp mainMenu] performKeyEquivalent:event.os_event])
|
[[NSApp mainMenu] performKeyEquivalent:event.os_event])
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
if (event.os_event.window &&
|
if (event.os_event.window &&
|
||||||
[event.os_event.window isKindOfClass:[EventDispatchingWindow class]])
|
[event.os_event.window isKindOfClass:[EventDispatchingWindow class]]) {
|
||||||
[event.os_event.window redispatchKeyEvent:event.os_event];
|
[event.os_event.window redispatchKeyEvent:event.os_event];
|
||||||
|
// FIXME(nornagon): this isn't the right return value; we should implement
|
||||||
|
// devtools windows as Widgets in order to take advantage of the
|
||||||
|
// pre-existing redispatch code in bridged_native_widget.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -17,25 +17,28 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
void CommonWebContentsDelegate::HandleKeyboardEvent(
|
bool CommonWebContentsDelegate::HandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::NativeWebKeyboardEvent& event) {
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
// Escape exits tabbed fullscreen mode.
|
// Escape exits tabbed fullscreen mode.
|
||||||
if (event.windows_key_code == ui::VKEY_ESCAPE && is_html_fullscreen()) {
|
if (event.windows_key_code == ui::VKEY_ESCAPE && is_html_fullscreen()) {
|
||||||
ExitFullscreenModeForTab(source);
|
ExitFullscreenModeForTab(source);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the webContents has preferences and to ignore shortcuts
|
// Check if the webContents has preferences and to ignore shortcuts
|
||||||
auto* web_preferences = WebContentsPreferences::From(source);
|
auto* web_preferences = WebContentsPreferences::From(source);
|
||||||
if (web_preferences &&
|
if (web_preferences &&
|
||||||
web_preferences->IsEnabled("ignoreMenuShortcuts", false))
|
web_preferences->IsEnabled("ignoreMenuShortcuts", false))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// Let the NativeWindow handle other parts.
|
// Let the NativeWindow handle other parts.
|
||||||
if (owner_window()) {
|
if (owner_window()) {
|
||||||
owner_window()->HandleKeyboardEvent(source, event);
|
owner_window()->HandleKeyboardEvent(source, event);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::ShowAutofillPopup(
|
void CommonWebContentsDelegate::ShowAutofillPopup(
|
||||||
|
|
|
@ -779,12 +779,11 @@ bool InspectableWebContentsImpl::ShouldCreateWebContents(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::HandleKeyboardEvent(
|
bool InspectableWebContentsImpl::HandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::NativeWebKeyboardEvent& event) {
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
auto* delegate = web_contents_->GetDelegate();
|
auto* delegate = web_contents_->GetDelegate();
|
||||||
if (delegate)
|
return !delegate || delegate->HandleKeyboardEvent(source, event);
|
||||||
delegate->HandleKeyboardEvent(source, event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::CloseContents(content::WebContents* source) {
|
void InspectableWebContentsImpl::CloseContents(content::WebContents* source) {
|
||||||
|
|
|
@ -182,7 +182,7 @@ class InspectableWebContentsImpl
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
const std::string& partition_id,
|
const std::string& partition_id,
|
||||||
content::SessionStorageNamespace* session_storage_namespace) override;
|
content::SessionStorageNamespace* session_storage_namespace) override;
|
||||||
void HandleKeyboardEvent(content::WebContents*,
|
bool HandleKeyboardEvent(content::WebContents*,
|
||||||
const content::NativeWebKeyboardEvent&) override;
|
const content::NativeWebKeyboardEvent&) override;
|
||||||
void CloseContents(content::WebContents* source) override;
|
void CloseContents(content::WebContents* source) override;
|
||||||
content::ColorChooser* OpenColorChooser(
|
content::ColorChooser* OpenColorChooser(
|
||||||
|
|
Loading…
Reference in a new issue