| 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 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 ASSERT(passedOuterNode); | 992 ASSERT(passedOuterNode); |
| 993 ASSERT(blockElement); | 993 ASSERT(blockElement); |
| 994 | 994 |
| 995 // First we clone the outerNode | 995 // First we clone the outerNode |
| 996 RefPtrWillBeRawPtr<Node> lastNode = nullptr; | 996 RefPtrWillBeRawPtr<Node> lastNode = nullptr; |
| 997 RefPtrWillBeRawPtr<Node> outerNode = passedOuterNode; | 997 RefPtrWillBeRawPtr<Node> outerNode = passedOuterNode; |
| 998 | 998 |
| 999 if (outerNode->isRootEditableElement()) { | 999 if (outerNode->isRootEditableElement()) { |
| 1000 lastNode = blockElement; | 1000 lastNode = blockElement; |
| 1001 } else { | 1001 } else { |
| 1002 lastNode = outerNode->cloneNode(isRenderedTableElement(outerNode.get()))
; | 1002 lastNode = outerNode->cloneNode(isRenderedHTMLTableElement(outerNode.get
())); |
| 1003 appendNode(lastNode, blockElement); | 1003 appendNode(lastNode, blockElement); |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 if (start.anchorNode() != outerNode && lastNode->isElementNode() && start.an
chorNode()->isDescendantOf(outerNode.get())) { | 1006 if (start.anchorNode() != outerNode && lastNode->isElementNode() && start.an
chorNode()->isDescendantOf(outerNode.get())) { |
| 1007 WillBeHeapVector<RefPtrWillBeMember<Node> > ancestors; | 1007 WillBeHeapVector<RefPtrWillBeMember<Node> > ancestors; |
| 1008 | 1008 |
| 1009 // Insert each node from innerNode to outerNode (excluded) in a list. | 1009 // Insert each node from innerNode to outerNode (excluded) in a list. |
| 1010 for (Node* n = start.deprecatedNode(); n && n != outerNode; n = n->paren
tNode()) | 1010 for (Node* n = start.deprecatedNode(); n && n != outerNode; n = n->paren
tNode()) |
| 1011 ancestors.append(n); | 1011 ancestors.append(n); |
| 1012 | 1012 |
| 1013 // Clone every node between start.deprecatedNode() and outerBlock. | 1013 // Clone every node between start.deprecatedNode() and outerBlock. |
| 1014 | 1014 |
| 1015 for (size_t i = ancestors.size(); i != 0; --i) { | 1015 for (size_t i = ancestors.size(); i != 0; --i) { |
| 1016 Node* item = ancestors[i - 1].get(); | 1016 Node* item = ancestors[i - 1].get(); |
| 1017 RefPtrWillBeRawPtr<Node> child = item->cloneNode(isRenderedTableElem
ent(item)); | 1017 RefPtrWillBeRawPtr<Node> child = item->cloneNode(isRenderedHTMLTable
Element(item)); |
| 1018 appendNode(child, toElement(lastNode)); | 1018 appendNode(child, toElement(lastNode)); |
| 1019 lastNode = child.release(); | 1019 lastNode = child.release(); |
| 1020 } | 1020 } |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 // Scripts specified in javascript protocol may remove |outerNode| | 1023 // Scripts specified in javascript protocol may remove |outerNode| |
| 1024 // during insertion, e.g. <iframe src="javascript:..."> | 1024 // during insertion, e.g. <iframe src="javascript:..."> |
| 1025 if (!outerNode->inDocument()) | 1025 if (!outerNode->inDocument()) |
| 1026 return; | 1026 return; |
| 1027 | 1027 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 // Add a br if pruning an empty block level element caused a collapse. For
example: | 1145 // Add a br if pruning an empty block level element caused a collapse. For
example: |
| 1146 // foo^ | 1146 // foo^ |
| 1147 // <div>bar</div> | 1147 // <div>bar</div> |
| 1148 // baz | 1148 // baz |
| 1149 // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. Th
at would | 1149 // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. Th
at would |
| 1150 // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br
. | 1150 // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br
. |
| 1151 // Must recononicalize these two VisiblePositions after the pruning above. | 1151 // Must recononicalize these two VisiblePositions after the pruning above. |
| 1152 beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent()); | 1152 beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent()); |
| 1153 afterParagraph = VisiblePosition(afterParagraph.deepEquivalent()); | 1153 afterParagraph = VisiblePosition(afterParagraph.deepEquivalent()); |
| 1154 | 1154 |
| 1155 if (beforeParagraph.isNotNull() && !isRenderedTable(beforeParagraph.deepEqui
valent().deprecatedNode()) | 1155 if (beforeParagraph.isNotNull() && !isRenderedTableElement(beforeParagraph.d
eepEquivalent().deprecatedNode()) |
| 1156 && ((!isEndOfParagraph(beforeParagraph) && !isStartOfParagraph(beforePar
agraph)) || beforeParagraph == afterParagraph)) { | 1156 && ((!isEndOfParagraph(beforeParagraph) && !isStartOfParagraph(beforePar
agraph)) || beforeParagraph == afterParagraph)) { |
| 1157 // FIXME: Trim text between beforeParagraph and afterParagraph if they a
ren't equal. | 1157 // FIXME: Trim text between beforeParagraph and afterParagraph if they a
ren't equal. |
| 1158 insertNodeAt(createBreakElement(document()), beforeParagraph.deepEquival
ent()); | 1158 insertNodeAt(createBreakElement(document()), beforeParagraph.deepEquival
ent()); |
| 1159 } | 1159 } |
| 1160 } | 1160 } |
| 1161 | 1161 |
| 1162 void CompositeEditCommand::moveParagraph(const VisiblePosition& startOfParagraph
ToMove, const VisiblePosition& endOfParagraphToMove, const VisiblePosition& dest
ination, bool preserveSelection, bool preserveStyle, Node* constrainingAncestor) | 1162 void CompositeEditCommand::moveParagraph(const VisiblePosition& startOfParagraph
ToMove, const VisiblePosition& endOfParagraphToMove, const VisiblePosition& dest
ination, bool preserveSelection, bool preserveStyle, Node* constrainingAncestor) |
| 1163 { | 1163 { |
| 1164 ASSERT(isStartOfParagraph(startOfParagraphToMove)); | 1164 ASSERT(isStartOfParagraph(startOfParagraphToMove)); |
| 1165 ASSERT(isEndOfParagraph(endOfParagraphToMove)); | 1165 ASSERT(isEndOfParagraph(endOfParagraphToMove)); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 } | 1499 } |
| 1500 | 1500 |
| 1501 void CompositeEditCommand::trace(Visitor* visitor) | 1501 void CompositeEditCommand::trace(Visitor* visitor) |
| 1502 { | 1502 { |
| 1503 visitor->trace(m_commands); | 1503 visitor->trace(m_commands); |
| 1504 visitor->trace(m_composition); | 1504 visitor->trace(m_composition); |
| 1505 EditCommand::trace(visitor); | 1505 EditCommand::trace(visitor); |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 } // namespace blink | 1508 } // namespace blink |
| OLD | NEW |