summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-06-24 14:04:39 +0200
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-06-26 00:48:07 +0200
commit4ff43880b4f6dcb4e1f3d8d38b32a96da2b80c6c (patch)
treeeba6dfddda14fed6d649976763b8532e538476fa
parentfbc21ad9ad6dc659f2150a89c4d903c612319781 (diff)
QWebHitTestResult::element() should return the inner element
QWebHitTestResult::element() currently only returns a non-null result if the innernode happens to be an element. This means it will never contain anything when hittesting over text. This patch changes QWebHitTestResult::element() to instead return the inner element. Task-number: QTBUG-39591 Change-Id: Ic00f30d0b6429f2bcfb47f6e386be7d890d45bfb Reviewed-by: Michael Bruning <michael.bruning@digia.com>
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp10
-rw-r--r--Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp1
2 files changed, 8 insertions, 3 deletions
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
index 5385b05d9..dafb0e287 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
@@ -924,9 +924,13 @@ QWebHitTestResultPrivate::~QWebHitTestResultPrivate()
QWebElement QWebHitTestResultPrivate::elementForInnerNode() const
{
- if (!innerNonSharedNode || !innerNonSharedNode->isElementNode())
- return QWebElement();
- return QWebElement(toElement(innerNonSharedNode));
+ // Uses the similar logic as HitTestResult::innerElement().
+ for (Node* node = innerNonSharedNode; node; node = node->parentNode()) {
+ if (node->isElementNode())
+ return QWebElement(toElement(node));
+ }
+
+ return QWebElement();
}
// ======================================================
diff --git a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index f852149d4..f792befcd 100644
--- a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -664,6 +664,7 @@ void tst_QWebFrame::hitTestContent()
QCOMPARE(result.linkText(), QString("link text"));
QWebElement link = result.linkElement();
QCOMPARE(link.attribute("target"), QString("_foo"));
+ QCOMPARE(result.element().tagName(), QString("A"));
}
void tst_QWebFrame::baseUrl_data()