QVariantMap JavascriptInvocation::clickPosition(QWebElement element, int left, int top, int width, int height) {
  QRect elementBox(left, top, width, height);
  QRect viewport(QPoint(0, 0), m_page->viewportSize());
  QRect boundedBox = elementBox.intersected(viewport);
  QPoint mousePos = boundedBox.center();

  QVariantMap m;
  m["relativeX"] = mousePos.x();
  m["relativeY"] = mousePos.y();

  QWebFrame *parent = element.webFrame();
  while (parent) {
    elementBox.translate(parent->geometry().topLeft());
    parent = parent->parentFrame();
  }

  boundedBox = elementBox.intersected(viewport);
  mousePos = boundedBox.center();

  m["absoluteX"] = mousePos.x();
  m["absoluteY"] = mousePos.y();

  return m;
}
Пример #2
0
bool WebPage::clickTest(QWebElement element, int absoluteX, int absoluteY) {
  QPoint mousePos(absoluteX, absoluteY);
  m_mousePosition = mousePos;
  QWebHitTestResult res = mainFrame()->hitTestContent(mousePos);
  return res.frame() == element.webFrame();
}
Пример #3
0
void ChatController::handleElement(const QWebElement &element)
{
    setPage(element.webFrame()->page());
}
bool JavascriptInvocation::clickTest(QWebElement element, int absoluteX, int absoluteY) {
  QPoint mousePos(absoluteX, absoluteY);
  QWebHitTestResult res = m_page->mainFrame()->hitTestContent(mousePos);
  return res.frame() == element.webFrame();
}