[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: Re: [PATCH] fix label form focus #59489
From: bj () altern ! org
Date: 2004-06-29 13:56:42
Message-ID: 200406291603.19771.bj () altern ! org
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
Improved (non-leaking) version of my patch.
["formsclick3.diff" (text/x-diff)]
Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.639
diff -u -3 -r1.639 khtmlview.cpp
--- khtmlview.cpp 19 Jun 2004 20:47:34 -0000 1.639
+++ khtmlview.cpp 29 Jun 2004 13:49:57 -0000
@@ -727,17 +733,17 @@
d->clickX = xm;
d->clickY = ym;
}
-
bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEDOWN_EVENT,mev.innerNode.handle(),true,
d->clickCount,_mouse,true,DOM::NodeImpl::MousePress);
-
+
khtml::RenderObject* r = mev.innerNode.handle() ? mev.innerNode.handle()->renderer() : 0;
if (r && r->isWidget())
_mouse->ignore();
-
+
if (!swallowEvent) {
emit m_part->nodeActivated(mev.innerNode);
-
+ if (mev.innerNode.handle()->parentNode()->id()==ID_LABEL)
+ static_cast<DOM::HTMLLabelElementImpl*>(mev.innerNode.handle()->parentNode())->activateFormElement();
khtml::MousePressEvent event( _mouse, xm, ym, mev.url, mev.target, mev.innerNode );
QApplication::sendEvent( m_part, &event );
// we might be deleted after this
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 29 Jun 2004 13:50:03 -0000
@@ -1553,6 +1553,21 @@
}
}
+void HTMLInputElementImpl::activateInput()
+{
+switch (m_type)
+{
+case RADIO:
+setChecked(true);
+break;
+case CHECKBOX:
+setChecked(!checked());
+break;
+default:
+focus();
+}
+}
+
bool HTMLInputElementImpl::isEditable()
{
return ((m_type == TEXT) || (m_type == PASSWORD) || (m_type == ISINDEX) || (m_type == FILE));
@@ -1580,15 +1595,24 @@
HTMLElementImpl::attach();
}
-#if 0
-ElementImpl *HTMLLabelElementImpl::formElement()
+
+void HTMLLabelElementImpl::activateFormElement()
{
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;
+ }
+ }
}
-#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 29 Jun 2004 13:50:04 -0000
@@ -291,6 +291,7 @@
DOMString altText() const;
void activate();
+ void activateInput();
protected:
@@ -319,6 +320,7 @@
virtual Id id() const;
virtual void attach();
+ virtual void activateFormElement();
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