Skip to content

Commit d115841

Browse files
committed
fixed truncation location mouse position
1 parent 0c66102 commit d115841

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/webdriver/extension_qt/graphics_web_view_executor.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <QtGui/QApplication>
2222
#endif
2323

24+
#include <cmath>
2425

2526
namespace webdriver {
2627

@@ -443,6 +444,10 @@ void GraphicsWebViewCmdExecutor::ClickElement(const ElementId& element, Error**
443444

444445
*error = webkitProxy_->GetClickableLocation(element, &location);
445446
if (!(*error)) {
447+
// consider truncation, round up value
448+
location.setX(std::ceil(location.x()));
449+
location.setY(std::ceil(location.y()));
450+
446451
session_->logger().Log(kFineLogLevel,
447452
base::StringPrintf("ClickElement at pos (%f, %f).", location.x(), location.y()));
448453
session_->set_mouse_position(location);

src/webdriver/extension_qt/qml_web_view_executor.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <QtGui/QStyleOptionGraphicsItem>
1717
#include <QtGui/QApplication>
1818

19+
#include <cmath>
20+
1921
namespace webdriver {
2022

2123
#define CHECK_VIEW_EXISTANCE \
@@ -408,6 +410,10 @@ void QmlWebViewCmdExecutor::ClickElement(const ElementId& element, Error** error
408410

409411
*error = webkitProxy_->GetClickableLocation(element, &location);
410412
if (!(*error)) {
413+
// consider truncation, round up value
414+
location.setX(std::ceil(location.x()));
415+
location.setY(std::ceil(location.y()));
416+
411417
session_->logger().Log(kFineLogLevel,
412418
base::StringPrintf("ClickElement at pos (%f, %f).", location.x(), location.y()));
413419
session_->set_mouse_position(location);

src/webdriver/extension_qt/web_view_executor.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
#endif
3333

3434
#define _USE_MATH_DEFINES
35-
#include <math.h>
35+
#include <cmath>
36+
3637
class QNetworkCookie;
3738
namespace webdriver {
3839

@@ -395,6 +396,10 @@ void QWebViewCmdExecutor::ClickElement(const ElementId& element, Error** error)
395396

396397
*error = webkitProxy_->GetClickableLocation(element, &location);
397398
if (!(*error)) {
399+
// consider truncation, round up value
400+
location.setX(std::ceil(location.x()));
401+
location.setY(std::ceil(location.y()));
402+
398403
session_->logger().Log(kFineLogLevel,
399404
base::StringPrintf("ClickElement at pos (%f, %f).", location.x(), location.y()));
400405
session_->set_mouse_position(location);

0 commit comments

Comments
 (0)