Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Side by Side Diff: Source/WebCore/editing/CompositeEditCommand.cpp

Issue 6591047: Merge 79536 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/648/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/editing/deleting/delete-blockquote-large-offsets-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.deprecatedNode()->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
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
OLDNEW
« no previous file with comments | « LayoutTests/editing/deleting/delete-blockquote-large-offsets-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698