| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Computer, 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 20 matching lines...) Expand all Loading... |
| 31 #include "core/layout/LayoutObject.h" | 31 #include "core/layout/LayoutObject.h" |
| 32 #include "core/style/ComputedStyle.h" | 32 #include "core/style/ComputedStyle.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 SimplifyMarkupCommand::SimplifyMarkupCommand(Document& document, Node* firstNode
, Node* nodeAfterLast) | 36 SimplifyMarkupCommand::SimplifyMarkupCommand(Document& document, Node* firstNode
, Node* nodeAfterLast) |
| 37 : CompositeEditCommand(document), m_firstNode(firstNode), m_nodeAfterLast(no
deAfterLast) | 37 : CompositeEditCommand(document), m_firstNode(firstNode), m_nodeAfterLast(no
deAfterLast) |
| 38 { | 38 { |
| 39 } | 39 } |
| 40 | 40 |
| 41 void SimplifyMarkupCommand::doApply() | 41 void SimplifyMarkupCommand::doApply(EditingState*) |
| 42 { | 42 { |
| 43 ContainerNode* rootNode = m_firstNode->parentNode(); | 43 ContainerNode* rootNode = m_firstNode->parentNode(); |
| 44 WillBeHeapVector<RefPtrWillBeMember<ContainerNode>> nodesToRemove; | 44 WillBeHeapVector<RefPtrWillBeMember<ContainerNode>> nodesToRemove; |
| 45 | 45 |
| 46 // Walk through the inserted nodes, to see if there are elements that could
be removed | 46 // Walk through the inserted nodes, to see if there are elements that could
be removed |
| 47 // without affecting the style. The goal is to produce leaner markup even wh
en starting | 47 // without affecting the style. The goal is to produce leaner markup even wh
en starting |
| 48 // from a verbose fragment. | 48 // from a verbose fragment. |
| 49 // We look at inline elements as well as non top level divs that don't have
attributes. | 49 // We look at inline elements as well as non top level divs that don't have
attributes. |
| 50 for (Node* node = m_firstNode.get(); node && node != m_nodeAfterLast; node =
NodeTraversal::next(*node)) { | 50 for (Node* node = m_firstNode.get(); node && node != m_nodeAfterLast; node =
NodeTraversal::next(*node)) { |
| 51 if (node->hasChildren() || (node->isTextNode() && node->nextSibling())) | 51 if (node->hasChildren() || (node->isTextNode() && node->nextSibling())) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 121 } |
| 122 | 122 |
| 123 DEFINE_TRACE(SimplifyMarkupCommand) | 123 DEFINE_TRACE(SimplifyMarkupCommand) |
| 124 { | 124 { |
| 125 visitor->trace(m_firstNode); | 125 visitor->trace(m_firstNode); |
| 126 visitor->trace(m_nodeAfterLast); | 126 visitor->trace(m_nodeAfterLast); |
| 127 CompositeEditCommand::trace(visitor); | 127 CompositeEditCommand::trace(visitor); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |