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

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

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