| OLD | NEW |
| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 removeNode(node); | 308 removeNode(node); |
| 309 break; | 309 break; |
| 310 } | 310 } |
| 311 node = node->lastChild(); | 311 node = node->lastChild(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 node = container->firstChild(); | 314 node = container->firstChild(); |
| 315 while (node) { | 315 while (node) { |
| 316 RefPtr<Node> next = NodeTraversal::next(*node); | 316 RefPtr<Node> next = NodeTraversal::next(*node); |
| 317 if (isInterchangeConvertedSpaceSpan(node)) { | 317 if (isInterchangeConvertedSpaceSpan(node)) { |
| 318 next = NodeTraversal::nextSkippingChildren(node); | 318 next = NodeTraversal::nextSkippingChildren(*node); |
| 319 removeNodePreservingChildren(node); | 319 removeNodePreservingChildren(node); |
| 320 } | 320 } |
| 321 node = next.get(); | 321 node = next.get(); |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 inline void ReplaceSelectionCommand::InsertedNodes::respondToNodeInsertion(Node&
node) | 325 inline void ReplaceSelectionCommand::InsertedNodes::respondToNodeInsertion(Node&
node) |
| 326 { | 326 { |
| 327 if (!m_firstNodeInserted) | 327 if (!m_firstNodeInserted) |
| 328 m_firstNodeInserted = &node; | 328 m_firstNodeInserted = &node; |
| 329 | 329 |
| 330 m_lastNodeInserted = &node; | 330 m_lastNodeInserted = &node; |
| 331 } | 331 } |
| 332 | 332 |
| 333 inline void ReplaceSelectionCommand::InsertedNodes::willRemoveNodePreservingChil
dren(Node& node) | 333 inline void ReplaceSelectionCommand::InsertedNodes::willRemoveNodePreservingChil
dren(Node& node) |
| 334 { | 334 { |
| 335 if (m_firstNodeInserted == node) | 335 if (m_firstNodeInserted == node) |
| 336 m_firstNodeInserted = NodeTraversal::next(node); | 336 m_firstNodeInserted = NodeTraversal::next(node); |
| 337 if (m_lastNodeInserted == node) | 337 if (m_lastNodeInserted == node) |
| 338 m_lastNodeInserted = node.lastChild() ? node.lastChild() : NodeTraversal
::nextSkippingChildren(&node); | 338 m_lastNodeInserted = node.lastChild() ? node.lastChild() : NodeTraversal
::nextSkippingChildren(node); |
| 339 } | 339 } |
| 340 | 340 |
| 341 inline void ReplaceSelectionCommand::InsertedNodes::willRemoveNode(Node& node) | 341 inline void ReplaceSelectionCommand::InsertedNodes::willRemoveNode(Node& node) |
| 342 { | 342 { |
| 343 if (m_firstNodeInserted == node && m_lastNodeInserted == node) { | 343 if (m_firstNodeInserted == node && m_lastNodeInserted == node) { |
| 344 m_firstNodeInserted = 0; | 344 m_firstNodeInserted = 0; |
| 345 m_lastNodeInserted = 0; | 345 m_lastNodeInserted = 0; |
| 346 } else if (m_firstNodeInserted == node) | 346 } else if (m_firstNodeInserted == node) { |
| 347 m_firstNodeInserted = NodeTraversal::nextSkippingChildren(m_firstNodeIns
erted.get()); | 347 m_firstNodeInserted = NodeTraversal::nextSkippingChildren(*m_firstNodeIn
serted); |
| 348 else if (m_lastNodeInserted == node) | 348 } else if (m_lastNodeInserted == node) { |
| 349 m_lastNodeInserted = NodeTraversal::previousSkippingChildren(*m_lastNode
Inserted); | 349 m_lastNodeInserted = NodeTraversal::previousSkippingChildren(*m_lastNode
Inserted); |
| 350 } |
| 350 } | 351 } |
| 351 | 352 |
| 352 inline void ReplaceSelectionCommand::InsertedNodes::didReplaceNode(Node& node, N
ode& newNode) | 353 inline void ReplaceSelectionCommand::InsertedNodes::didReplaceNode(Node& node, N
ode& newNode) |
| 353 { | 354 { |
| 354 if (m_firstNodeInserted == node) | 355 if (m_firstNodeInserted == node) |
| 355 m_firstNodeInserted = &newNode; | 356 m_firstNodeInserted = &newNode; |
| 356 if (m_lastNodeInserted == node) | 357 if (m_lastNodeInserted == node) |
| 357 m_lastNodeInserted = &newNode; | 358 m_lastNodeInserted = &newNode; |
| 358 } | 359 } |
| 359 | 360 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 | 697 |
| 697 static void removeHeadContents(ReplacementFragment& fragment) | 698 static void removeHeadContents(ReplacementFragment& fragment) |
| 698 { | 699 { |
| 699 Node* next = 0; | 700 Node* next = 0; |
| 700 for (Node* node = fragment.firstChild(); node; node = next) { | 701 for (Node* node = fragment.firstChild(); node; node = next) { |
| 701 if (node->hasTagName(baseTag) | 702 if (node->hasTagName(baseTag) |
| 702 || node->hasTagName(linkTag) | 703 || node->hasTagName(linkTag) |
| 703 || node->hasTagName(metaTag) | 704 || node->hasTagName(metaTag) |
| 704 || node->hasTagName(styleTag) | 705 || node->hasTagName(styleTag) |
| 705 || isHTMLTitleElement(node)) { | 706 || isHTMLTitleElement(node)) { |
| 706 next = NodeTraversal::nextSkippingChildren(node); | 707 next = NodeTraversal::nextSkippingChildren(*node); |
| 707 fragment.removeNode(node); | 708 fragment.removeNode(node); |
| 708 } else { | 709 } else { |
| 709 next = NodeTraversal::next(*node); | 710 next = NodeTraversal::next(*node); |
| 710 } | 711 } |
| 711 } | 712 } |
| 712 } | 713 } |
| 713 | 714 |
| 714 // Remove style spans before insertion if they are unnecessary. It's faster bec
ause we'll | 715 // Remove style spans before insertion if they are unnecessary. It's faster bec
ause we'll |
| 715 // avoid doing a layout. | 716 // avoid doing a layout. |
| 716 static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const
Position& insertionPos) | 717 static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const
Position& insertionPos) |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); | 1493 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); |
| 1493 | 1494 |
| 1494 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en
d); | 1495 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en
d); |
| 1495 | 1496 |
| 1496 setEndingSelection(selectionAfterReplace); | 1497 setEndingSelection(selectionAfterReplace); |
| 1497 | 1498 |
| 1498 return true; | 1499 return true; |
| 1499 } | 1500 } |
| 1500 | 1501 |
| 1501 } // namespace WebCore | 1502 } // namespace WebCore |
| OLD | NEW |