aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2015-02-02 13:11:09 +0100
committerAndy Shaw <andy.shaw@digia.com>2015-02-05 06:09:53 +0000
commitf09bd9825b29612f98d884460504b07150bcb639 (patch)
treedf1e2a5f6c3c7a69022683b888c7750dee45139d
parent459a2745d49fcb9d4bc776faf034b5ababcb12a3 (diff)
Respect the text's background-color when it is set in the style in HTML
Task-number: QTBUG-36837 Change-Id: Iea85f4bc7c66124178a318f0ebd776726cf72c96 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
-rw-r--r--src/quick/items/qquicktextnodeengine.cpp7
-rw-r--r--tests/manual/scenegraph_lancelot/data/text/text_colored_background.qml14
2 files changed, 21 insertions, 0 deletions
diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp
index 707b32755b..2103764273 100644
--- a/src/quick/items/qquicktextnodeengine.cpp
+++ b/src/quick/items/qquicktextnodeengine.cpp
@@ -1027,6 +1027,13 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText
fragmentEnd += preeditLength;
}
#endif
+ if (charFormat.background().style() != Qt::NoBrush) {
+ QTextLayout::FormatRange additionalFormat;
+ additionalFormat.start = textPos - block.position();
+ additionalFormat.length = fragmentEnd - textPos;
+ additionalFormat.format = charFormat;
+ colorChanges << additionalFormat;
+ }
textPos = addText(block, charFormat, textColor, colorChanges, textPos, fragmentEnd,
selectionStart, selectionEnd);
diff --git a/tests/manual/scenegraph_lancelot/data/text/text_colored_background.qml b/tests/manual/scenegraph_lancelot/data/text/text_colored_background.qml
new file mode 100644
index 0000000000..99917355f1
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/text/text_colored_background.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+Item {
+ width: 320
+ height: 480
+
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: 16
+ color: "blue"
+ textFormat: Text.RichText
+ text: "<p style=\"background-color:red\">Lorem ipsum</p><p style=\"background-color:green\">dolor sit amet,</p> consectetur."
+ }
+}