Changeset 250345 in webkit


Ignore:
Timestamp:
Sep 25, 2019, 9:01:38 AM (6 years ago)
Author:
Wenson Hsieh
Message:

[iPadOS] [DataActivation] Focus moves away after focusing input fields on www.att.com
https://bugs.webkit.org/show_bug.cgi?id=202167
<rdar://problem/55185021>

Reviewed by Tim Horton.

Source/WebCore:

Adds a new site-specific quirk. See WebKit ChangeLog for more details.

  • page/Quirks.cpp:

(WebCore::Quirks::shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation const):

  • page/Quirks.h:
  • platform/RuntimeApplicationChecks.h:
  • platform/cocoa/RuntimeApplicationChecksCocoa.mm:

(WebCore::IOSApplication::isDataActivation):

Source/WebKit:

When using the data activation page on www.att.com, one of the sections on the page contains several select
elements; in the case where the user agent:

  1. contains the string "iPad", and
  2. does not contain the string "Safari"

...www.att.com's data activation page will opt into a mode where it adds blur event listeners to the select
elements; in this blur event listener, www.att.com proceeds to programmatically focus a non-editable div element
after a 1 second timeout. The reasons for this behavior remain unclear to me, though it's worth noting that the
blur event handler name is "screenReaderFocus", which suggests that this is in place to ensure compatibility
with screen readers.

In iOS 12, dismissing the popover would blur the focused select menu with an animation. Since the animation
would take a slightly less than 1 second, www.att.com's logic would have the effect of moving focus to the div
element shortly after dismissing the select menu. However, after r243808, we no longer attempt to blur the
focused select element when dismissing the popover. This means that the select element is only blurred the next
time the user activates another focused element, such as one of the input fields on the page, or a different
select element. Consequently, the logic to move focus into a div element now occurs only after a different
element has already been focused; this results in focus moving away from newly focused elements after 1 second
in the case where a select element has previously focused.

To mitigate this, restore iOS 12 behavior behind a site- and app-specific quirk. See comments below for more
details.

  • Shared/FocusedElementInformation.cpp:

(WebKit::FocusedElementInformation::encode const):
(WebKit::FocusedElementInformation::decode):

  • Shared/FocusedElementInformation.h:

Add a new behavioral quirk flag to FocusedElementInformation to determine whether we should use "legacy" select
popover dismissal behavior (i.e. blurring the focused select element when dismissing the select popover, as well
as dismissing the popover with animation).

  • Shared/WebPreferences.yaml:

Enable site-specific quirks by default in WKWebView. With regards to this bug, this change allows for
site-specific hacks (namely, legacy select popover dismissal) in DataActivation. However, this also fixes
various known bugs that are otherwise addressed in Safari only, via site-specific quirks.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]):

For apps linked on or before iOS 13 and macOS 10.15, revert the default of value of NeedsSiteSpecificQuirks to
false. This is done here instead of in a default value function in WebPreferencesDefaultValues to prevent the
default values of NeedsSiteSpecificQuirks in the web process and UI process from going out of sync, since the
web process is not necessarily linked against the same SDK as the application.

  • UIProcess/Cocoa/VersionChecks.h:

Add a new DYLD version check for the first version of iOS and macOS where site-specific quirks are enabled by
default.

  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
(-[WKContentView _elementDidBlur]):
(-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]):

We only use "legacy" select popover dismissal behavior in the case where the site-specific quirk flag is on, a
select popover is used (i.e. the device is an iPad and a select element is focused), and the application bundle
is "com.apple.DataActivation".

  • UIProcess/ios/forms/WKFormSelectPopover.mm:

(-[WKSelectTableViewController shouldDismissWithAnimation]):

Keyed off of _shouldUseLegacySelectPopoverDismissalBehavior.

(-[WKSelectPopover controlEndEditing]):

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::getFocusedElementInformation):

Source/WTF:

Declare DYLD_IOS_VERSION_13_2.

  • wtf/spi/darwin/dyldSPI.h:

Tools:

Rebaseline an API test.

  • TestWebKitAPI/Tests/WebKit/WKPreferences.cpp:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r250309 r250345  
     12019-09-25  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] [DataActivation] Focus moves away after focusing input fields on www.att.com
     4        https://bugs.webkit.org/show_bug.cgi?id=202167
     5        <rdar://problem/55185021>
     6
     7        Reviewed by Tim Horton.
     8
     9        Declare DYLD_IOS_VERSION_13_2.
     10
     11        * wtf/spi/darwin/dyldSPI.h:
     12
    1132019-09-24  Keith Rollin  <krollin@apple.com>
    214
  • trunk/Source/WTF/wtf/spi/darwin/dyldSPI.h

    r247793 r250345  
    4646#endif
    4747
     48#ifndef DYLD_IOS_VERSION_13_2
     49#define DYLD_IOS_VERSION_13_2 0x000D0200
     50#endif
     51
    4852#ifndef DYLD_MACOSX_VERSION_10_13
    4953#define DYLD_MACOSX_VERSION_10_13 0x000A0D00
     
    5660#ifndef DYLD_MACOSX_VERSION_10_15
    5761#define DYLD_MACOSX_VERSION_10_15 0x000A0F00
     62#endif
     63
     64#ifndef DYLD_MACOSX_VERSION_10_15_1
     65#define DYLD_MACOSX_VERSION_10_15_1 0x000A0F01
    5866#endif
    5967
     
    7179#define DYLD_IOS_VERSION_12_0 0x000C0000
    7280#define DYLD_IOS_VERSION_13_0 0x000D0000
     81#define DYLD_IOS_VERSION_13_2 0x000D0200
    7382
    7483#define DYLD_MACOSX_VERSION_10_11 0x000A0B00
     
    7786#define DYLD_MACOSX_VERSION_10_14 0x000A0E00
    7887#define DYLD_MACOSX_VERSION_10_15 0x000A0F00
     88#define DYLD_MACOSX_VERSION_10_15_1 0x000A0F01
    7989
    8090#endif
  • trunk/Source/WebCore/ChangeLog

    r250344 r250345  
     12019-09-25  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] [DataActivation] Focus moves away after focusing input fields on www.att.com
     4        https://bugs.webkit.org/show_bug.cgi?id=202167
     5        <rdar://problem/55185021>
     6
     7        Reviewed by Tim Horton.
     8
     9        Adds a new site-specific quirk. See WebKit ChangeLog for more details.
     10
     11        * page/Quirks.cpp:
     12        (WebCore::Quirks::shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation const):
     13        * page/Quirks.h:
     14        * platform/RuntimeApplicationChecks.h:
     15        * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
     16        (WebCore::IOSApplication::isDataActivation):
     17
    1182019-09-25  Jonathan Bedard  <jbedard@apple.com>
    219
  • trunk/Source/WebCore/page/Quirks.cpp

    r250326 r250345  
    547547}
    548548
     549bool Quirks::shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation() const
     550{
     551    if (!needsQuirks())
     552        return false;
     553
     554    auto host = m_document->url().host();
     555    return equalLettersIgnoringASCIICase(host, "att.com") || host.endsWithIgnoringASCIICase(".att.com");
     556}
     557
    549558bool Quirks::shouldOpenAsAboutBlank(const String& stringToOpen) const
    550559{
  • trunk/Source/WebCore/page/Quirks.h

    r250326 r250345  
    6969    WEBCORE_EXPORT bool shouldAvoidResizingWhenInputViewBoundsChange() const;
    7070    WEBCORE_EXPORT bool shouldAvoidScrollingWhenFocusedContentIsVisible() const;
     71    WEBCORE_EXPORT bool shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation() const;
    7172
    7273    WEBCORE_EXPORT bool needsYouTubeMouseOutQuirk() const;
  • trunk/Source/WebCore/platform/RuntimeApplicationChecks.h

    r249770 r250345  
    9898WEBCORE_EXPORT bool isEvernote();
    9999WEBCORE_EXPORT bool isEventbrite();
     100WEBCORE_EXPORT bool isDataActivation();
    100101
    101102} // IOSApplication
  • trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm

    r249770 r250345  
    325325}
    326326
     327bool IOSApplication::isDataActivation()
     328{
     329    static bool isDataActivation = applicationBundleIsEqualTo("com.apple.DataActivation"_s);
     330    return isDataActivation;
     331}
     332
    327333#endif
    328334
  • trunk/Source/WebKit/ChangeLog

    r250344 r250345  
     12019-09-25  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] [DataActivation] Focus moves away after focusing input fields on www.att.com
     4        https://bugs.webkit.org/show_bug.cgi?id=202167
     5        <rdar://problem/55185021>
     6
     7        Reviewed by Tim Horton.
     8
     9        When using the data activation page on www.att.com, one of the sections on the page contains several select
     10        elements; in the case where the user agent:
     11
     12        1. contains the string "iPad", and
     13        2. does not contain the string "Safari"
     14
     15        ...www.att.com's data activation page will opt into a mode where it adds blur event listeners to the select
     16        elements; in this blur event listener, www.att.com proceeds to programmatically focus a non-editable div element
     17        after a 1 second timeout. The reasons for this behavior remain unclear to me, though it's worth noting that the
     18        blur event handler name is "screenReaderFocus", which suggests that this is in place to ensure compatibility
     19        with screen readers.
     20
     21        In iOS 12, dismissing the popover would blur the focused select menu with an animation. Since the animation
     22        would take a slightly less than 1 second, www.att.com's logic would have the effect of moving focus to the div
     23        element shortly after dismissing the select menu. However, after r243808, we no longer attempt to blur the
     24        focused select element when dismissing the popover. This means that the select element is only blurred the next
     25        time the user activates another focused element, such as one of the input fields on the page, or a different
     26        select element. Consequently, the logic to move focus into a div element now occurs only after a different
     27        element has already been focused; this results in focus moving away from newly focused elements after 1 second
     28        in the case where a select element has previously focused.
     29
     30        To mitigate this, restore iOS 12 behavior behind a site- and app-specific quirk. See comments below for more
     31        details.
     32
     33        * Shared/FocusedElementInformation.cpp:
     34        (WebKit::FocusedElementInformation::encode const):
     35        (WebKit::FocusedElementInformation::decode):
     36        * Shared/FocusedElementInformation.h:
     37
     38        Add a new behavioral quirk flag to FocusedElementInformation to determine whether we should use "legacy" select
     39        popover dismissal behavior (i.e. blurring the focused select element when dismissing the select popover, as well
     40        as dismissing the popover with animation).
     41
     42        * Shared/WebPreferences.yaml:
     43
     44        Enable site-specific quirks by default in WKWebView. With regards to this bug, this change allows for
     45        site-specific hacks (namely, legacy select popover dismissal) in DataActivation. However, this also fixes
     46        various known bugs that are otherwise addressed in Safari only, via site-specific quirks.
     47
     48        * UIProcess/API/Cocoa/WKWebView.mm:
     49        (-[WKWebView _initializeWithConfiguration:]):
     50
     51        For apps linked on or before iOS 13 and macOS 10.15, revert the default of value of NeedsSiteSpecificQuirks to
     52        false. This is done here instead of in a default value function in WebPreferencesDefaultValues to prevent the
     53        default values of NeedsSiteSpecificQuirks in the web process and UI process from going out of sync, since the
     54        web process is not necessarily linked against the same SDK as the application.
     55
     56        * UIProcess/Cocoa/VersionChecks.h:
     57
     58        Add a new DYLD version check for the first version of iOS and macOS where site-specific quirks are enabled by
     59        default.
     60
     61        * UIProcess/ios/WKContentViewInteraction.h:
     62        * UIProcess/ios/WKContentViewInteraction.mm:
     63        (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
     64        (-[WKContentView _elementDidBlur]):
     65        (-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]):
     66
     67        We only use "legacy" select popover dismissal behavior in the case where the site-specific quirk flag is on, a
     68        select popover is used (i.e. the device is an iPad and a select element is focused), and the application bundle
     69        is "com.apple.DataActivation".
     70
     71        * UIProcess/ios/forms/WKFormSelectPopover.mm:
     72        (-[WKSelectTableViewController shouldDismissWithAnimation]):
     73
     74        Keyed off of _shouldUseLegacySelectPopoverDismissalBehavior.
     75
     76        (-[WKSelectPopover controlEndEditing]):
     77        * WebProcess/WebPage/ios/WebPageIOS.mm:
     78        (WebKit::WebPage::getFocusedElementInformation):
     79
    1802019-09-25  Jonathan Bedard  <jbedard@apple.com>
    281
  • trunk/Source/WebKit/Shared/FocusedElementInformation.cpp

    r247746 r250345  
    109109    encoder << shouldAvoidResizingWhenInputViewBoundsChange;
    110110    encoder << shouldAvoidScrollingWhenFocusedContentIsVisible;
     111    encoder << shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation;
    111112}
    112113
     
    239240        return false;
    240241
     242    if (!decoder.decode(result.shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation))
     243        return false;
     244
    241245    return true;
    242246}
  • trunk/Source/WebKit/Shared/FocusedElementInformation.h

    r247746 r250345  
    141141    bool shouldAvoidResizingWhenInputViewBoundsChange { false };
    142142    bool shouldAvoidScrollingWhenFocusedContentIsVisible { false };
     143    bool shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation { false };
    143144
    144145    FocusedElementIdentifier focusedElementIdentifier { 0 };
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r250336 r250345  
    107107NeedsSiteSpecificQuirks:
    108108  type: bool
    109   defaultValue: false
     109  defaultValue: true
    110110
    111111AcceleratedCompositingEnabled:
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r250093 r250345  
    687687#endif
    688688
     689    if (!linkedOnOrAfter(WebKit::SDKVersion::FirstWhereSiteSpecificQuirksAreEnabledByDefault))
     690        pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::needsSiteSpecificQuirksKey(), WebKit::WebPreferencesStore::Value(false));
     691
    689692#if PLATFORM(IOS_FAMILY)
    690693    CGRect bounds = self.bounds;
  • trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h

    r249770 r250345  
    8181    FirstWhereWKContentViewDoesNotOverrideKeyCommands = DYLD_IOS_VERSION_13_0,
    8282    FirstThatSupportsOverflowHiddenOnMainFrame = DYLD_IOS_VERSION_13_0,
     83    FirstWhereSiteSpecificQuirksAreEnabledByDefault = DYLD_IOS_VERSION_13_2,
    8384#elif PLATFORM(MAC)
    8485    FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
     
    9091    FirstWithSnapshotAfterScreenUpdates = DYLD_MACOS_VERSION_FIRST_WITH_SNAPSHOT_AFTER_SCREEN_UPDATES,
    9192    FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
     93    FirstWhereSiteSpecificQuirksAreEnabledByDefault = DYLD_MACOSX_VERSION_10_15_1,
    9294#endif
    9395};
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r250256 r250345  
    556556@property (nonatomic, readonly) BOOL _shouldAvoidResizingWhenInputViewBoundsChange;
    557557@property (nonatomic, readonly) BOOL _shouldAvoidScrollingWhenFocusedContentIsVisible;
     558@property (nonatomic, readonly) BOOL _shouldUseLegacySelectPopoverDismissalBehavior;
    558559
    559560- (void)_didChangeLinkPreviewAvailability;
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r250315 r250345  
    13071307        // We need to complete the editing operation before we blur the element.
    13081308        [self _endEditing];
    1309         if ((reason == EndEditingReasonAccessoryDone && !currentUserInterfaceIdiomIsPad()) || _keyboardDidRequestDismissal) {
     1309        if ((reason == EndEditingReasonAccessoryDone && !currentUserInterfaceIdiomIsPad()) || _keyboardDidRequestDismissal || self._shouldUseLegacySelectPopoverDismissalBehavior) {
    13101310            _page->blurFocusedElement();
    13111311            // Don't wait for WebPageProxy::blurFocusedElement() to round-trip back to us to hide the keyboard
     
    55635563    _focusedElementInformation.shouldAvoidResizingWhenInputViewBoundsChange = false;
    55645564    _focusedElementInformation.shouldAvoidScrollingWhenFocusedContentIsVisible = false;
     5565    _focusedElementInformation.shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation = false;
    55655566    _inputPeripheral = nil;
    55665567    _focusRequiresStrongPasswordAssistance = NO;
     
    65356536{
    65366537    return _focusedElementInformation.shouldAvoidScrollingWhenFocusedContentIsVisible;
     6538}
     6539
     6540- (BOOL)_shouldUseLegacySelectPopoverDismissalBehavior
     6541{
     6542    if (!currentUserInterfaceIdiomIsPad())
     6543        return NO;
     6544
     6545    if (_focusedElementInformation.elementType != WebKit::InputType::Select)
     6546        return NO;
     6547
     6548    if (!_focusedElementInformation.shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation)
     6549        return NO;
     6550
     6551    return WebCore::IOSApplication::isDataActivation();
    65376552}
    65386553
  • trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPopover.mm

    r250306 r250345  
    9999}
    100100
    101 @property(nonatomic,assign) WKSelectPopover *popover;
     101@property (nonatomic, readonly) BOOL shouldDismissWithAnimation;
     102@property (nonatomic, assign) WKSelectPopover *popover;
    102103@end
    103104
     
    365366}
    366367
     368- (BOOL)shouldDismissWithAnimation
     369{
     370    return _contentView._shouldUseLegacySelectPopoverDismissalBehavior;
     371}
     372
    367373#if !USE(UIKIT_KEYBOARD_ADDITIONS)
    368374#pragma mark UIKeyInput delegate methods
     
    448454- (void)controlEndEditing
    449455{
    450     [self dismissPopoverAnimated:NO];
     456    [self dismissPopoverAnimated:[_tableViewController shouldDismissWithAnimation]];
    451457}
    452458
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r250315 r250345  
    30613061    information.shouldAvoidResizingWhenInputViewBoundsChange = quirks.shouldAvoidResizingWhenInputViewBoundsChange();
    30623062    information.shouldAvoidScrollingWhenFocusedContentIsVisible = quirks.shouldAvoidScrollingWhenFocusedContentIsVisible();
     3063    information.shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation = quirks.shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation();
    30633064}
    30643065
  • trunk/Tools/ChangeLog

    r250344 r250345  
     12019-09-25  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] [DataActivation] Focus moves away after focusing input fields on www.att.com
     4        https://bugs.webkit.org/show_bug.cgi?id=202167
     5        <rdar://problem/55185021>
     6
     7        Reviewed by Tim Horton.
     8
     9        Rebaseline an API test.
     10
     11        * TestWebKitAPI/Tests/WebKit/WKPreferences.cpp:
     12        (TestWebKitAPI::TEST):
     13
    1142019-09-25  Jonathan Bedard  <jbedard@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/WKPreferences.cpp

    r244390 r250345  
    9898    EXPECT_FALSE(WKPreferencesGetCompositingBordersVisible(preference));
    9999    EXPECT_FALSE(WKPreferencesGetCompositingRepaintCountersVisible(preference));
    100     EXPECT_FALSE(WKPreferencesGetNeedsSiteSpecificQuirks(preference));
     100    EXPECT_TRUE(WKPreferencesGetNeedsSiteSpecificQuirks(preference));
    101101    EXPECT_EQ(kWKAllowAllStorage, WKPreferencesGetStorageBlockingPolicy(preference));
    102102    EXPECT_FALSE(WKPreferencesGetTextAutosizingEnabled(preference));
Note: See TracChangeset for help on using the changeset viewer.