RESOLVED FIXED 92386
[Qt] Input method hints are not being set.
https://bugs.webkit.org/show_bug.cgi?id=92386
Summary [Qt] Input method hints are not being set.
Marcelo Lira
Reported 2012-07-26 08:59:29 PDT
When WebPage::editorState() is called it tries to get the information from an HTML input element, but it tries obtain this element from Frame::selection()->rootEditableElement(), which does not return the proper input object. Frame::document()->focusedNode() should be used instead, as it is seen on EditorClientQt::setInputMethodState(bool) method. The method QtWebPageEventHandler::updateTextInputState() must also advertise, by using the Qt::Hints flag, that information on input hints is available.
Attachments
Patch (3.21 KB, patch)
2012-07-26 09:06 PDT, Marcelo Lira
no flags
Patch (2.40 KB, patch)
2012-07-26 13:33 PDT, Marcelo Lira
no flags
Patch (4.50 KB, patch)
2012-07-27 10:53 PDT, Marcelo Lira
no flags
Patch (4.82 KB, patch)
2012-07-31 07:38 PDT, Marcelo Lira
no flags
Patch (8.09 KB, patch)
2012-08-10 11:01 PDT, Marcelo Lira
no flags
Patch (8.00 KB, patch)
2012-08-13 09:38 PDT, Marcelo Lira
no flags
Patch (8.05 KB, patch)
2012-08-13 10:39 PDT, Marcelo Lira
no flags
Patch for landing (8.08 KB, patch)
2012-08-13 10:49 PDT, Marcelo Lira
no flags
Patch (8.05 KB, patch)
2012-08-16 06:16 PDT, Marcelo Lira
no flags
Marcelo Lira
Comment 1 2012-07-26 09:06:43 PDT
Kenneth Rohde Christiansen
Comment 2 2012-07-26 09:27:15 PDT
Comment on attachment 154664 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=154664&action=review > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:484 > - Element* selectionRoot = frame->selection()->rootEditableElement(); > - Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement(); > - > - if (!scope) > - return result; > + HTMLInputElement* input = 0; > + if (frame->document() && frame->document()->focusedNode()) { > + if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag)) > + input = static_cast<HTMLInputElement*>(frame->document()->focusedNode()); > + } You are not explaining this change in the changelog, nor why it is correct. Isn't this going to break terrible with contents-editable and document editing mode? This definitely needs tests to prove otherwise
Marcelo Lira
Comment 3 2012-07-26 13:33:08 PDT
Caio Marcelo de Oliveira Filho
Comment 4 2012-07-26 13:48:57 PDT
LGTM.
Marcelo Lira
Comment 5 2012-07-26 13:53:14 PDT
Kenneth, you're right. Ignore the first patch, the second changes much less things, and does not messes with the cases you pointed out.
Simon Hausmann
Comment 6 2012-07-27 07:18:12 PDT
Comment on attachment 154736 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=154736&action=review > Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp:430 > + qApp->inputMethod()->update(Qt::ImQueryInput | Qt::ImEnabled | Qt::ImHints); I agree about this part, good catch. > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:487 > + if (selectionRoot) > + selectionRoot = selectionRoot->shadowHost(); I think this needs a test, it's quite a subtle change.
Marcelo Lira
Comment 7 2012-07-27 10:53:38 PDT
Caio Marcelo de Oliveira Filho
Comment 8 2012-07-27 10:56:53 PDT
Comment on attachment 154988 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=154988&action=review > Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:420 > + runJavaScript("document.getElementById('emailInputField').focus();"); Suggestion: could you also watch for signal that WebView emits informing that the focus was changed?
Marcelo Lira
Comment 9 2012-07-30 11:04:47 PDT
(In reply to comment #8) > (From update of attachment 154988 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=154988&action=review > > > Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:420 > > + runJavaScript("document.getElementById('emailInputField').focus();"); > > Suggestion: could you also watch for signal that WebView emits informing that the focus was changed? I will look into that, but I would make it a different patch.
Marcelo Lira
Comment 10 2012-07-31 07:27:54 PDT
Additional information on the Shadow DOM: http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/
Marcelo Lira
Comment 11 2012-07-31 07:38:27 PDT
Kenneth Rohde Christiansen
Comment 12 2012-08-02 09:48:10 PDT
Dimitri, Ryosuke, is this correct?
Alexey Proskuryakov
Comment 13 2012-08-02 10:20:56 PDT
This patch makes good sense to me conceptually. What doesn't make a lot of sense is that there is apparently no way to tell whether a function like rootEditableElement() will look inside shadow DOM or not. It feels like some core functions have this isInShadowTree() check internally, and some do not. But it's only tangentially related to this issue.
Simon Hausmann
Comment 14 2012-08-09 22:37:53 PDT
(In reply to comment #13) > This patch makes good sense to me conceptually. > > What doesn't make a lot of sense is that there is apparently no way to tell whether a function like rootEditableElement() will look inside shadow DOM or not. It feels like some core functions have this isInShadowTree() check internally, and some do not. But it's only tangentially related to this issue. Perhaps it would make sense to have at least an overload, rootEditableElementRespectingShadowTree(), that other ports can also use? I see the same "mistake" in the editing code of the other ports.
Marcelo Lira
Comment 15 2012-08-10 11:01:06 PDT
Kenneth Rohde Christiansen
Comment 16 2012-08-10 14:12:40 PDT
Comment on attachment 157759 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=157759&action=review Please improve the comment > Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:423 > + // The focus of an INPUT is really given to an underlying element in its shadow tree, > + // which will not give any input hints. This tests the WebPage::editorState() method > + // ability to get the root element (INPUT proper) from the focused shadow element. I find this hard to understand. // Setting focus on an input element results in an element in its shadow tree becoming the focus node. // Input hints should not be set from this shadow tree node but from the input element itself.
Marcelo Lira
Comment 17 2012-08-13 09:38:21 PDT
Kenneth Rohde Christiansen
Comment 18 2012-08-13 10:24:39 PDT
Comment on attachment 158020 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=158020&action=review > Source/WebCore/ChangeLog:17 > + (WebCore::FrameSelection::rootEditableElementRespectingShadowTree): Similar to WebCore::FrameSelection::rootEditableElement, but returns the first ancestor of the editable element outside the shadow tree. I would wrap that line
Marcelo Lira
Comment 19 2012-08-13 10:39:43 PDT
Marcelo Lira
Comment 20 2012-08-13 10:49:16 PDT
Created attachment 158039 [details] Patch for landing
Marcelo Lira
Comment 21 2012-08-16 06:16:46 PDT
WebKit Review Bot
Comment 22 2012-08-16 07:28:06 PDT
Comment on attachment 158795 [details] Patch Clearing flags on attachment: 158795 Committed r125777: <http://trac.webkit.org/changeset/125777>
WebKit Review Bot
Comment 23 2012-08-16 07:28:12 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.