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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 23 matching lines...) Expand all
34 namespace blink { 34 namespace blink {
35 35
36 SimplifyMarkupCommand::SimplifyMarkupCommand(Document& document, Node* firstNode , Node* nodeAfterLast) 36 SimplifyMarkupCommand::SimplifyMarkupCommand(Document& document, Node* firstNode , Node* nodeAfterLast)
37 : CompositeEditCommand(document), m_firstNode(firstNode), m_nodeAfterLast(no deAfterLast) 37 : CompositeEditCommand(document), m_firstNode(firstNode), m_nodeAfterLast(no deAfterLast)
38 { 38 {
39 } 39 }
40 40
41 void SimplifyMarkupCommand::doApply(EditingState* editingState) 41 void SimplifyMarkupCommand::doApply(EditingState* editingState)
42 { 42 {
43 ContainerNode* rootNode = m_firstNode->parentNode(); 43 ContainerNode* rootNode = m_firstNode->parentNode();
44 WillBeHeapVector<RefPtrWillBeMember<ContainerNode>> nodesToRemove; 44 HeapVector<Member<ContainerNode>> nodesToRemove;
45 45
46 // Walk through the inserted nodes, to see if there are elements that could be removed 46 // Walk through the inserted nodes, to see if there are elements that could be removed
47 // without affecting the style. The goal is to produce leaner markup even wh en starting 47 // without affecting the style. The goal is to produce leaner markup even wh en starting
48 // from a verbose fragment. 48 // from a verbose fragment.
49 // We look at inline elements as well as non top level divs that don't have attributes. 49 // We look at inline elements as well as non top level divs that don't have attributes.
50 for (Node* node = m_firstNode.get(); node && node != m_nodeAfterLast; node = NodeTraversal::next(*node)) { 50 for (Node* node = m_firstNode.get(); node && node != m_nodeAfterLast; node = NodeTraversal::next(*node)) {
51 if (node->hasChildren() || (node->isTextNode() && node->nextSibling())) 51 if (node->hasChildren() || (node->isTextNode() && node->nextSibling()))
52 continue; 52 continue;
53 53
54 ContainerNode* startingNode = node->parentNode(); 54 ContainerNode* startingNode = node->parentNode();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return; 93 return;
94 if (numPrunedAncestors < 0) 94 if (numPrunedAncestors < 0)
95 continue; 95 continue;
96 removeNodePreservingChildren(nodesToRemove[i], editingState, AssumeConte ntIsAlwaysEditable); 96 removeNodePreservingChildren(nodesToRemove[i], editingState, AssumeConte ntIsAlwaysEditable);
97 if (editingState->isAborted()) 97 if (editingState->isAborted())
98 return; 98 return;
99 i += numPrunedAncestors; 99 i += numPrunedAncestors;
100 } 100 }
101 } 101 }
102 102
103 int SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove(WillBeHeapVector<Ref PtrWillBeMember<ContainerNode>>& nodesToRemove, size_t startNodeIndex, EditingSt ate* editingState) 103 int SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove(HeapVector<Member<Co ntainerNode>>& nodesToRemove, size_t startNodeIndex, EditingState* editingState)
104 { 104 {
105 size_t pastLastNodeToRemove = startNodeIndex + 1; 105 size_t pastLastNodeToRemove = startNodeIndex + 1;
106 for (; pastLastNodeToRemove < nodesToRemove.size(); ++pastLastNodeToRemove) { 106 for (; pastLastNodeToRemove < nodesToRemove.size(); ++pastLastNodeToRemove) {
107 if (nodesToRemove[pastLastNodeToRemove - 1]->parentNode() != nodesToRemo ve[pastLastNodeToRemove]) 107 if (nodesToRemove[pastLastNodeToRemove - 1]->parentNode() != nodesToRemo ve[pastLastNodeToRemove])
108 break; 108 break;
109 ASSERT(nodesToRemove[pastLastNodeToRemove]->firstChild() == nodesToRemov e[pastLastNodeToRemove]->lastChild()); 109 ASSERT(nodesToRemove[pastLastNodeToRemove]->firstChild() == nodesToRemov e[pastLastNodeToRemove]->lastChild());
110 } 110 }
111 111
112 ContainerNode* highestAncestorToRemove = nodesToRemove[pastLastNodeToRemove - 1].get(); 112 ContainerNode* highestAncestorToRemove = nodesToRemove[pastLastNodeToRemove - 1].get();
113 RefPtrWillBeRawPtr<ContainerNode> parent = highestAncestorToRemove->parentNo de(); 113 RawPtr<ContainerNode> parent = highestAncestorToRemove->parentNode();
114 if (!parent) // Parent has already been removed. 114 if (!parent) // Parent has already been removed.
115 return -1; 115 return -1;
116 116
117 if (pastLastNodeToRemove == startNodeIndex + 1) 117 if (pastLastNodeToRemove == startNodeIndex + 1)
118 return 0; 118 return 0;
119 119
120 removeNode(nodesToRemove[startNodeIndex], editingState, AssumeContentIsAlway sEditable); 120 removeNode(nodesToRemove[startNodeIndex], editingState, AssumeContentIsAlway sEditable);
121 if (editingState->isAborted()) 121 if (editingState->isAborted())
122 return -1; 122 return -1;
123 insertNodeBefore(nodesToRemove[startNodeIndex], highestAncestorToRemove, edi tingState, AssumeContentIsAlwaysEditable); 123 insertNodeBefore(nodesToRemove[startNodeIndex], highestAncestorToRemove, edi tingState, AssumeContentIsAlwaysEditable);
124 if (editingState->isAborted()) 124 if (editingState->isAborted())
125 return -1; 125 return -1;
126 removeNode(highestAncestorToRemove, editingState, AssumeContentIsAlwaysEdita ble); 126 removeNode(highestAncestorToRemove, editingState, AssumeContentIsAlwaysEdita ble);
127 if (editingState->isAborted()) 127 if (editingState->isAborted())
128 return -1; 128 return -1;
129 129
130 return pastLastNodeToRemove - startNodeIndex - 1; 130 return pastLastNodeToRemove - startNodeIndex - 1;
131 } 131 }
132 132
133 DEFINE_TRACE(SimplifyMarkupCommand) 133 DEFINE_TRACE(SimplifyMarkupCommand)
134 { 134 {
135 visitor->trace(m_firstNode); 135 visitor->trace(m_firstNode);
136 visitor->trace(m_nodeAfterLast); 136 visitor->trace(m_nodeAfterLast);
137 CompositeEditCommand::trace(visitor); 137 CompositeEditCommand::trace(visitor);
138 } 138 }
139 139
140 } // namespace blink 140 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698