| 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 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 (U16_IS_TRAIL(text->data()[0]) || | 1836 (U16_IS_TRAIL(text->data()[0]) || |
| 1837 U16_IS_LEAD(text->data()[text->data().length() - 1])); | 1837 U16_IS_LEAD(text->data()[text->data().length() - 1])); |
| 1838 if (!hasIncompleteSurrogate && text->data().length() > kMergeSizeLimit) | 1838 if (!hasIncompleteSurrogate && text->data().length() > kMergeSizeLimit) |
| 1839 return; | 1839 return; |
| 1840 if (text->previousSibling() && text->previousSibling()->isTextNode()) { | 1840 if (text->previousSibling() && text->previousSibling()->isTextNode()) { |
| 1841 Text* previous = toText(text->previousSibling()); | 1841 Text* previous = toText(text->previousSibling()); |
| 1842 if (hasIncompleteSurrogate || | 1842 if (hasIncompleteSurrogate || |
| 1843 previous->data().length() <= kMergeSizeLimit) { | 1843 previous->data().length() <= kMergeSizeLimit) { |
| 1844 insertTextIntoNode(text, 0, previous->data()); | 1844 insertTextIntoNode(text, 0, previous->data()); |
| 1845 | 1845 |
| 1846 if (positionIsOffsetInAnchor) | 1846 if (positionIsOffsetInAnchor) { |
| 1847 position = | 1847 position = |
| 1848 Position(position.computeContainerNode(), | 1848 Position(position.computeContainerNode(), |
| 1849 previous->length() + position.offsetInContainerNode()); | 1849 previous->length() + position.offsetInContainerNode()); |
| 1850 else | 1850 } else { |
| 1851 updatePositionForNodeRemoval(position, *previous); | 1851 position = computePositionForNodeRemoval(position, *previous); |
| 1852 } |
| 1852 | 1853 |
| 1853 if (positionOnlyToBeUpdatedIsOffsetInAnchor) { | 1854 if (positionOnlyToBeUpdatedIsOffsetInAnchor) { |
| 1854 if (positionOnlyToBeUpdated.computeContainerNode() == text) | 1855 if (positionOnlyToBeUpdated.computeContainerNode() == text) |
| 1855 positionOnlyToBeUpdated = Position( | 1856 positionOnlyToBeUpdated = Position( |
| 1856 text, previous->length() + | 1857 text, previous->length() + |
| 1857 positionOnlyToBeUpdated.offsetInContainerNode()); | 1858 positionOnlyToBeUpdated.offsetInContainerNode()); |
| 1858 else if (positionOnlyToBeUpdated.computeContainerNode() == previous) | 1859 else if (positionOnlyToBeUpdated.computeContainerNode() == previous) |
| 1859 positionOnlyToBeUpdated = | 1860 positionOnlyToBeUpdated = |
| 1860 Position(text, positionOnlyToBeUpdated.offsetInContainerNode()); | 1861 Position(text, positionOnlyToBeUpdated.offsetInContainerNode()); |
| 1861 } else { | 1862 } else { |
| 1862 updatePositionForNodeRemoval(positionOnlyToBeUpdated, *previous); | 1863 positionOnlyToBeUpdated = |
| 1864 computePositionForNodeRemoval(positionOnlyToBeUpdated, *previous); |
| 1863 } | 1865 } |
| 1864 | 1866 |
| 1865 removeNode(previous, editingState); | 1867 removeNode(previous, editingState); |
| 1866 if (editingState->isAborted()) | 1868 if (editingState->isAborted()) |
| 1867 return; | 1869 return; |
| 1868 } | 1870 } |
| 1869 } | 1871 } |
| 1870 if (text->nextSibling() && text->nextSibling()->isTextNode()) { | 1872 if (text->nextSibling() && text->nextSibling()->isTextNode()) { |
| 1871 Text* next = toText(text->nextSibling()); | 1873 Text* next = toText(text->nextSibling()); |
| 1872 if (!hasIncompleteSurrogate && next->data().length() > kMergeSizeLimit) | 1874 if (!hasIncompleteSurrogate && next->data().length() > kMergeSizeLimit) |
| 1873 return; | 1875 return; |
| 1874 unsigned originalLength = text->length(); | 1876 unsigned originalLength = text->length(); |
| 1875 insertTextIntoNode(text, originalLength, next->data()); | 1877 insertTextIntoNode(text, originalLength, next->data()); |
| 1876 | 1878 |
| 1877 if (!positionIsOffsetInAnchor) | 1879 if (!positionIsOffsetInAnchor) |
| 1878 updatePositionForNodeRemoval(position, *next); | 1880 position = computePositionForNodeRemoval(position, *next); |
| 1879 | 1881 |
| 1880 if (positionOnlyToBeUpdatedIsOffsetInAnchor && | 1882 if (positionOnlyToBeUpdatedIsOffsetInAnchor && |
| 1881 positionOnlyToBeUpdated.computeContainerNode() == next) | 1883 positionOnlyToBeUpdated.computeContainerNode() == next) { |
| 1882 positionOnlyToBeUpdated = | 1884 positionOnlyToBeUpdated = |
| 1883 Position(text, originalLength + | 1885 Position(text, originalLength + |
| 1884 positionOnlyToBeUpdated.offsetInContainerNode()); | 1886 positionOnlyToBeUpdated.offsetInContainerNode()); |
| 1885 else | 1887 } else { |
| 1886 updatePositionForNodeRemoval(positionOnlyToBeUpdated, *next); | 1888 positionOnlyToBeUpdated = |
| 1889 computePositionForNodeRemoval(positionOnlyToBeUpdated, *next); |
| 1890 } |
| 1887 | 1891 |
| 1888 removeNode(next, editingState); | 1892 removeNode(next, editingState); |
| 1889 if (editingState->isAborted()) | 1893 if (editingState->isAborted()) |
| 1890 return; | 1894 return; |
| 1891 } | 1895 } |
| 1892 } | 1896 } |
| 1893 | 1897 |
| 1894 InputEvent::InputType ReplaceSelectionCommand::inputType() const { | 1898 InputEvent::InputType ReplaceSelectionCommand::inputType() const { |
| 1895 // |ReplaceSelectionCommand| could be used with Paste, Drag&Drop, | 1899 // |ReplaceSelectionCommand| could be used with Paste, Drag&Drop, |
| 1896 // InsertFragment and |TypingCommand|. | 1900 // InsertFragment and |TypingCommand|. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 visitor->trace(m_startOfInsertedContent); | 2038 visitor->trace(m_startOfInsertedContent); |
| 2035 visitor->trace(m_endOfInsertedContent); | 2039 visitor->trace(m_endOfInsertedContent); |
| 2036 visitor->trace(m_insertionStyle); | 2040 visitor->trace(m_insertionStyle); |
| 2037 visitor->trace(m_documentFragment); | 2041 visitor->trace(m_documentFragment); |
| 2038 visitor->trace(m_startOfInsertedRange); | 2042 visitor->trace(m_startOfInsertedRange); |
| 2039 visitor->trace(m_endOfInsertedRange); | 2043 visitor->trace(m_endOfInsertedRange); |
| 2040 CompositeEditCommand::trace(visitor); | 2044 CompositeEditCommand::trace(visitor); |
| 2041 } | 2045 } |
| 2042 | 2046 |
| 2043 } // namespace blink | 2047 } // namespace blink |
| OLD | NEW |