Summary: | Implement label form focus in khtml | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | Shift <shift> |
Component: | khtml forms | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | bugzilla-kde, glen, jsp, opensource |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Shift
2003-06-07 23:08:14 UTC
Oups !!! Sorry I have forgotten to set this bug as a wishlist one :-( How can I change this ? I think you can't do this. Did it for you. I can confirm this BUG (non standard compliance is a BUG IMO) with Konqueror up to (at last) 3.1.2 . This bug is still present in 3.2.0_alpha2. I also would call this a bug. Bug always here in KDE CVS Still in 3.2.1. It would ideally be marked NEW, not UNCONFIRMED, since several people have seen it. And I too think that since this is a clear failure to implement the HTML spec, this is a bug of at least normal severity, not a wishlist item. I can create and attach a test case if it would be useful. Safari would also benefit if this were fixed; maybe Apple would take it on. I just set this bug to status NEW, severity normal, so that someone can fix this bug. Here is an easier test case. <input id="check_group_id_28" type="checkbox" name="selected_group[]" value="28"> <label for="check_group_id_28">Can access Alarm System settings</label> Good news: I just posted a patch fixing this issue on the kfm-devel mailing list: http://lists.kde.org/?l=kfm-devel&m=108843658120199&w=2 Waiting for feedback :) CVS commit by mardelle: Clicking on a label will focus/activate the form element CCMAIL: 59489-done@bugs.kde.org M +6 -3 khtmlview.cpp 1.643 M +35 -8 html/html_formimpl.cpp 1.373 M +3 -1 html/html_formimpl.h 1.153 --- kdelibs/khtml/html/html_formimpl.cpp #1.372:1.373 @@ -1151,4 +1151,5 @@ void HTMLInputElementImpl::click() { QMouseEvent me(QEvent::MouseButtonRelease, QPoint(0,0),Qt::LeftButton, 0); + dispatchMouseEvent(&me,0, 1); dispatchMouseEvent(&me,EventImpl::CLICK_EVENT, 1); } @@ -1581,13 +1582,39 @@ void HTMLLabelElementImpl::attach() } -#if 0 -ElementImpl *HTMLLabelElementImpl::formElement() +NodeImpl* HTMLLabelElementImpl::getFormElement() { DOMString formElementId = getAttribute(ATTR_FOR); - if (formElementId.isEmpty()) - return 0; - return getDocument()->getElementById(formElementId); + NodeImpl *newNode=0L; + if (!formElementId.isEmpty()) + newNode=getDocument()->getElementById(formElementId); + if (!newNode){ + uint children=childNodeCount(); + if (children>1) + for (unsigned int i=0;i<children;i++){ + uint nodeId=childNode(i)->id(); + if (nodeId==ID_INPUT || nodeId==ID_SELECT || nodeId==ID_TEXTAREA){ + newNode=childNode(i); + break; + } + } + } +return newNode; +} + +void HTMLLabelElementImpl::defaultEventHandler(EventImpl *evt) + { + if ( !m_disabled && + evt->isMouseEvent() && evt->id() == EventImpl::CLICK_EVENT){ + NodeImpl *formNode=getFormElement(); + if (formNode) + { + getDocument()->setFocusNode(formNode); + if (formNode->id()==ID_INPUT) + static_cast<DOM::HTMLInputElementImpl*>(formNode)->click(); + } + evt->setDefaultHandled(); + } + HTMLGenericFormElementImpl::defaultEventHandler(evt); } -#endif // ------------------------------------------------------------------------- --- kdelibs/khtml/html/html_formimpl.h #1.152:1.153 @@ -320,4 +320,6 @@ public: virtual Id id() const; virtual void attach(); + virtual void defaultEventHandler(EventImpl *evt); + NodeImpl* getFormElement(); private: --- kdelibs/khtml/khtmlview.cpp #1.642:1.643 @@ -1878,4 +1878,10 @@ bool KHTMLView::focusNodeWithAccessKey( return true; } + if (node->id()==ID_LABEL) + { + // if Accesskey is a label, give focus to the label's referrer. + node=static_cast<ElementImpl *>(static_cast< HTMLLabelElementImpl* >( node )->getFormElement()); + if (!node) return true; + } switch( node->id()) { case ID_A: @@ -1891,7 +1897,4 @@ bool KHTMLView::focusNodeWithAccessKey( static_cast< HTMLAreaElementImpl* >( node )->click(); break; - case ID_LABEL: - // TODO should be click(), after it works for label - break; case ID_TEXTAREA: break; // just focusing it is enough This bug is still present in Konqueror 3.2.2 - so is it really fixed? Even Konqueror 3.2.3 has still this bug. The latest version of Konqueror is 3.3.0. It is most likely fixed in that version. Yup. Works for me in Konqueror 3.3. KHTML 3.5.4 svn trunk build 24.07.2006 GCC 3.3.5 label didn't checked by [code] <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr"> <head> <title>Accebility</title> </head> <body> <div> <label>Accebility <input type="checkbox" /> </label> <hr /> <label for="set">Accebility</label> <input id="set" type="checkbox" /> </div> </body> </html> [/CODE] Hmm.. as far as I can see we pass focus, but unlike firefox the button is not checked anymore. It's a regression SVN commit 567892 by carewolf: Correct the patch for #166092 so it doesn't regress #59489 CCBUG:116092 BUG:59489 M +2 -2 html_formimpl.cpp --- branches/KDE/3.5/kdelibs/khtml/html/html_formimpl.cpp #567891:567892 @@ -1917,10 +1917,10 @@ if (act) { NodeImpl* const formNode=getFormElement(); - if (formNode) { + if (formNode && evt->target() != formNode) { getDocument()->setFocusNode(formNode); if (formNode->id()==ID_INPUT) - static_cast<DOM::HTMLInputElementImpl*>(formNode)->defaultEventHandler(evt); + static_cast<DOM::HTMLInputElementImpl*>(formNode)->click(); evt->setDefaultHandled(); } } *** Bug 131730 has been marked as a duplicate of this bug. *** |