| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 return IsCharacterSmartReplaceExempt( | 1635 return IsCharacterSmartReplaceExempt( |
| 1636 character == kNoBreakSpaceCharacter ? ' ' : character, | 1636 character == kNoBreakSpaceCharacter ? ' ' : character, |
| 1637 previous_character); | 1637 previous_character); |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 void ReplaceSelectionCommand::AddSpacesForSmartReplace( | 1640 void ReplaceSelectionCommand::AddSpacesForSmartReplace( |
| 1641 EditingState* editing_state) { | 1641 EditingState* editing_state) { |
| 1642 VisiblePosition end_of_inserted_content = PositionAtEndOfInsertedContent(); | 1642 VisiblePosition end_of_inserted_content = PositionAtEndOfInsertedContent(); |
| 1643 Position end_upstream = | 1643 Position end_upstream = |
| 1644 MostBackwardCaretPosition(end_of_inserted_content.DeepEquivalent()); | 1644 MostBackwardCaretPosition(end_of_inserted_content.DeepEquivalent()); |
| 1645 Node* end_node = end_upstream.ComputeNodeBeforePosition(); | 1645 Node* end_node = const_cast<Node*>(end_upstream.ComputeNodeBeforePosition()); |
| 1646 int end_offset = | 1646 int end_offset = |
| 1647 end_node && end_node->IsTextNode() ? ToText(end_node)->length() : 0; | 1647 end_node && end_node->IsTextNode() ? ToText(end_node)->length() : 0; |
| 1648 if (end_upstream.IsOffsetInAnchor()) { | 1648 if (end_upstream.IsOffsetInAnchor()) { |
| 1649 end_node = end_upstream.ComputeContainerNode(); | 1649 end_node = end_upstream.ComputeContainerNode(); |
| 1650 end_offset = end_upstream.OffsetInContainerNode(); | 1650 end_offset = end_upstream.OffsetInContainerNode(); |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 bool needs_trailing_space = | 1653 bool needs_trailing_space = |
| 1654 !IsEndOfParagraph(end_of_inserted_content) && | 1654 !IsEndOfParagraph(end_of_inserted_content) && |
| 1655 !IsCharacterSmartReplaceExemptConsideringNonBreakingSpace( | 1655 !IsCharacterSmartReplaceExemptConsideringNonBreakingSpace( |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1778 Position& position_only_to_be_updated, | 1778 Position& position_only_to_be_updated, |
| 1779 EditingState* editing_state) { | 1779 EditingState* editing_state) { |
| 1780 bool position_is_offset_in_anchor = position.IsOffsetInAnchor(); | 1780 bool position_is_offset_in_anchor = position.IsOffsetInAnchor(); |
| 1781 bool position_only_to_be_updated_is_offset_in_anchor = | 1781 bool position_only_to_be_updated_is_offset_in_anchor = |
| 1782 position_only_to_be_updated.IsOffsetInAnchor(); | 1782 position_only_to_be_updated.IsOffsetInAnchor(); |
| 1783 Text* text = nullptr; | 1783 Text* text = nullptr; |
| 1784 if (position_is_offset_in_anchor && position.ComputeContainerNode() && | 1784 if (position_is_offset_in_anchor && position.ComputeContainerNode() && |
| 1785 position.ComputeContainerNode()->IsTextNode()) { | 1785 position.ComputeContainerNode()->IsTextNode()) { |
| 1786 text = ToText(position.ComputeContainerNode()); | 1786 text = ToText(position.ComputeContainerNode()); |
| 1787 } else { | 1787 } else { |
| 1788 Node* before = position.ComputeNodeBeforePosition(); | 1788 Node* before = const_cast<Node*>(position.ComputeNodeBeforePosition()); |
| 1789 if (before && before->IsTextNode()) { | 1789 if (before && before->IsTextNode()) { |
| 1790 text = ToText(before); | 1790 text = ToText(before); |
| 1791 } else { | 1791 } else { |
| 1792 Node* after = position.ComputeNodeAfterPosition(); | 1792 Node* after = position.ComputeNodeAfterPosition(); |
| 1793 if (after && after->IsTextNode()) | 1793 if (after && after->IsTextNode()) |
| 1794 text = ToText(after); | 1794 text = ToText(after); |
| 1795 } | 1795 } |
| 1796 } | 1796 } |
| 1797 if (!text) | 1797 if (!text) |
| 1798 return; | 1798 return; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 visitor->Trace(start_of_inserted_content_); | 2009 visitor->Trace(start_of_inserted_content_); |
| 2010 visitor->Trace(end_of_inserted_content_); | 2010 visitor->Trace(end_of_inserted_content_); |
| 2011 visitor->Trace(insertion_style_); | 2011 visitor->Trace(insertion_style_); |
| 2012 visitor->Trace(document_fragment_); | 2012 visitor->Trace(document_fragment_); |
| 2013 visitor->Trace(start_of_inserted_range_); | 2013 visitor->Trace(start_of_inserted_range_); |
| 2014 visitor->Trace(end_of_inserted_range_); | 2014 visitor->Trace(end_of_inserted_range_); |
| 2015 CompositeEditCommand::Trace(visitor); | 2015 CompositeEditCommand::Trace(visitor); |
| 2016 } | 2016 } |
| 2017 | 2017 |
| 2018 } // namespace blink | 2018 } // namespace blink |
| OLD | NEW |