| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 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 12 matching lines...) Expand all Loading... |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/editing/commands/RemoveNodePreservingChildrenCommand.h" | 26 #include "core/editing/commands/RemoveNodePreservingChildrenCommand.h" |
| 27 | 27 |
| 28 #include "core/dom/Node.h" | 28 #include "core/dom/Node.h" |
| 29 #include "wtf/Assertions.h" | 29 #include "wtf/Assertions.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand(PassRef
PtrWillBeRawPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeCont
entIsAlwaysEditable) | 33 RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand(RawPtr<
Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEdita
ble) |
| 34 : CompositeEditCommand(node->document()) | 34 : CompositeEditCommand(node->document()) |
| 35 , m_node(node) | 35 , m_node(node) |
| 36 , m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable) | 36 , m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable) |
| 37 { | 37 { |
| 38 ASSERT(m_node); | 38 ASSERT(m_node); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void RemoveNodePreservingChildrenCommand::doApply(EditingState* editingState) | 41 void RemoveNodePreservingChildrenCommand::doApply(EditingState* editingState) |
| 42 { | 42 { |
| 43 ABORT_EDITING_COMMAND_IF(!m_node->parentNode()); | 43 ABORT_EDITING_COMMAND_IF(!m_node->parentNode()); |
| 44 ABORT_EDITING_COMMAND_IF(!m_node->parentNode()->hasEditableStyle()); | 44 ABORT_EDITING_COMMAND_IF(!m_node->parentNode()->hasEditableStyle()); |
| 45 if (m_node->isContainerNode()) { | 45 if (m_node->isContainerNode()) { |
| 46 NodeVector children; | 46 NodeVector children; |
| 47 getChildNodes(toContainerNode(*m_node), children); | 47 getChildNodes(toContainerNode(*m_node), children); |
| 48 | 48 |
| 49 for (auto& currentChild : children) { | 49 for (auto& currentChild : children) { |
| 50 RefPtrWillBeRawPtr<Node> child = currentChild.release(); | 50 RawPtr<Node> child = currentChild.release(); |
| 51 removeNode(child, editingState, m_shouldAssumeContentIsAlwaysEditabl
e); | 51 removeNode(child, editingState, m_shouldAssumeContentIsAlwaysEditabl
e); |
| 52 if (editingState->isAborted()) | 52 if (editingState->isAborted()) |
| 53 return; | 53 return; |
| 54 insertNodeBefore(child.release(), m_node, editingState, m_shouldAssu
meContentIsAlwaysEditable); | 54 insertNodeBefore(child.release(), m_node, editingState, m_shouldAssu
meContentIsAlwaysEditable); |
| 55 if (editingState->isAborted()) | 55 if (editingState->isAborted()) |
| 56 return; | 56 return; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 removeNode(m_node, editingState, m_shouldAssumeContentIsAlwaysEditable); | 59 removeNode(m_node, editingState, m_shouldAssumeContentIsAlwaysEditable); |
| 60 } | 60 } |
| 61 | 61 |
| 62 DEFINE_TRACE(RemoveNodePreservingChildrenCommand) | 62 DEFINE_TRACE(RemoveNodePreservingChildrenCommand) |
| 63 { | 63 { |
| 64 visitor->trace(m_node); | 64 visitor->trace(m_node); |
| 65 CompositeEditCommand::trace(visitor); | 65 CompositeEditCommand::trace(visitor); |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace blink | 68 } // namespace blink |
| OLD | NEW |