Closed
Bug 559275
Opened 15 years ago
Closed 14 years ago
map attribute required to STATE_REQUIRED
Categories
(Core :: Disability Access APIs, defect)
Core
Disability Access APIs
Tracking
()
RESOLVED
FIXED
mozilla2.0b7
People
(Reporter: surkov, Assigned: davidb)
References
(Blocks 1 open bug, )
Details
(Keywords: access)
Attachments
(1 file, 4 obsolete files)
13.20 KB,
patch
|
surkov
:
review+
davidb
:
approval2.0+
|
Details | Diff | Splinter Review |
spun off bug 345822.
Mounir, what input types is @required attribute applicable to?
Comment 1•15 years ago
|
||
It apply for all types except: hidden, button, image, submit, rest and two which are not implemented yet: color and range.
If you have access to nsHTMLInputElement, you can use 'DoesRequiredApply()' and you will not have to guess if the type accepts @required ;)
By the way, @required is applicable for textarea element too.
Assignee | ||
Comment 2•14 years ago
|
||
Mounir I don't think we have access to nsHTMLInputElement. Do you know of a public interface we can use? Maybe there should be a virtual PRBool IsRequired on nsIFormControl or nsIDOMHTMLInputElement?
Assignee: nobody → bolterbugz
Comment 3•14 years ago
|
||
No need to have IsRequired.
You can use NS_EVENT_STATE_REQUIRED or the required attribute (which is in nsIDOMHTMLInputElement).
Comment 4•14 years ago
|
||
(In reply to comment #3)
> No need to have IsRequired.
> You can use NS_EVENT_STATE_REQUIRED or the required attribute (which is in
> nsIDOMHTMLInputElement).
Oups, I did not see my own comment (comment 2). I think NS_EVENT_STATE_REQUIRED would be fine because it will not apply on types which can't be required.
Assignee | ||
Comment 5•14 years ago
|
||
We really need the ability to query for the 'required' state. Are there any instances of nsIDOMHTMLInputElement for which the required attribute does not apply?
Comment 6•14 years ago
|
||
(In reply to comment #5)
> We really need the ability to query for the 'required' state. Are there any
> instances of nsIDOMHTMLInputElement for which the required attribute does not
> apply?
Yes, for some types, see comment 2.
But NS_EVENT_STATE_REQUIRED, if set, means that the element is currently required. If NS_EVENT_STATE_OPTIONAL is set, that means the elemnet is currently optional (which means it could be required). If none are sot, for <input>, that means the element can't be required.
That sounds the easiest way to do it.
Assignee | ||
Comment 7•14 years ago
|
||
Oh I see. I thought that was some at-event-time-only thing.
Assignee | ||
Comment 8•14 years ago
|
||
OK easy fix.
Attachment #478020 -
Flags: review?(surkov.alexander)
Attachment #478020 -
Flags: review?(marco.zehe)
Assignee | ||
Comment 9•14 years ago
|
||
(removed unnecessary include)
Attachment #478020 -
Attachment is obsolete: true
Attachment #478022 -
Flags: review?(surkov.alexander)
Attachment #478022 -
Flags: review?(marco.zehe)
Attachment #478020 -
Flags: review?(surkov.alexander)
Attachment #478020 -
Flags: review?(marco.zehe)
Reporter | ||
Comment 10•14 years ago
|
||
Comment on attachment 478022 [details] [diff] [review]
patch
>+ACCESSIBILITY_ATOM(required, "required") // HTML5 inputs
I don't see where it's used
>+
>+ // expose 'required' state for inputs
>+ if (mContent->IntrinsicState() & NS_EVENT_STATE_REQUIRED) {
>+ *aState |= nsIAccessibleStates::STATE_REQUIRED;
>+ }
nit: no braces around single if
nit: two space indent, you have four.
this place is not ready to add this code because it's about disabled state, not about HTML specific states. I'd like to see it reworked in some nice way.
btw, it might be nice to start to use IntristicState() instead of disabled attribute check.
Attachment #478022 -
Flags: review?(surkov.alexander)
Comment 11•14 years ago
|
||
(In reply to comment #10)
> btw, it might be nice to start to use IntristicState() instead of disabled
> attribute check.
Since bug 557087 has been fixed, it's would be more than nice, it's required ;)
I've open bug 599163 for that.
Reporter | ||
Comment 12•14 years ago
|
||
(In reply to comment #11)
> (In reply to comment #10)
> > btw, it might be nice to start to use IntristicState() instead of disabled
> > attribute check.
>
> Since bug 557087 has been fixed, it's would be more than nice, it's required ;)
> I've open bug 599163 for that.
thank you. But while we are here, does it work for XUL as well?
Comment 13•14 years ago
|
||
(In reply to comment #12)
> (In reply to comment #11)
> > (In reply to comment #10)
> > > btw, it might be nice to start to use IntristicState() instead of disabled
> > > attribute check.
> >
> > Since bug 557087 has been fixed, it's would be more than nice, it's required ;)
> > I've open bug 599163 for that.
>
> thank you. But while we are here, does it work for XUL as well?
If you are speaking of the disabled state, I've just wrote a patch which is going to make that working in XUL. Related bug: bug 598329.
Reporter | ||
Comment 14•14 years ago
|
||
yes, thanks again
Comment 15•14 years ago
|
||
Comment on attachment 478022 [details] [diff] [review]
patch
>+ <title>Test document hierarchy</title>
Nit: Please change the title to "HTML5 inputs" or something to that end to reflect the actual tests being run.
r=me thanks!
Attachment #478022 -
Flags: review?(marco.zehe) → review+
Assignee | ||
Comment 16•14 years ago
|
||
(In reply to comment #10)
> >+ACCESSIBILITY_ATOM(required, "required") // HTML5 inputs
>
> I don't see where it's used
Good catch - it is cruft.
>
> >+
> >+ // expose 'required' state for inputs
> >+ if (mContent->IntrinsicState() & NS_EVENT_STATE_REQUIRED) {
> >+ *aState |= nsIAccessibleStates::STATE_REQUIRED;
> >+ }
>
> nit: no braces around single if
I don't think I will ever get used to no braces ;)
> this place is not ready to add this code because it's about disabled state, not
> about HTML specific states. I'd like to see it reworked in some nice way.
I don't understand.
> btw, it might be nice to start to use IntristicState() instead of disabled
> attribute check.
Yep :)
Assignee | ||
Comment 17•14 years ago
|
||
(In reply to comment #15)
> Comment on attachment 478022 [details] [diff] [review]
> patch
>
> >+ <title>Test document hierarchy</title>
>
> Nit: Please change the title to "HTML5 inputs" or something to that end to
> reflect the actual tests being run.
Done.
Reporter | ||
Comment 18•14 years ago
|
||
(In reply to comment #16)
> > nit: no braces around single if
>
> I don't think I will ever get used to no braces ;)
isn't it nicer? ;)
>
> > this place is not ready to add this code because it's about disabled state, not
> > about HTML specific states. I'd like to see it reworked in some nice way.
>
> I don't understand.
we have something like
// Expose disabled state
if (isHTML()) {
disabled = isHTMLDIsabled();
} else {
disabled = isXULDisabled();
}
if (disabled) {
setDisabledState();
}
you do
// Expose disabled state
if (isHTML()) {
disabled = isHTMLDIsabled();
if (isHTMLRequired())
setRequired();
} else {
disabled = isXULDisabled();
}
...
I mean at least you should change comments to make this hunk of code not about disabled state only, but perhaps it makes sense to rethink it at all. For example, does it makes sense to check HTML namespace before to check IntristicState() & REQUIRED, taking into account ongoing disabled state changes (bug 599163). Btw, it might make sense to work on these bugs the same time in one patch.
Assignee | ||
Comment 19•14 years ago
|
||
(In reply to comment #18)
Got you. Agreed :)
Note I have a simple patch for intrinsic invalid state too, but would rather do that on another bug, with additional tests.
Attachment #478022 -
Attachment is obsolete: true
Attachment #478808 -
Flags: review?(surkov.alexander)
Assignee | ||
Comment 20•14 years ago
|
||
Oh hmmm we don't have xul disabled state tests.
Assignee | ||
Updated•14 years ago
|
Attachment #478808 -
Flags: review?(surkov.alexander)
Reporter | ||
Comment 21•14 years ago
|
||
Comment on attachment 478808 [details] [diff] [review]
patch 2
> // unavailable
> if (state & STATE_UNAVAILABLE) {
>- var role = getRole(aAccOrElmOrID);
>- if (role != ROLE_GROUPING && role != ROLE_EMBEDDED_OBJECT)
>- isState(state & STATE_FOCUSABLE, STATE_FOCUSABLE, false,
>- "Disabled " + id + " must be focusable!");
>+ isState(state & STATE_FOCUSABLE, 0, false,
>+ "Disabled " + id + " s not be focusable!");
I must miss something, it sounds disabled state code logic is preserved (not taking into account that XUL bug) but test changes has opposite logic. Could you comment this please?
Comment 22•14 years ago
|
||
Btw, XUL elements will not support :disabled for performance reasons. (follow-up from comments 12 and 13)
Reporter | ||
Comment 23•14 years ago
|
||
(In reply to comment #22)
> Btw, XUL elements will not support :disabled for performance reasons.
> (follow-up from comments 12 and 13)
so, we can't get disabled state from IntristicStates(), correct?
Comment 24•14 years ago
|
||
(In reply to comment #23)
> (In reply to comment #22)
> > Btw, XUL elements will not support :disabled for performance reasons.
> > (follow-up from comments 12 and 13)
>
> so, we can't get disabled state from IntristicStates(), correct?
For HTML elements you can. For XUL elements, you will have to check that @disable='true' but I guess you are already doing that.
Reporter | ||
Comment 25•14 years ago
|
||
right, thanks
Assignee | ||
Comment 26•14 years ago
|
||
(In reply to comment #21)
> Comment on attachment 478808 [details] [diff] [review]
> patch 2
>
>
> > // unavailable
> > if (state & STATE_UNAVAILABLE) {
> >- var role = getRole(aAccOrElmOrID);
> >- if (role != ROLE_GROUPING && role != ROLE_EMBEDDED_OBJECT)
> >- isState(state & STATE_FOCUSABLE, STATE_FOCUSABLE, false,
> >- "Disabled " + id + " must be focusable!");
> >+ isState(state & STATE_FOCUSABLE, 0, false,
> >+ "Disabled " + id + " s not be focusable!");
>
> I must miss something, it sounds disabled state code logic is preserved (not
> taking into account that XUL bug) but test changes has opposite logic. Could
> you comment this please?
I think the original isState check was never exercised before. The only existing test we have for STATE_UNAVAILABLE was for an embedded object which bails out before this check.
What were you intending to test here originally?
Assignee | ||
Comment 27•14 years ago
|
||
Oh nevermind. Was thinking it was an 'aState' check.
Assignee | ||
Comment 28•14 years ago
|
||
Attachment #478808 -
Attachment is obsolete: true
Attachment #479476 -
Flags: review?(surkov.alexander)
Comment 29•14 years ago
|
||
Comment on attachment 479476 [details] [diff] [review]
patch 3
Thanks for the additional tests, these look good!
Assignee | ||
Comment 30•14 years ago
|
||
Comment on attachment 479476 [details] [diff] [review]
patch 3
Marco, I should get your updated r+ since this patch has grown.
Attachment #479476 -
Flags: review?(marco.zehe)
Updated•14 years ago
|
Attachment #479476 -
Flags: review?(marco.zehe) → review+
Reporter | ||
Comment 31•14 years ago
|
||
Comment on attachment 479476 [details] [diff] [review]
patch 3
>- else if (mContent->IsElement()) {
>- nsIFrame *frame = GetFrame();
>- if (frame && frame->IsFocusable()) {
>- *aState |= nsIAccessibleStates::STATE_FOCUSABLE;
>- }
>-
>- if (gLastFocusedNode == mContent) {
>- *aState |= nsIAccessibleStates::STATE_FOCUSED;
>+ if (mContent->IsElement()) {
>+ nsIFrame *frame = GetFrame();
>+ if (frame && frame->IsFocusable()) {
>+ *aState |= nsIAccessibleStates::STATE_FOCUSABLE;
>+ }
>+
>+ if (gLastFocusedNode == mContent) {
>+ *aState |= nsIAccessibleStates::STATE_FOCUSED;
>+ }
I don't see why this change is.
>+ // Note: when we propogate aria-disabled down to descendants, we don't
>+ // currently unset the focusable state. Therefore we don't have a consistency
>+ // check here regarding STATE_UNAVAILABLE->!STATE_FOCUSABLE
> }
it sounds we shouldn't, moreover, we propagate state disabled to focusable items only. see bug 429285.
Attachment #479476 -
Flags: review?(surkov.alexander)
Assignee | ||
Comment 32•14 years ago
|
||
(In reply to comment #31)
> Comment on attachment 479476 [details] [diff] [review]
> patch 3
>
>
> >- else if (mContent->IsElement()) {
>
> I don't see why this change is.
Ah yes I think I can preserve the original blame here.
>
> >+ // Note: when we propogate aria-disabled down to descendants, we don't
> >+ // currently unset the focusable state. Therefore we don't have a consistency
> >+ // check here regarding STATE_UNAVAILABLE->!STATE_FOCUSABLE
> > }
>
> it sounds we shouldn't, moreover, we propagate state disabled to focusable
> items only. see bug 429285.
I think we need to trust the intrinsic state which will sometimes marry unavailable and !focusable.
Reporter | ||
Comment 33•14 years ago
|
||
(In reply to comment #32)
> I think we need to trust the intrinsic state which will sometimes marry
> unavailable and !focusable.
that's ok for intristic case, but we have different logic for ARIA disabled.
Assignee | ||
Comment 34•14 years ago
|
||
This patch improves blame preservation and covers bug 429285 under a more specific test. Prior to this patch we would have enforced disabled state to require focusable state which was strange, but wasn't an issue by shear luck.
Attachment #479476 -
Attachment is obsolete: true
Attachment #480128 -
Flags: review?(surkov.alexander)
Reporter | ||
Comment 35•14 years ago
|
||
Comment on attachment 480128 [details] [diff] [review]
patch 4
>+ // set unavailable state based on disabled state, otherwise set focus states
nit: capital 'S' letter, point in the end of sentence.
>- // unavailable
>- if (state & STATE_UNAVAILABLE) {
>- var role = getRole(aAccOrElmOrID);
>- if (role != ROLE_GROUPING && role != ROLE_EMBEDDED_OBJECT)
>- isState(state & STATE_FOCUSABLE, STATE_FOCUSABLE, false,
>- "Disabled " + id + " must be focusable!");
>- }
> <script type="application/javascript">
>+ function testAriaDisabledTree(aAccOrElmOrID)
>+ {
can we make this a part of testStatesInSubtree(), for example, by providing additional argument on testing function? Especially it makes sense because testStatesInSubtree is used for disabled state tests only. I like the idea to keep it "pure" but perhaps it's really worth to combine these functions.
btw, this function doesn't care about text leafs, it should I guess.
>+ <a target="_blank"
>+ href="https://bugzilla.mozilla.org/show_bug.cgi?id=559275"
>+ title="map attribute required to STATE_REQUIRED">
>+ Mozilla Bug 559275
nit: technically xul test is not about required attribute
r=me, please feel to rereqeust review for testStatesInSubtree code if you think it's necessary.
Attachment #480128 -
Flags: review?(surkov.alexander) → review+
Assignee | ||
Comment 36•14 years ago
|
||
(In reply to comment #35)
Thanks for nits.
> >+ function testAriaDisabledTree(aAccOrElmOrID)
> >+ {
>
> can we make this a part of testStatesInSubtree(), for example, by providing
> additional argument on testing function?
I had thought of doing this (it is less work for me), but I prefer not since it is so specific, and introduces ugly code to a util function. Do you feel strongly about it?
Reporter | ||
Comment 37•14 years ago
|
||
No, but it might be nice
function testStatesInSubtree(aID, aState, aExtraState, aSpecificTest)
{
var acc = getAccessible(aID);
var [state, extState= getStates(acc);
if (aSpecificTest)
aSpecificTest.call(acc, state, extState);
...
}
function testARIADisabledState(aAcc, aState, aExtraState)
{
...
}
testStatesIsSubtree("group", STATE_UNAVAILABLE, 0, testARIADisabledState);
Assignee | ||
Updated•14 years ago
|
Attachment #480128 -
Flags: approval2.0+
Assignee | ||
Comment 38•14 years ago
|
||
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Updated•14 years ago
|
Flags: in-testsuite+
Target Milestone: --- → mozilla2.0b8
Updated•14 years ago
|
Target Milestone: mozilla2.0b8 → mozilla2.0b7
You need to log in
before you can comment on or make changes to this bug.
Description
•