The default bug view has changed. See this FAQ.

label_for relation is missed on label implicitly associated with control

RESOLVED FIXED in mozilla27

Status

()

Core
Disability Access APIs
RESOLVED FIXED
6 years ago
4 years ago

People

(Reporter: surkov, Assigned: eeejay)

Tracking

(Blocks: 1 bug, {access})

unspecified
mozilla27
access
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

6 years ago
example:
<label>hello<input></label>
(Assignee)

Comment 1

4 years ago
Created attachment 806313 [details] [diff] [review]
Add relation_for for implicit labels.

Since we use HTMLLabelAccessible now for all HTML <label> tags, I figured this should be an override in that class.
Attachment #806313 - Flags: review?(surkov.alexander)
Comment on attachment 806313 [details] [diff] [review]
Add relation_for for implicit labels.

>+++ b/accessible/src/generic/Accessible.cpp
>@@ -25,16 +25,17 @@
> #include "TableAccessible.h"
> #include "TableCellAccessible.h"
> #include "TreeWalker.h"
> 
> #include "nsIDOMElement.h"
> #include "nsIDOMDocument.h"
> #include "nsIDOMNodeFilter.h"
> #include "nsIDOMHTMLElement.h"
>+#include "nsIDOMHTMLLabelElement.h"

why?

>+      if (mContent->Tag() == nsGkAtoms::label && !mContent->IsHTML()) {
>+        rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::control));
>+      }

no braces

>+++ b/accessible/src/html/HTMLElementAccessibles.cpp
>+using namespace mozilla::dom;

no, just use dom:: where you actually need it

>+HTMLLabelAccessible::RelationByType(uint32_t aType)
>+{
>+  Relation rel = AccessibleWrap::RelationByType(aType);
>+  if (aType == nsIAccessibleRelation::RELATION_LABEL_FOR) {
>+    HTMLLabelElement* label = HTMLLabelElement::FromContent(mContent);
>+    if (label) {

I don't think it can actually be null

>+      nsGenericHTMLElement* control = label->GetControl();
>+      if (control) {

no braces

>+        rel.AppendTarget(mDoc, control->AsContent());

AsContent() shouldn't be needed

>+++ b/accessible/src/html/HTMLElementAccessibles.h
>+  virtual Relation RelationByType(uint32_t aType);

MOZ_OVERRIDE

needs tests too
(Reporter)

Comment 3

4 years ago
Comment on attachment 806313 [details] [diff] [review]
Add relation_for for implicit labels.

Review of attachment 806313 [details] [diff] [review]:
-----------------------------------------------------------------

::: accessible/src/generic/Accessible.cpp
@@ +2020,5 @@
>  
>      case nsIAccessibleRelation::RELATION_LABEL_FOR: {
>        Relation rel(new RelatedAccIterator(Document(), mContent,
>                                            nsGkAtoms::aria_labelledby));
> +      if (mContent->Tag() == nsGkAtoms::label && !mContent->IsHTML()) {

mContent->IsXUL()

::: accessible/src/html/HTMLElementAccessibles.cpp
@@ +66,5 @@
>  }
>  
> +Relation
> +HTMLLabelAccessible::RelationByType(uint32_t aType)
> +{

wouldn't it be nicer to get this code under class like HTMLLabelledIterator dual to HTMLLabelIterator, at least we will be keep the logic not spread through the code.
> ::: accessible/src/html/HTMLElementAccessibles.cpp
> @@ +66,5 @@
> >  }
> >  
> > +Relation
> > +HTMLLabelAccessible::RelationByType(uint32_t aType)
> > +{
> 
> wouldn't it be nicer to get this code under class like HTMLLabelledIterator
> dual to HTMLLabelIterator, at least we will be keep the logic not spread
> through the code.

another iterator that's really silly? bleh

besides we already have code that does random things to get relations I don't see why this case is a big deal.
(Reporter)

Comment 5

4 years ago
(In reply to Trevor Saunders (:tbsaunde) from comment #4)
> another iterator that's really silly? bleh

the iterator here is probably too cumbersome but it adds symmetry. What we have with this patch:
labelled_by is implemented by Accessible by HTMLLabelIterator in HTML case and generic iterator in XUL case
label_for is implemented by Accessible by iterator in XUL case and implemented by HTMLLabelAccessible class by HTML case with no iterators

what we could have:
both labelled_by and label_for implemented by iterators by Accessible class both for HTML and XUL

> besides we already have code that does random things to get relations I
> don't see why this case is a big deal.

probably I don't really mind what way will you take but it sounds like proposed way makes the code a bit more complicated.
> probably I don't really mind what way will you take but it sounds like
> proposed way makes the code a bit more complicated.

I'd say adding a useless iterator makes things more complicated
(Reporter)

Comment 7

4 years ago
Comment on attachment 806313 [details] [diff] [review]
Add relation_for for implicit labels.

delegating it to Trev
Attachment #806313 - Flags: review?(surkov.alexander) → review?(trev.saunders)
Comment on attachment 806313 [details] [diff] [review]
Add relation_for for implicit labels.

I'd like to see patch after comment 2 is fixed
Attachment #806313 - Flags: review?(trev.saunders) → review-
(Assignee)

Comment 9

4 years ago
Created attachment 806881 [details] [diff] [review]
Add relation_for for implicit labels.

Much cleaner without all those null checks.
Attachment #806313 - Attachment is obsolete: true
Attachment #806881 - Flags: review?(trev.saunders)
Comment on attachment 806881 [details] [diff] [review]
Add relation_for for implicit labels.

>+  if (aType == nsIAccessibleRelation::RELATION_LABEL_FOR) {
>+    dom::HTMLLabelElement* label = dom::HTMLLabelElement::FromContent(mContent);

might be nicer to use auto here
Attachment #806881 - Flags: review?(trev.saunders) → review+
(Assignee)

Comment 11

4 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/caf1b9e056a7
(Assignee)

Updated

4 years ago
Assignee: nobody → eitan
https://hg.mozilla.org/mozilla-central/rev/caf1b9e056a7
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
You need to log in before you can comment on or make changes to this bug.