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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 if (m_atChild->parentNode() != m_element2) | 48 if (m_atChild->parentNode() != m_element2) |
49 return; | 49 return; |
50 | 50 |
51 HeapVector<Member<Node>> children; | 51 HeapVector<Member<Node>> children; |
52 for (Node* node = m_element2->firstChild(); node != m_atChild; node = node->
nextSibling()) | 52 for (Node* node = m_element2->firstChild(); node != m_atChild; node = node->
nextSibling()) |
53 children.append(node); | 53 children.append(node); |
54 | 54 |
55 TrackExceptionState exceptionState; | 55 TrackExceptionState exceptionState; |
56 | 56 |
57 ContainerNode* parent = m_element2->parentNode(); | 57 ContainerNode* parent = m_element2->parentNode(); |
58 if (!parent || !parent->hasEditableStyle()) | 58 if (!parent || !hasEditableStyle(*parent)) |
59 return; | 59 return; |
60 parent->insertBefore(m_element1.get(), m_element2.get(), exceptionState); | 60 parent->insertBefore(m_element1.get(), m_element2.get(), exceptionState); |
61 if (exceptionState.hadException()) | 61 if (exceptionState.hadException()) |
62 return; | 62 return; |
63 | 63 |
64 // Delete id attribute from the second element because the same id cannot be
used for more than one element | 64 // Delete id attribute from the second element because the same id cannot be
used for more than one element |
65 m_element2->removeAttribute(HTMLNames::idAttr); | 65 m_element2->removeAttribute(HTMLNames::idAttr); |
66 | 66 |
67 for (const auto& child : children) | 67 for (const auto& child : children) |
68 m_element1->appendChild(child, exceptionState); | 68 m_element1->appendChild(child, exceptionState); |
69 } | 69 } |
70 | 70 |
71 void SplitElementCommand::doApply(EditingState*) | 71 void SplitElementCommand::doApply(EditingState*) |
72 { | 72 { |
73 m_element1 = m_element2->cloneElementWithoutChildren(); | 73 m_element1 = m_element2->cloneElementWithoutChildren(); |
74 | 74 |
75 executeApply(); | 75 executeApply(); |
76 } | 76 } |
77 | 77 |
78 void SplitElementCommand::doUnapply() | 78 void SplitElementCommand::doUnapply() |
79 { | 79 { |
80 if (!m_element1 || !m_element1->hasEditableStyle() || !m_element2->hasEditab
leStyle()) | 80 if (!m_element1 || !hasEditableStyle(*m_element1) || !hasEditableStyle(*m_el
ement2)) |
81 return; | 81 return; |
82 | 82 |
83 NodeVector children; | 83 NodeVector children; |
84 getChildNodes(*m_element1, children); | 84 getChildNodes(*m_element1, children); |
85 | 85 |
86 Node* refChild = m_element2->firstChild(); | 86 Node* refChild = m_element2->firstChild(); |
87 | 87 |
88 for (const auto& child : children) | 88 for (const auto& child : children) |
89 m_element2->insertBefore(child, refChild, IGNORE_EXCEPTION); | 89 m_element2->insertBefore(child, refChild, IGNORE_EXCEPTION); |
90 | 90 |
(...skipping 15 matching lines...) Expand all Loading... |
106 | 106 |
107 DEFINE_TRACE(SplitElementCommand) | 107 DEFINE_TRACE(SplitElementCommand) |
108 { | 108 { |
109 visitor->trace(m_element1); | 109 visitor->trace(m_element1); |
110 visitor->trace(m_element2); | 110 visitor->trace(m_element2); |
111 visitor->trace(m_atChild); | 111 visitor->trace(m_atChild); |
112 SimpleEditCommand::trace(visitor); | 112 SimpleEditCommand::trace(visitor); |
113 } | 113 } |
114 | 114 |
115 } // namespace blink | 115 } // namespace blink |
OLD | NEW |