diff options
author | Iain Merrick <husky@google.com> | 2010-08-19 17:55:56 +0100 |
---|---|---|
committer | Iain Merrick <husky@google.com> | 2010-08-23 11:05:40 +0100 |
commit | f486d19d62f1bc33246748b14b14a9dfa617b57f (patch) | |
tree | 195485454c93125455a30e553a73981c3816144d /WebCore/editing/CompositeEditCommand.cpp | |
parent | 6ba0b43722d16bc295606bec39f396f596e4fef1 (diff) | |
download | external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.zip external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.gz external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.bz2 |
Merge WebKit at r65615 : Initial merge by git.
Change-Id: Ifbf384f4531e3b58475a662e38195c2d9152ae79
Diffstat (limited to 'WebCore/editing/CompositeEditCommand.cpp')
-rw-r--r-- | WebCore/editing/CompositeEditCommand.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/WebCore/editing/CompositeEditCommand.cpp b/WebCore/editing/CompositeEditCommand.cpp index 5ec87d6..f50929a 100644 --- a/WebCore/editing/CompositeEditCommand.cpp +++ b/WebCore/editing/CompositeEditCommand.cpp @@ -294,24 +294,24 @@ void CompositeEditCommand::joinTextNodes(PassRefPtr<Text> text1, PassRefPtr<Text void CompositeEditCommand::inputText(const String& text, bool selectInsertedText) { - int offset = 0; - int length = text.length(); + unsigned offset = 0; + unsigned length = text.length(); RefPtr<Range> startRange = Range::create(document(), Position(document()->documentElement(), 0), endingSelection().start()); - int startIndex = TextIterator::rangeLength(startRange.get()); - int newline; + unsigned startIndex = TextIterator::rangeLength(startRange.get()); + size_t newline; do { newline = text.find('\n', offset); if (newline != offset) { RefPtr<InsertTextCommand> command = InsertTextCommand::create(document()); applyCommandToComposite(command); - int substringLength = newline == -1 ? length - offset : newline - offset; + int substringLength = newline == notFound ? length - offset : newline - offset; command->input(text.substring(offset, substringLength), false); } - if (newline != -1) + if (newline != notFound) insertLineBreak(); offset = newline + 1; - } while (newline != -1 && offset != length); + } while (newline != notFound && offset != length); if (selectInsertedText) { RefPtr<Range> selectedRange = TextIterator::rangeFromLocationAndLength(document()->documentElement(), startIndex, length); @@ -489,7 +489,18 @@ void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un if (!textRenderer) return; - InlineTextBox* box = textRenderer->firstTextBox(); + Vector<InlineTextBox*> sortedTextBoxes; + size_t sortedTextBoxesPosition = 0; + + for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox = textBox->nextTextBox()) + sortedTextBoxes.append(textBox); + + // If there is mixed directionality text, the boxes can be out of order, + // (like Arabic with embedded LTR), so sort them first. + if (textRenderer->containsReversedText()) + std::sort(sortedTextBoxes.begin(), sortedTextBoxes.end(), InlineTextBox::compareByStart); + InlineTextBox* box = sortedTextBoxes.isEmpty() ? 0 : sortedTextBoxes[sortedTextBoxesPosition]; + if (!box) { // whole text node is empty removeNode(textNode); @@ -526,8 +537,12 @@ void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un } prevBox = box; - if (box) - box = box->nextTextBox(); + if (box) { + if (++sortedTextBoxesPosition < sortedTextBoxes.size()) + box = sortedTextBoxes[sortedTextBoxesPosition]; + else + box = 0; + } } if (!str.isNull()) { |