Bug 158634 - AX: Form label text should be exposed as static text if it contains only static text
Summary: AX: Form label text should be exposed as static text if it contains only stat...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-06-10 13:56 PDT by Doug Russell
Modified: 2016-06-14 14:27 PDT (History)
10 users (show)

See Also:


Attachments
Patch (20.69 KB, patch)
2016-06-10 14:07 PDT, Doug Russell
no flags Details | Formatted Diff | Diff
Patch (21.53 KB, patch)
2016-06-10 14:53 PDT, Doug Russell
no flags Details | Formatted Diff | Diff
Patch (26.14 KB, patch)
2016-06-10 17:44 PDT, Doug Russell
no flags Details | Formatted Diff | Diff
Patch (27.42 KB, patch)
2016-06-12 20:58 PDT, Doug Russell
no flags Details | Formatted Diff | Diff
Patch (32.58 KB, patch)
2016-06-14 13:58 PDT, Doug Russell
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Russell 2016-06-10 13:56:35 PDT
LabelRole is currently exposed as a group, but would be more appropriate as static text if all the elements it contains are static text. This will save AT the complexity of evaluating the labels subtree and stitching the text manually.
Comment 1 Radar WebKit Bug Importer 2016-06-10 13:58:25 PDT
<rdar://problem/26747020>
Comment 2 Doug Russell 2016-06-10 14:07:36 PDT
Created attachment 281045 [details]
Patch
Comment 3 chris fleizach 2016-06-10 14:14:32 PDT
Comment on attachment 281045 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        Use AccessibilityLabel to represent HTMLLabelElement to AT.

AT -> assistive technologies

> Source/WebCore/accessibility/AccessibilityLabel.cpp:71
> +        if (!child->accessibilityIsIgnored() && !child->isDetached()) {

I think we're guaranteed to only have unignored children in m_children

The same might be true of detached children

> Source/WebCore/accessibility/AccessibilityLabel.cpp:76
> +                    staticText = true;

Seems like you don't need to keep track of staticText. As soon as you get a failure can you can just return false

Then you can return true at the end of it right

Also, you could probably cache this value and then update when children are updated

> Source/WebCore/accessibility/AccessibilityLabel.cpp:92
> +    return WebCore::containsOnlyStaticText(m_children);

This WebCore:: prefix is probably unnecessary

> Source/WebCore/accessibility/AccessibilityLabel.h:41
> +    AccessibilityRole roleValue() const override { return LabelRole; }

Add a final to these

roleValue and stringValue() can probably be private

> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:2237
> +    if (role == LabelRole && is<AccessibilityLabel>(*m_object) && downcast<AccessibilityLabel>(*m_object).containsOnlyStaticText())

This check 
role == LabelRole

Is probably not necessary since is<AccessibilityLabel> guarantees role = Label
Comment 4 Doug Russell 2016-06-10 14:19:40 PDT
Comment on attachment 281045 [details]
Patch

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

>> Source/WebCore/accessibility/AccessibilityLabel.cpp:76
>> +                    staticText = true;
> 
> Seems like you don't need to keep track of staticText. As soon as you get a failure can you can just return false
> 
> Then you can return true at the end of it right
> 
> Also, you could probably cache this value and then update when children are updated

Having bool staticText means I don't have to check if children is empty. I could switch to size == 0 at the top.

Caching seemed tricky given there seem to be a lot of cases where the funnels aren't used and m_children.append() is used directly. And this method needs to be const to be called from stringValue() so calculating lazily and caching is tricky.

>> Source/WebCore/accessibility/AccessibilityLabel.cpp:92
>> +    return WebCore::containsOnlyStaticText(m_children);
> 
> This WebCore:: prefix is probably unnecessary

You need it to disambiguate from AccessibilityLabel::containsOnlyStaticText() (the compiler gets huffy without it)

>> Source/WebCore/accessibility/AccessibilityLabel.h:41
>> +    AccessibilityRole roleValue() const override { return LabelRole; }
> 
> Add a final to these
> 
> roleValue and stringValue() can probably be private

Will do on final.

I'll see about role and string.

>> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:2237
>> +    if (role == LabelRole && is<AccessibilityLabel>(*m_object) && downcast<AccessibilityLabel>(*m_object).containsOnlyStaticText())
> 
> This check 
> role == LabelRole
> 
> Is probably not necessary since is<AccessibilityLabel> guarantees role = Label

It's not strictly necessary, but it seemed likely that role == Label was cheaper than calling is<> on every m_object.
Comment 5 chris fleizach 2016-06-10 14:23:09 PDT
Comment on attachment 281045 [details]
Patch

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

>>> Source/WebCore/accessibility/AccessibilityLabel.cpp:76
>>> +                    staticText = true;
>> 
>> Seems like you don't need to keep track of staticText. As soon as you get a failure can you can just return false
>> 
>> Then you can return true at the end of it right
>> 
>> Also, you could probably cache this value and then update when children are updated
> 
> Having bool staticText means I don't have to check if children is empty. I could switch to size == 0 at the top.
> 
> Caching seemed tricky given there seem to be a lot of cases where the funnels aren't used and m_children.append() is used directly. And this method needs to be const to be called from stringValue() so calculating lazily and caching is tricky.

>> I could switch to size == 0 at the top.

That seems better to me

>>> Source/WebCore/accessibility/AccessibilityLabel.cpp:92
>>> +    return WebCore::containsOnlyStaticText(m_children);
>> 
>> This WebCore:: prefix is probably unnecessary
> 
> You need it to disambiguate from AccessibilityLabel::containsOnlyStaticText() (the compiler gets huffy without it)

Might be better named

objectsContainOnlyStaticText or elementsContainOnlyStaticText

Since children is no longer accurate, the method being static rattan than an instance
Comment 6 Doug Russell 2016-06-10 14:25:06 PDT
Comment on attachment 281045 [details]
Patch

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

>>>> Source/WebCore/accessibility/AccessibilityLabel.cpp:92
>>>> +    return WebCore::containsOnlyStaticText(m_children);
>>> 
>>> This WebCore:: prefix is probably unnecessary
>> 
>> You need it to disambiguate from AccessibilityLabel::containsOnlyStaticText() (the compiler gets huffy without it)
> 
> Might be better named
> 
> objectsContainOnlyStaticText or elementsContainOnlyStaticText
> 
> Since children is no longer accurate, the method being static rattan than an instance

The argument type is const AccessibilityObject::AccessibilityChildrenVector& so I think children is fair to use. I'll rename is childrenContainOnlyStaticText.
Comment 7 Doug Russell 2016-06-10 14:53:01 PDT
Created attachment 281050 [details]
Patch
Comment 8 Doug Russell 2016-06-10 17:44:31 PDT
Created attachment 281067 [details]
Patch
Comment 9 chris fleizach 2016-06-10 17:51:53 PDT
Comment on attachment 281067 [details]
Patch

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

> Source/WebCore/CMakeLists.txt:1049
> +    accessibility/AccessibilityLabel.cpp

Do we need to all to AccessibilityAllInOne.cpp for windows builds?

> Source/WebCore/accessibility/AccessibilityLabel.h:46
> +    AccessibilityRole roleValue() const final { return LabelRole; }

These should have the override keyword on them? Or does final take care of that
Comment 10 Doug Russell 2016-06-10 17:56:40 PDT
Comment on attachment 281067 [details]
Patch

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

>> Source/WebCore/CMakeLists.txt:1049
>> +    accessibility/AccessibilityLabel.cpp
> 
> Do we need to all to AccessibilityAllInOne.cpp for windows builds?

I believe so. I could try submitting the patch without it.

>> Source/WebCore/accessibility/AccessibilityLabel.h:46
>> +    AccessibilityRole roleValue() const final { return LabelRole; }
> 
> These should have the override keyword on them? Or does final take care of that

My understanding is that final implies override.
Comment 11 Doug Russell 2016-06-12 20:58:01 PDT
Created attachment 281154 [details]
Patch
Comment 12 chris fleizach 2016-06-12 22:39:24 PDT
Comment on attachment 281154 [details]
Patch

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

We should add to these tests so we check that if
A) <label> element does not contain only text children we do not concat values
B) when elements inside <label> change we are validating that we get the correct data

> LayoutTests/accessibility/mac/label-element-with-link-string-value.html:21
> +    description("This tests that if a label element contains text children it's AXValue will be their concatenated AXValues.");

This description is the same as the previous test (LayoutTests/accessibility/mac/label-element-all-text-string-value.html) - seems like it should be different
Comment 13 chris fleizach 2016-06-14 10:53:25 PDT
Comment on attachment 281154 [details]
Patch

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

> Source/WebCore/accessibility/AccessibilityLabel.cpp:100
> +    m_containsOnlyStaticTextDirty = false;

Shouldn't this one be set to true (m_containsOnlyStaticTextDirty) because we've just cleared the children and we want to recalculate?
Comment 14 chris fleizach 2016-06-14 11:42:52 PDT
Comment on attachment 281154 [details]
Patch

Were any of my comments addressed?
Comment 15 Doug Russell 2016-06-14 11:59:41 PDT
(In reply to comment #14)
> Comment on attachment 281154 [details]
> Patch
> 
> Were any of my comments addressed?

Forgot to hit submit before sending it back. Fixing now.
Comment 16 Doug Russell 2016-06-14 12:01:56 PDT
Comment on attachment 281154 [details]
Patch

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

>> Source/WebCore/accessibility/AccessibilityLabel.cpp:100
>> +    m_containsOnlyStaticTextDirty = false;
> 
> Shouldn't this one be set to true (m_containsOnlyStaticTextDirty) because we've just cleared the children and we want to recalculate?

No, it should be false because there are no children so m_containsOnlyStaticText is definitely false and we don't need to recalculate.
Comment 17 Doug Russell 2016-06-14 12:09:05 PDT
> We should add to these tests so we check that if
> A) <label> element does not contain only text children we do not concat
> values

label-element-with-link-string-value.html addresses this

> B) when elements inside <label> change we are validating that we get the
> correct data

I'll add a test for that

> 
> > LayoutTests/accessibility/mac/label-element-with-link-string-value.html:21
> > +    description("This tests that if a label element contains text children it's AXValue will be their concatenated AXValues.");
> 
> This description is the same as the previous test
> (LayoutTests/accessibility/mac/label-element-all-text-string-value.html) -
> seems like it should be different

Fixed in my next patch.
Comment 18 Doug Russell 2016-06-14 13:58:33 PDT
Created attachment 281279 [details]
Patch
Comment 19 WebKit Commit Bot 2016-06-14 14:27:00 PDT
Comment on attachment 281279 [details]
Patch

Clearing flags on attachment: 281279

Committed r202063: <http://trac.webkit.org/changeset/202063>
Comment 20 WebKit Commit Bot 2016-06-14 14:27:05 PDT
All reviewed patches have been landed.  Closing bug.