Changeset 59833 in webkit


Ignore:
Timestamp:
May 20, 2010 6:56:59 AM (14 years ago)
Author:
eric@webkit.org
Message:

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
Location:
trunk/WebKit/qt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/Api/qwebpage.cpp

    r59761 r59833  
    13701370                    return QVariant(renderTextControl->selectionEnd() - TextIterator::rangeLength(range.get()));
    13711371                }
    1372                 return QVariant(renderTextControl->selectionEnd());
     1372                return QVariant(frame->selection()->extent().offsetInContainerNode());
    13731373            }
    13741374            return QVariant();
     
    14021402                    return QVariant(renderTextControl->selectionStart() - TextIterator::rangeLength(range.get()));
    14031403                }
    1404                 return QVariant(renderTextControl->selectionStart());
     1404                return QVariant(frame->selection()->base().offsetInContainerNode());
    14051405            }
    14061406            return QVariant();
  • trunk/WebKit/qt/ChangeLog

    r59831 r59833  
     12010-05-20  Rajiv Ramanasankaran  <rajiv.ramanasankaran@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4       
     5        [Qt] QWebPage::inputMethodQuery() returns wrong values for Qt::ImCursorPosition, Qt::ImAnchorPosition
     6        https://bugs.webkit.org/show_bug.cgi?id=38779
     7
     8        The earlier implementation was written with the assumption that in this scenario the
     9        anchor position always corresponds to the START index and that the current cursor position
     10        always corresponds to the END index in WebKit.
     11
     12        Updated the implementation of QWebPage::inputMethodQuery(Qt::ImCursorPosition) and
     13        QWebPage::inputMethodQuery(Qt::ImAnchorPosition) for the case where the Editor is not in
     14        composition mode. In the non-composition mode, the Anchor and the Current cursor positions
     15        correspond to the Base and Extent position offsets in WebKit.
     16
     17        Also added the auto-tests for the RIGHT to LEFT and LEFT to RIGHT selections.
     18
     19        * Api/qwebpage.cpp:
     20        (QWebPage::inputMethodQuery): Now returning correct values for Qt::ImCursorPosition and
     21        Qt::ImAnchorPosition when the Editor is not in composition mode.
     22        * tests/qwebpage/tst_qwebpage.cpp:
     23        (tst_QWebPage::inputMethods): Added auto-tests for RIGHT to LEFT and LEFT to RIGHT selections
     24
    1252010-05-20  Luiz Agostini  <luiz.agostini@openbossa.org>
    226
  • trunk/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r59380 r59833  
    14951495#endif
    14961496
     1497    // Cancel current composition first
     1498    inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant());
     1499    QInputMethodEvent eventSelection4("", inputAttributes);
     1500    page->event(&eventSelection4);
     1501
     1502    // START - Tests for Selection when the Editor is NOT in Composition mode
     1503
     1504    // LEFT to RIGHT selection
     1505    // Deselect the selection by sending MouseButtonPress events
     1506    // This moves the current cursor to the end of the text
     1507    page->event(&evpres);
     1508    page->event(&evrel);
     1509
     1510    //Move to the start of the line
     1511    page->triggerAction(QWebPage::MoveToStartOfLine);
     1512
     1513    QKeyEvent keyRightEventPress(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier);
     1514    QKeyEvent keyRightEventRelease(QEvent::KeyRelease, Qt::Key_Right, Qt::NoModifier);
     1515
     1516    //Move 2 characters RIGHT
     1517    for (int j = 0; j < 2; ++j) {
     1518        page->event(&keyRightEventPress);
     1519        page->event(&keyRightEventRelease);
     1520    }
     1521
     1522    //Select to the end of the line
     1523    page->triggerAction(QWebPage::SelectEndOfLine);
     1524
     1525    //ImAnchorPosition QtWebKit
     1526    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
     1527    anchorPosition =  variant.toInt();
     1528    QCOMPARE(anchorPosition, 2);
     1529
     1530    //ImCursorPosition
     1531    variant = page->inputMethodQuery(Qt::ImCursorPosition);
     1532    cursorPosition =  variant.toInt();
     1533    QCOMPARE(cursorPosition, 8);
     1534
     1535    //ImCurrentSelection
     1536    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
     1537    selectionValue = variant.value<QString>();
     1538    QCOMPARE(selectionValue, QString("WebKit"));
     1539
     1540    //RIGHT to LEFT selection
     1541    //Deselect the selection (this moves the current cursor to the end of the text)
     1542    page->event(&evpres);
     1543    page->event(&evrel);
     1544
     1545    //ImAnchorPosition
     1546    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
     1547    anchorPosition =  variant.toInt();
     1548    QCOMPARE(anchorPosition, 8);
     1549
     1550    //ImCursorPosition
     1551    variant = page->inputMethodQuery(Qt::ImCursorPosition);
     1552    cursorPosition =  variant.toInt();
     1553    QCOMPARE(cursorPosition, 8);
     1554
     1555    //ImCurrentSelection
     1556    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
     1557    selectionValue = variant.value<QString>();
     1558    QCOMPARE(selectionValue, QString(""));
     1559
     1560    QKeyEvent keyLeftEventPress(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier);
     1561    QKeyEvent keyLeftEventRelease(QEvent::KeyRelease, Qt::Key_Left, Qt::NoModifier);
     1562
     1563    //Move 2 characters LEFT
     1564    for (int i = 0; i < 2; ++i) {
     1565        page->event(&keyLeftEventPress);
     1566        page->event(&keyLeftEventRelease);
     1567    }
     1568
     1569    //Select to the start of the line
     1570    page->triggerAction(QWebPage::SelectStartOfLine);
     1571
     1572    //ImAnchorPosition
     1573    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
     1574    anchorPosition =  variant.toInt();
     1575    QCOMPARE(anchorPosition, 6);
     1576
     1577    //ImCursorPosition
     1578    variant = page->inputMethodQuery(Qt::ImCursorPosition);
     1579    cursorPosition =  variant.toInt();
     1580    QCOMPARE(cursorPosition, 0);
     1581
     1582    //ImCurrentSelection
     1583    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
     1584    selectionValue = variant.value<QString>();
     1585    QCOMPARE(selectionValue, QString("QtWebK"));
     1586
     1587    //END - Tests for Selection when the Editor is not in Composition mode
     1588
    14971589    //ImhHiddenText
    14981590    QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
Note: See TracChangeset for help on using the changeset viewer.