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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/SimplifyMarkupCommand.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-28T16:44:17 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) 2012 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2012 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (currentNode->firstChild() != currentNode->lastChild()) { 73 if (currentNode->firstChild() != currentNode->lastChild()) {
74 topNodeWithStartingStyle = 0; 74 topNodeWithStartingStyle = 0;
75 break; 75 break;
76 } 76 }
77 77
78 if (!currentNode->computedStyle()->visualInvalidationDiff(*startingS tyle).hasDifference()) 78 if (!currentNode->computedStyle()->visualInvalidationDiff(*startingS tyle).hasDifference())
79 topNodeWithStartingStyle = currentNode; 79 topNodeWithStartingStyle = currentNode;
80 80
81 } 81 }
82 if (topNodeWithStartingStyle) { 82 if (topNodeWithStartingStyle) {
83 for (ContainerNode* node = startingNode; node != topNodeWithStarting Style; node = node->parentNode()) 83 for (Node& node : NodeTraversal::ancestorsOrSelfOf(startingNode)) {
84 nodesToRemove.append(node); 84 if (node == topNodeWithStartingStyle)
85 break;
86 nodesToRemove.append(static_cast<ContainerNode*>(&node));
87 }
85 } 88 }
86 } 89 }
87 90
88 // we perform all the DOM mutations at once. 91 // we perform all the DOM mutations at once.
89 for (size_t i = 0; i < nodesToRemove.size(); ++i) { 92 for (size_t i = 0; i < nodesToRemove.size(); ++i) {
90 // FIXME: We can do better by directly moving children from nodesToRemov e[i]. 93 // FIXME: We can do better by directly moving children from nodesToRemov e[i].
91 int numPrunedAncestors = pruneSubsequentAncestorsToRemove(nodesToRemove, i, editingState); 94 int numPrunedAncestors = pruneSubsequentAncestorsToRemove(nodesToRemove, i, editingState);
92 if (editingState->isAborted()) 95 if (editingState->isAborted())
93 return; 96 return;
94 if (numPrunedAncestors < 0) 97 if (numPrunedAncestors < 0)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 134 }
132 135
133 DEFINE_TRACE(SimplifyMarkupCommand) 136 DEFINE_TRACE(SimplifyMarkupCommand)
134 { 137 {
135 visitor->trace(m_firstNode); 138 visitor->trace(m_firstNode);
136 visitor->trace(m_nodeAfterLast); 139 visitor->trace(m_nodeAfterLast);
137 CompositeEditCommand::trace(visitor); 140 CompositeEditCommand::trace(visitor);
138 } 141 }
139 142
140 } // namespace blink 143 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698