Commit 2aa1a2f6 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS] Set FirstResponderSendAction as default

Remove experiment flag, and set enabled behavior as default.

Keep old behavior when asking the NTP and WebView to become first
responder. This is done checking if the first responder is a view, and
asking if not. Because in the previous logic for GetFirstResponder() the
search was made in the view hierarchy, ignoring view controllers.

The experiment enabled without the check added in this CL could explain
issues like crbug.com/1150498.

Bug: 816427, 1150498
Change-Id: Ib9ac17b59da8635d00beff071aee4bd6afeedb78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495976Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Javier Flores <javierrobles@chromium.org>
Auto-Submit: Javier Flores <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830632}
parent 31bd38f0
......@@ -3772,9 +3772,12 @@ NSString* const kBrowserViewControllerSnackbarCategory =
[SizeClassRecorder pageLoadedWithHorizontalSizeClass:sizeClass];
}
// If there is no first responder, try to make the webview or the NTP first
// responder to have it answer keyboard commands (e.g. space bar to scroll).
if (!GetFirstResponder() && self.currentWebState) {
// If there is no first responder, or it is not a view, try to make the
// webview or the NTP first responder to have it answer keyboard commands
// (e.g. space bar to scroll).
BOOL isFirstResponderView =
[GetFirstResponder() isKindOfClass:[UIView class]];
if (!isFirstResponderView && self.currentWebState) {
NewTabPageTabHelper* NTPHelper =
NewTabPageTabHelper::FromWebState(webState);
if (NTPHelper && NTPHelper->IsActive()) {
......
......@@ -31,9 +31,6 @@ const base::Feature kForceUnstackedTabstrip{"ForceUnstackedTabstrip",
const base::Feature kTestFeature{"TestFeature",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kFirstResponderSendAction{
"FirstResponderSendAction", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kEnableNativeContextMenus{
"EnableNativeContextMenus", base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -34,9 +34,6 @@ extern const base::Feature kForceUnstackedTabstrip;
// features in tests works.
extern const base::Feature kTestFeature;
// Verify if the crash in https://crbug.com/816427 is fixed on iOS 12.
extern const base::Feature kFirstResponderSendAction;
// Feature flag that enables the native UI Context Menus (not for Web content).
extern const base::Feature kEnableNativeContextMenus;
......
......@@ -181,7 +181,7 @@ bool IsSplitToolbarMode(id<UITraitEnvironment> environment);
// bottom toolbar or if it is displayed as only one toolbar.
bool IsSplitToolbarMode(UITraitCollection* traitCollection);
// Returns the current first responder for keyWindow.
// Returns the current first responder.
UIResponder* GetFirstResponder();
// Trigger a haptic vibration for various types of actions. This is a no-op for
......
......@@ -315,19 +315,15 @@ UIView* GetFirstResponderSubview(UIView* view) {
UIResponder* GetFirstResponder() {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
if (base::FeatureList::IsEnabled(kFirstResponderSendAction)) {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
DCHECK(!g_first_responder);
[[UIApplication sharedApplication]
sendAction:@selector(cr_markSelfCurrentFirstResponder)
to:nil
from:nil
forEvent:nil];
UIResponder* firstResponder = g_first_responder;
g_first_responder = nil;
return firstResponder;
}
return GetFirstResponderSubview([UIApplication sharedApplication].keyWindow);
DCHECK(!g_first_responder);
[[UIApplication sharedApplication]
sendAction:@selector(cr_markSelfCurrentFirstResponder)
to:nil
from:nil
forEvent:nil];
UIResponder* firstResponder = g_first_responder;
g_first_responder = nil;
return firstResponder;
}
// Trigger a haptic vibration for the user selecting an action. This is a no-op
......
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