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

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

Issue 54803003: Have Node::lastDescendant() return a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Kill firstDescendant()! 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
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/editing/ReplaceSelectionCommand.h » ('j') | 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 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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // NodeTraversal::nextSkippingChildren just blew past the end po sition, so stop deleting 516 // NodeTraversal::nextSkippingChildren just blew past the end po sition, so stop deleting
517 node = 0; 517 node = 0;
518 } else if (!m_downstreamEnd.deprecatedNode()->isDescendantOf(node.ge t())) { 518 } else if (!m_downstreamEnd.deprecatedNode()->isDescendantOf(node.ge t())) {
519 RefPtr<Node> nextNode = NodeTraversal::nextSkippingChildren(node .get()); 519 RefPtr<Node> nextNode = NodeTraversal::nextSkippingChildren(node .get());
520 // if we just removed a node from the end container, update end position so the 520 // if we just removed a node from the end container, update end position so the
521 // check above will work 521 // check above will work
522 updatePositionForNodeRemoval(m_downstreamEnd, node.get()); 522 updatePositionForNodeRemoval(m_downstreamEnd, node.get());
523 removeNode(node.get()); 523 removeNode(node.get());
524 node = nextNode.get(); 524 node = nextNode.get();
525 } else { 525 } else {
526 Node* n = node->lastDescendant(); 526 Node& n = node->lastDescendant();
527 if (m_downstreamEnd.deprecatedNode() == n && m_downstreamEnd.dep recatedEditingOffset() >= caretMaxOffset(n)) { 527 if (m_downstreamEnd.deprecatedNode() == n && m_downstreamEnd.dep recatedEditingOffset() >= caretMaxOffset(&n)) {
528 removeNode(node.get()); 528 removeNode(node.get());
529 node = 0; 529 node = 0;
530 } else 530 } else
531 node = NodeTraversal::next(node.get()); 531 node = NodeTraversal::next(node.get());
532 } 532 }
533 } 533 }
534 534
535 if (m_downstreamEnd.deprecatedNode() != startNode && !m_upstreamStart.de precatedNode()->isDescendantOf(m_downstreamEnd.deprecatedNode()) && m_downstream End.inDocument() && m_downstreamEnd.deprecatedEditingOffset() >= caretMinOffset( m_downstreamEnd.deprecatedNode())) { 535 if (m_downstreamEnd.deprecatedNode() != startNode && !m_upstreamStart.de precatedNode()->isDescendantOf(m_downstreamEnd.deprecatedNode()) && m_downstream End.inDocument() && m_downstreamEnd.deprecatedEditingOffset() >= caretMinOffset( m_downstreamEnd.deprecatedNode())) {
536 if (m_downstreamEnd.atLastEditingPositionForNode() && !canHaveChildr enForEditing(m_downstreamEnd.deprecatedNode())) { 536 if (m_downstreamEnd.atLastEditingPositionForNode() && !canHaveChildr enForEditing(m_downstreamEnd.deprecatedNode())) {
537 // The node itself is fully selected, not just its contents. De lete it. 537 // The node itself is fully selected, not just its contents. De lete it.
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 853
854 // Normally deletion doesn't preserve the typing style that was present before i t. For example, 854 // Normally deletion doesn't preserve the typing style that was present before i t. For example,
855 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't 855 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't
856 // stick around. Deletion should preserve a typing style that *it* sets, howeve r. 856 // stick around. Deletion should preserve a typing style that *it* sets, howeve r.
857 bool DeleteSelectionCommand::preservesTypingStyle() const 857 bool DeleteSelectionCommand::preservesTypingStyle() const
858 { 858 {
859 return m_typingStyle; 859 return m_typingStyle;
860 } 860 }
861 861
862 } // namespace WebCore 862 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/editing/ReplaceSelectionCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698