[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    [PATCH] Last version of the "fix label form focus" (59489)
From:       bj () altern ! org
Date:       2004-06-30 20:02:55
Message-ID: 200406302209.32300.bj () altern ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi!

Ok, I am beginning to understand how it works.
I think this patch should be good enough for committing (at least much better 
than my 2 previous versions). It also adds support for label accesskey, and 
improves form input accesskeys (pressing a checkbox accesskey now 
checks/unchecks it instead of just focusing it).

Comments welcome.

regards

["formsclick8.diff" (text/x-diff)]

Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.640
diff -u -3 -r1.640 khtmlview.cpp
--- khtmlview.cpp	30 Jun 2004 16:20:34 -0000	1.640
+++ khtmlview.cpp	30 Jun 2004 19:46:41 -0000
@@ -1876,7 +1876,7 @@
             static_cast< HTMLAnchorElementImpl* >( node )->click();
           break;
         case ID_INPUT:
-            static_cast< HTMLInputElementImpl* >( node )->click();
+            static_cast< HTMLInputElementImpl* >( node )->activateInput();
           break;
         case ID_BUTTON:
             static_cast< HTMLButtonElementImpl* >( node )->click();
@@ -1885,7 +1885,7 @@
             static_cast< HTMLAreaElementImpl* >( node )->click();
           break;
         case ID_LABEL:
-            // TODO should be click(), after it works for label
+            static_cast< HTMLLabelElementImpl* >( node )->click();
           break;
         case ID_TEXTAREA:
           break; // just focusing it is enough
Index: html/html_formimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_formimpl.cpp,v
retrieving revision 1.372
diff -u -3 -r1.372 html_formimpl.cpp
--- html/html_formimpl.cpp	22 Jun 2004 05:46:41 -0000	1.372
+++ html/html_formimpl.cpp	30 Jun 2004 19:46:46 -0000
@@ -1553,6 +1553,25 @@
     }
 }
 
+void HTMLInputElementImpl::activateInput()
+{
+switch (m_type)
+{
+case RADIO:
+setChecked(true);
+break;
+case CHECKBOX:
+setChecked(!checked());
+break;
+case SUBMIT:
+case BUTTON:
+activate();
+break;
+default:
+focus();
+}
+}
+
 bool HTMLInputElementImpl::isEditable()
 {
     return ((m_type == TEXT) || (m_type == PASSWORD) || (m_type == ISINDEX) || \
(m_type == FILE)); @@ -1580,15 +1599,30 @@
     HTMLElementImpl::attach();
 }
 
-#if 0
-ElementImpl *HTMLLabelElementImpl::formElement()
+
+void HTMLLabelElementImpl::click()
 {
     DOMString formElementId = getAttribute(ATTR_FOR);
-    if (formElementId.isEmpty())
-        return 0;
-    return getDocument()->getElementById(formElementId);
+    if (!formElementId.isEmpty())
+    static_cast<DOM::HTMLInputElementImpl*>(getDocument()->getElementById(formElementId))->activateInput();
 +    else
+    {
+    uint children=childNodeCount();
+    if (children>1) 
+    for (unsigned int i=0;i<children;i++)
+    if (childNode(i)->id()==ID_INPUT)
+    {
+    static_cast<DOM::HTMLInputElementImpl*>(childNode(i))->activateInput();
+    break;
+    }
+    }
+}
+
+void HTMLLabelElementImpl::defaultEventHandler(EventImpl *evt)
+{
+    if (( !m_disabled ) && (evt->isMouseEvent()))
+		 if (evt->id() == EventImpl::CLICK_EVENT) click();
 }
-#endif
 
 // -------------------------------------------------------------------------
 
Index: html/html_formimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_formimpl.h,v
retrieving revision 1.152
diff -u -3 -r1.152 html_formimpl.h
--- html/html_formimpl.h	22 Jun 2004 05:46:41 -0000	1.152
+++ html/html_formimpl.h	30 Jun 2004 19:46:47 -0000
@@ -291,6 +291,7 @@
 
     DOMString altText() const;
     void activate();
+    void activateInput();
 
 protected:
 
@@ -319,6 +320,8 @@
 
     virtual Id id() const;
     virtual void attach();
+    virtual void click();
+    virtual void defaultEventHandler(EventImpl *evt);
 
  private:
     DOMString m_formElementID;


[Attachment #6 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic