OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 rebalanceWhitespaceAt(selection.start()); | 692 rebalanceWhitespaceAt(selection.start()); |
693 if (selection.isRange()) | 693 if (selection.isRange()) |
694 rebalanceWhitespaceAt(selection.end()); | 694 rebalanceWhitespaceAt(selection.end()); |
695 } | 695 } |
696 | 696 |
697 void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un
signed start, unsigned end) | 697 void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un
signed start, unsigned end) |
698 { | 698 { |
699 if (!textNode || start >= end) | 699 if (!textNode || start >= end) |
700 return; | 700 return; |
701 | 701 |
| 702 document()->updateLayout(); |
| 703 |
702 RenderText* textRenderer = toRenderText(textNode->renderer()); | 704 RenderText* textRenderer = toRenderText(textNode->renderer()); |
703 if (!textRenderer) | 705 if (!textRenderer) |
704 return; | 706 return; |
705 | 707 |
706 Vector<InlineTextBox*> sortedTextBoxes; | 708 Vector<InlineTextBox*> sortedTextBoxes; |
707 size_t sortedTextBoxesPosition = 0; | 709 size_t sortedTextBoxesPosition = 0; |
708 | 710 |
709 for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) | 711 for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) |
710 sortedTextBoxes.append(textBox); | 712 sortedTextBoxes.append(textBox); |
711 | 713 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 } | 776 } |
775 | 777 |
776 void CompositeEditCommand::deleteInsignificantText(const Position& start, const
Position& end) | 778 void CompositeEditCommand::deleteInsignificantText(const Position& start, const
Position& end) |
777 { | 779 { |
778 if (start.isNull() || end.isNull()) | 780 if (start.isNull() || end.isNull()) |
779 return; | 781 return; |
780 | 782 |
781 if (comparePositions(start, end) >= 0) | 783 if (comparePositions(start, end) >= 0) |
782 return; | 784 return; |
783 | 785 |
784 Node* next; | 786 Vector<RefPtr<Text> > nodes; |
785 for (Node* node = start.deprecatedNode(); node; node = next) { | 787 for (Node* node = start.deprecatedNode(); node; node = node->traverseNextNod
e()) { |
786 next = node->traverseNextNode(); | 788 if (node->isTextNode()) |
787 if (node->isTextNode()) { | 789 nodes.append(static_cast<Text*>(node)); |
788 Text* textNode = static_cast<Text*>(node); | |
789 int startOffset = node == start.deprecatedNode() ? start.deprecatedE
ditingOffset() : 0; | |
790 int endOffset = node == end.deprecatedNode() ? end.deprecatedEditing
Offset() : static_cast<int>(textNode->length()); | |
791 deleteInsignificantText(textNode, startOffset, endOffset); | |
792 } | |
793 if (node == end.deprecatedNode()) | 790 if (node == end.deprecatedNode()) |
794 break; | 791 break; |
795 } | 792 } |
| 793 |
| 794 for (size_t i = 0; i < nodes.size(); ++i) { |
| 795 Text* textNode = nodes[i].get(); |
| 796 int startOffset = textNode == start.deprecatedNode() ? start.deprecatedE
ditingOffset() : 0; |
| 797 int endOffset = textNode == end.deprecatedNode() ? end.deprecatedEditing
Offset() : static_cast<int>(textNode->length()); |
| 798 deleteInsignificantText(textNode, startOffset, endOffset); |
| 799 } |
796 } | 800 } |
797 | 801 |
798 void CompositeEditCommand::deleteInsignificantTextDownstream(const Position& pos
) | 802 void CompositeEditCommand::deleteInsignificantTextDownstream(const Position& pos
) |
799 { | 803 { |
800 Position end = VisiblePosition(pos, VP_DEFAULT_AFFINITY).next().deepEquivale
nt().downstream(); | 804 Position end = VisiblePosition(pos, VP_DEFAULT_AFFINITY).next().deepEquivale
nt().downstream(); |
801 deleteInsignificantText(pos, end); | 805 deleteInsignificantText(pos, end); |
802 } | 806 } |
803 | 807 |
804 PassRefPtr<Node> CompositeEditCommand::appendBlockPlaceholder(PassRefPtr<Element
> container) | 808 PassRefPtr<Node> CompositeEditCommand::appendBlockPlaceholder(PassRefPtr<Element
> container) |
805 { | 809 { |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 return node.release(); | 1429 return node.release(); |
1426 } | 1430 } |
1427 | 1431 |
1428 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) | 1432 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) |
1429 { | 1433 { |
1430 RefPtr<Element> breakNode = document->createElement(brTag, false); | 1434 RefPtr<Element> breakNode = document->createElement(brTag, false); |
1431 return breakNode.release(); | 1435 return breakNode.release(); |
1432 } | 1436 } |
1433 | 1437 |
1434 } // namespace WebCore | 1438 } // namespace WebCore |
OLD | NEW |