| 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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 setEndingSelection(VisibleSelection::selectionFromContentsOfNode(anchorNode)
); | 952 setEndingSelection(VisibleSelection::selectionFromContentsOfNode(anchorNode)
); |
| 953 applyStyledElement(toElement(anchorNode)); | 953 applyStyledElement(toElement(anchorNode)); |
| 954 // Clones of anchorNode have been pushed down, now remove it. | 954 // Clones of anchorNode have been pushed down, now remove it. |
| 955 if (anchorNode->inDocument()) | 955 if (anchorNode->inDocument()) |
| 956 removeNodePreservingChildren(anchorNode); | 956 removeNodePreservingChildren(anchorNode); |
| 957 } | 957 } |
| 958 | 958 |
| 959 // Clone the paragraph between start and end under blockElement, | 959 // Clone the paragraph between start and end under blockElement, |
| 960 // preserving the hierarchy up to outerNode. | 960 // preserving the hierarchy up to outerNode. |
| 961 | 961 |
| 962 void CompositeEditCommand::cloneParagraphUnderNewElement(Position& start, Positi
on& end, Node* passedOuterNode, Element* blockElement) | 962 void CompositeEditCommand::cloneParagraphUnderNewElement(const Position& start,
const Position& end, Node* passedOuterNode, Element* blockElement) |
| 963 { | 963 { |
| 964 ASSERT(comparePositions(start, end) <= 0); |
| 965 |
| 964 // First we clone the outerNode | 966 // First we clone the outerNode |
| 965 RefPtr<Node> lastNode; | 967 RefPtr<Node> lastNode; |
| 966 RefPtr<Node> outerNode = passedOuterNode; | 968 RefPtr<Node> outerNode = passedOuterNode; |
| 967 | 969 |
| 968 if (outerNode->isRootEditableElement()) { | 970 if (outerNode->isRootEditableElement()) { |
| 969 lastNode = blockElement; | 971 lastNode = blockElement; |
| 970 } else { | 972 } else { |
| 971 lastNode = outerNode->cloneNode(isRenderedTableElement(outerNode.get()))
; | 973 lastNode = outerNode->cloneNode(isRenderedTableElement(outerNode.get()))
; |
| 972 appendNode(lastNode, blockElement); | 974 appendNode(lastNode, blockElement); |
| 973 } | 975 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 { | 1085 { |
| 1084 ASSERT(outerNode); | 1086 ASSERT(outerNode); |
| 1085 ASSERT(blockElement); | 1087 ASSERT(blockElement); |
| 1086 | 1088 |
| 1087 VisiblePosition beforeParagraph = startOfParagraphToMove.previous(); | 1089 VisiblePosition beforeParagraph = startOfParagraphToMove.previous(); |
| 1088 VisiblePosition afterParagraph(endOfParagraphToMove.next()); | 1090 VisiblePosition afterParagraph(endOfParagraphToMove.next()); |
| 1089 | 1091 |
| 1090 // We upstream() the end and downstream() the start so that we don't include
collapsed whitespace in the move. | 1092 // We upstream() the end and downstream() the start so that we don't include
collapsed whitespace in the move. |
| 1091 // When we paste a fragment, spaces after the end and before the start are t
reated as though they were rendered. | 1093 // When we paste a fragment, spaces after the end and before the start are t
reated as though they were rendered. |
| 1092 Position start = startOfParagraphToMove.deepEquivalent().downstream(); | 1094 Position start = startOfParagraphToMove.deepEquivalent().downstream(); |
| 1093 Position end = endOfParagraphToMove.deepEquivalent().upstream(); | 1095 Position end = startOfParagraphToMove == endOfParagraphToMove ? start : endO
fParagraphToMove.deepEquivalent().upstream(); |
| 1094 | 1096 |
| 1095 cloneParagraphUnderNewElement(start, end, outerNode, blockElement); | 1097 cloneParagraphUnderNewElement(start, end, outerNode, blockElement); |
| 1096 | 1098 |
| 1097 setEndingSelection(VisibleSelection(start, end, DOWNSTREAM)); | 1099 setEndingSelection(VisibleSelection(start, end, DOWNSTREAM)); |
| 1098 deleteSelection(false, false, false, false); | 1100 deleteSelection(false, false, false, false); |
| 1099 | 1101 |
| 1100 // There are bugs in deletion when it removes a fully selected table/list. | 1102 // There are bugs in deletion when it removes a fully selected table/list. |
| 1101 // It expands and removes the entire table/list, but will let content | 1103 // It expands and removes the entire table/list, but will let content |
| 1102 // before and after the table/list collapse onto one line. | 1104 // before and after the table/list collapse onto one line. |
| 1103 | 1105 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 return node.release(); | 1458 return node.release(); |
| 1457 } | 1459 } |
| 1458 | 1460 |
| 1459 PassRefPtr<Element> createBlockPlaceholderElement(Document& document) | 1461 PassRefPtr<Element> createBlockPlaceholderElement(Document& document) |
| 1460 { | 1462 { |
| 1461 RefPtr<Element> breakNode = document.createElement(brTag, false); | 1463 RefPtr<Element> breakNode = document.createElement(brTag, false); |
| 1462 return breakNode.release(); | 1464 return breakNode.release(); |
| 1463 } | 1465 } |
| 1464 | 1466 |
| 1465 } // namespace WebCore | 1467 } // namespace WebCore |
| OLD | NEW |