Closed Bug 277543 Opened 20 years ago Closed 20 years ago

Add default handling for xforms-focus

Categories

(Core Graveyard :: XForms, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: smaug, Assigned: smaug)

References

()

Details

Attachments

(1 file, 2 obsolete files)

*** Bug 279179 has been marked as a duplicate of this bug. ***
Status: NEW → ASSIGNED
Attached patch v1 (obsolete) — Splinter Review
This doesn't support repeat yet. I think it can be done after Bug 278209.
Attachment #172028 - Flags: review?(aaronr)
Comment on attachment 172028 [details] [diff] [review]
v1

yep, that is exactly how I was thinking to do it.  -'ing to allow smaug chance
to include two exceptional circumstances we found in the spec (handling focus
w.r.t. group and non-relevant controls).
Attachment #172028 - Flags: review-
Attached patch v2 (obsolete) — Splinter Review
Attachment #172028 - Attachment is obsolete: true
Attachment #172115 - Flags: review?(aaronr)
Comment on attachment 172115 [details] [diff] [review]
v2

Looks ok to me.  Good job!
r=aaronr
Attachment #172115 - Flags: review?(aaronr) → review+
Attachment #172115 - Flags: superreview?(bryner)
Comment on attachment 172115 [details] [diff] [review]
v2

>@@ -211,12 +216,54 @@ nsXFormsGroupElement::Refresh()
>   result->GetSingleNodeValue(getter_AddRefs(mBoundNode));
>   NS_ENSURE_STATE(mBoundNode);
>   
>   return NS_OK;
> }
> 
>+PRBool
>+nsXFormsGroupElement::TryFocusChildControl(nsIDOMNode* aParent)
>+{
>+  if (!aParent)
>+    return PR_FALSE;
>+
>+  nsCOMPtr<nsIDOMNodeList> children;
>+  nsresult rv = aParent->GetChildNodes(getter_AddRefs(children));
>+  if (NS_FAILED(rv))
>+    return PR_FALSE;
>+
>+  PRUint32 childCount = 0;
>+  children->GetLength(&childCount);
>+  nsCOMPtr<nsIDOMNode> child;
>+
>+  for (PRUint32 i = 0; i < childCount; ++i) {

Hm, should this use the navIndex as described in 4.3.1?

>--- nsXFormsInputElement.cpp	19 Jan 2005 16:05:31 -0000	1.19
>+++ nsXFormsInputElement.cpp	22 Jan 2005 19:36:57 -0000
>@@ -339,12 +340,35 @@ nsXFormsInputElement::Refresh()
>     input->SetReadOnly(readonly);
>   }
> 
>   return NS_OK;
> }
> 
>+NS_IMETHODIMP
>+nsXFormsInputElement::TryFocus(PRBool* aOK)
>+{
>+  *aOK = PR_FALSE;
>+  if (GetRelevantState()) {
>+    nsresult rv = NS_ERROR_FAILURE;
>+    if (mType == eType_TextArea) {
>+      nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea = do_QueryInterface(mControl);
>+      if (textArea)
>+        rv = textArea->Focus();
>+      
>+    } else {
>+      nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(mControl);
>+      if (input)
>+        rv = input->Focus();
>+    }
>+

Slightly easier:

nsCOMPtr<nsIDOMNSHTMLElement> element = do_QueryInterface(mControl);
element->Focus();

This handles both control types.  You could add
nsXFormsUtils::FocusControl(nsIDOMElemnet *aElement) to make things more
compact, too.
Attachment #172115 - Flags: superreview?(bryner) → superreview-
I read navIndex in 4.3.1 as being something that is used by the host language
(XHTML2, SVG).  We could use an attribute like navIndex, but since it isn't part
of the spec, I don't know if the other XForms processors would honor it.  And of
course strictly honoring navIndex values, we'd have to worry about tab
navigation jumping over HTML elements that might be intermingled in the document
and basically preventing them from focusing.  These are the kinds of things that
are worrying me about how to generate the DOMFocusOut and DOMFocusIn events, too.
This doesn't support navIndex. If we want to support that, it should be done in
a
separate bug I think.
btw, navIndex is not mentioned in XForms schema.
Attachment #172115 - Attachment is obsolete: true
Attachment #172477 - Flags: superreview?(bryner)
(In reply to comment #9)
> Created an attachment (id=172477) [edit]

How about having a nsIDOMNSHTMLElement* on nsXFormsControlStub, and then having
a common TryFocus() function there? Most controls would just need to set the
pointer at OnCreated() to whatever control should get focus.
Attachment #172477 - Flags: superreview?(bryner) → superreview+
This has been checked in.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: