| Index: Source/core/editing/SimplifyMarkupCommand.cpp
|
| diff --git a/Source/core/editing/SimplifyMarkupCommand.cpp b/Source/core/editing/SimplifyMarkupCommand.cpp
|
| index 2692b09ff710d699fbea56e014f954a1577fbb1b..67defe99e400e63d4e4b6583eed41dc16b01bfc9 100644
|
| --- a/Source/core/editing/SimplifyMarkupCommand.cpp
|
| +++ b/Source/core/editing/SimplifyMarkupCommand.cpp
|
| @@ -20,7 +20,7 @@
|
| * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
| * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| #include "config.h"
|
| @@ -34,24 +34,24 @@
|
|
|
| namespace WebCore {
|
|
|
| -SimplifyMarkupCommand::SimplifyMarkupCommand(Document* document, Node* firstNode, Node* nodeAfterLast)
|
| +SimplifyMarkupCommand::SimplifyMarkupCommand(Document* document, Node* firstNode, Node* nodeAfterLast)
|
| : CompositeEditCommand(document), m_firstNode(firstNode), m_nodeAfterLast(nodeAfterLast)
|
| {
|
| }
|
| -
|
| +
|
| void SimplifyMarkupCommand::doApply()
|
| {
|
| Node* rootNode = m_firstNode->parentNode();
|
| Vector<RefPtr<Node> > nodesToRemove;
|
| -
|
| +
|
| // Walk through the inserted nodes, to see if there are elements that could be removed
|
| // without affecting the style. The goal is to produce leaner markup even when starting
|
| // from a verbose fragment.
|
| - // We look at inline elements as well as non top level divs that don't have attributes.
|
| + // We look at inline elements as well as non top level divs that don't have attributes.
|
| for (Node* node = m_firstNode.get(); node && node != m_nodeAfterLast; node = NodeTraversal::next(node)) {
|
| if (node->firstChild() || (node->isTextNode() && node->nextSibling()))
|
| continue;
|
| -
|
| +
|
| Node* startingNode = node->parentNode();
|
| if (!startingNode)
|
| continue;
|
| @@ -63,23 +63,23 @@ void SimplifyMarkupCommand::doApply()
|
| while (currentNode != rootNode) {
|
| if (currentNode->parentNode() != rootNode && isRemovableBlock(currentNode))
|
| nodesToRemove.append(currentNode);
|
| -
|
| +
|
| currentNode = currentNode->parentNode();
|
| if (!currentNode)
|
| break;
|
|
|
| if (!currentNode->renderer() || !currentNode->renderer()->isRenderInline() || toRenderInline(currentNode->renderer())->alwaysCreateLineBoxes())
|
| continue;
|
| -
|
| +
|
| if (currentNode->firstChild() != currentNode->lastChild()) {
|
| topNodeWithStartingStyle = 0;
|
| break;
|
| }
|
| -
|
| +
|
| unsigned context;
|
| if (currentNode->renderStyle()->diff(startingStyle, context) == StyleDifferenceEqual)
|
| topNodeWithStartingStyle = currentNode;
|
| -
|
| +
|
| }
|
| if (topNodeWithStartingStyle) {
|
| for (Node* node = startingNode; node != topNodeWithStartingStyle; node = node->parentNode())
|
| @@ -111,7 +111,7 @@ int SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove(Vector<RefPtr<Node>
|
| RefPtr<ContainerNode> parent = highestAncestorToRemove->parentNode();
|
| if (!parent) // Parent has already been removed.
|
| return -1;
|
| -
|
| +
|
| if (pastLastNodeToRemove == startNodeIndex + 1)
|
| return 0;
|
|
|
|
|