Bug 243768 - AX: role="spinbutton" elements are not adjustable on iOS
Summary: AX: role="spinbutton" elements are not adjustable on iOS
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-08-09 22:03 PDT by Tyler Wilcock
Modified: 2022-08-13 10:29 PDT (History)
10 users (show)

See Also:


Attachments
Patch (12.44 KB, patch)
2022-08-09 22:07 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (14.11 KB, patch)
2022-08-09 22:21 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (16.17 KB, patch)
2022-08-10 10:51 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (16.16 KB, patch)
2022-08-10 16:45 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (16.35 KB, patch)
2022-08-11 22:07 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tyler Wilcock 2022-08-09 22:03:18 PDT
role="spinbutton" components are not required to have accompanying buttons to adjust the value, so they should be adjustable on their own.

Example component can be found on:

https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/
Comment 1 Radar WebKit Bug Importer 2022-08-09 22:03:28 PDT
<rdar://problem/98426197>
Comment 2 Tyler Wilcock 2022-08-09 22:07:48 PDT
Created attachment 461519 [details]
Patch
Comment 3 Tyler Wilcock 2022-08-09 22:21:37 PDT
Created attachment 461520 [details]
Patch
Comment 4 Andres Gonzalez 2022-08-10 05:50:18 PDT
(In reply to Tyler Wilcock from comment #3)
> Created attachment 461520 [details]
> Patch

Looks good.

--- a/LayoutTests/accessibility/spinbutton-increment-decrement.html
+++ a/LayoutTests/accessibility/spinbutton-increment-decrement.html

Should we also test that the spin button exposes the right value after increment/decrement?
Comment 5 Tyler Wilcock 2022-08-10 10:51:00 PDT
Created attachment 461531 [details]
Patch
Comment 6 James Craig 2022-08-10 14:57:09 PDT
Comment on attachment 461531 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=461531&action=review

> Source/WebCore/accessibility/AccessibilityNodeObject.cpp:1205
> +void AccessibilityNodeObject::alterStepperValue(StepAction stepAction)

How about "range" which the superclass of slider, scrollbar, and spinbutton. Note: ARIA spinbutton = Mac "stepper"

> Source/WebCore/accessibility/AccessibilityNodeObject.cpp:1207
> +    if (roleValue() != AccessibilityRole::Slider && roleValue() != AccessibilityRole::SpinButton)

scrollbar too, right?

> Source/WebCore/accessibility/AccessibilityNodeObject.cpp:1217
>      if (!getAttribute(stepAttr).isEmpty())
> -        changeValueByStep(increase);
> +        changeValueByStep(stepAction);
>      else
> -        changeValueByPercent(increase ? 5 : -5);
> +        changeValueByPercent(stepAction == StepAction::Increment ? 5 : -5);

I think direct value changes should only happen on native form elements, never on custom ARIA fields. Does this cover all the HTML5 stepper types like <input type="number">? There are about 2 dozen input types, and several are steppers. The layout test should probably cover these too... I don't recall if the stepAttr conditional will catch all. Does this also catch the default step value when the attribute is missing like `input[type=slider]:not([step])`?
Comment 7 James Craig 2022-08-10 15:08:13 PDT
> several are steppers.

Looks likeWebKit, Chrome, and Firefox implement type=number as the only stepper, too. I recalled there were more. 🤷
Comment 8 Tyler Wilcock 2022-08-10 16:45:04 PDT
Created attachment 461539 [details]
Patch
Comment 9 Andres Gonzalez 2022-08-11 05:16:38 PDT
(In reply to Tyler Wilcock from comment #8)
> Created attachment 461539 [details]
> Patch

--- a/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
+++ a/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

 void AccessibilityNodeObject::changeValueByPercent(float percentChange)
@@ -1321,7 +1325,7 @@ void AccessibilityNodeObject::changeValueByPercent(float percentChange)
         step = std::abs(percentChange) * (1 / percentChange);

     value += step;
-    setNodeValue(percentChange > 0, value);
+    setNodeValue(percentChange > 0 ? StepAction::Increment : StepAction::Decrement, value);
 }

This function is missing some early returns and sanity checks like percentCahnge == 0, and value between min and max... Since you're touching this, could you please add them?

--- a/LayoutTests/platform/ios/accessibility/spinbutton-increment-decrement-expected.txt
+++ a/LayoutTests/platform/ios/accessibility/spinbutton-increment-decrement-expected.txt
Interesting that the value for MacOS and iOS differ in type? int vs float?
Comment 10 Tyler Wilcock 2022-08-11 22:07:56 PDT
Created attachment 461555 [details]
Patch
Comment 11 Tyler Wilcock 2022-08-11 22:14:41 PDT
(In reply to Andres Gonzalez from comment #9)
> (In reply to Tyler Wilcock from comment #8)
> > Created attachment 461539 [details]
> > Patch
> 
> --- a/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
> +++ a/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
> 
>  void AccessibilityNodeObject::changeValueByPercent(float percentChange)
> @@ -1321,7 +1325,7 @@ void
> AccessibilityNodeObject::changeValueByPercent(float percentChange)
>          step = std::abs(percentChange) * (1 / percentChange);
> 
>      value += step;
> -    setNodeValue(percentChange > 0, value);
> +    setNodeValue(percentChange > 0 ? StepAction::Increment :
> StepAction::Decrement, value);
>  }
> 
> This function is missing some early returns and sanity checks like
> percentCahnge == 0, and value between min and max... Since you're touching
> this, could you please add them?
I added the check for !percentChange. Investigated the prevention of setting values outside the min and max, but that will be a little more involved (because we can't just do it in this one function, or need to centralize it somewhere else) and will require it's own layout test, so I think it will be best to save that one for a separate patch.

> ---
> a/LayoutTests/platform/ios/accessibility/spinbutton-increment-decrement-
> expected.txt
> +++
> a/LayoutTests/platform/ios/accessibility/spinbutton-increment-decrement-
> expected.txt
> Interesting that the value for MacOS and iOS differ in type? int vs float?
Yeah, it's unfortunate...we should make these the same in a later patch.
Comment 12 EWS 2022-08-13 10:29:18 PDT
Committed 253403@main (9a87db7810f8): <https://commits.webkit.org/253403@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 461555 [details].