Commit 3805470b authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Revert "[iOS] Set FirstResponderSendAction as default"

This reverts commit 2aa1a2f6.

Reason for revert: Potential culprit for crbug.com/1152587

Original change's description:
> [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/+/2495976
> Reviewed-by: Gauthier 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}

TBR=gambard@chromium.org,javierrobles@chromium.org

Change-Id: If4c1451b7ed278b02164f0816d8b01bf11314289
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 816427
Bug: 1150498
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560097Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830927}
parent 2da0057a
......@@ -3772,12 +3772,9 @@ NSString* const kBrowserViewControllerSnackbarCategory =
[SizeClassRecorder pageLoadedWithHorizontalSizeClass:sizeClass];
}
// 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) {
// 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) {
NewTabPageTabHelper* NTPHelper =
NewTabPageTabHelper::FromWebState(webState);
if (NTPHelper && NTPHelper->IsActive()) {
......
......@@ -31,6 +31,9 @@ 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,6 +34,9 @@ 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.
// Returns the current first responder for keyWindow.
UIResponder* GetFirstResponder();
// Trigger a haptic vibration for various types of actions. This is a no-op for
......
......@@ -315,15 +315,19 @@ UIView* GetFirstResponderSubview(UIView* view) {
UIResponder* GetFirstResponder() {
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;
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);
}
// 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