5353#include " InsertNodeBeforeCommand.h"
5454#include " InsertParagraphSeparatorCommand.h"
5555#include " InsertTextCommand.h"
56+ #include " LayoutIntegrationRunIterator.h"
5657#include " MergeIdenticalElementsCommand.h"
5758#include " NodeTraversal.h"
5859#include " RemoveNodeCommand.h"
@@ -981,20 +982,8 @@ void CompositeEditCommand::deleteInsignificantText(Text& textNode, unsigned star
981982 if (!textRenderer)
982983 return ;
983984
984- Vector<InlineTextBox*> sortedTextBoxes;
985- size_t sortedTextBoxesPosition = 0 ;
986-
987- textRenderer->ensureLineBoxes ();
988- for (InlineTextBox* textBox = textRenderer->firstTextBox (); textBox; textBox = textBox->nextTextBox ())
989- sortedTextBoxes.append (textBox);
990-
991- // If there is mixed directionality text, the boxes can be out of order,
992- // (like Arabic with embedded LTR), so sort them first.
993- if (textRenderer->containsReversedText ())
994- std::sort (sortedTextBoxes.begin (), sortedTextBoxes.end (), InlineTextBox::compareByStart);
995- InlineTextBox* box = sortedTextBoxes.isEmpty () ? 0 : sortedTextBoxes[sortedTextBoxesPosition];
996-
997- if (!box) {
985+ auto run = LayoutIntegration::firstTextRunInTextOrderFor (*textRenderer);
986+ if (!run) {
998987 // whole text node is empty
999988 removeNode (textNode);
1000989 return ;
@@ -1005,18 +994,18 @@ void CompositeEditCommand::deleteInsignificantText(Text& textNode, unsigned star
1005994 return ;
1006995
1007996 unsigned removed = 0 ;
1008- InlineTextBox* prevBox = nullptr ;
997+ LayoutIntegration::TextRunIterator previousRun ;
1009998 String str;
1010999
10111000 // This loop structure works to process all gaps preceding a box,
10121001 // and also will look at the gap after the last box.
1013- while (prevBox || box ) {
1014- unsigned gapStart = prevBox ? prevBox-> start () + prevBox-> len () : 0 ;
1002+ while (previousRun || run ) {
1003+ unsigned gapStart = previousRun ? previousRun-> end () : 0 ;
10151004 if (end < gapStart)
10161005 // No more chance for any intersections
10171006 break ;
10181007
1019- unsigned gapEnd = box ? box ->start () : length;
1008+ unsigned gapEnd = run ? run ->start () : length;
10201009 bool indicesIntersect = start <= gapEnd && end >= gapStart;
10211010 int gapLen = gapEnd - gapStart;
10221011 if (indicesIntersect && gapLen > 0 ) {
@@ -1029,13 +1018,9 @@ void CompositeEditCommand::deleteInsignificantText(Text& textNode, unsigned star
10291018 removed += gapLen;
10301019 }
10311020
1032- prevBox = box;
1033- if (box) {
1034- if (++sortedTextBoxesPosition < sortedTextBoxes.size ())
1035- box = sortedTextBoxes[sortedTextBoxesPosition];
1036- else
1037- box = nullptr ;
1038- }
1021+ previousRun = run;
1022+ if (run)
1023+ run.traverseNextTextRunInTextOrder ();
10391024 }
10401025
10411026 if (!str.isNull ()) {
0 commit comments