| 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 24 matching lines...) Expand all Loading... |
| 35 WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand(Element* element) | 35 WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand(Element* element) |
| 36 : SimpleEditCommand(element->document()), m_element(element) { | 36 : SimpleEditCommand(element->document()), m_element(element) { |
| 37 DCHECK(m_element); | 37 DCHECK(m_element); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void WrapContentsInDummySpanCommand::executeApply() { | 40 void WrapContentsInDummySpanCommand::executeApply() { |
| 41 NodeVector children; | 41 NodeVector children; |
| 42 getChildNodes(*m_element, children); | 42 getChildNodes(*m_element, children); |
| 43 | 43 |
| 44 for (auto& child : children) | 44 for (auto& child : children) |
| 45 m_dummySpan->appendChild(child.release(), IGNORE_EXCEPTION); | 45 m_dummySpan->appendChild(child.release(), IGNORE_EXCEPTION_FOR_TESTING); |
| 46 | 46 |
| 47 m_element->appendChild(m_dummySpan.get(), IGNORE_EXCEPTION); | 47 m_element->appendChild(m_dummySpan.get(), IGNORE_EXCEPTION_FOR_TESTING); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void WrapContentsInDummySpanCommand::doApply(EditingState*) { | 50 void WrapContentsInDummySpanCommand::doApply(EditingState*) { |
| 51 m_dummySpan = HTMLSpanElement::create(document()); | 51 m_dummySpan = HTMLSpanElement::create(document()); |
| 52 | 52 |
| 53 executeApply(); | 53 executeApply(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void WrapContentsInDummySpanCommand::doUnapply() { | 56 void WrapContentsInDummySpanCommand::doUnapply() { |
| 57 DCHECK(m_element); | 57 DCHECK(m_element); |
| 58 | 58 |
| 59 if (!m_dummySpan || !hasEditableStyle(*m_element)) | 59 if (!m_dummySpan || !hasEditableStyle(*m_element)) |
| 60 return; | 60 return; |
| 61 | 61 |
| 62 NodeVector children; | 62 NodeVector children; |
| 63 getChildNodes(*m_dummySpan, children); | 63 getChildNodes(*m_dummySpan, children); |
| 64 | 64 |
| 65 for (auto& child : children) | 65 for (auto& child : children) |
| 66 m_element->appendChild(child.release(), IGNORE_EXCEPTION); | 66 m_element->appendChild(child.release(), IGNORE_EXCEPTION_FOR_TESTING); |
| 67 | 67 |
| 68 m_dummySpan->remove(IGNORE_EXCEPTION); | 68 m_dummySpan->remove(IGNORE_EXCEPTION_FOR_TESTING); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void WrapContentsInDummySpanCommand::doReapply() { | 71 void WrapContentsInDummySpanCommand::doReapply() { |
| 72 DCHECK(m_element); | 72 DCHECK(m_element); |
| 73 | 73 |
| 74 if (!m_dummySpan || !hasEditableStyle(*m_element)) | 74 if (!m_dummySpan || !hasEditableStyle(*m_element)) |
| 75 return; | 75 return; |
| 76 | 76 |
| 77 executeApply(); | 77 executeApply(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 DEFINE_TRACE(WrapContentsInDummySpanCommand) { | 80 DEFINE_TRACE(WrapContentsInDummySpanCommand) { |
| 81 visitor->trace(m_element); | 81 visitor->trace(m_element); |
| 82 visitor->trace(m_dummySpan); | 82 visitor->trace(m_dummySpan); |
| 83 SimpleEditCommand::trace(visitor); | 83 SimpleEditCommand::trace(visitor); |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace blink | 86 } // namespace blink |
| OLD | NEW |