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

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

Issue 3027024: Merge 63773 - 2010-07-20 Abhishek Arya <inferno@chromium.org>... (Closed) Base URL: svn://chrome-svn/chrome/branches/WebKit/472/
Patch Set: Created 10 years, 5 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
« no previous file with comments | « WebCore/editing/InsertLineBreakCommand.cpp ('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 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 // Build up list of ancestors in between the start node and the start block. 306 // Build up list of ancestors in between the start node and the start block.
307 Vector<Element*> ancestors; 307 Vector<Element*> ancestors;
308 getAncestorsInsideBlock(insertionPosition.node(), startBlock, ancestors); 308 getAncestorsInsideBlock(insertionPosition.node(), startBlock, ancestors);
309 309
310 // Make sure we do not cause a rendered space to become unrendered. 310 // Make sure we do not cause a rendered space to become unrendered.
311 // FIXME: We need the affinity for pos, but pos.downstream() does not give i t 311 // FIXME: We need the affinity for pos, but pos.downstream() does not give i t
312 Position leadingWhitespace = insertionPosition.leadingWhitespacePosition(VP_ DEFAULT_AFFINITY); 312 Position leadingWhitespace = insertionPosition.leadingWhitespacePosition(VP_ DEFAULT_AFFINITY);
313 // FIXME: leadingWhitespacePosition is returning the position before preserv ed newlines for positions 313 // FIXME: leadingWhitespacePosition is returning the position before preserv ed newlines for positions
314 // after the preserved newline, causing the newline to be turned into a nbsp . 314 // after the preserved newline, causing the newline to be turned into a nbsp .
315 if (leadingWhitespace.isNotNull()) { 315 if (leadingWhitespace.isNotNull() && leadingWhitespace.node()->isTextNode()) {
316 Text* textNode = static_cast<Text*>(leadingWhitespace.node()); 316 Text* textNode = static_cast<Text*>(leadingWhitespace.node());
317 ASSERT(!textNode->renderer() || textNode->renderer()->style()->collapseW hiteSpace()); 317 ASSERT(!textNode->renderer() || textNode->renderer()->style()->collapseW hiteSpace());
318 replaceTextInNode(textNode, leadingWhitespace.deprecatedEditingOffset(), 1, nonBreakingSpaceString()); 318 replaceTextInNode(textNode, leadingWhitespace.deprecatedEditingOffset(), 1, nonBreakingSpaceString());
319 } 319 }
320 320
321 // Split at pos if in the middle of a text node. 321 // Split at pos if in the middle of a text node.
322 if (insertionPosition.node()->isTextNode()) { 322 if (insertionPosition.node()->isTextNode()) {
323 Text* textNode = static_cast<Text*>(insertionPosition.node()); 323 Text* textNode = static_cast<Text*>(insertionPosition.node());
324 bool atEnd = (unsigned)insertionPosition.deprecatedEditingOffset() >= te xtNode->length(); 324 bool atEnd = (unsigned)insertionPosition.deprecatedEditingOffset() >= te xtNode->length();
325 if (insertionPosition.deprecatedEditingOffset() > 0 && !atEnd) { 325 if (insertionPosition.deprecatedEditingOffset() > 0 && !atEnd) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 leftParent = leftParent->parentElement(); 378 leftParent = leftParent->parentElement();
379 } 379 }
380 } 380 }
381 381
382 // Handle whitespace that occurs after the split 382 // Handle whitespace that occurs after the split
383 if (splitText) { 383 if (splitText) {
384 updateLayout(); 384 updateLayout();
385 insertionPosition = Position(insertionPosition.node(), 0); 385 insertionPosition = Position(insertionPosition.node(), 0);
386 if (!insertionPosition.isRenderedCharacter()) { 386 if (!insertionPosition.isRenderedCharacter()) {
387 // Clear out all whitespace and insert one non-breaking space 387 // Clear out all whitespace and insert one non-breaking space
388 ASSERT(insertionPosition.node()->isTextNode());
389 ASSERT(!insertionPosition.node()->renderer() || insertionPosition.no de()->renderer()->style()->collapseWhiteSpace()); 388 ASSERT(!insertionPosition.node()->renderer() || insertionPosition.no de()->renderer()->style()->collapseWhiteSpace());
390 deleteInsignificantTextDownstream(insertionPosition); 389 deleteInsignificantTextDownstream(insertionPosition);
391 insertTextIntoNode(static_cast<Text*>(insertionPosition.node()), 0, nonBreakingSpaceString()); 390 if (insertionPosition.node()->isTextNode())
391 insertTextIntoNode(static_cast<Text*>(insertionPosition.node()), 0, nonBreakingSpaceString());
392 } 392 }
393 } 393 }
394 394
395 setEndingSelection(VisibleSelection(Position(blockToInsert.get(), 0), DOWNST REAM)); 395 setEndingSelection(VisibleSelection(Position(blockToInsert.get(), 0), DOWNST REAM));
396 applyStyleAfterInsertion(startBlock); 396 applyStyleAfterInsertion(startBlock);
397 } 397 }
398 398
399 } // namespace WebCore 399 } // namespace WebCore
OLDNEW
« no previous file with comments | « WebCore/editing/InsertLineBreakCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698