Closed Bug 123836 Opened 23 years ago Closed 16 years ago

Implement .indeterminate property on checkboxes

Categories

(Core :: Layout: Form Controls, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: ian, Assigned: ventnor.bugzilla)

References

Details

(Keywords: dev-doc-complete)

Attachments

(2 files, 4 obsolete files)

It would be rather useful if <input type="checkbox"> and <input type="radio"> controls could support tri-state mode, triggered by the "indeterminate" DOM property as defined by Microsoft: http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/indeterminate.asp http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/inputelement/indeterminate.asp
DOM WG doesn't want this, so we'll have to put it in nsIDOMNSHTMLInputElement. When XBL form controls are turned on, this will be just as easy as setting the :checked property will. Setting to 1.1 since that's the milestone-after-XBL.
Target Milestone: --- → mozilla1.1
QA Contact: madhur → tpreston
Status: NEW → ASSIGNED
What's the status on this ... would it have to be done using XBL?
"The official feedback on DOM Level 2 HTML is a request to add an 'indeterminate' property to Interface HTMLInputElement." "In November 2000, DOM Level 2 HTML was delayed for backward compatibility reasons and our intent is to capture the current practice in several implementation, which is not the case for indeterminate. Only IE implementations are supporting this indeterminate feature for the moment. The TriState implementation does support indeterminate property but it is not equivalent to the one in IEs. So, even if other implementation are going to implement indeterminate in the future, we prefer not to add this new feature for the moment. This certainly needs to be on the list for an XForms API at some point." <http://www.w3.org/2001/12/DOM-Level-2-issues>
HTML 5 got this property newly added to it. We might as well try it out, it seems like it could add nice polish to web apps that use treefuls of checkboxes.
Assignee: john → ventnor.bugzilla
QA Contact: tpreston → layout.form-controls
Target Milestone: mozilla1.1alpha → ---
Attached patch Patch (obsolete) — Splinter Review
This adds backend support for the property, plus adds drawing support for generic widgets and GTK widgets. Mac and Windows can be done later.
Attachment #355652 - Flags: superreview?(roc)
Attachment #355652 - Flags: review?(roc)
+[scriptable, uuid(b92b725e-b75a-49a0-b6f9-e16bc4bfa3de)] interface nsIDOMHTMLInputElement : nsIDOMHTMLElement nsIDOMHTMLInputElement is frozen so you can't do this. Add to nsIDOMNSHTMLInputElement instead. +PaintIndeterminateMark(nsIRenderingContext& aRenderingContext, + const nsRect& aRect) +{ + // Drawing a thin horizontal line in the middle of the rect. Why is this the right thing to do? + nsCOMPtr<nsIDOMHTMLInputElement> elem(do_QueryInterface(mContent)); + PRBool retval = PR_FALSE; + elem->GetIndeterminate(&retval); Probably best to do a null check here in case our content is an unexpected type. Otherwise looks good. When you post a new patch, ask jst for review on the content part.
Are we out of bits in the bitfield? If not, why are we adding a new member? I'd really like to see a diff with more context and -p here. In fact, it might be worth setting your mq to always do that...
We discussed these IRL :) but I'll put them in a comment anyway. (In reply to comment #6) > +PaintIndeterminateMark(nsIRenderingContext& aRenderingContext, > + const nsRect& aRect) > +{ > + // Drawing a thin horizontal line in the middle of the rect. > > Why is this the right thing to do? This is what Mac and most GTK themes do. Windows seems to change their appearance of tristate checkboxes in each version. Plus its easy to do. > + nsCOMPtr<nsIDOMHTMLInputElement> elem(do_QueryInterface(mContent)); > + PRBool retval = PR_FALSE; > + elem->GetIndeterminate(&retval); > > Probably best to do a null check here in case our content is an unexpected > type. The other existing function GetChecked() doesn't do that. I don't think the content will ever be an unexpected type.
Oops, in HTML5 I only made it apply to checkboxes. Does it apply to radio buttons too?
No.
Attached patch Patch 2 (obsolete) — Splinter Review
Fixes comments.
Attachment #355652 - Attachment is obsolete: true
Attachment #355667 - Flags: superreview?(roc)
Attachment #355667 - Flags: review?(roc)
Attachment #355652 - Flags: superreview?(roc)
Attachment #355652 - Flags: review?(roc)
Attachment #355667 - Flags: superreview?(roc)
Attachment #355667 - Flags: superreview+
Attachment #355667 - Flags: review?(roc)
Attachment #355667 - Flags: review?(jst)
Attachment #355667 - Flags: review+
Comment on attachment 355667 [details] [diff] [review] Patch 2 nsRefPtr<nsDOMFileList> mFileList; + }; Lose the blank line
So the indeterminate state doesn't affect :checked matching on checkboxes/radios? That is, they match based on their checked state no matter what the indeterminate state is?
Correct. According to HTML5 (and MSDN, God help it), indeterminate only affects the appearance of the control and the checked state is toggled independently.
I'm not talking about the "checked state" in terms of DOM state but in terms of CSS style matching. Should the CSS :checked selector match indeterminate controls?
I don't think so. The way the spec reads, it says the indeterminate attribute should not affect anything other than just the appearance of the control.
I'm not sure that makes sense to me, especially since the whole point of styling _is_ appearance.
We can say that :checked doesn't apply if :indeterminate applies. I haven't defined how the pseudos match HTML5 stuff yet.
Attached patch Patch 3 (obsolete) — Splinter Review
Remove that space.
Attachment #355667 - Attachment is obsolete: true
Attachment #355703 - Flags: review?(jst)
Attachment #355667 - Flags: review?(jst)
Comment on attachment 355703 [details] [diff] [review] Patch 3 r=jst. Are there bugs filed on doing the Mac and Windows drawing part of this changed?
Attachment #355703 - Flags: review?(jst) → review+
Attached patch Updated to tip (obsolete) — Splinter Review
Not that I'm aware of. I might file them later.
Attachment #355703 - Attachment is obsolete: true
Oops, that patch got the tests dropped from it.
Whiteboard: [needs landing]
Whiteboard: [needs landing]
Attachment #358069 - Attachment is obsolete: true
Keywords: checkin-needed
Whiteboard: [needs landing]
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Whiteboard: [needs landing]
Blocks: 474868
Blocks: 474878
Summary: Implement .indeterminate property on checkboxes and radio buttons → Implement .indeterminate property on checkboxes
Target Milestone: --- → mozilla1.9.2a1
Just curious, why do the test pass on Windows and Mac if that's not implemented there yet and the manifest does not exclude these platforms?
The test turns off native theming using -moz-appearance: none, so it falls back to the cross-platform rendering.
ok, makes sense now. Thanks for the explanations.
Attached file testcase
Testcase showing various checked/indeterminate/enabled variations on checkboxes and radios. Firefox/IE/Safari Mac seem to agree on the rendering here, except Safari on Windows which renders a checkbox with checked+indeterminate the same way as a non-indeterminate checked checkbox (looks like a bug).
Depends on: 480719
Keywords: dev-doc-needed
Is this only a DOM attribute (settable in Javascript) or a content attribute (settable in the HTML tag)? The original IE implementation has it as a content attribute with the nonstandard indeterminate="true"/"false" syntax. HTML5 only defines it as a DOM attribute, not as a content attribute: http://www.w3.org/TR/html5/forms.html#the-input-element http://www.w3.org/TR/html5/forms.html#dom-input-indeterminate
DOM only.
While the CSS :indeterminate is documented, we need to document the input element's support for this too.
Do we handle the indeterminate state on checkboxes inside a tree/listbox differently? When I try to get the value of the restore column of the listbox in the about:sessionrestore page, I get true, false, and 0. Here an example: var elem = document.getElementById("tabList"); var restore = elem.view.getCellValue(0, tree.columns.getColumnAt(0)) If any tab under a window should not be restored, 'restore' will be 0.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: