From feed8bf3d12bb4050a7b10d2b4d4608021d52959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Thu, 24 May 2018 12:19:56 +0200 Subject: Return invalid ImCursorRectangle when height is zero The test tst_QWebEngineView::microFocusCoordinates is flaky due to a timing issue where TextInputManager::GetSelectionRegion() returns a selection rectangle with zero height if called too soon after the HTMLElement.focus() call. Change-Id: Iba52eadd6c2d4f9027284fedbff40c3fcc951a28 Reviewed-by: Peter Varga --- src/core/render_widget_host_view_qt.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core/render_widget_host_view_qt.cpp') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 695e9cc74..9424b2ae4 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1140,10 +1140,12 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) case Qt::ImCursorRectangle: { if (text_input_manager_) { if (auto *region = text_input_manager_->GetSelectionRegion()) { - gfx::Rect caretRect = gfx::RectBetweenSelectionBounds(region->anchor, region->focus); - if (caretRect.width() == 0) - caretRect.set_width(1); // IME API on Windows expects a width > 0 - return toQt(caretRect); + if (region->focus.GetHeight() > 0) { + gfx::Rect caretRect = gfx::RectBetweenSelectionBounds(region->anchor, region->focus); + if (caretRect.width() == 0) + caretRect.set_width(1); // IME API on Windows expects a width > 0 + return toQt(caretRect); + } } } return QVariant(); -- cgit v1.2.3