WebKit/qt/tests/qwebview/tst_qwebview.cpp

4848
4949 void reusePage_data();
5050 void reusePage();
 51 void microFocusCoordinates();
5152
5253 void crashTests();
5354};

203204 QTRY_VERIFY(tester.m_executed); // If fail it means that the test wasn't executed.
204205}
205206
 207void tst_QWebView::microFocusCoordinates()
 208{
 209 QWebPage* page = new QWebPage;
 210 QWebView* webView = new QWebView;
 211 webView->setPage( page );
206212
 213 page->mainFrame()->setHtml("<html><body>" \
 214 "<input type='text' id='input1' style='font--family: serif' value='' maxlength='20'/><br>" \
 215 "<canvas id='canvas1' width='500' height='500'/>" \
 216 "<input type='password'/><br>" \
 217 "<canvas id='canvas2' width='500' height='500'/>" \
 218 "</body></html>");
 219
 220 page->mainFrame()->setFocus();
 221
 222 QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus);
 223 QVERIFY(initialMicroFocus.isValid());
 224
 225 page->mainFrame()->scroll(0,50);
 226 QTest::qWait(200);
 227
 228 QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus);
 229 QVERIFY(currentMicroFocus.isValid());
 230
 231 QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-50)), currentMicroFocus.toRect());
 232}
 233
207234QTEST_MAIN(tst_QWebView)
208235#include "tst_qwebview.moc"
58015

WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp

3131private slots:
3232 void qgraphicswebview();
3333 void crashOnViewlessWebPages();
 34 void microFocusCoordinates();
3435};
3536
3637void tst_QGraphicsWebView::qgraphicswebview()

102103 QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool))));
103104}
104105
 106void tst_QGraphicsWebView::microFocusCoordinates()
 107{
 108 QWebPage* page = new QWebPage;
 109 QGraphicsWebView* webView = new QGraphicsWebView;
 110 webView->setPage( page );
 111 QGraphicsView* view = new QGraphicsView;
 112 QGraphicsScene* scene = new QGraphicsScene(view);
 113 view->setScene(scene);
 114 scene->addItem(webView);
 115 view->setGeometry(QRect(0,0,500,500));
 116
 117 page->mainFrame()->setHtml("<html><body>" \
 118 "<input type='text' id='input1' style='font--family: serif' value='' maxlength='20'/><br>" \
 119 "<canvas id='canvas1' width='500' height='500'/>" \
 120 "<input type='password'/><br>" \
 121 "<canvas id='canvas2' width='500' height='500'/>" \
 122 "</body></html>");
 123
 124 page->mainFrame()->setFocus();
 125
 126 QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus);
 127 QVERIFY(initialMicroFocus.isValid());
 128
 129 page->mainFrame()->scroll(0,300);
 130
 131 QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus);
 132 QVERIFY(currentMicroFocus.isValid());
 133
 134 QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-300)), currentMicroFocus.toRect());
 135
 136 delete view;
 137}
 138
 139
105140QTEST_MAIN(tst_QGraphicsWebView)
106141
107142#include "tst_qgraphicswebview.moc"
58015

WebKit/qt/ChangeLog

 12010-04-22 John Pavan <john.pavan@nokia.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 [Qt] QWebPage::inputMethodQuery(Qt::ImMicroFocus)
 6 returns results in the coordinate system of the web page.
 7
 8 QWebPage::inputMethodQuery is modified so that it
 9 returns coordinates in the widget's coordinate system.
 10 Tests are added for QGraphicsWebView and QWebView
 11 to verify that this behavior is correct after the webpage
 12 has been scrolled.
 13
 14 * Api/qwebpage.cpp:
 15 (QWebPage::inputMethodQuery):
 16 * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
 17 (tst_QGraphicsWebView::microFocusCoordinates):
 18 * tests/qwebview/tst_qwebview.cpp:
 19 (tst_QWebView::microFocusCoordinates):
 20
1212010-04-22 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
222
323 Reviewed by Kenneth Rohde Christiansen.
58102

WebKit/qt/Api/qwebpage.cpp

14371437 // We can't access absoluteCaretBounds() while the view needs to layout.
14381438 return QVariant();
14391439 }
1440  return QVariant(frame->selection()->absoluteCaretBounds());
 1440 return QVariant( view->contentsToWindow( frame->selection()->absoluteCaretBounds() ) );
14411441 }
14421442 case Qt::ImFont: {
14431443 if (renderTextControl) {
58015