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

Side by Side Diff: third_party/WebKit/Source/core/editing/SelectionEditor.cpp

Issue 2691913002: Introduce computePositionForNodeRemoval() as replacement of updatePositionForNodeRemoval() (Closed)
Patch Set: 2017-02-24T16:31:47 Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 const Position& newExtent = 184 const Position& newExtent =
185 computePositionForChildrenRemoval(oldExtent, container); 185 computePositionForChildrenRemoval(oldExtent, container);
186 if (newBase == oldBase && newExtent == oldExtent) 186 if (newBase == oldBase && newExtent == oldExtent)
187 return; 187 return;
188 m_selection = SelectionInDOMTree::Builder() 188 m_selection = SelectionInDOMTree::Builder()
189 .setBaseAndExtent(newBase, newExtent) 189 .setBaseAndExtent(newBase, newExtent)
190 .build(); 190 .build();
191 markCacheDirty(); 191 markCacheDirty();
192 } 192 }
193 193
194 static Position computePositionForNodeRemoval(const Position& position,
195 Node& nodeToBeRemoved) {
196 Position result = position;
197 // TODO(yosin): We should rename |updatePositionForNodeRemoval()|
198 // to |computePositionForNodeRemoval()| to avoid using output parameter.
199 updatePositionForNodeRemoval(result, nodeToBeRemoved);
200 return result;
201 }
202
203 void SelectionEditor::nodeWillBeRemoved(Node& nodeToBeRemoved) { 194 void SelectionEditor::nodeWillBeRemoved(Node& nodeToBeRemoved) {
204 if (m_selection.isNone()) 195 if (m_selection.isNone())
205 return; 196 return;
206 const Position oldBase = m_selection.m_base; 197 const Position oldBase = m_selection.m_base;
207 const Position oldExtent = m_selection.m_extent; 198 const Position oldExtent = m_selection.m_extent;
208 const Position& newBase = 199 const Position& newBase =
209 computePositionForNodeRemoval(oldBase, nodeToBeRemoved); 200 computePositionForNodeRemoval(oldBase, nodeToBeRemoved);
210 const Position& newExtent = 201 const Position& newExtent =
211 computePositionForNodeRemoval(oldExtent, nodeToBeRemoved); 202 computePositionForNodeRemoval(oldExtent, nodeToBeRemoved);
212 if (newBase == oldBase && newExtent == oldExtent) 203 if (newBase == oldBase && newExtent == oldExtent)
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 visitor->trace(m_frame); 425 visitor->trace(m_frame);
435 visitor->trace(m_selection); 426 visitor->trace(m_selection);
436 visitor->trace(m_cachedVisibleSelectionInDOMTree); 427 visitor->trace(m_cachedVisibleSelectionInDOMTree);
437 visitor->trace(m_cachedVisibleSelectionInFlatTree); 428 visitor->trace(m_cachedVisibleSelectionInFlatTree);
438 visitor->trace(m_logicalRange); 429 visitor->trace(m_logicalRange);
439 visitor->trace(m_cachedRange); 430 visitor->trace(m_cachedRange);
440 SynchronousMutationObserver::trace(visitor); 431 SynchronousMutationObserver::trace(visitor);
441 } 432 }
442 433
443 } // namespace blink 434 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698