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

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

Issue 13954003: Remove mail blockquote special case handling. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005, 2006 Apple Computer, 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // We don't want to return a root node (if it happens to be a div, e.g., in a document fragment) because there are no 52 // We don't want to return a root node (if it happens to be a div, e.g., in a document fragment) because there are no
53 // siblings for us to append to. 53 // siblings for us to append to.
54 while (!curBlock->nextSibling() && curBlock->parentElement()->hasTagName(div Tag) && curBlock->parentElement()->parentElement()) { 54 while (!curBlock->nextSibling() && curBlock->parentElement()->hasTagName(div Tag) && curBlock->parentElement()->parentElement()) {
55 if (curBlock->parentElement()->hasAttributes()) 55 if (curBlock->parentElement()->hasAttributes())
56 break; 56 break;
57 curBlock = curBlock->parentElement(); 57 curBlock = curBlock->parentElement();
58 } 58 }
59 return curBlock; 59 return curBlock;
60 } 60 }
61 61
62 InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *docum ent, bool mustUseDefaultParagraphElement, bool pasteBlockqutoeIntoUnquotedArea) 62 InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *docum ent, bool mustUseDefaultParagraphElement)
63 : CompositeEditCommand(document) 63 : CompositeEditCommand(document)
64 , m_mustUseDefaultParagraphElement(mustUseDefaultParagraphElement) 64 , m_mustUseDefaultParagraphElement(mustUseDefaultParagraphElement)
65 , m_pasteBlockqutoeIntoUnquotedArea(pasteBlockqutoeIntoUnquotedArea)
66 { 65 {
67 } 66 }
68 67
69 bool InsertParagraphSeparatorCommand::preservesTypingStyle() const 68 bool InsertParagraphSeparatorCommand::preservesTypingStyle() const
70 { 69 {
71 return true; 70 return true;
72 } 71 }
73 72
74 void InsertParagraphSeparatorCommand::calculateStyleBeforeInsertion(const Positi on &pos) 73 void InsertParagraphSeparatorCommand::calculateStyleBeforeInsertion(const Positi on &pos)
75 { 74 {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if (nestNewBlock) { 215 if (nestNewBlock) {
217 if (isFirstInBlock && !lineBreakExistsAtVisiblePosition(visiblePos)) { 216 if (isFirstInBlock && !lineBreakExistsAtVisiblePosition(visiblePos)) {
218 // The block is empty. Create an empty block to 217 // The block is empty. Create an empty block to
219 // represent the paragraph that we're leaving. 218 // represent the paragraph that we're leaving.
220 RefPtr<Element> extraBlock = createDefaultParagraphElement(docum ent()); 219 RefPtr<Element> extraBlock = createDefaultParagraphElement(docum ent());
221 appendNode(extraBlock, startBlock); 220 appendNode(extraBlock, startBlock);
222 appendBlockPlaceholder(extraBlock); 221 appendBlockPlaceholder(extraBlock);
223 } 222 }
224 appendNode(blockToInsert, startBlock); 223 appendNode(blockToInsert, startBlock);
225 } else { 224 } else {
226 // We can get here if we pasted a copied portion of a blockquote wit h a newline at the end and are trying to paste it
227 // into an unquoted area. We then don't want the newline within the blockquote or else it will also be quoted.
228 if (m_pasteBlockqutoeIntoUnquotedArea) {
229 if (Node* highestBlockquote = highestEnclosingNodeOfType(canonic alPos, &isMailBlockquote))
230 startBlock = toElement(highestBlockquote);
231 }
232
233 // Most of the time we want to stay at the nesting level of the star tBlock (e.g., when nesting within lists). However, 225 // Most of the time we want to stay at the nesting level of the star tBlock (e.g., when nesting within lists). However,
234 // for div nodes, this can result in nested div tags that are hard t o break out of. 226 // for div nodes, this can result in nested div tags that are hard t o break out of.
235 Element* siblingNode = startBlock.get(); 227 Element* siblingNode = startBlock.get();
236 if (blockToInsert->hasTagName(divTag)) 228 if (blockToInsert->hasTagName(divTag))
237 siblingNode = highestVisuallyEquivalentDivBelowRoot(startBlock.g et()); 229 siblingNode = highestVisuallyEquivalentDivBelowRoot(startBlock.g et());
238 insertNodeAfter(blockToInsert, siblingNode); 230 insertNodeAfter(blockToInsert, siblingNode);
239 } 231 }
240 232
241 // Recreate the same structure in the new paragraph. 233 // Recreate the same structure in the new paragraph.
242 234
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (positionAfterSplit.deprecatedNode()->isTextNode()) 383 if (positionAfterSplit.deprecatedNode()->isTextNode())
392 insertTextIntoNode(toText(positionAfterSplit.containerNode()), 0 , nonBreakingSpaceString()); 384 insertTextIntoNode(toText(positionAfterSplit.containerNode()), 0 , nonBreakingSpaceString());
393 } 385 }
394 } 386 }
395 387
396 setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert.get()) , DOWNSTREAM, endingSelection().isDirectional())); 388 setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert.get()) , DOWNSTREAM, endingSelection().isDirectional()));
397 applyStyleAfterInsertion(startBlock.get()); 389 applyStyleAfterInsertion(startBlock.get());
398 } 390 }
399 391
400 } // namespace WebCore 392 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698