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

Unified Diff: third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp

Issue 2251703002: Introduce EphemeralRange::nodes() helper to traverse over a range. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move inRange() to EphemeralRange::nodes() Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp
index 73d90630a003e57147bb3418f14174757b5f4ddb..7e845e4da9957ad7fff4f3560d958d3c4e710166 100644
--- a/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp
@@ -437,23 +437,24 @@ void DeleteSelectionCommand::deleteTextFromNode(Text* node, unsigned offset, uns
void DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss(EditingState* editingState)
{
- Range* range = createRange(m_selectionToDelete.toNormalizedEphemeralRange());
- Node* node = range->firstNode();
- while (node && node != range->pastLastNode()) {
- Node* nextNode = NodeTraversal::next(*node);
- if (isHTMLStyleElement(*node) || isHTMLLinkElement(*node)) {
- nextNode = NodeTraversal::nextSkippingChildren(*node);
- Element* element = rootEditableElement(*node);
+ auto iterableRange = m_selectionToDelete.toNormalizedEphemeralRange().nodes();
+ for (auto it = iterableRange.begin(), end = iterableRange.end(); !it.isNull() && it != end;) {
yosin_UTC9 2016/08/18 02:11:09 We could write this loop as (copied from another m
+ Node& node = *it;
+ if (isHTMLStyleElement(node) || isHTMLLinkElement(node)) {
+ Node* nextNode = NodeTraversal::nextSkippingChildren(node);
+ Element* element = rootEditableElement(node);
if (element) {
- removeNode(node, editingState);
+ removeNode(&node, editingState);
if (editingState->isAborted())
return;
- appendNode(node, element, editingState);
+ appendNode(&node, element, editingState);
if (editingState->isAborted())
return;
}
+ it.setCurrent(nextNode);
+ } else {
+ ++it;
}
- node = nextNode;
}
}

Powered by Google App Engine
This is Rietveld 408576698