Change hoveringOverLink implementation to have less issues.
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2008 09:56:20 +0000 (09:56 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2008 09:56:20 +0000 (09:56 +0000)
* Currently we only compare a pointer. In the worst case we
  could delete the Element we have pointed to and a new one
  gets the same address. But even if that doesn't happen the
  WebCore::Element is mutable and JavaScript could change the
  URL, Title or Content. So we have to compare all these three
  attributes.
* This does not seem to be a performance impact.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29520 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index 88311994fade05072d5849e9ec656e0422d60dd4..4e346239ef273e9900ec316797ce9d70e2b9b2da 100644 (file)
@@ -107,7 +107,6 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions)
 QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
     : q(qq)
     , view(0)
-    , lastHoverElement(0)
     , modified(false)
 {
     chromeClient = new ChromeClientQt(q);
@@ -340,10 +339,14 @@ void QWebPagePrivate::mouseMoveEvent(QMouseEvent *ev)
         mainFrame->d->verticalScrollBar() ? mainFrame->d->verticalScrollBar()->value() : 0;
     IntPoint pt(ev->x() + xOffset, ev->y() + yOffset);
     WebCore::HitTestResult result = QWebFramePrivate::core(mainFrame)->eventHandler()->hitTestResultAtPoint(pt, false);
-    WebCore::Element *link = result.URLElement();
-    if (link != lastHoverElement) {
-        lastHoverElement = link;
-        emit q->hoveringOverLink(result.absoluteLinkURL().prettyURL(), result.title(), result.textContent());
+
+    if (result.absoluteLinkURL() != lastHoverURL
+        || result.title() != lastHoverTitle
+        || result.textContent() != lastHoverContent) {
+        lastHoverURL = result.absoluteLinkURL();
+        lastHoverTitle = result.title();
+        lastHoverContent = result.textContent();
+        emit q->hoveringOverLink(lastHoverURL.prettyURL(), lastHoverTitle, lastHoverContent);
     }
 }
 
index f87d5ad36f3b64c7dcc04b6cb7aff6fa5b550d6e..26457a1fd6f869ff5cc40d34cb7c0238b96b04f0 100644 (file)
@@ -29,6 +29,9 @@
 #include "qwebhistory.h"
 #include "qwebframe.h"
 
+#include "KURL.h"
+#include "PlatformString.h"
+
 #include <wtf/RefPtr.h>
 
 namespace WebCore
@@ -126,7 +129,10 @@ public:
     QWebPage *q;
     QUndoStack *undoStack;
     QWidget *view;
-    WebCore::Element *lastHoverElement;
+
+    WebCore::KURL lastHoverURL;
+    WebCore::String lastHoverTitle;
+    WebCore::String lastHoverContent;
 
     bool modified;
 
index ec5eeb6777ace0ba3bc0ceecab10221522bf8a25..d9bdb0372dfbf17d9fb5f4daa716b490d523fb96 100644 (file)
@@ -1,3 +1,22 @@
+2008-01-16  Holger Freyther  <holger.freyther@trolltech.com>
+
+        Reviewed by Simon.
+
+        Change hoveringOverLink implementation to have less issues.
+        
+        * Currently we only compare a pointer. In the worst case we
+        could delete the Element we have pointed to and a new one
+        gets the same address. But even if that doesn't happen the
+        WebCore::Element is mutable and JavaScript could change the
+        URL, Title or Content. So we have to compare all these three
+        attributes.
+        * This does not seem to be a performance impact.
+        
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::mouseMoveEvent):
+        * Api/qwebpage_p.h:
+
 2008-01-16  Holger Freyther  <holger.freyther@trolltech.com>
 
         Reviewed by Simon.