| 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 bool CompositeEditCommand::canRebalance(const Position& position) const | 606 bool CompositeEditCommand::canRebalance(const Position& position) const |
| 607 { | 607 { |
| 608 Node* node = position.containerNode(); | 608 Node* node = position.containerNode(); |
| 609 if (position.anchorType() != Position::PositionIsOffsetInAnchor || !node ||
!node->isTextNode()) | 609 if (position.anchorType() != Position::PositionIsOffsetInAnchor || !node ||
!node->isTextNode()) |
| 610 return false; | 610 return false; |
| 611 | 611 |
| 612 Text* textNode = toText(node); | 612 Text* textNode = toText(node); |
| 613 if (textNode->length() == 0) | 613 if (textNode->length() == 0) |
| 614 return false; | 614 return false; |
| 615 | 615 |
| 616 RenderObject* renderer = textNode->renderer(); | 616 RenderText* renderer = textNode->renderer(); |
| 617 if (renderer && !renderer->style()->collapseWhiteSpace()) | 617 if (renderer && !renderer->style()->collapseWhiteSpace()) |
| 618 return false; | 618 return false; |
| 619 | 619 |
| 620 return true; | 620 return true; |
| 621 } | 621 } |
| 622 | 622 |
| 623 // FIXME: Doesn't go into text nodes that contribute adjacent text (siblings, co
usins, etc). | 623 // FIXME: Doesn't go into text nodes that contribute adjacent text (siblings, co
usins, etc). |
| 624 void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position) | 624 void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position) |
| 625 { | 625 { |
| 626 Node* node = position.containerNode(); | 626 Node* node = position.containerNode(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 675 |
| 676 void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio
n) | 676 void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio
n) |
| 677 { | 677 { |
| 678 Node* node = position.deprecatedNode(); | 678 Node* node = position.deprecatedNode(); |
| 679 if (!node || !node->isTextNode()) | 679 if (!node || !node->isTextNode()) |
| 680 return; | 680 return; |
| 681 Text* textNode = toText(node); | 681 Text* textNode = toText(node); |
| 682 | 682 |
| 683 if (textNode->length() == 0) | 683 if (textNode->length() == 0) |
| 684 return; | 684 return; |
| 685 RenderObject* renderer = textNode->renderer(); | 685 RenderText* renderer = textNode->renderer(); |
| 686 if (renderer && !renderer->style()->collapseWhiteSpace()) | 686 if (renderer && !renderer->style()->collapseWhiteSpace()) |
| 687 return; | 687 return; |
| 688 | 688 |
| 689 // Delete collapsed whitespace so that inserting nbsps doesn't uncollapse it
. | 689 // Delete collapsed whitespace so that inserting nbsps doesn't uncollapse it
. |
| 690 Position upstreamPos = position.upstream(); | 690 Position upstreamPos = position.upstream(); |
| 691 deleteInsignificantText(upstreamPos, position.downstream()); | 691 deleteInsignificantText(upstreamPos, position.downstream()); |
| 692 position = upstreamPos.downstream(); | 692 position = upstreamPos.downstream(); |
| 693 | 693 |
| 694 VisiblePosition visiblePos(position); | 694 VisiblePosition visiblePos(position); |
| 695 VisiblePosition previousVisiblePos(visiblePos.previous()); | 695 VisiblePosition previousVisiblePos(visiblePos.previous()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 718 rebalanceWhitespaceAt(selection.end()); | 718 rebalanceWhitespaceAt(selection.end()); |
| 719 } | 719 } |
| 720 | 720 |
| 721 void CompositeEditCommand::deleteInsignificantText(PassRefPtrWillBeRawPtr<Text>
textNode, unsigned start, unsigned end) | 721 void CompositeEditCommand::deleteInsignificantText(PassRefPtrWillBeRawPtr<Text>
textNode, unsigned start, unsigned end) |
| 722 { | 722 { |
| 723 if (!textNode || start >= end) | 723 if (!textNode || start >= end) |
| 724 return; | 724 return; |
| 725 | 725 |
| 726 document().updateLayout(); | 726 document().updateLayout(); |
| 727 | 727 |
| 728 RenderText* textRenderer = toRenderText(textNode->renderer()); | 728 RenderText* textRenderer = textNode->renderer(); |
| 729 if (!textRenderer) | 729 if (!textRenderer) |
| 730 return; | 730 return; |
| 731 | 731 |
| 732 Vector<InlineTextBox*> sortedTextBoxes; | 732 Vector<InlineTextBox*> sortedTextBoxes; |
| 733 size_t sortedTextBoxesPosition = 0; | 733 size_t sortedTextBoxesPosition = 0; |
| 734 | 734 |
| 735 for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) | 735 for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) |
| 736 sortedTextBoxes.append(textBox); | 736 sortedTextBoxes.append(textBox); |
| 737 | 737 |
| 738 // If there is mixed directionality text, the boxes can be out of order, | 738 // If there is mixed directionality text, the boxes can be out of order, |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 } | 1495 } |
| 1496 | 1496 |
| 1497 void CompositeEditCommand::trace(Visitor* visitor) | 1497 void CompositeEditCommand::trace(Visitor* visitor) |
| 1498 { | 1498 { |
| 1499 visitor->trace(m_commands); | 1499 visitor->trace(m_commands); |
| 1500 visitor->trace(m_composition); | 1500 visitor->trace(m_composition); |
| 1501 EditCommand::trace(visitor); | 1501 EditCommand::trace(visitor); |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 } // namespace blink | 1504 } // namespace blink |
| OLD | NEW |