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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 VisiblePosition atBR(positionBeforeNode(br.get())); | 1091 VisiblePosition atBR(positionBeforeNode(br.get())); |
1092 // If the br we inserted collapsed, for example foo<br><blockquote>...</bloc
kquote>, insert | 1092 // If the br we inserted collapsed, for example foo<br><blockquote>...</bloc
kquote>, insert |
1093 // a second one. | 1093 // a second one. |
1094 if (!isStartOfParagraph(atBR)) | 1094 if (!isStartOfParagraph(atBR)) |
1095 insertNodeBefore(createBreakElement(document()), br); | 1095 insertNodeBefore(createBreakElement(document()), br); |
1096 setEndingSelection(VisibleSelection(atBR)); | 1096 setEndingSelection(VisibleSelection(atBR)); |
1097 | 1097 |
1098 // If this is an empty paragraph there must be a line break here. | 1098 // If this is an empty paragraph there must be a line break here. |
1099 if (!lineBreakExistsAtVisiblePosition(caret)) | 1099 if (!lineBreakExistsAtVisiblePosition(caret)) |
1100 return false; | 1100 return false; |
1101 | 1101 |
1102 Position caretPos(caret.deepEquivalent()); | 1102 Position caretPos(caret.deepEquivalent().downstream()); |
1103 // A line break is either a br or a preserved newline. | 1103 // A line break is either a br or a preserved newline. |
1104 ASSERT(caretPos.node()->hasTagName(brTag) || (caretPos.node()->isTextNode()
&& caretPos.node()->renderer()->style()->preserveNewline())); | 1104 ASSERT(caretPos.node()->hasTagName(brTag) || (caretPos.node()->isTextNode()
&& caretPos.node()->renderer()->style()->preserveNewline())); |
1105 | 1105 |
1106 if (caretPos.node()->hasTagName(brTag)) { | 1106 if (caretPos.node()->hasTagName(brTag)) { |
1107 Position beforeBR(positionInParentBeforeNode(caretPos.node())); | 1107 Position beforeBR(positionInParentBeforeNode(caretPos.node())); |
1108 removeNode(caretPos.node()); | 1108 removeNode(caretPos.node()); |
1109 prune(beforeBR.node()); | 1109 prune(beforeBR.node()); |
1110 } else { | 1110 } else if (caretPos.node()->isTextNode()) { |
1111 ASSERT(caretPos.deprecatedEditingOffset() == 0); | 1111 ASSERT(caretPos.deprecatedEditingOffset() == 0); |
1112 Text* textNode = static_cast<Text*>(caretPos.node()); | 1112 Text* textNode = static_cast<Text*>(caretPos.node()); |
1113 ContainerNode* parentNode = textNode->parentNode(); | 1113 ContainerNode* parentNode = textNode->parentNode(); |
1114 // The preserved newline must be the first thing in the node, since othe
rwise the previous | 1114 // The preserved newline must be the first thing in the node, since othe
rwise the previous |
1115 // paragraph would be quoted, and we verified that it wasn't above. | 1115 // paragraph would be quoted, and we verified that it wasn't above. |
1116 deleteTextFromNode(textNode, 0, 1); | 1116 deleteTextFromNode(textNode, 0, 1); |
1117 prune(parentNode); | 1117 prune(parentNode); |
1118 } | 1118 } |
1119 | 1119 |
1120 return true; | 1120 return true; |
1121 } | 1121 } |
1122 | 1122 |
1123 // Operations use this function to avoid inserting content into an anchor when a
t the start or the end of | 1123 // Operations use this function to avoid inserting content into an anchor when a
t the start or the end of |
1124 // that anchor, as in NSTextView. | 1124 // that anchor, as in NSTextView. |
1125 // FIXME: This is only an approximation of NSTextViews insertion behavior, which
varies depending on how | 1125 // FIXME: This is only an approximation of NSTextViews insertion behavior, which
varies depending on how |
1126 // the caret was made. | 1126 // the caret was made. |
1127 Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(const Posi
tion& original) | 1127 Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(const Posi
tion& original) |
1128 { | 1128 { |
1129 if (original.isNull()) | 1129 if (original.isNull()) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 return node.release(); | 1203 return node.release(); |
1204 } | 1204 } |
1205 | 1205 |
1206 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) | 1206 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) |
1207 { | 1207 { |
1208 RefPtr<Element> breakNode = document->createElement(brTag, false); | 1208 RefPtr<Element> breakNode = document->createElement(brTag, false); |
1209 return breakNode.release(); | 1209 return breakNode.release(); |
1210 } | 1210 } |
1211 | 1211 |
1212 } // namespace WebCore | 1212 } // namespace WebCore |
OLD | NEW |