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

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

Issue 69543007: Have NodeTraversal::nextSkippingChildren() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 CompositeEditCommand::deleteTextFromNode(node, offset, count); 424 CompositeEditCommand::deleteTextFromNode(node, offset, count);
425 } 425 }
426 426
427 void DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPr eventStyleLoss() 427 void DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPr eventStyleLoss()
428 { 428 {
429 RefPtr<Range> range = m_selectionToDelete.toNormalizedRange(); 429 RefPtr<Range> range = m_selectionToDelete.toNormalizedRange();
430 RefPtr<Node> node = range->firstNode(); 430 RefPtr<Node> node = range->firstNode();
431 while (node && node != range->pastLastNode()) { 431 while (node && node != range->pastLastNode()) {
432 RefPtr<Node> nextNode = NodeTraversal::next(*node); 432 RefPtr<Node> nextNode = NodeTraversal::next(*node);
433 if ((node->hasTagName(styleTag) && !(toElement(node)->hasAttribute(scope dAttr))) || node->hasTagName(linkTag)) { 433 if ((node->hasTagName(styleTag) && !(toElement(node)->hasAttribute(scope dAttr))) || node->hasTagName(linkTag)) {
434 nextNode = NodeTraversal::nextSkippingChildren(node.get()); 434 nextNode = NodeTraversal::nextSkippingChildren(*node);
435 RefPtr<ContainerNode> rootEditableElement = node->rootEditableElemen t(); 435 RefPtr<ContainerNode> rootEditableElement = node->rootEditableElemen t();
436 if (rootEditableElement.get()) { 436 if (rootEditableElement.get()) {
437 removeNode(node); 437 removeNode(node);
438 appendNode(node, rootEditableElement); 438 appendNode(node, rootEditableElement);
439 } 439 }
440 } 440 }
441 node = nextNode; 441 node = nextNode;
442 } 442 }
443 } 443 }
444 444
(...skipping 16 matching lines...) Expand all
461 return; 461 return;
462 } 462 }
463 463
464 if (startOffset >= caretMaxOffset(startNode) && startNode->isTextNode()) { 464 if (startOffset >= caretMaxOffset(startNode) && startNode->isTextNode()) {
465 Text* text = toText(startNode); 465 Text* text = toText(startNode);
466 if (text->length() > (unsigned)caretMaxOffset(startNode)) 466 if (text->length() > (unsigned)caretMaxOffset(startNode))
467 deleteTextFromNode(text, caretMaxOffset(startNode), text->length() - caretMaxOffset(startNode)); 467 deleteTextFromNode(text, caretMaxOffset(startNode), text->length() - caretMaxOffset(startNode));
468 } 468 }
469 469
470 if (startOffset >= lastOffsetForEditing(startNode)) { 470 if (startOffset >= lastOffsetForEditing(startNode)) {
471 startNode = NodeTraversal::nextSkippingChildren(startNode); 471 startNode = NodeTraversal::nextSkippingChildren(*startNode);
472 startOffset = 0; 472 startOffset = 0;
473 } 473 }
474 474
475 // Done adjusting the start. See if we're all done. 475 // Done adjusting the start. See if we're all done.
476 if (!startNode) 476 if (!startNode)
477 return; 477 return;
478 478
479 if (startNode == m_downstreamEnd.deprecatedNode()) { 479 if (startNode == m_downstreamEnd.deprecatedNode()) {
480 if (m_downstreamEnd.deprecatedEditingOffset() - startOffset > 0) { 480 if (m_downstreamEnd.deprecatedEditingOffset() - startOffset > 0) {
481 if (startNode->isTextNode()) { 481 if (startNode->isTextNode()) {
(...skipping 28 matching lines...) Expand all
510 Text* text = toText(m_upstreamEnd.deprecatedNode()); 510 Text* text = toText(m_upstreamEnd.deprecatedNode());
511 deleteTextFromNode(text, 0, m_upstreamEnd.deprecatedEditingOffset()) ; 511 deleteTextFromNode(text, 0, m_upstreamEnd.deprecatedEditingOffset()) ;
512 } 512 }
513 513
514 // handle deleting all nodes that are completely selected 514 // handle deleting all nodes that are completely selected
515 while (node && node != m_downstreamEnd.deprecatedNode()) { 515 while (node && node != m_downstreamEnd.deprecatedNode()) {
516 if (comparePositions(firstPositionInOrBeforeNode(node.get()), m_down streamEnd) >= 0) { 516 if (comparePositions(firstPositionInOrBeforeNode(node.get()), m_down streamEnd) >= 0) {
517 // NodeTraversal::nextSkippingChildren just blew past the end po sition, so stop deleting 517 // NodeTraversal::nextSkippingChildren just blew past the end po sition, so stop deleting
518 node = 0; 518 node = 0;
519 } else if (!m_downstreamEnd.deprecatedNode()->isDescendantOf(node.ge t())) { 519 } else if (!m_downstreamEnd.deprecatedNode()->isDescendantOf(node.ge t())) {
520 RefPtr<Node> nextNode = NodeTraversal::nextSkippingChildren(node .get()); 520 RefPtr<Node> nextNode = NodeTraversal::nextSkippingChildren(*nod e);
521 // if we just removed a node from the end container, update end position so the 521 // if we just removed a node from the end container, update end position so the
522 // check above will work 522 // check above will work
523 updatePositionForNodeRemoval(m_downstreamEnd, node.get()); 523 updatePositionForNodeRemoval(m_downstreamEnd, node.get());
524 removeNode(node.get()); 524 removeNode(node.get());
525 node = nextNode.get(); 525 node = nextNode.get();
526 } else { 526 } else {
527 Node& n = node->lastDescendant(); 527 Node& n = node->lastDescendant();
528 if (m_downstreamEnd.deprecatedNode() == n && m_downstreamEnd.dep recatedEditingOffset() >= caretMaxOffset(&n)) { 528 if (m_downstreamEnd.deprecatedNode() == n && m_downstreamEnd.dep recatedEditingOffset() >= caretMaxOffset(&n)) {
529 removeNode(node.get()); 529 removeNode(node.get());
530 node = 0; 530 node = 0;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 855
856 // Normally deletion doesn't preserve the typing style that was present before i t. For example, 856 // Normally deletion doesn't preserve the typing style that was present before i t. For example,
857 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't 857 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't
858 // stick around. Deletion should preserve a typing style that *it* sets, howeve r. 858 // stick around. Deletion should preserve a typing style that *it* sets, howeve r.
859 bool DeleteSelectionCommand::preservesTypingStyle() const 859 bool DeleteSelectionCommand::preservesTypingStyle() const
860 { 860 {
861 return m_typingStyle; 861 return m_typingStyle;
862 } 862 }
863 863
864 } // namespace WebCore 864 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/CompositeEditCommand.cpp ('k') | Source/core/editing/ReplaceSelectionCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698