Changeset 70259 in webkit
- Timestamp:
- Oct 21, 2010 12:53:09 PM (14 years ago)
- Location:
- trunk/WebKit/qt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/qt/Api/qwebpage.cpp
r69961 r70259 1009 1009 WebCore::Frame *frame = page->focusController()->focusedOrMainFrame(); 1010 1010 WebCore::Editor *editor = frame->editor(); 1011 QInputMethodEvent::Attribute selection(QInputMethodEvent::Selection, 0, 0, QVariant());1012 1011 1013 1012 if (!editor->canEdit()) { … … 1049 1048 } 1050 1049 case QInputMethodEvent::Selection: { 1051 selection = a;1052 1050 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 } 1053 1067 break; 1054 1068 } … … 1058 1072 if (!ev->commitString().isEmpty()) 1059 1073 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()); 1076 1076 1077 1077 ev->accept(); … … 1330 1330 QString text = renderTextControl->text(); 1331 1331 RefPtr<Range> range = editor->compositionRange(); 1332 if (range) {1332 if (range) 1333 1333 text.remove(range->startPosition().offsetInContainerNode(), TextIterator::rangeLength(range.get())); 1334 }1335 1334 return QVariant(text); 1336 1335 } -
trunk/WebKit/qt/ChangeLog
r70134 r70259 1 2010-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 1 27 2010-10-20 Luiz Agostini <luiz.agostini@openbossa.org> 2 28 -
trunk/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
r69825 r70259 78 78 79 79 void acceptNavigationRequest(); 80 void infiniteLoopJS();81 80 void geolocationRequestJS(); 82 81 void loadFinished(); … … 129 128 void findText(); 130 129 void supportedContentType(); 130 void infiniteLoopJS(); 131 131 132 132 private: … … 1517 1517 QCOMPARE(selectionValue, QString("eb")); 1518 1518 1519 //Cancel current composition first1520 inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant());1521 QInputMethodEvent eventSelection2("",inputAttributes);1522 page->event(&eventSelection2);1523 1524 1519 //Set selection with negative length 1525 1520 inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 6, -5, QVariant());
Note: See TracChangeset
for help on using the changeset viewer.