| 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 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 return; | 1637 return; |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 // TextIterator::rangeLength requires clean layout. | 1640 // TextIterator::rangeLength requires clean layout. |
| 1641 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 1641 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1642 | 1642 |
| 1643 destinationIndex = TextIterator::rangeLength( | 1643 destinationIndex = TextIterator::rangeLength( |
| 1644 Position::firstPositionInNode(document().documentElement()), | 1644 Position::firstPositionInNode(document().documentElement()), |
| 1645 destination.toParentAnchoredPosition(), true); | 1645 destination.toParentAnchoredPosition(), true); |
| 1646 | 1646 |
| 1647 VisibleSelection destinationSelection = createVisibleSelection( | 1647 VisibleSelection destinationSelection = |
| 1648 destination.toPositionWithAffinity(), originalIsDirectional); | 1648 createVisibleSelection(SelectionInDOMTree::Builder() |
| 1649 .collapse(destination.toPositionWithAffinity()) |
| 1650 .setIsDirectional(originalIsDirectional) |
| 1651 .build()); |
| 1649 if (endingSelection().isNone()) { | 1652 if (endingSelection().isNone()) { |
| 1650 // We abort executing command since |destination| becomes invisible. | 1653 // We abort executing command since |destination| becomes invisible. |
| 1651 editingState->abort(); | 1654 editingState->abort(); |
| 1652 return; | 1655 return; |
| 1653 } | 1656 } |
| 1654 setEndingSelection(destinationSelection); | 1657 setEndingSelection(destinationSelection); |
| 1655 ReplaceSelectionCommand::CommandOptions options = | 1658 ReplaceSelectionCommand::CommandOptions options = |
| 1656 ReplaceSelectionCommand::SelectReplacement | | 1659 ReplaceSelectionCommand::SelectReplacement | |
| 1657 ReplaceSelectionCommand::MovingParagraph; | 1660 ReplaceSelectionCommand::MovingParagraph; |
| 1658 if (shouldPreserveStyle == DoNotPreserveStyle) | 1661 if (shouldPreserveStyle == DoNotPreserveStyle) |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 VisiblePosition atBR = VisiblePosition::beforeNode(br); | 1865 VisiblePosition atBR = VisiblePosition::beforeNode(br); |
| 1863 // If the br we inserted collapsed, for example: | 1866 // If the br we inserted collapsed, for example: |
| 1864 // foo<br><blockquote>...</blockquote> | 1867 // foo<br><blockquote>...</blockquote> |
| 1865 // insert a second one. | 1868 // insert a second one. |
| 1866 if (!isStartOfParagraph(atBR)) { | 1869 if (!isStartOfParagraph(atBR)) { |
| 1867 insertNodeBefore(HTMLBRElement::create(document()), br, editingState); | 1870 insertNodeBefore(HTMLBRElement::create(document()), br, editingState); |
| 1868 if (editingState->isAborted()) | 1871 if (editingState->isAborted()) |
| 1869 return false; | 1872 return false; |
| 1870 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 1873 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1871 } | 1874 } |
| 1872 setEndingSelection(createVisibleSelection(atBR.toPositionWithAffinity(), | 1875 setEndingSelection(createVisibleSelection( |
| 1873 endingSelection().isDirectional())); | 1876 SelectionInDOMTree::Builder() |
| 1877 .collapse(atBR.toPositionWithAffinity()) |
| 1878 .setIsDirectional(endingSelection().isDirectional()) |
| 1879 .build())); |
| 1874 | 1880 |
| 1875 // If this is an empty paragraph there must be a line break here. | 1881 // If this is an empty paragraph there must be a line break here. |
| 1876 if (!lineBreakExistsAtVisiblePosition(caret)) | 1882 if (!lineBreakExistsAtVisiblePosition(caret)) |
| 1877 return false; | 1883 return false; |
| 1878 | 1884 |
| 1879 Position caretPos(mostForwardCaretPosition(caret.deepEquivalent())); | 1885 Position caretPos(mostForwardCaretPosition(caret.deepEquivalent())); |
| 1880 // A line break is either a br or a preserved newline. | 1886 // A line break is either a br or a preserved newline. |
| 1881 DCHECK(isHTMLBRElement(caretPos.anchorNode()) || | 1887 DCHECK(isHTMLBRElement(caretPos.anchorNode()) || |
| 1882 (caretPos.anchorNode()->isTextNode() && | 1888 (caretPos.anchorNode()->isTextNode() && |
| 1883 caretPos.anchorNode()->layoutObject()->style()->preserveNewline())) | 1889 caretPos.anchorNode()->layoutObject()->style()->preserveNewline())) |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2017 return node; | 2023 return node; |
| 2018 } | 2024 } |
| 2019 | 2025 |
| 2020 DEFINE_TRACE(CompositeEditCommand) { | 2026 DEFINE_TRACE(CompositeEditCommand) { |
| 2021 visitor->trace(m_commands); | 2027 visitor->trace(m_commands); |
| 2022 visitor->trace(m_composition); | 2028 visitor->trace(m_composition); |
| 2023 EditCommand::trace(visitor); | 2029 EditCommand::trace(visitor); |
| 2024 } | 2030 } |
| 2025 | 2031 |
| 2026 } // namespace blink | 2032 } // namespace blink |
| OLD | NEW |