* Don't segfault when event pos is outside of the widget.
authortreat@webkit.org <treat@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2007 15:33:55 +0000 (15:33 +0000)
committertreat@webkit.org <treat@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2007 15:33:55 +0000 (15:33 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27904 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebpage.cpp
WebKit/qt/ChangeLog

index f8976abc9ef573e74492f06bc951e36d895f5651..98fd3951529b7fe3f006c61738fef6f9d52be8e4 100644 (file)
@@ -842,7 +842,11 @@ void QWebPage::paintEvent(QPaintEvent *ev)
 
 void QWebPage::mouseMoveEvent(QMouseEvent *ev)
 {
-    QWebFramePrivate *frame = d->currentFrame(ev->pos())->d;
+    QWebFrame *f = d->currentFrame(ev->pos());
+    if (!f)
+        return;
+
+    QWebFramePrivate *frame = f->d;
     if (!frame->frameView)
         return;
 
@@ -863,6 +867,9 @@ void QWebPage::mouseMoveEvent(QMouseEvent *ev)
 void QWebPage::mousePressEvent(QMouseEvent *ev)
 {
     d->frameUnderMouse = d->frameAt(ev->pos());
+    if (!d->frameUnderMouse)
+        return;
+
     QWebFramePrivate *frame = d->frameUnderMouse->d;
     if (!frame->eventHandler)
         return;
@@ -875,7 +882,11 @@ void QWebPage::mousePressEvent(QMouseEvent *ev)
 
 void QWebPage::mouseDoubleClickEvent(QMouseEvent *ev)
 {
-    QWebFramePrivate *frame = d->currentFrame(ev->pos())->d;
+    QWebFrame *f = d->currentFrame(ev->pos());
+    if (!f)
+        return;
+
+    QWebFramePrivate *frame = f->d;
     if (!frame->eventHandler)
         return;
 
@@ -887,21 +898,31 @@ void QWebPage::mouseDoubleClickEvent(QMouseEvent *ev)
 
 void QWebPage::mouseReleaseEvent(QMouseEvent *ev)
 {
-    QWebFramePrivate *frame = d->currentFrame(ev->pos())->d;
-    if (frame->frameView) {
-        frame->eventHandler->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
+    QWebFrame *f = d->currentFrame(ev->pos());
+    if (!f)
+        return;
 
-        //FIXME need to keep track of subframe focus for key events!
-        frame->page->setFocus();
-    }
+    QWebFramePrivate *frame = f->d;
+    if (!frame->frameView)
+        return;
+
+    frame->eventHandler->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
+
+    //FIXME need to keep track of subframe focus for key events!
+    frame->page->setFocus();
     d->frameUnderMouse = 0;
 }
 
 void QWebPage::contextMenuEvent(QContextMenuEvent *ev)
 {
-    QWebFramePrivate *frame = d->currentFrame(ev->pos())->d;
+    QWebFrame *f = d->currentFrame(ev->pos());
+    if (!f)
+        return;
+
+    QWebFramePrivate *frame = f->d;
     if (!frame->eventHandler)
         return;
+
     d->page->contextMenuController()->clearContextMenu();
     frame->eventHandler->sendContextMenuEvent(PlatformMouseEvent(ev, 1));
     ContextMenu *menu = d->page->contextMenuController()->contextMenu();
index 757f65999c2c291011f0a50064d4703675314950..dab146d999ebdbea1606565064172b45f784a4c0 100644 (file)
@@ -1,3 +1,16 @@
+2007-11-19  Adam Treat  <treat@kde.org>
+
+        Reviewed by Simon.
+
+        * Don't segfault when event pos is outside of the widget.
+
+        * Api/qwebpage.cpp:
+        (QWebPage::mouseMoveEvent):
+        (QWebPage::mousePressEvent):
+        (QWebPage::mouseDoubleClickEvent):
+        (QWebPage::mouseReleaseEvent):
+        (QWebPage::contextMenuEvent):
+
 2007-11-17  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Mark Rowe.