summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Ottaviano <lottaviano@develer.com>2014-01-09 10:15:14 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-15 13:40:09 +0100
commit4c10389c55ef4d78076478bfda72060bf7de8e69 (patch)
tree6f3aff65c0d73ec417e6bfcb8a819e33fbcd10a7
parent9b0de4a45f7172710d5722ff302d43efde2c5365 (diff)
Ensure that cursor rectangle is always valid.
The cursor rectangle is given an invalid size when the user clicks on an input field; the reported size is 0 pixel wide. The cursor is then converted to a QRect, which is invalid if rectangle width is 0. This can interefere with input methods that check for cursorRect validity before reporting a cursorRect change. Make sure that a cursor rectangle with at least one valid dimension becomes a valid QRect. Task-number: QTBUG-35996 Change-Id: I4026f1136cfb006efc5d7915f0f10c1b5187c730 Signed-off-by: Luca Ottaviano <lottaviano@develer.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebPage.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
index b25bd0245..6d75b2b83 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -663,8 +663,20 @@ EditorState WebPage::editorState() const
result.selectedText = range->text();
}
- if (range)
+ if (range) {
result.cursorRect = frame->view()->contentsToWindow(frame->editor().firstRectForRange(range.get()));
+ // Check that at least one dimension is valid
+ if (result.cursorRect.width() != 0 || result.cursorRect.height() != 0)
+ {
+ if (result.cursorRect.width() == 0)
+ result.cursorRect.setWidth(1);
+ if (result.cursorRect.height() == 0)
+ result.cursorRect.setHeight(1);
+ }
+ // now adjust the cursor coordinates to take scrolling into account
+ result.cursorRect.moveBy(-frame->view()->visibleContentRect().location());
+ }
+
// FIXME: We should only transfer innerText when it changes and do this on the UI side.
if (result.isContentEditable && !result.isInPasswordField) {