| OLD | NEW |
| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 applyCommandToComposite(RemoveNodePreservingChildrenCommand::create(node)); | 396 applyCommandToComposite(RemoveNodePreservingChildrenCommand::create(node)); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void CompositeEditCommand::removeNodeAndPruneAncestors(PassRefPtr<Node> node) | 399 void CompositeEditCommand::removeNodeAndPruneAncestors(PassRefPtr<Node> node) |
| 400 { | 400 { |
| 401 RefPtr<ContainerNode> parent = node->parentNode(); | 401 RefPtr<ContainerNode> parent = node->parentNode(); |
| 402 removeNode(node); | 402 removeNode(node); |
| 403 prune(parent.release()); | 403 prune(parent.release()); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void CompositeEditCommand::moveRemainingSiblingsToNewParent(Node* node, Node* pa
stLastNodeToMove, PassRefPtr<Element> prpNewParent) |
| 407 { |
| 408 NodeVector nodesToRemove; |
| 409 RefPtr<Element> newParent = prpNewParent; |
| 410 |
| 411 for (; node && node != pastLastNodeToMove; node = node->nextSibling()) |
| 412 nodesToRemove.append(node); |
| 413 |
| 414 for (unsigned i = 0; i < nodesToRemove.size(); i++) { |
| 415 removeNode(nodesToRemove[i]); |
| 416 appendNode(nodesToRemove[i], newParent); |
| 417 } |
| 418 } |
| 419 |
| 406 HTMLElement* CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAt
tributes(PassRefPtr<HTMLElement> node) | 420 HTMLElement* CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAt
tributes(PassRefPtr<HTMLElement> node) |
| 407 { | 421 { |
| 408 // It would also be possible to implement all of ReplaceNodeWithSpanCommand | 422 // It would also be possible to implement all of ReplaceNodeWithSpanCommand |
| 409 // as a series of existing smaller edit commands. Someone who wanted to | 423 // as a series of existing smaller edit commands. Someone who wanted to |
| 410 // reduce the number of edit commands could do so here. | 424 // reduce the number of edit commands could do so here. |
| 411 RefPtr<ReplaceNodeWithSpanCommand> command = ReplaceNodeWithSpanCommand::cre
ate(node); | 425 RefPtr<ReplaceNodeWithSpanCommand> command = ReplaceNodeWithSpanCommand::cre
ate(node); |
| 412 applyCommandToComposite(command); | 426 applyCommandToComposite(command); |
| 413 // Returning a raw pointer here is OK because the command is retained by | 427 // Returning a raw pointer here is OK because the command is retained by |
| 414 // applyCommandToComposite (thus retaining the span), and the span is also | 428 // applyCommandToComposite (thus retaining the span), and the span is also |
| 415 // in the DOM tree, and thus alive whie it has a parent. | 429 // in the DOM tree, and thus alive whie it has a parent. |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 return node.release(); | 1451 return node.release(); |
| 1438 } | 1452 } |
| 1439 | 1453 |
| 1440 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) | 1454 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) |
| 1441 { | 1455 { |
| 1442 RefPtr<Element> breakNode = document->createElement(brTag, false); | 1456 RefPtr<Element> breakNode = document->createElement(brTag, false); |
| 1443 return breakNode.release(); | 1457 return breakNode.release(); |
| 1444 } | 1458 } |
| 1445 | 1459 |
| 1446 } // namespace WebCore | 1460 } // namespace WebCore |
| OLD | NEW |