aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextnodeengine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-24/+24
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of most QT_NO_FOO usagesLars Knoll2016-11-291-3/+3
| | | | | | | | Instead use QT_CONFIG(foo). This change actually detected a few mis-spelled macros and invalid usages. Change-Id: I06ac327098dd1a458e6bc379d637b8e2dac52f85 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix flow text objects in beginning of RTL blockEskil Abrahamsen Blomfeldt2016-11-141-1/+6
| | | | | | | | | | | | | If the block is right-to-left and starts with a text object, it should be aligned to the right edge of the QTextLine instead of the left one. [ChangeLog][QtQuick][Text] Fixed placement of flowing text objects in the start of a right-to-left block. Task-number: QTBUG-43133 Change-Id: Id790e88f3464280f124c38b4260386b84cac8826 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQuickTextNode: Minor cleanupRobin Burchell2016-07-111-18/+18
| | | | | | | Move decorations to QQuickTextNodeEngine, as the only place that uses them. Change-Id: I7d0b2bf8979bf5d7e447beac02c3419da4edb759 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-06-131-1/+4
|\ | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp Change-Id: I26d6435a29cac3840bb567ade5149c2562a94bf9
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-06-101-1/+4
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of 0e053528 was reverted in the merge, about lastTimestamp. It will be applied later in separate commit. qmltest::shadersource-dynamic-sourceobject::test_endresult() was blacklisted on linux. Conflicts: .qmake.conf tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp tests/auto/qmltest/BLACKLIST tests/auto/qmltest/qmltest.pro Task-number: QTBUG-53590 Task-number: QTBUG-53971 Change-Id: I48af90b49a3c7b29de16f4178a04807f8bc05130
| | * QQuickTextNodeEngine: early out if no document layout.Edward Welbourne2016-06-011-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | As Coverity (CID 22302) points out, qobject_cast<> can return NULL; if we don't get a document layout, then we have no frame decorations to add to it. Change-Id: I2cd428456b3a3b24a28a5dd18ce948a8e95d21cb Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | | QQuickTextNodeEngine: Use correct boundingRect when merging nodesAndy Nichols2016-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Use the transformed QRectF of otherNode instead of the untransformed boundingRect of the QGlyphRun. Change-Id: Ie2a97cccee45e2b924c2f599d8d3855aa85a4713 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* | | QQuickTextNodeEngine: Update boundingRects when merging nodesAndy Nichols2016-03-031-0/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QGlyphRun has the behavior that it will calculate it's boundingRect based on the united rects of its contained glyphs unless a boundingRect has been previously set. In the case of QQuickTextNodeEngine the QGlphyRuns are coming from lines in a QTextDocument which would have already had setBoundingRect called. For the QGlyphRun that results from the merging of text nodes to have the correct boundingRect we would need set the united boundingRects of the nodes merged. This could go overlooked with the default renderer because it doesn't need to know the boundingRect of the QGlyphRun to render accurately. However this detail is important for partial update support with Qt Quick 2D Renderer. Change-Id: I4a5bd20afcfadf6cb0ad0659f9a797a980b47a81 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-02-191-3/+4
|\| | | | | | | | | | | | | | | | | Conflicts: src/quick/items/qquickitem.cpp tests/auto/quick/qquickgridview/tst_qquickgridview.cpp tests/auto/quick/qquicklistview/tst_qquicklistview.cpp Change-Id: I3cf47faa2fe567d62fffd985aeecbefe5811cc42
| * Fix off-by-one when checking overlaps in selection rangesEskil Abrahamsen Blomfeldt2016-02-171-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was found while researching QTBUG-49596. The selection ranges in the QGlyphRun are inclusive, so the length needs to be end - start + 1. For a node of 1 glyph with either preceding or succeeding node, we would detect an overlap always, since the initial rangeLength would be 0. This is reproduced by the textinput_selected_fallback_font.qml test, but the bug was hidden by a different bug in QTextLayout. Change-Id: I65d70b1223eebeb5cfbb277fade7f4753465364f Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-191-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Move QQuickTextDocumentWithImageResources out of qquicktext_p_p.hJ-P Nurmi2015-10-291-1/+2
| | | | | | | | | | | | | | QQuickTextDocumentWithImageResources was autotest-exported in b63185. The problem is that the QQuickLabel in qtquickcontrols2 inherits QQuickText, and therefore includes the private header. An autotest- exported class with Q_OBJECT macro leads to a linking error: qquickcontrol.obj : error LNK2019: unresolved external symbol "public: static struct TestNamespace::QMetaObject const TestNamespace::QQuickTextDocumentWithImageResources::staticMetaObject" (?staticMetaObject@QQuickTextDocumentWithImageResources@TestNamespace@@2UQMetaObject@2@B) referenced in function "public: static class TestNamespace::QString __cdecl TestNamespace::QQuickTextDocumentWithImageResources::tr(char const *,char const *,int)" (?tr@QQuickTextDocumentWithImageResources@TestNamespace@@SA?AVQString@2@PBD0H@Z) qquicklabel.obj : error LNK2001: unresolved external symbol "public: static struct TestNamespace::QMetaObject const TestNamespace::QQuickTextDocumentWithImageResources::staticMetaObject" (?staticMetaObject@QQuickTextDocumentWithImageResources@TestNamespace@@2UQMetaObject@2@B) ..\..\lib\Qt5LabsTemplatesTestInfix.dll : fatal error LNK1120: 1 unresolved externals Change-Id: I7e8731973c4ad67fca40f87bf009dc55336c3d6f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into 5.6Ulf Hermann2015-08-181-9/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/debugger/qv4debugservice.cpp src/qml/jsruntime/qv4value_inl_p.h src/qml/jsruntime/qv4value_p.h src/qml/memory/qv4mm.cpp src/qml/memory/qv4mm_p.h src/qml/qml/qqmlnotifier_p.h src/qml/qml/qqmlproperty.cpp src/quick/items/qquickflickable.cpp src/quick/items/qquicktextedit.cpp tests/auto/quick/qquickwindow/BLACKLIST The extra changes in qqmlbinding.cpp are ported from changes to qqmlproperty.cpp that occurred in parallel with writeBinding() being moved to qqmlbinding.cpp. Change-Id: I16d1920abf448c29a01822256f52153651a56356
| * Fix selecting single character in middle of stringEskil Abrahamsen Blomfeldt2015-08-031-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix for QTBUG-46829 revealed a bug in the code to handle selecting part of ligatures. The ranges were assumed to be [start, end], while they are in fact [start, end>. This would cause the engine to assume the previous node overlapped completely with the selected node and that the node had thus already been added to the graph. Due to the bug in QTBUG-46829, this accidentally worked before, but when that bug was fixed, this bug appeared. Change-Id: I517d260de9f58db4504dd4320b7113fbbe305a81 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
| * Fix disappearing selection spanning different scriptsEskil Abrahamsen Blomfeldt2015-08-031-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the way itemization is currently done in Qt, Cyrillic text (and other writing systems) separated by spaces will become separate items because the spaces are itemized as Script_Common. In the Scenegraph's text node engine, we should merge these items into a single node as long as the same font is used for all the text. But a bug in the engine caused this to fail when the text was selected. The symptom of this was that in some rare cases one of the items would vanish if it were in the middle of a selection. In order to support the bearing of selected text leaning outside the selection rect, I previously added a hack which would add all selected text as unselected text as well in b0783c21fb54b939f07ddf5658cc51113b8014e6. This was an awkward way of doing it and caused said regression. A less intrusive way is just to add the text to the scene graph twice, as this does not interfere with the logic needed to support selecting part of ligatures nor the engine's ability to merge nodes correctly. [ChangeLog][Text] Fixed regression with selections spanning different scripts. Task-number: QTBUG-46829 Change-Id: I0faed76fb2cd1ac0b2e5cc54b81008b5e2550733 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* | Fix users of QTextLayout::additionalFormats to use the new APIMarc Mutz2015-06-051-1/+1
|/ | | | | | | | | QTextLayout::additionalFormats setters and getters using QList<FormatRange> have been deprecated; port to the QVector versions. Change-Id: I6702430c09b30aa033fe4e34f39a9aa3350e471b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Fix disappearing text in selectionsEskil Abrahamsen Blomfeldt2015-03-241-24/+28
| | | | | | | | | | | | | | | | | | Change 11a595e30615943cd6c63f08cc44cde7861112eb introduced a regression where selected text might disappear randomly because we changed the order the nodes were added to the list. The order is significant in cases where there is overlap, such as for painting selections. Instead of iterating over the hash and thus getting the regular nodes in random order, we make the first node with any given key the primary node, add this to the list immediately, and then just do a look up in the hash for the nodes that should be merged with it. Change-Id: Id2208ab672294aa3dd2bc9741e6c6697c2c66746 Task-number: QTBUG-45133 Reviewed-by: aavit <eirik.aavitsland@theqtcompany.com>
* Reduce number of allocations when constructing text nodesEskil Abrahamsen Blomfeldt2015-03-091-36/+61
| | | | | | | | | | | | | | | | | | | | | In cases where you have a huge number of text elements that can be merged, we would do a lot of reallocations (one per node that would be merged into another). As the number of merges grew, this seemed to converge at about 50% of the time spent in updatePaintNode() in the text classes. We can almost eliminate this cost by only doing one realloc per node that will actually end up in the scene graph. This patch does a first pass where it simply bundles together nodes that can be merged. Then it does a second pass where it actually merges the nodes. In this second pass it can easily precount the required size of the arrays and we can limit it to a single realloc. Task-number: QTBUG-37365 Change-Id: I4e44c01cd83df39304cbbce34f3b8f773763e091 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Frederik Gladhorn2015-02-241-1/+1
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf LICENSE.GPLv2 examples/qml/networkaccessmanagerfactory/view.qml src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4stringobject.cpp Change-Id: I5d12f436d60995e51d5c2f59d364e9cbc24f8e32
| * Fix vertical positioning of the first image in TextJoni Poikelin2015-02-021-1/+1
| | | | | | | | | | | | Task-number: QTBUG-38528 Change-Id: Ie16000cf9ba20598da51683751a8fb62798a1322 Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
* | Account for leading when drawing text decorationEskil Abrahamsen Blomfeldt2015-02-201-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the text line is offset by the leading distance, the text decoration needs to be offset by the same value, otherwise it will be drawn in the wrong location. [ChangeLog][TextEdit] Fixed positioning of text decoration with some fonts. Change-Id: Ic15134326b878255a9b424c14762c3817dfd3123 Task-number: QTBUG-44492 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Andrew Knight <qt@panimo.net> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* | Respect the text's background-color when it is set in the style in HTMLAndy Shaw2015-02-051-0/+7
| | | | | | | | | | | | Task-number: QTBUG-36837 Change-Id: Iea85f4bc7c66124178a318f0ebd776726cf72c96 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* | Fix subscript and superscript for QQuickTextJoni Poikelin2014-10-211-1/+12
|/ | | | | | | | Task-number: QTBUG-32948 Change-Id: I4920015b2604afbd9e2050f0225de98d5188d589 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Fix missing glyphs in selectionEskil Abrahamsen Blomfeldt2014-10-091-17/+56
| | | | | | | | | | | | | | | | | Change 198009db79a85d3cab7fe3a6432635d36123a2d6 revealed a bug in the new selection algorithm which would occur sometimes when a given run of text spanned several script items. Since we are checking the glyph runs for overlaps in the actual text, we need to report the exact characters spanned by the glyph run. We use the new enabler for this in QGlyphRunPrivate. Added a new test case which is an error case we did not yet cover, which is when there is only a single script item, but several font engines are used to produce it (fallback fonts). Change-Id: Ie4c3e79ad98a033d5c75fd67ada4ae83df33435b Task-number: QTBUG-41808 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix selection of text with negative right bearingEskil Abrahamsen Blomfeldt2014-09-021-59/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Selecting text with a negative right bearing (like italic text) would cause clipping to occur at the edges of the characters. The algorithm for drawing text and text selection tried to divide the text into two: 1. Selected text, and 2. Unselected text. However, the selected text might be drawn outside the selection rect when it has a negative right bearing. Similarly, unselected text before the selection might overlap with the selection rect when it has a negative right bearing, or unselected text after the selection might overlap if it has a negative left bearing. See added test textinput_italic_selected.qml for an example. To rectify this, we do drawing of selected text like this: 1. Draw all text with unselected color 2. Draw selection rects 3. Draw the following in the selection text color and clipped to the selection rect: A. The selected text B. The unselected text right before the selection C. The unselected text right after the selection To avoid drawing the same text twice for extra boldness, we check if 3B or 3C actually contain 3A, in which case we skip 3A. [ChangeLog][Text] Fixed clipping when selecting text with negative right bearing. Task-number: QTBUG-34233 Change-Id: I3506b3a72a2d963c5f24c5b819bbb92769b9aee1 Reviewed-by: Samuel Nevala <samuel.nevala@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Create rectangle nodes in the text editing through the contextLars Knoll2014-08-131-5/+4
| | | | | | | | | | Unfortunately we can't re-use the QSGSimpleRectNode, as it doesn't provide us with virtual methods to move it's creation into the context. But's since it's only 20 lines of code anyway, this is still a nice cleanup. And it also allows the re-use of any optimizations in the renderer for QSGRectangleNode. Change-Id: I957777fbbeb0a994a9c257baf3bfe87fce8cc9e8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix preedit text layoutRobin Burchell2013-11-041-2/+2
| | | | | | | | preeditPosition is relative to the block position Done-with: Aaron Kennedy <aaron.kennedy@jollamobile.com> Change-Id: If96a1d0939f84ab11f0642d5fe78d786c30f418a Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* Fix license headers of QtQuick sources.Gunnar Sletta2013-09-301-1/+1
| | | | | Change-Id: I3750c47640bf21c3567c5fa1c4667e3e2552942e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Improve memory usage of QQuickTextNode.Michael Brasser2013-08-061-3/+3
| | | | | | | | | | The typical number of BinaryTreeNodes needed for a text line should be much lower than 256. Task-number: QTBUG-32770 Change-Id: I85aa161eb7cb6e55657213304b7577a0a33f1b67 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* Optimize QQuickTextEdit for larger documents.Pierre Rossi2013-03-201-0/+935
The rationale is to not end up re-processing the whole document on each update Since we know where the editing takes place, we can break down the text edit's contents in several text nodes and only re-create the affected text nodes upon editing. This requires ripping out the SelectionEngine helper class from QQuickTextNode so that QQuickTextEdit can tap into its functionality directly. A positive side-effect of this exercise is that it should be much harder to to come across GlyphNodes packing more than 16300 glyphs or so. Task-number: QTBUG-29596 Change-Id: Id29b0709baa43f5b29c44ab02398ba996be3e28a Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>