Title: [125777] trunk/Source
Revision
125777
Author
[email protected]
Date
2012-08-16 07:27:50 -0700 (Thu, 16 Aug 2012)

Log Message

[Qt] Input method hints are not being set.
https://bugs.webkit.org/show_bug.cgi?id=92386

Patch by Marcelo Lira <[email protected]> on 2012-08-16
Reviewed by Kenneth Rohde Christiansen.

Input method hints for an editable element must be obtained from a proper
HTML element. If the editable element is a complex one, it will have elements
in the Shadow DOM, and it's one of those that will be returned as the root
editable element. This works for editable DIVs, but not for INPUT elements.
Using Element::shadowHost() on the root editable element will provide the
needed HTML element, and for further clarity a method that does this was added
to FrameSelection.

Source/WebCore:

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::rootEditableElementRespectingShadowTree): Similar to
WebCore::FrameSelection::rootEditableElement, but returns the first ancestor of
the editable element outside the shadow tree.
(WebCore):
* editing/FrameSelection.h:
(FrameSelection):

Source/WebKit2:

Added an API test to the Qt port regarding the correct setting
of input method hints information on INPUT HTML tags.

* UIProcess/API/qt/tests/html/inputmethod.html:
* UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
(tst_QQuickWebView):
(tst_QQuickWebView::inputMethodHints):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125776 => 125777)


--- trunk/Source/WebCore/ChangeLog	2012-08-16 14:17:17 UTC (rev 125776)
+++ trunk/Source/WebCore/ChangeLog	2012-08-16 14:27:50 UTC (rev 125777)
@@ -1,3 +1,26 @@
+2012-08-16  Marcelo Lira  <[email protected]>
+
+        [Qt] Input method hints are not being set.
+        https://bugs.webkit.org/show_bug.cgi?id=92386
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Input method hints for an editable element must be obtained from a proper
+        HTML element. If the editable element is a complex one, it will have elements
+        in the Shadow DOM, and it's one of those that will be returned as the root
+        editable element. This works for editable DIVs, but not for INPUT elements.
+        Using Element::shadowHost() on the root editable element will provide the
+        needed HTML element, and for further clarity a method that does this was added
+        to FrameSelection.
+
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::rootEditableElementRespectingShadowTree): Similar to
+        WebCore::FrameSelection::rootEditableElement, but returns the first ancestor of
+        the editable element outside the shadow tree.
+        (WebCore):
+        * editing/FrameSelection.h:
+        (FrameSelection):
+
 2012-08-16  Zeno Albisser  <[email protected]>
 
         Make GraphicsSurface double buffered by default.

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (125776 => 125777)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2012-08-16 14:17:17 UTC (rev 125776)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2012-08-16 14:27:50 UTC (rev 125777)
@@ -124,6 +124,14 @@
     return selectionRoot ? selectionRoot : m_frame->document()->documentElement();
 }
 
+Element* FrameSelection::rootEditableElementRespectingShadowTree() const
+{
+    Element* selectionRoot = m_selection.rootEditableElement();
+    if (selectionRoot && selectionRoot->isInShadowTree())
+        selectionRoot = selectionRoot->shadowHost();
+    return selectionRoot;
+}
+
 void FrameSelection::moveTo(const VisiblePosition &pos, EUserTriggered userTriggered, CursorAlignOnScroll align)
 {
     SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered;

Modified: trunk/Source/WebCore/editing/FrameSelection.h (125776 => 125777)


--- trunk/Source/WebCore/editing/FrameSelection.h	2012-08-16 14:17:17 UTC (rev 125776)
+++ trunk/Source/WebCore/editing/FrameSelection.h	2012-08-16 14:27:50 UTC (rev 125777)
@@ -135,6 +135,8 @@
 
     Element* rootEditableElement() const { return m_selection.rootEditableElement(); }
     Element* rootEditableElementOrDocumentElement() const;
+    Element* rootEditableElementRespectingShadowTree() const;
+
     bool rendererIsEditable() const { return m_selection.rendererIsEditable(); }
     bool isContentEditable() const { return m_selection.isContentEditable(); }
     bool isContentRichlyEditable() const { return m_selection.isContentRichlyEditable(); }

Modified: trunk/Source/WebKit2/ChangeLog (125776 => 125777)


--- trunk/Source/WebKit2/ChangeLog	2012-08-16 14:17:17 UTC (rev 125776)
+++ trunk/Source/WebKit2/ChangeLog	2012-08-16 14:27:50 UTC (rev 125777)
@@ -1,3 +1,28 @@
+2012-08-16  Marcelo Lira  <[email protected]>
+
+        [Qt] Input method hints are not being set.
+        https://bugs.webkit.org/show_bug.cgi?id=92386
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Input method hints for an editable element must be obtained from a proper
+        HTML element. If the editable element is a complex one, it will have elements
+        in the Shadow DOM, and it's one of those that will be returned as the root
+        editable element. This works for editable DIVs, but not for INPUT elements.
+        Using Element::shadowHost() on the root editable element will provide the
+        needed HTML element, and for further clarity a method that does this was added
+        to FrameSelection.
+
+        Added an API test to the Qt port regarding the correct setting
+        of input method hints information on INPUT HTML tags.
+
+        * UIProcess/API/qt/tests/html/inputmethod.html:
+        * UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
+        (tst_QQuickWebView):
+        (tst_QQuickWebView::inputMethodHints):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::editorState):
+
 2012-08-16  Zeno Albisser  <[email protected]>
 
         Make GraphicsSurface double buffered by default.

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/html/inputmethod.html (125776 => 125777)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/html/inputmethod.html	2012-08-16 14:17:17 UTC (rev 125776)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/html/inputmethod.html	2012-08-16 14:27:50 UTC (rev 125777)
@@ -5,5 +5,7 @@
 <body>
 <h1>Basic page</h1>
 <input id="inputField" />
+<input id="emailInputField" type="email" />
+<div id="editableDiv" contenteditable></div>
 </body>
 </html>

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp (125776 => 125777)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp	2012-08-16 14:17:17 UTC (rev 125776)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp	2012-08-16 14:27:50 UTC (rev 125777)
@@ -58,6 +58,7 @@
     void transparentWebViews();
 
     void inputMethod();
+    void inputMethodHints();
     void basicRenderingSanity();
 
 private:
@@ -410,6 +411,33 @@
     QVERIFY(!view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
 }
 
+void tst_QQuickWebView::inputMethodHints()
+{
+    QQuickWebView* view = webView();
+
+    view->setUrl(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/inputmethod.html")));
+    QVERIFY(waitForLoadSucceeded(view));
+
+    // 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.
+    runJavaScript("document.getElementById('emailInputField').focus();");
+    QVERIFY(view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
+    QInputMethodQueryEvent query(Qt::ImHints);
+    QGuiApplication::sendEvent(view, &query);
+    Qt::InputMethodHints hints(query.value(Qt::ImHints).toUInt() & Qt::ImhExclusiveInputMask);
+    QCOMPARE(hints, Qt::ImhEmailCharactersOnly);
+
+    // The focus of an editable DIV is given directly to it, so no shadow root element
+    // is necessary. This tests the WebPage::editorState() method ability to get the
+    // right element without breaking.
+    runJavaScript("document.getElementById('editableDiv').focus();");
+    QVERIFY(view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
+    query = QInputMethodQueryEvent(Qt::ImHints);
+    QGuiApplication::sendEvent(view, &query);
+    hints = Qt::InputMethodHints(query.value(Qt::ImHints).toUInt());
+    QCOMPARE(hints, Qt::ImhNone);
+}
+
 void tst_QQuickWebView::scrollRequest()
 {
     webView()->setSize(QSizeF(300, 400));

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (125776 => 125777)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-08-16 14:17:17 UTC (rev 125776)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-08-16 14:27:50 UTC (rev 125777)
@@ -485,7 +485,7 @@
     size_t location = 0;
     size_t length = 0;
 
-    Element* selectionRoot = frame->selection()->rootEditableElement();
+    Element* selectionRoot = frame->selection()->rootEditableElementRespectingShadowTree();
     Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
 
     if (!scope)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to