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

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

Issue 1932523003: Introduce NodeTraversal::ancestorsOf() and inclusiveAncestors() for range-based for loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-04-28T18:38:12 Created 4 years, 7 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) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 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 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 lastNode = outerNode->cloneNode(isDisplayInsideTable(outerNode)); 1069 lastNode = outerNode->cloneNode(isDisplayInsideTable(outerNode));
1070 appendNode(lastNode, blockElement, editingState); 1070 appendNode(lastNode, blockElement, editingState);
1071 if (editingState->isAborted()) 1071 if (editingState->isAborted())
1072 return; 1072 return;
1073 } 1073 }
1074 1074
1075 if (start.anchorNode() != outerNode && lastNode->isElementNode() && start.an chorNode()->isDescendantOf(outerNode)) { 1075 if (start.anchorNode() != outerNode && lastNode->isElementNode() && start.an chorNode()->isDescendantOf(outerNode)) {
1076 HeapVector<Member<Node>> ancestors; 1076 HeapVector<Member<Node>> ancestors;
1077 1077
1078 // Insert each node from innerNode to outerNode (excluded) in a list. 1078 // Insert each node from innerNode to outerNode (excluded) in a list.
1079 for (Node* n = start.anchorNode(); n && n != outerNode; n = n->parentNod e()) 1079 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*start.anchorNod e())) {
1080 ancestors.append(n); 1080 if (runner == outerNode)
1081 break;
1082 ancestors.append(runner);
1083 }
1081 1084
1082 // Clone every node between start.anchorNode() and outerBlock. 1085 // Clone every node between start.anchorNode() and outerBlock.
1083 1086
1084 for (size_t i = ancestors.size(); i != 0; --i) { 1087 for (size_t i = ancestors.size(); i != 0; --i) {
1085 Node* item = ancestors[i - 1].get(); 1088 Node* item = ancestors[i - 1].get();
1086 Node* child = item->cloneNode(isDisplayInsideTable(item)); 1089 Node* child = item->cloneNode(isDisplayInsideTable(item));
1087 appendNode(child, toElement(lastNode), editingState); 1090 appendNode(child, toElement(lastNode), editingState);
1088 if (editingState->isAborted()) 1091 if (editingState->isAborted())
1089 return; 1092 return;
1090 lastNode = child; 1093 lastNode = child;
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 } 1617 }
1615 1618
1616 DEFINE_TRACE(CompositeEditCommand) 1619 DEFINE_TRACE(CompositeEditCommand)
1617 { 1620 {
1618 visitor->trace(m_commands); 1621 visitor->trace(m_commands);
1619 visitor->trace(m_composition); 1622 visitor->trace(m_composition);
1620 EditCommand::trace(visitor); 1623 EditCommand::trace(visitor);
1621 } 1624 }
1622 1625
1623 } // namespace blink 1626 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698