Summary: | SECURITY - Form input field focus stealing using tabs + javascript | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | marazm |
Component: | general | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | bastian |
Priority: | NOR | ||
Version First Reported In: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: |
patch for khtml
tab-switching patch for khtml khtml patch #3 khtml patch #4 khtml patch #5 |
Description
marazm
2005-01-23 16:20:59 UTC
Yup, not nice. One possible solution is to switch to the tab that asks the focus. We do that with popup messgaes already. Another solution is to somehow check if another tab has the focus, perhaps we can check if the widget is visible and only set focus if it is? Created attachment 9244 [details]
patch for khtml
Attached patch only sets focus when widget is visible.
Comment by Dirk Mueller: I'm not sure.. you do want to be able to set the focus to the widget even if its not visible.. khtml will scroll to it then (e.g. tabbing through a page). you more want to bring up the tab into the front that has the input focus. that should be done generically I guess. Yes, that's a good point, tabbing through a page indeed no longer seems to scroll to not-yet-visible widgets with the above patch. Note that tabbing is a bit buggy, I can't tab out of the "Comments" field on the bugreports page ("Allow Tabulations" is unchecked) I'll try to make a patch that gives focus to the tab. I'm not sure how annoying that is going to be. Created attachment 9245 [details]
tab-switching patch for khtml
Patch to switch tabs. Unfortunately it flickers like hell because konqueror
switches tab even if the tab already has focus. I guess that's fixable.
Flicker fixed in CVS. I'm a bit concerned that this switch-tab on focus request can be rather annoying though. Corresponding issue in Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=124750 Created attachment 9246 [details]
khtml patch #3
patch #3 is an improvement of the first patch, instead of only giving focus
when the widget is visible, it only gives focus when the html-view is visible.
Note that with this patch the following Mozilla comment applies to Konqueror as
well:
"right now, background tab ignores focused items on load ...
a real fix should remember the item focused in a background and focus that item
when switching to the tab."
Created attachment 9259 [details]
khtml patch #4
New patch that includes the suggestion in #7
Patch #4 seems to have some issues where the text-area gets only "half" focus. In particular when the textarea has focus and you then click in another part of the page. Created attachment 9271 [details]
khtml patch #5
New patch that doesn't set focus on form element if khtmlview got focus due to
mouseclick
CVS commit by waba: Proper focus management with multiple tabs. BUG: 97722 M +8 -4 khtmlview.cpp 1.690 M +4 -1 xml/dom_docimpl.cpp 1.307 --- kdelibs/khtml/khtmlview.cpp #1.689:1.690 @@ -2828,4 +2828,9 @@ void KHTMLView::dropEvent( QDropEvent *e void KHTMLView::focusInEvent( QFocusEvent *e ) { + DOM::NodeImpl* fn = m_part->xmlDocImpl() ? m_part->xmlDocImpl()->focusNode() : 0; + if (fn && fn->renderer() && fn->renderer()->isWidget() && + (e->reason() != QFocusEvent::Mouse) && + static_cast<khtml::RenderWidget*>(fn->renderer())->widget()) + static_cast<khtml::RenderWidget*>(fn->renderer())->widget()->setFocus(); #ifndef KHTML_NO_CARET // Restart blink frequency timer if it has been killed, but only on @@ -2833,10 +2838,9 @@ void KHTMLView::focusInEvent( QFocusEven if (d->m_caretViewContext && d->m_caretViewContext->freqTimerId == -1 && - m_part->xmlDocImpl()) { - NodeImpl *caretNode = m_part->xmlDocImpl()->focusNode(); + fn) { if (m_part->isCaretMode() || m_part->isEditable() - || (caretNode && caretNode->renderer() - && caretNode->renderer()->style()->userInput() + || (fn && fn->renderer() + && fn->renderer()->style()->userInput() == UI_ENABLED)) { d->m_caretViewContext->freqTimerId = startTimer(500); --- kdelibs/khtml/xml/dom_docimpl.cpp #1.306:1.307 @@ -2075,7 +2075,10 @@ void DocumentImpl::setFocusNode(NodeImpl view()->setFocus(); else if (static_cast<RenderWidget*>(m_focusNode->renderer())->widget()) + { + if (view()->isVisible()) static_cast<RenderWidget*>(m_focusNode->renderer())->widget()->setFocus(); } } + } updateRendering(); |