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

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

Issue 17381003: When trying to break a line after an image followed by some text, contrary to the expected behavior… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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/inserting/insert-paragraph-after-non-editable-node-before-text-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 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 309
310 // Move downstream. Typing style code will take care of carrying along the 310 // Move downstream. Typing style code will take care of carrying along the
311 // style of the upstream position. 311 // style of the upstream position.
312 insertionPosition = insertionPosition.downstream(); 312 insertionPosition = insertionPosition.downstream();
313 313
314 // At this point, the insertionPosition's node could be a container, and we want to make sure we include 314 // At this point, the insertionPosition's node could be a container, and we want to make sure we include
315 // all of the correct nodes when building the ancestor list. So this needs to be the deepest representation of the position 315 // all of the correct nodes when building the ancestor list. So this needs to be the deepest representation of the position
316 // before we walk the DOM tree. 316 // before we walk the DOM tree.
317 insertionPosition = positionOutsideTabSpan(VisiblePosition(insertionPosition ).deepEquivalent()); 317 insertionPosition = positionOutsideTabSpan(VisiblePosition(insertionPosition ).deepEquivalent());
318 318
319 // If the returned position lies either at the end or at the start of an ele ment that is ignored by editing
320 // we should move to its upstream or downstream position.
321 if (editingIgnoresContent(insertionPosition.deprecatedNode())) {
322 if (insertionPosition.atLastEditingPositionForNode())
323 insertionPosition = insertionPosition.downstream();
324 else if (insertionPosition.atFirstEditingPositionForNode())
325 insertionPosition = insertionPosition.upstream();
326 }
327
319 // Make sure we do not cause a rendered space to become unrendered. 328 // Make sure we do not cause a rendered space to become unrendered.
320 // FIXME: We need the affinity for pos, but pos.downstream() does not give i t 329 // FIXME: We need the affinity for pos, but pos.downstream() does not give i t
321 Position leadingWhitespace = insertionPosition.leadingWhitespacePosition(VP_ DEFAULT_AFFINITY); 330 Position leadingWhitespace = insertionPosition.leadingWhitespacePosition(VP_ DEFAULT_AFFINITY);
322 // FIXME: leadingWhitespacePosition is returning the position before preserv ed newlines for positions 331 // FIXME: leadingWhitespacePosition is returning the position before preserv ed newlines for positions
323 // after the preserved newline, causing the newline to be turned into a nbsp . 332 // after the preserved newline, causing the newline to be turned into a nbsp .
324 if (leadingWhitespace.isNotNull() && leadingWhitespace.deprecatedNode()->isT extNode()) { 333 if (leadingWhitespace.isNotNull() && leadingWhitespace.deprecatedNode()->isT extNode()) {
325 Text* textNode = toText(leadingWhitespace.deprecatedNode()); 334 Text* textNode = toText(leadingWhitespace.deprecatedNode());
326 ASSERT(!textNode->renderer() || textNode->renderer()->style()->collapseW hiteSpace()); 335 ASSERT(!textNode->renderer() || textNode->renderer()->style()->collapseW hiteSpace());
327 replaceTextInNodePreservingMarkers(textNode, leadingWhitespace.deprecate dEditingOffset(), 1, nonBreakingSpaceString()); 336 replaceTextInNodePreservingMarkers(textNode, leadingWhitespace.deprecate dEditingOffset(), 1, nonBreakingSpaceString());
328 } 337 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (positionAfterSplit.deprecatedNode()->isTextNode()) 399 if (positionAfterSplit.deprecatedNode()->isTextNode())
391 insertTextIntoNode(toText(positionAfterSplit.containerNode()), 0 , nonBreakingSpaceString()); 400 insertTextIntoNode(toText(positionAfterSplit.containerNode()), 0 , nonBreakingSpaceString());
392 } 401 }
393 } 402 }
394 403
395 setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert.get()) , DOWNSTREAM, endingSelection().isDirectional())); 404 setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert.get()) , DOWNSTREAM, endingSelection().isDirectional()));
396 applyStyleAfterInsertion(startBlock.get()); 405 applyStyleAfterInsertion(startBlock.get());
397 } 406 }
398 407
399 } // namespace WebCore 408 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/inserting/insert-paragraph-after-non-editable-node-before-text-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698