Changeset 72650 in webkit
- Timestamp:
- Nov 24, 2010 1:34:56 AM (13 years ago)
- Location:
- trunk/WebKit/qt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/qt/Api/qgraphicswebview.cpp
r72612 r72650 54 54 : q(parent) 55 55 , page(0) 56 , resizesToContents(false) {} 56 , resizesToContents(false) 57 , currentScene(0) {} 57 58 58 59 virtual ~QGraphicsWebViewPrivate(); … … 76 77 QWebPage* page; 77 78 bool resizesToContents; 79 QGraphicsScene* currentScene; 78 80 79 81 QGraphicsItemOverlay* overlay() const … … 253 255 QObject::connect(this, SIGNAL(scaleChanged()), this, SLOT(_q_scaleChanged())); 254 256 #endif 257 258 if (scene()) { 259 d->currentScene = scene(); 260 d->currentScene->installEventFilter(this); 261 } 255 262 } 256 263 … … 305 312 page()->mainFrame()->render(painter, QWebFrame::AllLayers, option->exposedRect.toRect()); 306 313 #endif 314 } 315 316 /*! \reimp 317 */ 318 bool QGraphicsWebView::eventFilter(QObject* object, QEvent* event) 319 { 320 if (object == d->currentScene 321 && (event->type() == QEvent::FocusIn 322 || event->type() == QEvent::FocusOut)) { 323 QFocusEvent* focusEvent = static_cast<QFocusEvent*>(event); 324 if (focusEvent->reason() == Qt::ActiveWindowFocusReason) 325 d->page->event(event); 326 } 327 return false; 307 328 } 308 329 … … 342 363 QApplication::sendEvent(this, &event); 343 364 return value; 365 } 366 case ItemSceneHasChanged: { 367 QGraphicsScene* newScene = qVariantValue<QGraphicsScene*>(value); 368 if (d->currentScene) 369 d->currentScene->removeEventFilter(this); 370 d->currentScene = newScene; 371 if (d->currentScene) 372 d->currentScene->installEventFilter(this); 344 373 } 345 374 default: -
trunk/WebKit/qt/Api/qgraphicswebview.h
r68457 r72650 141 141 virtual bool sceneEvent(QEvent*); 142 142 143 virtual bool eventFilter(QObject*, QEvent*); 144 143 145 private: 144 146 Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success)) -
trunk/WebKit/qt/ChangeLog
r72612 r72650 1 2010-11-24 Jan Erik Hanssen <jhanssen@sencha.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Html autofocus not working with QGraphicsWebView 6 https://bugs.webkit.org/show_bug.cgi?id=43169 7 8 QGraphicsScene does not propagate Qt::ActivateWindowFocusReason focus 9 events when there are no active items. 10 11 * Api/qgraphicswebview.cpp: 12 (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): 13 (QGraphicsWebView::QGraphicsWebView): 14 (QGraphicsWebView::eventFilter): 15 (QGraphicsWebView::itemChange): 16 * Api/qgraphicswebview.h: 17 * tests/qgraphicswebview/tst_qgraphicswebview.cpp: 18 (FocusPage::FocusPage): 19 (FocusPage::event): 20 (FocusPage::gotFocus): 21 (tst_QGraphicsWebView::receivesFocusInOnShow): 22 1 23 2010-11-23 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 24 -
trunk/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
r70556 r72650 37 37 void crashOnSetScaleBeforeSetUrl(); 38 38 void widgetsRenderingThroughCache(); 39 void receivesFocusInOnShow(); 39 40 }; 40 41 … … 260 261 } 261 262 263 class FocusPage : public QWebPage { 264 public: 265 FocusPage(QObject* parent = 0); 266 267 bool gotFocus() const; 268 269 protected: 270 bool event(QEvent* e); 271 272 private: 273 bool m_focus; 274 }; 275 276 FocusPage::FocusPage(QObject *parent) 277 : QWebPage(parent), m_focus(false) 278 { 279 } 280 281 bool FocusPage::event(QEvent *e) 282 { 283 if (e->type() == QEvent::FocusIn) 284 m_focus = true; 285 return QWebPage::event(e); 286 } 287 288 bool FocusPage::gotFocus() const 289 { 290 return m_focus; 291 } 292 293 void tst_QGraphicsWebView::receivesFocusInOnShow() 294 { 295 QGraphicsWebView webView; 296 webView.setHtml("<body><input type=text autofocus=autofocus></input></body>"); 297 FocusPage page; 298 webView.setPage(&page); 299 300 for (int i = 0; i < 3; ++i) { 301 QGraphicsView view; 302 QGraphicsScene* scene = new QGraphicsScene(&view); 303 view.setScene(scene); 304 scene->addItem(&webView); 305 view.setGeometry(QRect(0, 0, 500, 500)); 306 307 view.show(); 308 QTest::qWaitForWindowShown(&view); 309 310 QVERIFY(page.gotFocus()); 311 312 scene->removeItem(&webView); 313 } 314 } 262 315 263 316
Note: See TracChangeset
for help on using the changeset viewer.