| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/editing/commands/RemoveNodeCommand.h" | 26 #include "core/editing/commands/RemoveNodeCommand.h" |
| 27 | 27 |
| 28 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 28 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 29 #include "core/dom/Node.h" | 29 #include "core/dom/Node.h" |
| 30 #include "wtf/Assertions.h" | 30 #include "wtf/Assertions.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 RemoveNodeCommand::RemoveNodeCommand(PassRefPtrWillBeRawPtr<Node> node, ShouldAs
sumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable) | 34 RemoveNodeCommand::RemoveNodeCommand(RawPtr<Node> node, ShouldAssumeContentIsAlw
aysEditable shouldAssumeContentIsAlwaysEditable) |
| 35 : SimpleEditCommand(node->document()) | 35 : SimpleEditCommand(node->document()) |
| 36 , m_node(node) | 36 , m_node(node) |
| 37 , m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable) | 37 , m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable) |
| 38 { | 38 { |
| 39 ASSERT(m_node); | 39 ASSERT(m_node); |
| 40 ASSERT(m_node->parentNode()); | 40 ASSERT(m_node->parentNode()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void RemoveNodeCommand::doApply() | 43 void RemoveNodeCommand::doApply() |
| 44 { | 44 { |
| 45 ContainerNode* parent = m_node->parentNode(); | 45 ContainerNode* parent = m_node->parentNode(); |
| 46 if (!parent || (m_shouldAssumeContentIsAlwaysEditable == DoNotAssumeContentI
sAlwaysEditable | 46 if (!parent || (m_shouldAssumeContentIsAlwaysEditable == DoNotAssumeContentI
sAlwaysEditable |
| 47 && !parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable) &&
parent->inActiveDocument())) | 47 && !parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable) &&
parent->inActiveDocument())) |
| 48 return; | 48 return; |
| 49 ASSERT(parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable) ||
!parent->inActiveDocument()); | 49 ASSERT(parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable) ||
!parent->inActiveDocument()); |
| 50 | 50 |
| 51 m_parent = parent; | 51 m_parent = parent; |
| 52 m_refChild = m_node->nextSibling(); | 52 m_refChild = m_node->nextSibling(); |
| 53 | 53 |
| 54 m_node->remove(IGNORE_EXCEPTION); | 54 m_node->remove(IGNORE_EXCEPTION); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void RemoveNodeCommand::doUnapply() | 57 void RemoveNodeCommand::doUnapply() |
| 58 { | 58 { |
| 59 RefPtrWillBeRawPtr<ContainerNode> parent = m_parent.release(); | 59 RawPtr<ContainerNode> parent = m_parent.release(); |
| 60 RefPtrWillBeRawPtr<Node> refChild = m_refChild.release(); | 60 RawPtr<Node> refChild = m_refChild.release(); |
| 61 if (!parent || !parent->hasEditableStyle()) | 61 if (!parent || !parent->hasEditableStyle()) |
| 62 return; | 62 return; |
| 63 | 63 |
| 64 parent->insertBefore(m_node.get(), refChild.get(), IGNORE_EXCEPTION); | 64 parent->insertBefore(m_node.get(), refChild.get(), IGNORE_EXCEPTION); |
| 65 } | 65 } |
| 66 | 66 |
| 67 DEFINE_TRACE(RemoveNodeCommand) | 67 DEFINE_TRACE(RemoveNodeCommand) |
| 68 { | 68 { |
| 69 visitor->trace(m_node); | 69 visitor->trace(m_node); |
| 70 visitor->trace(m_parent); | 70 visitor->trace(m_parent); |
| 71 visitor->trace(m_refChild); | 71 visitor->trace(m_refChild); |
| 72 SimpleEditCommand::trace(visitor); | 72 SimpleEditCommand::trace(visitor); |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |