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

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

Issue 188033005: Have Position deal with more references (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 { 105 {
106 Node* startSpecialContainer = 0; 106 Node* startSpecialContainer = 0;
107 Node* endSpecialContainer = 0; 107 Node* endSpecialContainer = 0;
108 108
109 start = m_selectionToDelete.start(); 109 start = m_selectionToDelete.start();
110 end = m_selectionToDelete.end(); 110 end = m_selectionToDelete.end();
111 111
112 // For HRs, we'll get a position at (HR,1) when hitting delete from the begi nning of the previous line, or (HR,0) when forward deleting, 112 // For HRs, we'll get a position at (HR,1) when hitting delete from the begi nning of the previous line, or (HR,0) when forward deleting,
113 // but in these cases, we want to delete it, so manually expand the selectio n 113 // but in these cases, we want to delete it, so manually expand the selectio n
114 if (start.deprecatedNode()->hasTagName(hrTag)) 114 if (start.deprecatedNode()->hasTagName(hrTag))
115 start = positionBeforeNode(start.deprecatedNode()); 115 start = positionBeforeNode(*start.deprecatedNode());
116 else if (end.deprecatedNode()->hasTagName(hrTag)) 116 else if (end.deprecatedNode()->hasTagName(hrTag))
117 end = positionAfterNode(end.deprecatedNode()); 117 end = positionAfterNode(*end.deprecatedNode());
118 118
119 // FIXME: This is only used so that moveParagraphs can avoid the bugs in spe cial element expansion. 119 // FIXME: This is only used so that moveParagraphs can avoid the bugs in spe cial element expansion.
120 if (!m_expandForSpecialElements) 120 if (!m_expandForSpecialElements)
121 return; 121 return;
122 122
123 while (1) { 123 while (1) {
124 startSpecialContainer = 0; 124 startSpecialContainer = 0;
125 endSpecialContainer = 0; 125 endSpecialContainer = 0;
126 126
127 Position s = positionBeforeContainingSpecialElement(start, &startSpecial Container); 127 Position s = positionBeforeContainingSpecialElement(start, &startSpecial Container);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 bool upstreamStartIsBR = nodeAfterUpstreamStart->hasTagName(brTag); 308 bool upstreamStartIsBR = nodeAfterUpstreamStart->hasTagName(brTag);
309 bool downstreamStartIsBR = nodeAfterDownstreamStart->hasTagName(brTag); 309 bool downstreamStartIsBR = nodeAfterDownstreamStart->hasTagName(brTag);
310 bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && nodeAf terDownstreamStart == nodeAfterUpstreamEnd; 310 bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && nodeAf terDownstreamStart == nodeAfterUpstreamEnd;
311 if (isBROnLineByItself) { 311 if (isBROnLineByItself) {
312 removeNode(nodeAfterDownstreamStart); 312 removeNode(nodeAfterDownstreamStart);
313 return true; 313 return true;
314 } 314 }
315 315
316 // FIXME: This code doesn't belong in here. 316 // FIXME: This code doesn't belong in here.
317 // We detect the case where the start is an empty line consisting of BR not wrapped in a block element. 317 // We detect the case where the start is an empty line consisting of BR not wrapped in a block element.
318 if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(VisiblePosi tion(positionBeforeNode(nodeAfterUpstreamStart))) && isEndOfBlock(VisiblePositio n(positionAfterNode(nodeAfterUpstreamStart))))) { 318 if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(VisiblePosi tion(positionBeforeNode(*nodeAfterUpstreamStart))) && isEndOfBlock(VisiblePositi on(positionAfterNode(*nodeAfterUpstreamStart))))) {
319 m_startsAtEmptyLine = true; 319 m_startsAtEmptyLine = true;
320 m_endingPosition = m_downstreamEnd; 320 m_endingPosition = m_downstreamEnd;
321 } 321 }
322 322
323 return false; 323 return false;
324 } 324 }
325 325
326 static Position firstEditablePositionInNode(Node* node) 326 static Position firstEditablePositionInNode(Node* node)
327 { 327 {
328 ASSERT(node); 328 ASSERT(node);
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 856
857 // Normally deletion doesn't preserve the typing style that was present before i t. For example, 857 // Normally deletion doesn't preserve the typing style that was present before i t. For example,
858 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't 858 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't
859 // stick around. Deletion should preserve a typing style that *it* sets, howeve r. 859 // stick around. Deletion should preserve a typing style that *it* sets, howeve r.
860 bool DeleteSelectionCommand::preservesTypingStyle() const 860 bool DeleteSelectionCommand::preservesTypingStyle() const
861 { 861 {
862 return m_typingStyle; 862 return m_typingStyle;
863 } 863 }
864 864
865 } // namespace WebCore 865 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/CompositeEditCommand.cpp ('k') | Source/core/editing/FormatBlockCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698