Changeset 70259 in webkit


Ignore:
Timestamp:
Oct 21, 2010 12:53:09 PM (14 years ago)
Author:
robert@webkit.org
Message:

2010-10-21 Robert Hogan <robert@webkit.org>

Reviewed by Simon Hausmann.

[Qt] Sending a QInputMethodEvent::Selection event forces the

Editor to go into Composition mode

Improve QWebPage handling of input method events:

  • Selections don't trigger entering composition mode.
  • Handle multiple selections

Also remove redundant cancellation of composition in tst_qwebpage.
There is no composition in progress at that point.

Finally, move infiniteLoopJS() to the end of the tst_qwebpage unit
tests - so you don't have to wait for it to complete when running
other tests.

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

  • Api/qwebpage.cpp: (QWebPagePrivate::inputMethodEvent): (QWebPage::inputMethodQuery):
  • 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

    r69961 r70259  
    10091009    WebCore::Frame *frame = page->focusController()->focusedOrMainFrame();
    10101010    WebCore::Editor *editor = frame->editor();
    1011     QInputMethodEvent::Attribute selection(QInputMethodEvent::Selection, 0, 0, QVariant());
    10121011
    10131012    if (!editor->canEdit()) {
     
    10491048        }
    10501049        case QInputMethodEvent::Selection: {
    1051             selection = a;
    10521050            hasSelection = true;
     1051            // A selection in the inputMethodEvent is always reflected in the visible text
     1052            if (renderTextControl) {
     1053                renderTextControl->setSelectionStart(qMin(a.start, (a.start + a.length)));
     1054                renderTextControl->setSelectionEnd(qMax(a.start, (a.start + a.length)));
     1055            }
     1056
     1057            if (!ev->preeditString().isEmpty()) {
     1058                editor->setComposition(ev->preeditString(), underlines,
     1059                                      (a.length < 0) ? a.start + a.length : a.start,
     1060                                      (a.length < 0) ? a.start : a.start + a.length);
     1061            } else {
     1062                // If we are in the middle of a composition, an empty pre-edit string and a selection of zero
     1063                // cancels the current composition
     1064                if (editor->hasComposition() && (a.start + a.length == 0))
     1065                    editor->setComposition(QString(), underlines, 0, 0);
     1066            }
    10531067            break;
    10541068        }
     
    10581072    if (!ev->commitString().isEmpty())
    10591073        editor->confirmComposition(ev->commitString());
    1060     else {
    1061         // 1. empty preedit with a selection attribute, and start/end of 0 cancels composition
    1062         // 2. empty preedit with a selection attribute, and start/end of non-0 updates selection of current preedit text
    1063         // 3. populated preedit with a selection attribute, and start/end of 0 or non-0 updates selection of supplied preedit text
    1064         // 4. otherwise event is updating supplied pre-edit text
    1065         QString preedit = ev->preeditString();
    1066         if (hasSelection) {
    1067             QString text = (renderTextControl) ? QString(renderTextControl->text()) : QString();
    1068             if (preedit.isEmpty() && selection.start + selection.length > 0)
    1069                 preedit = text;
    1070             editor->setComposition(preedit, underlines,
    1071                                    (selection.length < 0) ? selection.start + selection.length : selection.start,
    1072                                    (selection.length < 0) ? selection.start : selection.start + selection.length);
    1073         } else if (!preedit.isEmpty())
    1074             editor->setComposition(preedit, underlines, preedit.length(), 0);
    1075     }
     1074    else if (!hasSelection && !ev->preeditString().isEmpty())
     1075        editor->setComposition(ev->preeditString(), underlines, 0, ev->preeditString().length());
    10761076
    10771077    ev->accept();
     
    13301330                QString text = renderTextControl->text();
    13311331                RefPtr<Range> range = editor->compositionRange();
    1332                 if (range) {
     1332                if (range)
    13331333                    text.remove(range->startPosition().offsetInContainerNode(), TextIterator::rangeLength(range.get()));
    1334                 }
    13351334                return QVariant(text);
    13361335            }
  • trunk/WebKit/qt/ChangeLog

    r70134 r70259  
     12010-10-21  Robert Hogan  <robert@webkit.org>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Sending a QInputMethodEvent::Selection event forces the
     6             Editor to go into Composition mode
     7
     8        Improve QWebPage handling of input method events:
     9         - Selections don't trigger entering composition mode.
     10         - Handle multiple selections
     11
     12        Also remove redundant cancellation of composition in tst_qwebpage.
     13        There is no composition in progress at that point.
     14
     15        Finally, move infiniteLoopJS() to the end of the tst_qwebpage unit
     16        tests - so you don't have to wait for it to complete when running
     17        other tests.
     18
     19        https://bugs.webkit.org/show_bug.cgi?id=39625
     20
     21        * Api/qwebpage.cpp:
     22        (QWebPagePrivate::inputMethodEvent):
     23        (QWebPage::inputMethodQuery):
     24        * tests/qwebpage/tst_qwebpage.cpp:
     25        (tst_QWebPage::inputMethods):
     26
    1272010-10-20  Luiz Agostini  <luiz.agostini@openbossa.org>
    228
  • trunk/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r69825 r70259  
    7878
    7979    void acceptNavigationRequest();
    80     void infiniteLoopJS();
    8180    void geolocationRequestJS();
    8281    void loadFinished();
     
    129128    void findText();
    130129    void supportedContentType();
     130    void infiniteLoopJS();
    131131   
    132132private:
     
    15171517    QCOMPARE(selectionValue, QString("eb"));
    15181518
    1519     //Cancel current composition first
    1520     inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant());
    1521     QInputMethodEvent eventSelection2("",inputAttributes);
    1522     page->event(&eventSelection2);
    1523 
    15241519    //Set selection with negative length
    15251520    inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 6, -5, QVariant());
Note: See TracChangeset for help on using the changeset viewer.