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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #include "core/events/ScopedEventQueue.h" | 64 #include "core/events/ScopedEventQueue.h" |
65 #include "core/frame/LocalFrame.h" | 65 #include "core/frame/LocalFrame.h" |
66 #include "core/html/HTMLBRElement.h" | 66 #include "core/html/HTMLBRElement.h" |
67 #include "core/html/HTMLDivElement.h" | 67 #include "core/html/HTMLDivElement.h" |
68 #include "core/html/HTMLElement.h" | 68 #include "core/html/HTMLElement.h" |
69 #include "core/html/HTMLLIElement.h" | 69 #include "core/html/HTMLLIElement.h" |
70 #include "core/html/HTMLQuoteElement.h" | 70 #include "core/html/HTMLQuoteElement.h" |
71 #include "core/html/HTMLSpanElement.h" | 71 #include "core/html/HTMLSpanElement.h" |
72 #include "core/layout/LayoutBlock.h" | 72 #include "core/layout/LayoutBlock.h" |
73 #include "core/layout/LayoutListItem.h" | 73 #include "core/layout/LayoutListItem.h" |
| 74 #include "core/layout/LayoutText.h" |
74 #include "core/layout/line/InlineTextBox.h" | 75 #include "core/layout/line/InlineTextBox.h" |
75 #include "core/rendering/RenderText.h" | |
76 | 76 |
77 namespace blink { | 77 namespace blink { |
78 | 78 |
79 using namespace HTMLNames; | 79 using namespace HTMLNames; |
80 | 80 |
81 PassRefPtrWillBeRawPtr<EditCommandComposition> EditCommandComposition::create(Do
cument* document, | 81 PassRefPtrWillBeRawPtr<EditCommandComposition> EditCommandComposition::create(Do
cument* document, |
82 const VisibleSelection& startingSelection, const VisibleSelection& endingSel
ection, EditAction editAction) | 82 const VisibleSelection& startingSelection, const VisibleSelection& endingSel
ection, EditAction editAction) |
83 { | 83 { |
84 return adoptRefWillBeNoop(new EditCommandComposition(document, startingSelec
tion, endingSelection, editAction)); | 84 return adoptRefWillBeNoop(new EditCommandComposition(document, startingSelec
tion, endingSelection, editAction)); |
85 } | 85 } |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 bool CompositeEditCommand::canRebalance(const Position& position) const | 614 bool CompositeEditCommand::canRebalance(const Position& position) const |
615 { | 615 { |
616 Node* node = position.containerNode(); | 616 Node* node = position.containerNode(); |
617 if (position.anchorType() != Position::PositionIsOffsetInAnchor || !node ||
!node->isTextNode()) | 617 if (position.anchorType() != Position::PositionIsOffsetInAnchor || !node ||
!node->isTextNode()) |
618 return false; | 618 return false; |
619 | 619 |
620 Text* textNode = toText(node); | 620 Text* textNode = toText(node); |
621 if (textNode->length() == 0) | 621 if (textNode->length() == 0) |
622 return false; | 622 return false; |
623 | 623 |
624 RenderText* renderer = textNode->renderer(); | 624 LayoutText* renderer = textNode->renderer(); |
625 if (renderer && !renderer->style()->collapseWhiteSpace()) | 625 if (renderer && !renderer->style()->collapseWhiteSpace()) |
626 return false; | 626 return false; |
627 | 627 |
628 return true; | 628 return true; |
629 } | 629 } |
630 | 630 |
631 // FIXME: Doesn't go into text nodes that contribute adjacent text (siblings, co
usins, etc). | 631 // FIXME: Doesn't go into text nodes that contribute adjacent text (siblings, co
usins, etc). |
632 void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position) | 632 void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position) |
633 { | 633 { |
634 Node* node = position.containerNode(); | 634 Node* node = position.containerNode(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 | 683 |
684 void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio
n) | 684 void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio
n) |
685 { | 685 { |
686 Node* node = position.deprecatedNode(); | 686 Node* node = position.deprecatedNode(); |
687 if (!node || !node->isTextNode()) | 687 if (!node || !node->isTextNode()) |
688 return; | 688 return; |
689 Text* textNode = toText(node); | 689 Text* textNode = toText(node); |
690 | 690 |
691 if (textNode->length() == 0) | 691 if (textNode->length() == 0) |
692 return; | 692 return; |
693 RenderText* renderer = textNode->renderer(); | 693 LayoutText* renderer = textNode->renderer(); |
694 if (renderer && !renderer->style()->collapseWhiteSpace()) | 694 if (renderer && !renderer->style()->collapseWhiteSpace()) |
695 return; | 695 return; |
696 | 696 |
697 // Delete collapsed whitespace so that inserting nbsps doesn't uncollapse it
. | 697 // Delete collapsed whitespace so that inserting nbsps doesn't uncollapse it
. |
698 Position upstreamPos = position.upstream(); | 698 Position upstreamPos = position.upstream(); |
699 deleteInsignificantText(upstreamPos, position.downstream()); | 699 deleteInsignificantText(upstreamPos, position.downstream()); |
700 position = upstreamPos.downstream(); | 700 position = upstreamPos.downstream(); |
701 | 701 |
702 VisiblePosition visiblePos(position); | 702 VisiblePosition visiblePos(position); |
703 VisiblePosition previousVisiblePos(visiblePos.previous()); | 703 VisiblePosition previousVisiblePos(visiblePos.previous()); |
(...skipping 22 matching lines...) Expand all Loading... |
726 rebalanceWhitespaceAt(selection.end()); | 726 rebalanceWhitespaceAt(selection.end()); |
727 } | 727 } |
728 | 728 |
729 void CompositeEditCommand::deleteInsignificantText(PassRefPtrWillBeRawPtr<Text>
textNode, unsigned start, unsigned end) | 729 void CompositeEditCommand::deleteInsignificantText(PassRefPtrWillBeRawPtr<Text>
textNode, unsigned start, unsigned end) |
730 { | 730 { |
731 if (!textNode || start >= end) | 731 if (!textNode || start >= end) |
732 return; | 732 return; |
733 | 733 |
734 document().updateLayout(); | 734 document().updateLayout(); |
735 | 735 |
736 RenderText* textRenderer = textNode->renderer(); | 736 LayoutText* textRenderer = textNode->renderer(); |
737 if (!textRenderer) | 737 if (!textRenderer) |
738 return; | 738 return; |
739 | 739 |
740 Vector<InlineTextBox*> sortedTextBoxes; | 740 Vector<InlineTextBox*> sortedTextBoxes; |
741 size_t sortedTextBoxesPosition = 0; | 741 size_t sortedTextBoxesPosition = 0; |
742 | 742 |
743 for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) | 743 for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) |
744 sortedTextBoxes.append(textBox); | 744 sortedTextBoxes.append(textBox); |
745 | 745 |
746 // If there is mixed directionality text, the boxes can be out of order, | 746 // If there is mixed directionality text, the boxes can be out of order, |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 } | 1498 } |
1499 | 1499 |
1500 DEFINE_TRACE(CompositeEditCommand) | 1500 DEFINE_TRACE(CompositeEditCommand) |
1501 { | 1501 { |
1502 visitor->trace(m_commands); | 1502 visitor->trace(m_commands); |
1503 visitor->trace(m_composition); | 1503 visitor->trace(m_composition); |
1504 EditCommand::trace(visitor); | 1504 EditCommand::trace(visitor); |
1505 } | 1505 } |
1506 | 1506 |
1507 } // namespace blink | 1507 } // namespace blink |
OLD | NEW |