Changeset 72471 in webkit


Ignore:
Timestamp:
Nov 20, 2010 12:15:10 AM (13 years ago)
Author:
andreas.kling@nokia.com
Message:

2010-11-19 Kristian Amlie <kristian.amlie@nokia.com>

Reviewed by Andreas Kling.

Fixed handling of QInputMethodEvents with nonzero replacementLength.

These types of events replace text that is already in the widget, but
WebKit did not check for replacementLength at all.

Also made sure that the preeditString is always respected, even if
there is committed text. This is how QLineEdit does it.

https://bugs.webkit.org/show_bug.cgi?id=49787

  • Api/qwebpage.cpp: (QWebPagePrivate::inputMethodEvent):
  • tests/qwebpage/tst_qwebpage.cpp: (tst_QWebPage::inputMethods):
Location:
trunk/WebKit/qt
Files:
3 edited

Legend:

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

    r72370 r72471  
    10811081    }
    10821082
    1083     if (!ev->commitString().isEmpty())
     1083    if (node && ev->replacementLength() > 0) {
     1084        int cursorPos = frame->selection()->extent().offsetInContainerNode();
     1085        int start = cursorPos + ev->replacementStart();
     1086        setSelectionRange(node, start, start + ev->replacementLength());
     1087        // Commit regardless of whether commitString is empty, to get rid of selection.
    10841088        editor->confirmComposition(ev->commitString());
    1085     else if (!hasSelection && !ev->preeditString().isEmpty())
     1089    } else if (!ev->commitString().isEmpty())
     1090        editor->confirmComposition(ev->commitString());
     1091    if (!hasSelection && !ev->preeditString().isEmpty())
    10861092        editor->setComposition(ev->preeditString(), underlines, 0, 0);
    10871093
  • trunk/WebKit/qt/ChangeLog

    r72467 r72471  
     12010-11-19  Kristian Amlie  <kristian.amlie@nokia.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        Fixed handling of QInputMethodEvents with nonzero replacementLength.
     6
     7        These types of events replace text that is already in the widget, but
     8        WebKit did not check for replacementLength at all.
     9
     10        Also made sure that the preeditString is always respected, even if
     11        there is committed text. This is how QLineEdit does it.
     12
     13        https://bugs.webkit.org/show_bug.cgi?id=49787
     14
     15        * Api/qwebpage.cpp:
     16        (QWebPagePrivate::inputMethodEvent):
     17        * tests/qwebpage/tst_qwebpage.cpp:
     18        (tst_QWebPage::inputMethods):
     19
    1202010-11-19  Benjamin Poulain  <benjamin.poulain@nokia.com>
    221
  • trunk/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r72370 r72471  
    15691569    page->event(&evrel);
    15701570
     1571    {
     1572        QList<QInputMethodEvent::Attribute> attributes;
     1573        QInputMethodEvent event(QString(), attributes);
     1574        event.setCommitString("XXX", 0, 0);
     1575        page->event(&event);
     1576        event.setCommitString(QString(), -2, 2); // Erase two characters.
     1577        page->event(&event);
     1578        event.setCommitString(QString(), -1, 1); // Erase one character.
     1579        page->event(&event);
     1580        variant = page->inputMethodQuery(Qt::ImSurroundingText);
     1581        value = variant.value<QString>();
     1582        QCOMPARE(value, QString("QtWebKit"));
     1583    }
     1584
    15711585    //Move to the start of the line
    15721586    page->triggerAction(QWebPage::MoveToStartOfLine);
Note: See TracChangeset for help on using the changeset viewer.