Commit e84a1b27 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2010-05-20 Rajiv Ramanasankaran <rajiv.ramanasankaran@nokia.com>

        Reviewed by Simon Hausmann.

        [Qt] QWebPage::inputMethodQuery() returns wrong values for Qt::ImCursorPosition, Qt::ImAnchorPosition
        https://bugs.webkit.org/show_bug.cgi?id=38779

        The earlier implementation was written with the assumption that in this scenario the
        anchor position always corresponds to the START index and that the current cursor position
        always corresponds to the END index in WebKit.

        Updated the implementation of QWebPage::inputMethodQuery(Qt::ImCursorPosition) and
        QWebPage::inputMethodQuery(Qt::ImAnchorPosition) for the case where the Editor is not in
        composition mode. In the non-composition mode, the Anchor and the Current cursor positions
        correspond to the Base and Extent position offsets in WebKit.

        Also added the auto-tests for the RIGHT to LEFT and LEFT to RIGHT selections.

        * Api/qwebpage.cpp:
        (QWebPage::inputMethodQuery): Now returning correct values for Qt::ImCursorPosition and
        Qt::ImAnchorPosition when the Editor is not in composition mode.
        * tests/qwebpage/tst_qwebpage.cpp:
        (tst_QWebPage::inputMethods): Added auto-tests for RIGHT to LEFT and LEFT to RIGHT selections

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@59833 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 61cd574c
......@@ -1369,7 +1369,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
RefPtr<Range> range = editor->compositionRange();
return QVariant(renderTextControl->selectionEnd() - TextIterator::rangeLength(range.get()));
}
return QVariant(renderTextControl->selectionEnd());
return QVariant(frame->selection()->extent().offsetInContainerNode());
}
return QVariant();
}
......@@ -1401,7 +1401,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
RefPtr<Range> range = editor->compositionRange();
return QVariant(renderTextControl->selectionStart() - TextIterator::rangeLength(range.get()));
}
return QVariant(renderTextControl->selectionStart());
return QVariant(frame->selection()->base().offsetInContainerNode());
}
return QVariant();
}
......
2010-05-20 Rajiv Ramanasankaran <rajiv.ramanasankaran@nokia.com>
Reviewed by Simon Hausmann.
[Qt] QWebPage::inputMethodQuery() returns wrong values for Qt::ImCursorPosition, Qt::ImAnchorPosition
https://bugs.webkit.org/show_bug.cgi?id=38779
The earlier implementation was written with the assumption that in this scenario the
anchor position always corresponds to the START index and that the current cursor position
always corresponds to the END index in WebKit.
Updated the implementation of QWebPage::inputMethodQuery(Qt::ImCursorPosition) and
QWebPage::inputMethodQuery(Qt::ImAnchorPosition) for the case where the Editor is not in
composition mode. In the non-composition mode, the Anchor and the Current cursor positions
correspond to the Base and Extent position offsets in WebKit.
Also added the auto-tests for the RIGHT to LEFT and LEFT to RIGHT selections.
* Api/qwebpage.cpp:
(QWebPage::inputMethodQuery): Now returning correct values for Qt::ImCursorPosition and
Qt::ImAnchorPosition when the Editor is not in composition mode.
* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::inputMethods): Added auto-tests for RIGHT to LEFT and LEFT to RIGHT selections
2010-05-20 Luiz Agostini <luiz.agostini@openbossa.org>
 
Reviewed by Kenneth Rohde Christiansen.
......
......@@ -1494,6 +1494,98 @@ void tst_QWebPage::inputMethods()
QCOMPARE(value, QString("QtWebKit"));
#endif
// Cancel current composition first
inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant());
QInputMethodEvent eventSelection4("", inputAttributes);
page->event(&eventSelection4);
// START - Tests for Selection when the Editor is NOT in Composition mode
// LEFT to RIGHT selection
// Deselect the selection by sending MouseButtonPress events
// This moves the current cursor to the end of the text
page->event(&evpres);
page->event(&evrel);
//Move to the start of the line
page->triggerAction(QWebPage::MoveToStartOfLine);
QKeyEvent keyRightEventPress(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier);
QKeyEvent keyRightEventRelease(QEvent::KeyRelease, Qt::Key_Right, Qt::NoModifier);
//Move 2 characters RIGHT
for (int j = 0; j < 2; ++j) {
page->event(&keyRightEventPress);
page->event(&keyRightEventRelease);
}
//Select to the end of the line
page->triggerAction(QWebPage::SelectEndOfLine);
//ImAnchorPosition QtWebKit
variant = page->inputMethodQuery(Qt::ImAnchorPosition);
anchorPosition = variant.toInt();
QCOMPARE(anchorPosition, 2);
//ImCursorPosition
variant = page->inputMethodQuery(Qt::ImCursorPosition);
cursorPosition = variant.toInt();
QCOMPARE(cursorPosition, 8);
//ImCurrentSelection
variant = page->inputMethodQuery(Qt::ImCurrentSelection);
selectionValue = variant.value<QString>();
QCOMPARE(selectionValue, QString("WebKit"));
//RIGHT to LEFT selection
//Deselect the selection (this moves the current cursor to the end of the text)
page->event(&evpres);
page->event(&evrel);
//ImAnchorPosition
variant = page->inputMethodQuery(Qt::ImAnchorPosition);
anchorPosition = variant.toInt();
QCOMPARE(anchorPosition, 8);
//ImCursorPosition
variant = page->inputMethodQuery(Qt::ImCursorPosition);
cursorPosition = variant.toInt();
QCOMPARE(cursorPosition, 8);
//ImCurrentSelection
variant = page->inputMethodQuery(Qt::ImCurrentSelection);
selectionValue = variant.value<QString>();
QCOMPARE(selectionValue, QString(""));
QKeyEvent keyLeftEventPress(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier);
QKeyEvent keyLeftEventRelease(QEvent::KeyRelease, Qt::Key_Left, Qt::NoModifier);
//Move 2 characters LEFT
for (int i = 0; i < 2; ++i) {
page->event(&keyLeftEventPress);
page->event(&keyLeftEventRelease);
}
//Select to the start of the line
page->triggerAction(QWebPage::SelectStartOfLine);
//ImAnchorPosition
variant = page->inputMethodQuery(Qt::ImAnchorPosition);
anchorPosition = variant.toInt();
QCOMPARE(anchorPosition, 6);
//ImCursorPosition
variant = page->inputMethodQuery(Qt::ImCursorPosition);
cursorPosition = variant.toInt();
QCOMPARE(cursorPosition, 0);
//ImCurrentSelection
variant = page->inputMethodQuery(Qt::ImCurrentSelection);
selectionValue = variant.value<QString>();
QCOMPARE(selectionValue, QString("QtWebK"));
//END - Tests for Selection when the Editor is not in Composition mode
//ImhHiddenText
QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
page->event(&evpresPassword);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment