[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 16:10:07 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 3d6ffa71efe26a2bee7e98e064f9e050b80669b5
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 19 09:35:09 2010 +0000

    2010-11-19  Yi Shen  <yi.4.shen at nokia.com>
    
            Reviewed by Andreas Kling.
    
            https://bugs.webkit.org/show_bug.cgi?id=49200
            [Qt] bugs in Composition mode for QWebPage::inputMethodEvent & inputMethodQuery()
    
            Make QWebPage work as following when editor is in composition mode:
            1. anchor position and cursor position are the same and always >= 0
            2. current selection is always null
    
            * Api/qwebpage.cpp:
            (QWebPagePrivate::inputMethodEvent):
            (QWebPage::inputMethodQuery):
            * tests/qwebpage/tst_qwebpage.cpp:
            (tst_QWebPage::inputMethods):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72370 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index a29d417..2e8c6b7 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -1067,11 +1067,9 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
             if (node)
                 setSelectionRange(node, qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)));
 
-            if (!ev->preeditString().isEmpty()) {
-                editor->setComposition(ev->preeditString(), underlines,
-                                      (a.length < 0) ? a.start + a.length : a.start,
-                                      (a.length < 0) ? a.start : a.start + a.length);
-            } else {
+            if (!ev->preeditString().isEmpty())
+                editor->setComposition(ev->preeditString(), underlines, qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)));
+            else {
                 // If we are in the middle of a composition, an empty pre-edit string and a selection of zero
                 // cancels the current composition
                 if (editor->hasComposition() && (a.start + a.length == 0))
@@ -1085,7 +1083,7 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
     if (!ev->commitString().isEmpty())
         editor->confirmComposition(ev->commitString());
     else if (!hasSelection && !ev->preeditString().isEmpty())
-        editor->setComposition(ev->preeditString(), underlines, 0, ev->preeditString().length());
+        editor->setComposition(ev->preeditString(), underlines, 0, 0);
 
     ev->accept();
 }
@@ -1370,10 +1368,8 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
             return QVariant(QFont());
         }
         case Qt::ImCursorPosition: {
-            if (editor->hasComposition()) {
-                RefPtr<Range> range = editor->compositionRange();
-                return QVariant(frame->selection()->end().offsetInContainerNode() - TextIterator::rangeLength(range.get()));
-            }
+            if (editor->hasComposition())
+                return QVariant(frame->selection()->end().offsetInContainerNode());
             return QVariant(frame->selection()->extent().offsetInContainerNode());
         }
         case Qt::ImSurroundingText: {
@@ -1387,7 +1383,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
             return QVariant();
         }
         case Qt::ImCurrentSelection: {
-            if (renderTextControl) {
+            if (!editor->hasComposition() && renderTextControl) {
                 int start = frame->selection()->start().offsetInContainerNode();
                 int end = frame->selection()->end().offsetInContainerNode();
                 if (end > start)
@@ -1397,10 +1393,8 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
 
         }
         case Qt::ImAnchorPosition: {
-            if (editor->hasComposition()) {
-                RefPtr<Range> range = editor->compositionRange();
-                return QVariant(frame->selection()->start().offsetInContainerNode() - TextIterator::rangeLength(range.get()));
-            }
+            if (editor->hasComposition())
+                return QVariant(frame->selection()->start().offsetInContainerNode());
             return QVariant(frame->selection()->base().offsetInContainerNode());
         }
         case Qt::ImMaximumTextLength: {
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 68918ed..7c0fb8e 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,20 @@
+2010-11-19  Yi Shen  <yi.4.shen at nokia.com>
+
+        Reviewed by Andreas Kling.
+
+        https://bugs.webkit.org/show_bug.cgi?id=49200
+        [Qt] bugs in Composition mode for QWebPage::inputMethodEvent & inputMethodQuery()
+
+        Make QWebPage work as following when editor is in composition mode:
+        1. anchor position and cursor position are the same and always >= 0
+        2. current selection is always null
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::inputMethodEvent):
+        (QWebPage::inputMethodQuery):
+        * tests/qwebpage/tst_qwebpage.cpp:
+        (tst_QWebPage::inputMethods):
+
 2010-11-18  Gavin Barraclough  <barraclough at apple.com>
 
         Build fix - update error messages folllowing r72360.
diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index e6b5909..413984a 100644
--- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -1687,6 +1687,314 @@ void tst_QWebPage::inputMethods()
     QCOMPARE(inputValue, QString("QtWebKit2"));
     //END - Test for sending empty QInputMethodEvent
 
+    page->mainFrame()->setHtml("<html><body>" \
+                                            "<input type='text' id='input4' value='QtWebKit inputMethod'/>" \
+                                            "</body></html>");
+    page->mainFrame()->evaluateJavaScript("var inputEle = document.getElementById('input4'); inputEle.focus(); inputEle.select();");
+
+    // Clear the selection, also cancel the ongoing composition if there is one.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant());
+        attributes.append(newSelection);
+        QInputMethodEvent event("", attributes);
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    QString surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("QtWebKit inputMethod"));
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 0);
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 0);
+
+    // 1. Insert a character to the begining of the line.
+    // Send temporary text, which makes the editor has composition 'm'.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent event("m", attributes);
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("QtWebKit inputMethod"));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 0);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 0);
+
+    // Send temporary text, which makes the editor has composition 'n'.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent event("n", attributes);
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("QtWebKit inputMethod"));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 0);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 0);
+
+    // Send commit text, which makes the editor conforms composition.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent event("", attributes);
+        event.setCommitString("o");
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("oQtWebKit inputMethod"));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 1);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 1);
+
+    // 2. insert a character to the middle of the line.
+    // Send temporary text, which makes the editor has composition 'd'.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent event("d", attributes);
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("oQtWebKit inputMethod"));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 1);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 1);
+
+    // Send commit text, which makes the editor conforms composition.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent event("", attributes);
+        event.setCommitString("e");
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethod"));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 2);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 2);
+
+    // 3. Insert a character to the end of the line.
+    page->triggerAction(QWebPage::MoveToEndOfLine);
+    
+    // Send temporary text, which makes the editor has composition 't'.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent event("t", attributes);
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethod"));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 22);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 22);
+
+    // Send commit text, which makes the editor conforms composition.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent event("", attributes);
+        event.setCommitString("t");
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethodt"));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 23);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 23);
+
+    // 4. Replace the selection.
+    page->triggerAction(QWebPage::SelectPreviousWord);
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString("inputMethodt"));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethodt"));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 11);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 23);
+
+    // Send temporary text, which makes the editor has composition 'w'.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent event("w", attributes);
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("oeQtWebKit "));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 11);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 11);
+
+    // Send commit text, which makes the editor conforms composition.
+    {
+        QList<QInputMethodEvent::Attribute> attributes;
+        QInputMethodEvent event("", attributes);
+        event.setCommitString("2");
+        page->event(&event);
+    }
+
+    // ImCurrentSelection
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
+    selectionValue = variant.value<QString>();
+    QCOMPARE(selectionValue, QString(""));
+
+    // ImSurroundingText
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
+    surroundingValue = variant.value<QString>();
+    QCOMPARE(surroundingValue, QString("oeQtWebKit 2"));
+
+    // ImCursorPosition
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
+    cursorPosition =  variant.toInt();
+    QCOMPARE(cursorPosition, 12);
+
+    // ImAnchorPosition
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
+    anchorPosition =  variant.toInt();
+    QCOMPARE(anchorPosition, 12);
+
     delete container;
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list