summaryrefslogtreecommitdiffstats
path: root/src/core/render_widget_host_view_qt.cpp
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2016-08-23 13:32:55 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2016-09-23 05:34:16 +0000
commitdd7917e0203a9144719214c5a5d36fcd7a0b6f93 (patch)
tree1ab6c2d6d4ef0d43e663e30bc59cc3b538456030 /src/core/render_widget_host_view_qt.cpp
parenta4dcc5b4894aac423f65fcf9a13394078ee72257 (diff)
Add support of colored underline and background to InputMethodEvent
Moreover, unskip and update inputMethodsTextFormat widget auto test and move it to the tst_QWebEngineView tests. New manual test has been also added for testing input methods format. Task-number: QTBUG-55766 Change-Id: I4c71e15cb426925f76c770266a3c20f1cc12b687 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r--src/core/render_widget_host_view_qt.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 77fd55aab..097dda1cd 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -1026,7 +1026,25 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
int start = qMin(attribute.start, (attribute.start + attribute.length));
int end = qMax(attribute.start, (attribute.start + attribute.length));
- underlines.push_back(blink::WebCompositionUnderline(start, end, /*color*/ SK_ColorBLACK, /*thick*/ false, /*backgroundColor*/ SK_ColorTRANSPARENT));
+
+ // Blink does not support negative position values. Adjust start and end positions
+ // to non-negative values.
+ if (start < 0) {
+ start = 0;
+ end = qMax(0, start + end);
+ }
+
+ QTextCharFormat format = qvariant_cast<QTextFormat>(attribute.value).toCharFormat();
+
+ QColor underlineColor(0, 0, 0, 0);
+ if (format.underlineStyle() != QTextCharFormat::NoUnderline)
+ underlineColor = format.underlineColor();
+
+ QColor backgroundColor(0, 0, 0, 0);
+ if (format.background().style() != Qt::NoBrush)
+ backgroundColor = format.background().color();
+
+ underlines.push_back(blink::WebCompositionUnderline(start, end, toSk(underlineColor), /*thick*/ false, toSk(backgroundColor)));
break;
}
case QInputMethodEvent::Cursor: