Changeset 39232 in webkit
- Timestamp:
- Dec 12, 2008, 1:42:16 AM (16 years ago)
- Location:
- trunk/WebKit/qt
- Files:
-
- 3 edited
-
Api/qwebpage.cpp (modified) (2 diffs)
-
ChangeLog (modified) (1 diff)
-
tests/qwebframe/tst_qwebframe.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/qt/Api/qwebpage.cpp
r39210 r39232 730 730 void QWebPagePrivate::focusInEvent(QFocusEvent *ev) 731 731 { 732 if (ev->reason() == Qt::PopupFocusReason)733 return;734 735 732 FocusController *focusController = page->focusController(); 736 733 Frame *frame = focusController->focusedFrame(); … … 745 742 void QWebPagePrivate::focusOutEvent(QFocusEvent *ev) 746 743 { 747 if (ev->reason() == Qt::PopupFocusReason)748 return;749 750 744 // only set the focused frame inactive so that we stop painting the caret 751 745 // and the focus frame. But don't tell the focus controller so that upon -
trunk/WebKit/qt/ChangeLog
r39231 r39232 1 2008-12-11 Enrico Ros <enrico.ros@m31.com> 2 3 Reviewed by Simon Hausmann. 4 5 Fix the broken focus behavior that happened when QWebPage lost 6 focus to a popup menu. 7 8 The previous code didn't notify the QWebPage at all when the 9 focus was back in (breaking focus rects, caret blinking, ...). 10 By the way when a popup is show, 2 FocusOut events are delivered 11 to the QWebPage, but this doesn't seem to hurt. 12 13 Added a test to check popup opening, closing a lineedit blinks. 14 15 * Api/qwebpage.cpp: 16 (QWebPagePrivate::focusInEvent): 17 (QWebPagePrivate::focusOutEvent): 18 * tests/qwebframe/tst_qwebframe.cpp: 19 (tst_QWebFrame::): 20 1 21 2008-12-11 Ariya Hidayat <ariya.hidayat@trolltech.com> 2 22 -
trunk/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
r38947 r39232 26 26 #include <qwebframe.h> 27 27 #include <qwebhistory.h> 28 #include <QAbstractItemView> 29 #include <QApplication> 30 #include <QComboBox> 28 31 #include <QRegExp> 29 32 #include <QNetworkRequest> … … 539 542 tst_QWebFrame(); 540 543 virtual ~tst_QWebFrame(); 544 bool eventFilter(QObject* watched, QEvent* event); 541 545 542 546 public slots: … … 568 572 void ipv6HostEncoding(); 569 573 void metaData(); 574 void popupFocus(); 570 575 private: 571 576 QString evalJS(const QString&s) { … … 613 618 return ret; 614 619 } 620 QObject* firstChildByClassName(QObject* parent, const char* className) { 621 const QObjectList & children = parent->children(); 622 foreach (QObject* child, children) { 623 if (!strcmp(child->metaObject()->className(), className)) { 624 return child; 625 } 626 } 627 return 0; 628 } 615 629 616 630 const QString sTrue; … … 628 642 QWebPage* m_page; 629 643 MyQObject* m_myObject; 644 QWebView* m_popupTestView; 645 int m_popupTestPaintCount; 630 646 }; 631 647 632 648 tst_QWebFrame::tst_QWebFrame() 633 649 : sTrue("true"), sFalse("false"), sUndefined("undefined"), sArray("array"), sFunction("function"), sError("error"), 634 sString("string"), sObject("object"), sNumber("number") 650 sString("string"), sObject("object"), sNumber("number"), m_popupTestView(0), m_popupTestPaintCount(0) 635 651 { 636 652 } … … 638 654 tst_QWebFrame::~tst_QWebFrame() 639 655 { 656 } 657 658 bool tst_QWebFrame::eventFilter(QObject* watched, QEvent* event) 659 { 660 // used on the popupFocus test 661 if (watched == m_popupTestView) { 662 if (event->type() == QEvent::Paint) 663 m_popupTestPaintCount++; 664 } 665 return QObject::eventFilter(watched, event); 640 666 } 641 667 … … 2174 2200 } 2175 2201 2202 void tst_QWebFrame::popupFocus() 2203 { 2204 QWebView view; 2205 view.setHtml("<html>" 2206 " <body>" 2207 " <select name=\"select\">" 2208 " <option>1</option>" 2209 " <option>2</option>" 2210 " </select>" 2211 " <input type=\"text\"> </input>" 2212 " <textarea name=\"text_area\" rows=\"3\" cols=\"40\">" 2213 "This test checks whether showing and hiding a popup" 2214 "takes the focus away from the webpage." 2215 " </textarea>" 2216 " </body>" 2217 "</html>"); 2218 view.resize(400, 100); 2219 view.show(); 2220 view.setFocus(); 2221 QTest::qWait(200); 2222 QVERIFY2(view.hasFocus(), 2223 "The WebView should be created"); 2224 2225 // open the popup by clicking. check if focus is on the popup 2226 QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(25, 25)); 2227 QObject* webpopup = firstChildByClassName(&view, "WebCore::QWebPopup"); 2228 QComboBox* combo = dynamic_cast<QComboBox*>(webpopup); 2229 QTest::qWait(1); 2230 QVERIFY2(!view.hasFocus() && combo->view()->hasFocus(), 2231 "Focus sould be on the Popup"); 2232 2233 // hide the popup and check if focus is on the page 2234 combo->hidePopup(); 2235 QTest::qWait(1); 2236 QVERIFY2(view.hasFocus() && !combo->view()->hasFocus(), 2237 "Focus sould be back on the WebView"); 2238 2239 // focus the lineedit and check if it blinks 2240 QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(200, 25)); 2241 m_popupTestView = &view; 2242 view.installEventFilter( this ); 2243 QTest::qWait(2000); 2244 QVERIFY2(m_popupTestPaintCount >= 4, 2245 "The input field should have a blinking caret"); 2246 } 2247 2176 2248 QTEST_MAIN(tst_QWebFrame) 2177 2249 #include "tst_qwebframe.moc"
Note:
See TracChangeset
for help on using the changeset viewer.