diff options
-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(); |