diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-08-31 00:02:31 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-08-31 00:02:31 (GMT) |
commit | 6a294f8f19763c7fa9e80fcbe9b2e7d7b521e780 (patch) | |
tree | 442cfe016e92a43dd9aa9723e17b24ea45e0bce9 | |
parent | e1dd37f6b54881aef3b9e1e686dc56bb96fc14ed (diff) | |
download | Qt-6a294f8f19763c7fa9e80fcbe9b2e7d7b521e780.zip Qt-6a294f8f19763c7fa9e80fcbe9b2e7d7b521e780.tar.gz Qt-6a294f8f19763c7fa9e80fcbe9b2e7d7b521e780.tar.bz2 |
Element-at functionality
Not used yet.
-rw-r--r-- | src/declarative/fx/qfxwebview.cpp | 20 | ||||
-rw-r--r-- | src/declarative/fx/qfxwebview.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index b150ca0..cd60a76 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -1190,6 +1190,26 @@ void QFxWebView::setNewWindowParent(QFxItem *parent) d->newWindowParent = parent; } +/*! + Returns the area of the largest element at position (\a x,\a y) that is no larger + than \a maxwidth by \a maxheight pixels. + + May return an area larger in the case when no smaller element is at the position. +*/ +QRect QFxWebView::elementAreaAt(int x, int y, int maxwidth, int maxheight) const +{ + QWebHitTestResult hit = page()->mainFrame()->hitTestContent(QPoint(x,y)); + QWebElement element = hit.enclosingBlockElement(); + QWebElement parent = element.parent(); + if (maxwidth<=0) maxwidth = INT_MAX; + if (maxheight<=0) maxheight = INT_MAX; + while (!parent.isNull() && parent.geometry().width() <= maxwidth && parent.geometry().height() <= maxheight) { + element = parent; + parent = element.parent(); + } + return element.geometry(); +} + /*! diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index f084d61..29284a4 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -222,6 +222,7 @@ protected: virtual void focusChanged(bool); virtual bool sceneEvent(QEvent *event); QFxWebView *createWindow(QWebPage::WebWindowType type); + QRect elementAreaAt(int x, int y, int minwidth, int minheight) const; private: void init(); |