Closed Bug 742431 Opened 12 years ago Closed 4 years ago

Remove IsDisabled() in favor of EventStates

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1405087

People

(Reporter: mounir, Assigned: mounir)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

Attached patch Patch v1 (obsolete) — Splinter Review
      No description provided.
Attachment #612249 - Flags: review?(bzbarsky)
Comment on attachment 612249 [details] [diff] [review]
Patch v1

Why not keep IsDisabled() to return State().HasState(NS_EVENT_STATE_DISABLED), but more readable?
Attached patch Patch v2 (obsolete) — Splinter Review
Attachment #612249 - Attachment is obsolete: true
Attachment #612249 - Flags: review?(bzbarsky)
Attachment #612481 - Flags: review?(bzbarsky)
Comment on attachment 612481 [details] [diff] [review]
Patch v2

>+   * We need a method to do this because of the recursive check.

How about:

  This should only be called from intrinsic state computation.

instead?

r=me
Attachment #612481 - Flags: review?(bzbarsky) → review+
Actually, this is failing some tests because checking State() in IntrinsicState() is wrong because mState isn't updated so it returns a wrong value. I should try to find an idea to fix that cleanly. Boris, feel free to step in if you have one...
Er... what's checking State() in IntrinsicState()?
(In reply to Boris Zbarsky (:bz) from comment #5)
> Er... what's checking State() in IntrinsicState()?

Arg, I've been looking at ::AfterSetAttr() thinking it was ::IntrinsicState() yesterday... It's not that but something more subtle actually: when fieldset's disabled state is changed, all descendants have FieldSetDisabledChanged() called and form controls that can be invalid will update their validity state based on that change, *then*, UpdateState() is called. Which means NS_EVENT_STATE_DISABLED will have the same state when checking the validity state.

The cleanest way I see to fix that would be to have UpdateState() called twice: once before checking the validity and once after. With a callback when states change (I have a patch doing that), we could actually update the validity state on state change. Would that be an okay solution?
Attached patch Patch v2.1Splinter Review
I'm adding a call to UpdateState(aNotify) in *::FieldSetDisabledChanged(). This is fixing the bug but might make us notify twice for a state change Shouldn't be horrible though.

If we implement a callback when a state changes, we could remove *::FieldSetDisabledChanged() and only update the validity when NS_EVENT_STATE_DISABLED is changed. However, that would make us call UpdateState() for the StateChanged() callback called from UpdateState().
Attachment #612481 - Attachment is obsolete: true
Attachment #612879 - Flags: review?(bzbarsky)
> +   * We need a method to do this because of the recursive check.

See comment 3.
Comment on attachment 612879 [details] [diff] [review]
Patch v2.1

r=me
Attachment #612879 - Flags: review?(bzbarsky) → review+
(In reply to Boris Zbarsky (:bz) from comment #8)
> > +   * We need a method to do this because of the recursive check.
> 
> See comment 3.

Oups, I missed that. It's fixed locally.

So, you confirm you are okay with the two UpdateState() call after each other?
Yes, that sounds reasonable to me.

This is done in:

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: