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

Side by Side Diff: Source/WebCore/editing/ReplaceSelectionCommand.cpp

Issue 10536125: Merge 119870 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 Node* firstChild() const; 75 Node* firstChild() const;
76 Node* lastChild() const; 76 Node* lastChild() const;
77 77
78 bool isEmpty() const; 78 bool isEmpty() const;
79 79
80 bool hasInterchangeNewlineAtStart() const { return m_hasInterchangeNewlineAt Start; } 80 bool hasInterchangeNewlineAtStart() const { return m_hasInterchangeNewlineAt Start; }
81 bool hasInterchangeNewlineAtEnd() const { return m_hasInterchangeNewlineAtEn d; } 81 bool hasInterchangeNewlineAtEnd() const { return m_hasInterchangeNewlineAtEn d; }
82 82
83 void removeNode(PassRefPtr<Node>); 83 void removeNode(PassRefPtr<Node>);
84 void removeNodePreservingChildren(Node*); 84 void removeNodePreservingChildren(PassRefPtr<Node>);
85 85
86 private: 86 private:
87 PassRefPtr<StyledElement> insertFragmentForTestRendering(Node* rootEditableN ode); 87 PassRefPtr<StyledElement> insertFragmentForTestRendering(Node* rootEditableN ode);
88 void removeUnrenderedNodes(Node*); 88 void removeUnrenderedNodes(Node*);
89 void restoreAndRemoveTestRenderingNodesToFragment(StyledElement*); 89 void restoreAndRemoveTestRenderingNodesToFragment(StyledElement*);
90 void removeInterchangeNodes(Node*); 90 void removeInterchangeNodes(Node*);
91 91
92 void insertNodeBefore(PassRefPtr<Node> node, Node* refNode); 92 void insertNodeBefore(PassRefPtr<Node> node, Node* refNode);
93 93
94 RefPtr<Document> m_document; 94 RefPtr<Document> m_document;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 Node *ReplacementFragment::firstChild() const 204 Node *ReplacementFragment::firstChild() const
205 { 205 {
206 return m_fragment ? m_fragment->firstChild() : 0; 206 return m_fragment ? m_fragment->firstChild() : 0;
207 } 207 }
208 208
209 Node *ReplacementFragment::lastChild() const 209 Node *ReplacementFragment::lastChild() const
210 { 210 {
211 return m_fragment ? m_fragment->lastChild() : 0; 211 return m_fragment ? m_fragment->lastChild() : 0;
212 } 212 }
213 213
214 void ReplacementFragment::removeNodePreservingChildren(Node *node) 214 void ReplacementFragment::removeNodePreservingChildren(PassRefPtr<Node> node)
215 { 215 {
216 if (!node) 216 if (!node)
217 return; 217 return;
218 218
219 while (RefPtr<Node> n = node->firstChild()) { 219 while (RefPtr<Node> n = node->firstChild()) {
220 removeNode(n); 220 removeNode(n);
221 insertNodeBefore(n.release(), node); 221 insertNodeBefore(n.release(), node.get());
222 } 222 }
223 removeNode(node); 223 removeNode(node);
224 } 224 }
225 225
226 void ReplacementFragment::removeNode(PassRefPtr<Node> node) 226 void ReplacementFragment::removeNode(PassRefPtr<Node> node)
227 { 227 {
228 if (!node) 228 if (!node)
229 return; 229 return;
230 230
231 ContainerNode* parent = node->nonShadowBoundaryParentNode(); 231 ContainerNode* parent = node->nonShadowBoundaryParentNode();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 if (isInterchangeNewlineNode(node)) { 322 if (isInterchangeNewlineNode(node)) {
323 m_hasInterchangeNewlineAtEnd = true; 323 m_hasInterchangeNewlineAtEnd = true;
324 removeNode(node); 324 removeNode(node);
325 break; 325 break;
326 } 326 }
327 node = node->lastChild(); 327 node = node->lastChild();
328 } 328 }
329 329
330 node = container->firstChild(); 330 node = container->firstChild();
331 while (node) { 331 while (node) {
332 Node *next = node->traverseNextNode(); 332 RefPtr<Node> next = node->traverseNextNode();
333 if (isInterchangeConvertedSpaceSpan(node)) { 333 if (isInterchangeConvertedSpaceSpan(node)) {
334 RefPtr<Node> n = 0; 334 next = node->traverseNextSibling();
335 while ((n = node->firstChild())) { 335 removeNodePreservingChildren(node);
336 removeNode(n);
337 insertNodeBefore(n, node);
338 }
339 removeNode(node);
340 if (n)
341 next = n->traverseNextNode();
342 } 336 }
343 node = next; 337 node = next.get();
344 } 338 }
345 } 339 }
346 340
347 inline void ReplaceSelectionCommand::InsertedNodes::respondToNodeInsertion(Node* node) 341 inline void ReplaceSelectionCommand::InsertedNodes::respondToNodeInsertion(Node* node)
348 { 342 {
349 if (!node) 343 if (!node)
350 return; 344 return;
351 345
352 if (!m_firstNodeInserted) 346 if (!m_firstNodeInserted)
353 m_firstNodeInserted = node; 347 m_firstNodeInserted = node;
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); 1310 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get());
1317 1311
1318 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); 1312 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d);
1319 1313
1320 setEndingSelection(selectionAfterReplace); 1314 setEndingSelection(selectionAfterReplace);
1321 1315
1322 return true; 1316 return true;
1323 } 1317 }
1324 1318
1325 } // namespace WebCore 1319 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698