Changeset 230527 in webkit


Ignore:
Timestamp:
Apr 11, 2018 9:43:53 AM (6 years ago)
Author:
Wenson Hsieh
Message:

[Extra zoom mode] Missing label when focusing a <select> with a title attribute but no associated <label>
https://bugs.webkit.org/show_bug.cgi?id=184352
<rdar://problem/39237683>

Reviewed by Andy Estes.

Source/WebKit:

Currently, AssistedNodeInformation only sends the title of input elements to the UI process. This means that
any information requested in the UI process that is dependent on the title of the focused element is broken
in the case of select elements. An existing example of this is the title of the table view controller used to
present select menus on iPad.

To fix this, we simply send the title of the focused element across, as long as the focused element is an
HTMLElement. This ensures that there's label text when focusing unlabeled select elements with titles in extra
zoom mode, and also fixes a currenly broken codepath where we show the title of the select in the presented view
controller's title.

Test: fast/forms/ios/ipad/select-with-title.html

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView selectFormPopoverTitle]):

  • UIProcess/API/Cocoa/WKWebViewPrivate.h:

Add new testing SPI to fetch the title of the UITableViewController presented for the currently focused select
element.

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

(-[WKContentView selectFormPopoverTitle]):

  • UIProcess/ios/forms/WKFormSelectControl.h:
  • UIProcess/ios/forms/WKFormSelectControl.mm:

(-[WKFormSelectControl selectFormPopoverTitle]):

  • UIProcess/ios/forms/WKFormSelectPopover.h:
  • UIProcess/ios/forms/WKFormSelectPopover.mm:

(-[WKSelectPopover initWithView:hasGroups:]):
(-[WKSelectPopover tableViewController]):

  • WebProcess/WebPage/ios/WebPageIOS.mm:

Always send the title across if the focused node is an HTMLElement.

(WebKit::WebPage::getAssistedNodeInformation):

Tools:

Add support for UIScriptController::selectFormPopoverTitle, which returns the title of the current select
popover's UITableViewController (for testing purposes).

  • DumpRenderTree/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptController::selectFormPopoverTitle const):

  • TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
  • TestRunnerShared/UIScriptContext/UIScriptController.cpp:

(WTR::UIScriptController::selectFormPopoverTitle const):

  • TestRunnerShared/UIScriptContext/UIScriptController.h:
  • WebKitTestRunner/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptController::selectFormPopoverTitle const):

LayoutTests:

Add a new layout test to check that the title of select elements is propagated to the UI process upon focus.
This title is used for several purposes, one of them being the title of select menus in the table view
controller presented when tapping on a select on an iPad, so the test checks that the title of the select is
shown here.

Also moves a select-related helper into UIHelper from basic-gestures.js (since this doesn't involve user gesture
simulation in any way) and also introduces a new UIHelper method for querying the title of the select menu that
is currently being presented.

  • fast/forms/ios/ipad/multiple-select-updates-renderer.html:
  • fast/forms/ios/ipad/select-with-title-expected.txt: Added.
  • fast/forms/ios/ipad/select-with-title.html: Copied from LayoutTests/fast/forms/ios/ipad/multiple-select-updates-renderer.html.
  • resources/basic-gestures.js:
  • resources/ui-helper.js:

(window.UIHelper.selectFormAccessoryPickerRow):
(window.UIHelper.selectFormPopoverTitle):
(window.UIHelper):

Location:
trunk
Files:
1 added
20 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r230525 r230527  
     12018-04-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Missing label when focusing a <select> with a title attribute but no associated <label>
     4        https://bugs.webkit.org/show_bug.cgi?id=184352
     5        <rdar://problem/39237683>
     6
     7        Reviewed by Andy Estes.
     8
     9        Add a new layout test to check that the title of select elements is propagated to the UI process upon focus.
     10        This title is used for several purposes, one of them being the title of select menus in the table view
     11        controller presented when tapping on a select on an iPad, so the test checks that the title of the select is
     12        shown here.
     13
     14        Also moves a select-related helper into UIHelper from basic-gestures.js (since this doesn't involve user gesture
     15        simulation in any way) and also introduces a new UIHelper method for querying the title of the select menu that
     16        is currently being presented.
     17
     18        * fast/forms/ios/ipad/multiple-select-updates-renderer.html:
     19        * fast/forms/ios/ipad/select-with-title-expected.txt: Added.
     20        * fast/forms/ios/ipad/select-with-title.html: Copied from LayoutTests/fast/forms/ios/ipad/multiple-select-updates-renderer.html.
     21        * resources/basic-gestures.js:
     22        * resources/ui-helper.js:
     23        (window.UIHelper.selectFormAccessoryPickerRow):
     24        (window.UIHelper.selectFormPopoverTitle):
     25        (window.UIHelper):
     26
    1272018-04-10  Ryan Haddad  <ryanhaddad@apple.com>
    228
  • trunk/LayoutTests/fast/forms/ios/ipad/multiple-select-updates-renderer.html

    r230055 r230527  
    1515</style>
    1616<script src="../../../../resources/basic-gestures.js"></script>
     17<script src="../../../../resources/ui-helper.js"></script>
    1718<script>
    1819    async function run()
     
    2223
    2324        await tapAtPoint(100, 100);
    24         await selectFormAccessoryPickerRow(0);
     25        await UIHelper.selectFormAccessoryPickerRow(0);
    2526        doneEvaluatingUIScript = true;
    2627        checkDone();
  • trunk/LayoutTests/fast/forms/ios/ipad/select-with-title.html

    r230526 r230527  
    1414    }
    1515</style>
     16<script src="../../../../resources/js-test.js"></script>
     17<script src="../../../../resources/ui-helper.js"></script>
    1618<script src="../../../../resources/basic-gestures.js"></script>
    1719<script>
     
    2224
    2325        await tapAtPoint(100, 100);
    24         await selectFormAccessoryPickerRow(0);
    25         doneEvaluatingUIScript = true;
     26        popoverTitle = await UIHelper.selectFormPopoverTitle();
     27        await UIHelper.selectFormAccessoryPickerRow(1);
    2628        checkDone();
    2729    }
     
    2931    function checkDone()
    3032    {
    31         if (window.doneEvaluatingUIScript && window.valueChanged && window.testRunner)
     33        doneCount = 1 + (window.doneCount ? doneCount : 0);
     34        if (doneCount == 2 && window.testRunner) {
     35            shouldBe("popoverTitle", "document.getElementById('select').title");
    3236            testRunner.notifyDone();
     37        }
    3338    }
    3439</script>
    3540</head>
    3641<body onload="run()">
    37     <select multiple id="select"><option>This is an option.</option></select>
     42    <select title="This is a title" id="select">
     43        <option>1</option>
     44        <option>2</option>
     45        <option>3</option>
     46    </select>
    3847    <pre id="output"></pre>
    3948</body>
    4049<script>
    41     select.addEventListener("change", () => {
    42         if (window.internals) {
    43             const renderTreeAsText = internals.elementRenderTreeAsText(document.documentElement);
    44             const expectedOptionValue = "This is an option.";
    45             if (renderTreeAsText.indexOf(expectedOptionValue) != -1)
    46                 output.textContent = "PASS";
    47             else
    48                 output.textContent = `FAIL: expected '${expectedOptionValue}' in render tree dump:\n${renderTreeAsText}`;
    49         }
    50 
    51         select.blur();
    52         valueChanged = true;
    53         checkDone();
    54     });
     50    select.addEventListener("blur", checkDone);
     51    select.addEventListener("change", () => select.blur());
    5552
    5653    if (window.testRunner) {
  • trunk/LayoutTests/resources/basic-gestures.js

    r230055 r230527  
    139139            })();`, resolve);
    140140    });
    141 }
    142 
    143 function selectFormAccessoryPickerRow(rowIndex)
    144 {
    145     const selectRowScript = `(() => uiController.selectFormAccessoryPickerRow(${rowIndex}))()`;
    146     return new Promise(resolve => testRunner.runUIScript(selectRowScript, resolve));
    147141}
    148142
  • trunk/LayoutTests/resources/ui-helper.js

    r224606 r230527  
    162162        internals.withUserGesture(callback);
    163163    }
     164
     165    static selectFormAccessoryPickerRow(rowIndex)
     166    {
     167        const selectRowScript = `(() => uiController.selectFormAccessoryPickerRow(${rowIndex}))()`;
     168        return new Promise(resolve => testRunner.runUIScript(selectRowScript, resolve));
     169    }
     170
     171    static selectFormPopoverTitle()
     172    {
     173        return new Promise(resolve => {
     174            testRunner.runUIScript(`(() => {
     175                uiController.uiScriptComplete(uiController.selectFormPopoverTitle);
     176            })()`, resolve);
     177        });
     178    }
    164179}
  • trunk/Source/WebKit/ChangeLog

    r230526 r230527  
     12018-04-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Missing label when focusing a <select> with a title attribute but no associated <label>
     4        https://bugs.webkit.org/show_bug.cgi?id=184352
     5        <rdar://problem/39237683>
     6
     7        Reviewed by Andy Estes.
     8
     9        Currently, AssistedNodeInformation only sends the `title` of input elements to the UI process. This means that
     10        any information requested in the UI process that is dependent on the `title` of the focused element is broken
     11        in the case of select elements. An existing example of this is the title of the table view controller used to
     12        present select menus on iPad.
     13
     14        To fix this, we simply send the `title` of the focused element across, as long as the focused element is an
     15        HTMLElement. This ensures that there's label text when focusing unlabeled select elements with titles in extra
     16        zoom mode, and also fixes a currenly broken codepath where we show the title of the select in the presented view
     17        controller's title.
     18
     19        Test: fast/forms/ios/ipad/select-with-title.html
     20
     21        * UIProcess/API/Cocoa/WKWebView.mm:
     22        (-[WKWebView selectFormPopoverTitle]):
     23        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     24
     25        Add new testing SPI to fetch the title of the UITableViewController presented for the currently focused select
     26        element.
     27
     28        * UIProcess/ios/WKContentViewInteraction.h:
     29        * UIProcess/ios/WKContentViewInteraction.mm:
     30        (-[WKContentView selectFormPopoverTitle]):
     31        * UIProcess/ios/forms/WKFormSelectControl.h:
     32        * UIProcess/ios/forms/WKFormSelectControl.mm:
     33        (-[WKFormSelectControl selectFormPopoverTitle]):
     34        * UIProcess/ios/forms/WKFormSelectPopover.h:
     35        * UIProcess/ios/forms/WKFormSelectPopover.mm:
     36        (-[WKSelectPopover initWithView:hasGroups:]):
     37        (-[WKSelectPopover tableViewController]):
     38        * WebProcess/WebPage/ios/WebPageIOS.mm:
     39
     40        Always send the title across if the focused node is an HTMLElement.
     41
     42        (WebKit::WebPage::getAssistedNodeInformation):
     43
    1442018-04-11  Ryan Haddad  <ryanhaddad@apple.com>
    245
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r230496 r230527  
    58725872}
    58735873
     5874- (NSString *)selectFormPopoverTitle
     5875{
     5876    return [_contentView selectFormPopoverTitle];
     5877}
     5878
    58745879- (void)didStartFormControlInteraction
    58755880{
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r230470 r230527  
    382382- (void)dismissFormAccessoryView WK_API_AVAILABLE(ios(10.3));
    383383- (void)selectFormAccessoryPickerRow:(int)rowIndex WK_API_AVAILABLE(ios(10.3));
     384@property (nonatomic, readonly) NSString *selectFormPopoverTitle WK_API_AVAILABLE(ios(WK_IOS_TBA));
    384385
    385386- (void)applyAutocorrection:(NSString *)newString toString:(NSString *)oldString withCompletionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(ios(11.0));
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r230526 r230527  
    364364- (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem;
    365365
     366@property (nonatomic, readonly) NSString *selectFormPopoverTitle;
     367
    366368@end
    367369
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r230526 r230527  
    54405440}
    54415441
     5442- (NSString *)selectFormPopoverTitle
     5443{
     5444    if (![_inputPeripheral isKindOfClass:[WKFormSelectControl self]])
     5445        return nil;
     5446
     5447    return [(WKFormSelectControl *)_inputPeripheral selectFormPopoverTitle];
     5448}
     5449
    54425450- (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem
    54435451{
  • trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectControl.h

    r204535 r230527  
    4242@interface WKFormSelectControl(WKTesting)
    4343- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection;
     44@property (nonatomic, readonly) NSString *selectFormPopoverTitle;
    4445@end
    4546
  • trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectControl.mm

    r226335 r230527  
    112112}
    113113
     114- (NSString *)selectFormPopoverTitle
     115{
     116    if (![_control isKindOfClass:[WKSelectPopover class]])
     117        return nil;
     118
     119    return [(WKSelectPopover *)_control.get() tableViewController].title;
     120}
     121
    114122@end
    115123
  • trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPopover.h

    r204535 r230527  
    2929#import "WKFormPopover.h"
    3030
     31@class UITableViewController;
    3132@class WKContentView;
    3233
     
    3435- (instancetype)initWithView:(WKContentView *)view hasGroups:(BOOL)hasGroups;
    3536- (void)_userActionDismissedPopover:(id)sender;
     37@property (nonatomic, readonly) UITableViewController *tableViewController;
    3638@end
    3739
  • trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPopover.mm

    r223857 r230527  
    390390    UIViewController *popoverViewController = _tableViewController.get();
    391391    UINavigationController *navController = nil;
    392     NSString *title = view.assistedNodeInformation.title;
    393     BOOL needsNavigationController = !!title.length;
     392    BOOL needsNavigationController = !view.assistedNodeInformation.title.isEmpty();
    394393    if (needsNavigationController) {
    395394        navController = [[UINavigationController alloc] initWithRootViewController:_tableViewController.get()];
     
    443442}
    444443
     444- (UITableViewController *)tableViewController
     445{
     446    return _tableViewController.get();
     447}
     448
    445449@end
    446450
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r230526 r230527  
    27872787    }
    27882788
     2789    if (is<HTMLElement>(m_assistedNode.get()))
     2790        information.title = downcast<HTMLElement>(*m_assistedNode).title();
     2791
    27892792    if (is<HTMLSelectElement>(*m_assistedNode)) {
    27902793        HTMLSelectElement& element = downcast<HTMLSelectElement>(*m_assistedNode);
     
    28672870        information.value = element.value();
    28682871        information.valueAsNumber = element.valueAsNumber();
    2869         information.title = element.title();
    28702872        information.autofillFieldName = WebCore::toAutofillFieldName(element.autofillData().fieldName);
    28712873    } else if (m_assistedNode->hasEditableStyle()) {
  • trunk/Tools/ChangeLog

    r230510 r230527  
     12018-04-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Missing label when focusing a <select> with a title attribute but no associated <label>
     4        https://bugs.webkit.org/show_bug.cgi?id=184352
     5        <rdar://problem/39237683>
     6
     7        Reviewed by Andy Estes.
     8
     9        Add support for UIScriptController::selectFormPopoverTitle, which returns the title of the current select
     10        popover's UITableViewController (for testing purposes).
     11
     12        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
     13        (WTR::UIScriptController::selectFormPopoverTitle const):
     14        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
     15        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
     16        (WTR::UIScriptController::selectFormPopoverTitle const):
     17        * TestRunnerShared/UIScriptContext/UIScriptController.h:
     18        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
     19        (WTR::UIScriptController::selectFormPopoverTitle const):
     20
    1212018-04-10  Nan Wang  <n_wang@apple.com>
    222
  • trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm

    r226750 r230527  
    159159{
    160160}
     161
     162JSRetainPtr<JSStringRef> UIScriptController::selectFormPopoverTitle() const
     163{
     164    return nullptr;
     165}
    161166   
    162167JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
  • trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl

    r228857 r230527  
    188188    // <select> picker
    189189    void selectFormAccessoryPickerRow(long rowIndex);
     190    readonly attribute DOMString selectFormPopoverTitle;
    190191
    191192    void keyboardAccessoryBarNext();
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp

    r228857 r230527  
    299299}
    300300
     301JSRetainPtr<JSStringRef> UIScriptController::selectFormPopoverTitle() const
     302{
     303    return nullptr;
     304}
     305
    301306void UIScriptController::scrollToOffset(long x, long y)
    302307{
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h

    r228857 r230527  
    9898    void dismissFormAccessoryView();
    9999    void selectFormAccessoryPickerRow(long);
     100    JSRetainPtr<JSStringRef> selectFormPopoverTitle() const;
    100101   
    101102    JSObjectRef contentsOfUserInterfaceItem(JSStringRef) const;
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

    r226750 r230527  
    419419}
    420420
     421JSRetainPtr<JSStringRef> UIScriptController::selectFormPopoverTitle() const
     422{
     423    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     424    return JSStringCreateWithCFString((CFStringRef)webView.selectFormPopoverTitle);
     425}
     426
    421427void UIScriptController::selectFormAccessoryPickerRow(long rowIndex)
    422428{
Note: See TracChangeset for help on using the changeset viewer.