Title: [280398] trunk
Revision
280398
Author
akeer...@apple.com
Date
2021-07-28 13:21:30 -0700 (Wed, 28 Jul 2021)

Log Message

[iOS] <select> picker value committed to incorrect element after programmatic focus change
https://bugs.webkit.org/show_bug.cgi?id=228556
rdar://81222952

Reviewed by Wenson Hsieh.

Source/WebKit:

The old <select> picker is a UIPickerView that only commits any value
changes to the WebProcess once the user dismisses the picker, or focus
is lost programmatically. Currently, the value change is committed by
sending a message to the WebProcess, telling it to update the value of
the currently focused element. However, when focus is changed
programmatically, the focused element in the WebProcess is updated
before the commit, and the incorrect element's value can be changed.

To fix, update all methods which commit value changes to the focused
element to take an ElementContext parameter representing the element
that needs its value modified. Then, in the WebProcess, rather than
commit the value change to the currently focused element, retrieve the
element from the ElementContext, ensuring the correct element is
updated.

Note that this bug only surfaces in the old <select> picker, on apps
linked before iOS 13, since the new picker commits value changes
immediately and dismisses itself.

Test: fast/forms/ios/select-picker-change-and-focus-another-select-programmatically.html

* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView accessoryClear]):
(-[WKContentView updateFocusedElementValueAsNumber:]):
(-[WKContentView updateFocusedElementValue:]):
(-[WKContentView updateFocusedElementValueAsColor:]):
(-[WKContentView updateFocusedElementSelectedIndex:allowsMultipleSelection:]):
(-[WKContentView insertTextSuggestion:]):
(-[WKContentView selectMenu:didSelectItemAtIndex:]):
(-[WKContentView selectMenu:didCheckItemAtIndex:checked:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::setFocusedElementValue):
(WebKit::WebPageProxy::setFocusedElementValueAsNumber):
(WebKit::WebPageProxy::setFocusedElementSelectedIndex):
* UIProcess/ios/forms/WKDateTimeInputControl.mm:
(-[WKDateTimePicker reset:]):
* UIProcess/ios/forms/WKFormSelectPicker.mm:
(-[WKMultipleSelectPicker pickerView:row:column:checked:]):
(-[WKSelectSinglePicker controlEndEditing]):
(-[WKSelectPicker didSelectOptionIndex:]):
(-[WKSelectPickerTableViewController tableView:didSelectRowAtIndexPath:]):
* UIProcess/ios/forms/WKFormSelectPopover.mm:
(-[WKSelectTableViewController tableView:didSelectRowAtIndexPath:]):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::setFocusedElementValue):
(WebKit::WebPage::setFocusedElementValueAsNumber):
(WebKit::WebPage::setFocusedElementSelectedIndex):

LayoutTests:

Added a test to verify that changing focus programmatically, while changes
in the <select> picker have not been committed, updates the value of the
correct element.

* fast/forms/ios/select-picker-change-and-focus-another-select-programmatically-expected.txt: Added.
* fast/forms/ios/select-picker-change-and-focus-another-select-programmatically.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280397 => 280398)


--- trunk/LayoutTests/ChangeLog	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/LayoutTests/ChangeLog	2021-07-28 20:21:30 UTC (rev 280398)
@@ -1,3 +1,18 @@
+2021-07-28  Aditya Keerthi  <akeer...@apple.com>
+
+        [iOS] <select> picker value committed to incorrect element after programmatic focus change
+        https://bugs.webkit.org/show_bug.cgi?id=228556
+        rdar://81222952
+
+        Reviewed by Wenson Hsieh.
+
+        Added a test to verify that changing focus programmatically, while changes
+        in the <select> picker have not been committed, updates the value of the
+        correct element.
+
+        * fast/forms/ios/select-picker-change-and-focus-another-select-programmatically-expected.txt: Added.
+        * fast/forms/ios/select-picker-change-and-focus-another-select-programmatically.html: Added.
+
 2021-07-28  Eric Hutchison  <ehutchi...@apple.com>
 
         http/tests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-live-broadcast.html is a flaky timeout.

Added: trunk/LayoutTests/fast/forms/ios/select-picker-change-and-focus-another-select-programmatically-expected.txt (0 => 280398)


--- trunk/LayoutTests/fast/forms/ios/select-picker-change-and-focus-another-select-programmatically-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/select-picker-change-and-focus-another-select-programmatically-expected.txt	2021-07-28 20:21:30 UTC (rev 280398)
@@ -0,0 +1,11 @@
+This test verifies changing the value of one select element using the picker, and then focusing another select element programmatically, only changes the value of the first element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS first.value is "B"
+PASS second.value is "1"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/ios/select-picker-change-and-focus-another-select-programmatically.html (0 => 280398)


--- trunk/LayoutTests/fast/forms/ios/select-picker-change-and-focus-another-select-programmatically.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/select-picker-change-and-focus-another-select-programmatically.html	2021-07-28 20:21:30 UTC (rev 280398)
@@ -0,0 +1,52 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true IOSFormControlRefreshEnabled=false ] -->
+<html>
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+    <script src=""
+    <script src=""
+    <style>
+        select {
+            width: 100px;
+            height: 100px;
+        }
+    </style>
+</head>
+<body>
+    <select id="first">
+        <option value="A">A</option>
+        <option value="B">B</option>
+        <option value="C">C</option>
+        <option value="D">D</option>
+    </select>
+
+    <select id="second">
+        <option value="1">1</option>
+        <option value="2">2</option>
+        <option value="3">3</option>
+        <option value="4">4</option>
+    </select>
+</body>
+<script>
+jsTestIsAsync = true;
+
+addEventListener("load", async () => {
+    description("This test verifies changing the value of one select element using the picker, and then focusing another select element programmatically, only changes the value of the first element.");
+
+    second.addEventListener("touchend", event => {
+        second.focus();
+    });
+
+    // Activate first select element and change the value using the picker.
+    await UIHelper.activateElementAndWaitForInputSession(first);
+    await UIHelper.selectFormAccessoryPickerRow(1);
+
+    // Activate second select element without dismissing the picker.
+    await UIHelper.activateFormControl(second);
+
+    shouldBeEqualToString("first.value", "B");
+    shouldBeEqualToString("second.value", "1");
+
+    finishJSTest();
+});
+</script>
+</html>

Modified: trunk/Source/WebKit/ChangeLog (280397 => 280398)


--- trunk/Source/WebKit/ChangeLog	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/ChangeLog	2021-07-28 20:21:30 UTC (rev 280398)
@@ -1,3 +1,63 @@
+2021-07-28  Aditya Keerthi  <akeer...@apple.com>
+
+        [iOS] <select> picker value committed to incorrect element after programmatic focus change
+        https://bugs.webkit.org/show_bug.cgi?id=228556
+        rdar://81222952
+
+        Reviewed by Wenson Hsieh.
+
+        The old <select> picker is a UIPickerView that only commits any value
+        changes to the WebProcess once the user dismisses the picker, or focus
+        is lost programmatically. Currently, the value change is committed by
+        sending a message to the WebProcess, telling it to update the value of
+        the currently focused element. However, when focus is changed
+        programmatically, the focused element in the WebProcess is updated
+        before the commit, and the incorrect element's value can be changed.
+
+        To fix, update all methods which commit value changes to the focused
+        element to take an ElementContext parameter representing the element
+        that needs its value modified. Then, in the WebProcess, rather than
+        commit the value change to the currently focused element, retrieve the
+        element from the ElementContext, ensuring the correct element is
+        updated.
+
+        Note that this bug only surfaces in the old <select> picker, on apps
+        linked before iOS 13, since the new picker commits value changes
+        immediately and dismisses itself.
+
+        Test: fast/forms/ios/select-picker-change-and-focus-another-select-programmatically.html
+
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView accessoryClear]):
+        (-[WKContentView updateFocusedElementValueAsNumber:]):
+        (-[WKContentView updateFocusedElementValue:]):
+        (-[WKContentView updateFocusedElementValueAsColor:]):
+        (-[WKContentView updateFocusedElementSelectedIndex:allowsMultipleSelection:]):
+        (-[WKContentView insertTextSuggestion:]):
+        (-[WKContentView selectMenu:didSelectItemAtIndex:]):
+        (-[WKContentView selectMenu:didCheckItemAtIndex:checked:]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::setFocusedElementValue):
+        (WebKit::WebPageProxy::setFocusedElementValueAsNumber):
+        (WebKit::WebPageProxy::setFocusedElementSelectedIndex):
+        * UIProcess/ios/forms/WKDateTimeInputControl.mm:
+        (-[WKDateTimePicker reset:]):
+        * UIProcess/ios/forms/WKFormSelectPicker.mm:
+        (-[WKMultipleSelectPicker pickerView:row:column:checked:]):
+        (-[WKSelectSinglePicker controlEndEditing]):
+        (-[WKSelectPicker didSelectOptionIndex:]):
+        (-[WKSelectPickerTableViewController tableView:didSelectRowAtIndexPath:]):
+        * UIProcess/ios/forms/WKFormSelectPopover.mm:
+        (-[WKSelectTableViewController tableView:didSelectRowAtIndexPath:]):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::setFocusedElementValue):
+        (WebKit::WebPage::setFocusedElementValueAsNumber):
+        (WebKit::WebPage::setFocusedElementSelectedIndex):
+
 2021-07-28  Tim Horton  <timothy_hor...@apple.com>
 
         iOS Simulator doesn't have any WebKit system feature flags

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (280397 => 280398)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-07-28 20:21:30 UTC (rev 280398)
@@ -836,9 +836,9 @@
     void performActionOnElement(uint32_t action);
     void saveImageToLibrary(const SharedMemory::IPCHandle& imageHandle);
     void focusNextFocusedElement(bool isForward, CompletionHandler<void()>&& = [] { });
-    void setFocusedElementValue(const String&);
-    void setFocusedElementValueAsNumber(double);
-    void setFocusedElementSelectedIndex(uint32_t index, bool allowMultipleSelection = false);
+    void setFocusedElementValue(const WebCore::ElementContext&, const String&);
+    void setFocusedElementValueAsNumber(const WebCore::ElementContext&, double);
+    void setFocusedElementSelectedIndex(const WebCore::ElementContext&, uint32_t index, bool allowMultipleSelection = false);
     void applicationDidEnterBackground();
     void applicationDidFinishSnapshottingAfterEnteringBackground();
     void applicationWillEnterForeground();

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (280397 => 280398)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-07-28 20:21:30 UTC (rev 280398)
@@ -670,6 +670,7 @@
 - (void)updateFocusedElementValueAsColor:(UIColor *)value;
 - (void)updateFocusedElementValueAsNumber:(double)value;
 - (void)updateFocusedElementValue:(NSString *)value;
+- (void)updateFocusedElementSelectedIndex:(uint32_t)index allowsMultipleSelection:(bool)allowsMultipleSelection;
 - (void)updateFocusedElementFocusedWithDataListDropdown:(BOOL)value;
 
 - (void)_requestDOMPasteAccessWithElementRect:(const WebCore::IntRect&)elementRect originIdentifier:(const String&)originIdentifier completionHandler:(CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&)completionHandler;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (280397 => 280398)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-07-28 20:21:30 UTC (rev 280398)
@@ -4814,7 +4814,7 @@
 
 - (void)accessoryClear
 {
-    _page->setFocusedElementValue({ });
+    _page->setFocusedElementValue(_focusedElementInformation.elementContext, { });
 }
 
 - (void)accessoryDone
@@ -4826,13 +4826,13 @@
 
 - (void)updateFocusedElementValueAsNumber:(double)value
 {
-    _page->setFocusedElementValueAsNumber(value);
+    _page->setFocusedElementValueAsNumber(_focusedElementInformation.elementContext, value);
     _focusedElementInformation.valueAsNumber = value;
 }
 
 - (void)updateFocusedElementValue:(NSString *)value
 {
-    _page->setFocusedElementValue(value);
+    _page->setFocusedElementValue(_focusedElementInformation.elementContext, value);
     _focusedElementInformation.value = value;
 }
 
@@ -4841,11 +4841,16 @@
     WebCore::Color color(value.CGColor);
     String valueAsString = WebCore::serializationForHTML(color);
 
-    _page->setFocusedElementValue(valueAsString);
+    _page->setFocusedElementValue(_focusedElementInformation.elementContext, valueAsString);
     _focusedElementInformation.value = valueAsString;
     _focusedElementInformation.colorValue = color;
 }
 
+- (void)updateFocusedElementSelectedIndex:(uint32_t)index allowsMultipleSelection:(bool)allowsMultipleSelection
+{
+    _page->setFocusedElementSelectedIndex(_focusedElementInformation.elementContext, index, allowsMultipleSelection);
+}
+
 - (void)updateFocusedElementFocusedWithDataListDropdown:(BOOL)value
 {
     _focusedElementInformation.isFocusingWithDataListDropdown = value;
@@ -4978,7 +4983,7 @@
     }
 #if ENABLE(DATALIST_ELEMENT)
     if ([textSuggestion isKindOfClass:[WKDataListTextSuggestion class]]) {
-        _page->setFocusedElementValue([textSuggestion inputText]);
+        _page->setFocusedElementValue(_focusedElementInformation.elementContext, [textSuggestion inputText]);
         return;
     }
 #endif
@@ -7062,7 +7067,7 @@
 - (void)selectMenu:(WKSelectMenuListViewController *)selectMenu didSelectItemAtIndex:(NSUInteger)index
 {
     ASSERT(!_focusedElementInformation.isMultiSelect);
-    _page->setFocusedElementSelectedIndex(index, false);
+    [self updateFocusedElementSelectedIndex:index allowsMultipleSelection:false];
 }
 
 - (NSUInteger)numberOfItemsInSelectMenu:(WKSelectMenuListViewController *)selectMenu
@@ -7095,7 +7100,7 @@
         return;
     }
 
-    _page->setFocusedElementSelectedIndex(index, true);
+    [self updateFocusedElementSelectedIndex:index allowsMultipleSelection:true];
     option.isSelected = checked;
 }
 

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (280397 => 280398)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-07-28 20:21:30 UTC (rev 280398)
@@ -968,19 +968,19 @@
     });
 }
 
-void WebPageProxy::setFocusedElementValue(const String& value)
+void WebPageProxy::setFocusedElementValue(const WebCore::ElementContext& context, const String& value)
 {
-    send(Messages::WebPage::SetFocusedElementValue(value));
+    send(Messages::WebPage::SetFocusedElementValue(context, value));
 }
 
-void WebPageProxy::setFocusedElementValueAsNumber(double value)
+void WebPageProxy::setFocusedElementValueAsNumber(const WebCore::ElementContext& context, double value)
 {
-    send(Messages::WebPage::SetFocusedElementValueAsNumber(value));
+    send(Messages::WebPage::SetFocusedElementValueAsNumber(context, value));
 }
 
-void WebPageProxy::setFocusedElementSelectedIndex(uint32_t index, bool allowMultipleSelection)
+void WebPageProxy::setFocusedElementSelectedIndex(const WebCore::ElementContext& context, uint32_t index, bool allowMultipleSelection)
 {
-    send(Messages::WebPage::SetFocusedElementSelectedIndex(index, allowMultipleSelection));
+    send(Messages::WebPage::SetFocusedElementSelectedIndex(context, index, allowMultipleSelection));
 }
 
 void WebPageProxy::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm (280397 => 280398)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm	2021-07-28 20:21:30 UTC (rev 280398)
@@ -525,7 +525,7 @@
 - (void)reset:(id)sender
 {
     [self setDateTimePickerToInitialValue];
-    [_view page]->setFocusedElementValue(String());
+    [_view page]->setFocusedElementValue([_view focusedElementInformation].elementContext, String());
 }
 
 - (void)done:(id)sender

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPicker.mm (280397 => 280398)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPicker.mm	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPicker.mm	2021-07-28 20:21:30 UTC (rev 280398)
@@ -298,7 +298,7 @@
     }
 
     if ([self allowsMultipleSelection]) {
-        [_view page]->setFocusedElementSelectedIndex([self findItemIndexAt:rowIndex], true);
+        [_view updateFocusedElementSelectedIndex:[self findItemIndexAt:rowIndex] allowsMultipleSelection:true];
         item.isSelected = isChecked;
     } else if (isChecked) {
         // Single selection.
@@ -309,7 +309,7 @@
 
         // This private delegate often gets called for multiple rows in the picker,
         // so we only activate and set as selected the checked item in single selection.
-        [_view page]->setFocusedElementSelectedIndex([self findItemIndexAt:rowIndex]);
+        [_view updateFocusedElementSelectedIndex:[self findItemIndexAt:rowIndex] allowsMultipleSelection:false];
         item.isSelected = true;
     } else
         item.isSelected = false;
@@ -391,7 +391,7 @@
 
     if (_selectedIndex < (NSInteger)[_view focusedSelectElementOptions].size()) {
         [_view focusedSelectElementOptions][_selectedIndex].isSelected = true;
-        [_view page]->setFocusedElementSelectedIndex(_selectedIndex);
+        [_view updateFocusedElementSelectedIndex:_selectedIndex allowsMultipleSelection:false];
     }
 }
 
@@ -544,7 +544,7 @@
         optionIndex++;
     }
 
-    [_view page]->setFocusedElementSelectedIndex(index);
+    [_view updateFocusedElementSelectedIndex:index allowsMultipleSelection:false];
 }
 
 #if USE(UICONTEXTMENU)
@@ -1107,7 +1107,7 @@
     else
         cell.imageView.image = [[UIImage systemImageNamed:@"circle"] imageWithTintColor:UIColor.tertiaryLabelColor renderingMode:UIImageRenderingModeAlwaysOriginal];
 
-    [_contentView page]->setFocusedElementSelectedIndex([self findItemIndexAt:indexPath], true);
+    [_contentView updateFocusedElementSelectedIndex:[self findItemIndexAt:indexPath] allowsMultipleSelection:true];
     option->isSelected = !option->isSelected;
 }
 

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPopover.mm (280397 => 280398)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPopover.mm	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPopover.mm	2021-07-28 20:21:30 UTC (rev 280398)
@@ -316,8 +316,7 @@
         // To trigger onchange events programmatically we need to go through this
         // SPI which mimics a user action on the <select>. Normally programmatic
         // changes do not trigger "change" events on such selects.
-    
-        [_contentView page]->setFocusedElementSelectedIndex(itemIndex, true);
+        [_contentView updateFocusedElementSelectedIndex:itemIndex allowsMultipleSelection:true];
         OptionItem& item = [_contentView focusedSelectElementOptions][itemIndex];
         item.isSelected = newStateIsSelected;
     } else {
@@ -349,8 +348,8 @@
             
             _singleSelectionIndex = indexPath.row;
             _singleSelectionSection = indexPath.section;
- 
-            [_contentView page]->setFocusedElementSelectedIndex(itemIndex);
+
+            [_contentView updateFocusedElementSelectedIndex:itemIndex allowsMultipleSelection:false];
             OptionItem& newItem = [_contentView focusedSelectElementOptions][itemIndex];
             newItem.isSelected = true;
         }

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (280397 => 280398)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-07-28 20:21:30 UTC (rev 280398)
@@ -789,9 +789,9 @@
     void performActionOnElement(uint32_t action);
     void focusNextFocusedElement(bool isForward, CompletionHandler<void()>&&);
     void autofillLoginCredentials(const String&, const String&);
-    void setFocusedElementValue(const String&);
-    void setFocusedElementValueAsNumber(double);
-    void setFocusedElementSelectedIndex(uint32_t index, bool allowMultipleSelection);
+    void setFocusedElementValue(const WebCore::ElementContext&, const String&);
+    void setFocusedElementValueAsNumber(const WebCore::ElementContext&, double);
+    void setFocusedElementSelectedIndex(const WebCore::ElementContext&, uint32_t index, bool allowMultipleSelection);
     void setIsShowingInputViewForFocusedElement(bool);
     bool isShowingInputViewForFocusedElement() const { return m_isShowingInputViewForFocusedElement; }
     void updateSelectionAppearance();

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (280397 => 280398)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-07-28 20:21:30 UTC (rev 280398)
@@ -93,10 +93,10 @@
     StopInteraction()
     PerformActionOnElement(uint32_t action)
     FocusNextFocusedElement(bool isForward) -> () Async
-    SetFocusedElementValue(String value)
     AutofillLoginCredentials(String username, String password)
-    SetFocusedElementValueAsNumber(double value)
-    SetFocusedElementSelectedIndex(uint32_t index, bool allowMultipleSelection)
+    SetFocusedElementValue(struct WebCore::ElementContext context, String value)
+    SetFocusedElementValueAsNumber(struct WebCore::ElementContext context, double value)
+    SetFocusedElementSelectedIndex(struct WebCore::ElementContext context, uint32_t index, bool allowMultipleSelection)
     ApplicationWillResignActive()
     ApplicationDidEnterBackground(bool isSuspendedUnderLock)
     ApplicationDidFinishSnapshottingAfterEnteringBackground()

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (280397 => 280398)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-07-28 20:07:23 UTC (rev 280397)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-07-28 20:21:30 UTC (rev 280398)
@@ -1303,23 +1303,26 @@
     m_isShowingInputViewForFocusedElement = showingInputView;
 }
 
-void WebPage::setFocusedElementValue(const String& value)
+void WebPage::setFocusedElementValue(const WebCore::ElementContext& context, const String& value)
 {
+    RefPtr<Element> element = elementForContext(context);
     // FIXME: should also handle the case of HTMLSelectElement.
-    if (is<HTMLInputElement>(m_focusedElement.get()))
-        downcast<HTMLInputElement>(*m_focusedElement).setValue(value, DispatchInputAndChangeEvent);
+    if (is<HTMLInputElement>(element))
+        downcast<HTMLInputElement>(*element).setValue(value, DispatchInputAndChangeEvent);
 }
 
-void WebPage::setFocusedElementValueAsNumber(double value)
+void WebPage::setFocusedElementValueAsNumber(const WebCore::ElementContext& context, double value)
 {
-    if (is<HTMLInputElement>(m_focusedElement.get()))
-        downcast<HTMLInputElement>(*m_focusedElement).setValueAsNumber(value, DispatchInputAndChangeEvent);
+    RefPtr<Element> element = elementForContext(context);
+    if (is<HTMLInputElement>(element))
+        downcast<HTMLInputElement>(*element).setValueAsNumber(value, DispatchInputAndChangeEvent);
 }
 
-void WebPage::setFocusedElementSelectedIndex(uint32_t index, bool allowMultipleSelection)
+void WebPage::setFocusedElementSelectedIndex(const WebCore::ElementContext& context, uint32_t index, bool allowMultipleSelection)
 {
-    if (is<HTMLSelectElement>(m_focusedElement.get()))
-        downcast<HTMLSelectElement>(*m_focusedElement).optionSelectedByUser(index, true, allowMultipleSelection);
+    RefPtr<Element> element = elementForContext(context);
+    if (is<HTMLSelectElement>(element))
+        downcast<HTMLSelectElement>(*element).optionSelectedByUser(index, true, allowMultipleSelection);
 }
 
 void WebPage::showInspectorHighlight(const WebCore::InspectorOverlay::Highlight& highlight)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to