summaryrefslogtreecommitdiff
path: root/Source/WebCore/editing/BreakBlockquoteCommand.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/editing/BreakBlockquoteCommand.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/editing/BreakBlockquoteCommand.cpp')
-rw-r--r--Source/WebCore/editing/BreakBlockquoteCommand.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/Source/WebCore/editing/BreakBlockquoteCommand.cpp b/Source/WebCore/editing/BreakBlockquoteCommand.cpp
index e4ee4c389..515f1a011 100644
--- a/Source/WebCore/editing/BreakBlockquoteCommand.cpp
+++ b/Source/WebCore/editing/BreakBlockquoteCommand.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -31,14 +31,13 @@
#include "NodeTraversal.h"
#include "RenderListItem.h"
#include "Text.h"
-#include "VisiblePosition.h"
#include "htmlediting.h"
namespace WebCore {
using namespace HTMLNames;
-BreakBlockquoteCommand::BreakBlockquoteCommand(Document *document)
+BreakBlockquoteCommand::BreakBlockquoteCommand(Document& document)
: CompositeEditCommand(document)
{
}
@@ -105,18 +104,18 @@ void BreakBlockquoteCommand::doApply()
// startNode is the first node that we need to move to the new blockquote.
Node* startNode = pos.deprecatedNode();
-
+ ASSERT(startNode);
// Split at pos if in the middle of a text node.
- if (startNode->isTextNode()) {
- Text* textNode = toText(startNode);
- if ((unsigned)pos.deprecatedEditingOffset() >= textNode->length()) {
- startNode = NodeTraversal::next(startNode);
+ if (is<Text>(*startNode)) {
+ Text& textNode = downcast<Text>(*startNode);
+ if ((unsigned)pos.deprecatedEditingOffset() >= textNode.length()) {
+ startNode = NodeTraversal::next(*startNode);
ASSERT(startNode);
} else if (pos.deprecatedEditingOffset() > 0)
- splitTextNode(textNode, pos.deprecatedEditingOffset());
+ splitTextNode(&textNode, pos.deprecatedEditingOffset());
} else if (pos.deprecatedEditingOffset() > 0) {
- Node* childAtOffset = startNode->childNode(pos.deprecatedEditingOffset());
- startNode = childAtOffset ? childAtOffset : NodeTraversal::next(startNode);
+ Node* childAtOffset = startNode->traverseToChildAt(pos.deprecatedEditingOffset());
+ startNode = childAtOffset ? childAtOffset : NodeTraversal::next(*startNode);
ASSERT(startNode);
}
@@ -127,12 +126,12 @@ void BreakBlockquoteCommand::doApply()
}
// Build up list of ancestors in between the start node and the top blockquote.
- Vector<RefPtr<Element> > ancestors;
+ Vector<RefPtr<Element>> ancestors;
for (Element* node = startNode->parentElement(); node && node != topBlockquote; node = node->parentElement())
ancestors.append(node);
// Insert a clone of the top blockquote after the break.
- RefPtr<Element> clonedBlockquote = toElement(topBlockquote)->cloneElementWithoutChildren();
+ RefPtr<Element> clonedBlockquote = downcast<Element>(*topBlockquote).cloneElementWithoutChildren(document());
insertNodeAfter(clonedBlockquote.get(), breakNode.get());
// Clone startNode's ancestors into the cloned blockquote.
@@ -141,7 +140,7 @@ void BreakBlockquoteCommand::doApply()
// or clonedBlockquote if ancestors is empty).
RefPtr<Element> clonedAncestor = clonedBlockquote;
for (size_t i = ancestors.size(); i != 0; --i) {
- RefPtr<Element> clonedChild = ancestors[i - 1]->cloneElementWithoutChildren();
+ RefPtr<Element> clonedChild = ancestors[i - 1]->cloneElementWithoutChildren(document());
// Preserve list item numbering in cloned lists.
if (clonedChild->isElementNode() && clonedChild->hasTagName(olTag)) {
Node* listChildNode = i > 1 ? ancestors[i - 2].get() : startNode;
@@ -149,8 +148,8 @@ void BreakBlockquoteCommand::doApply()
// find the first one so that we know where to start numbering.
while (listChildNode && !listChildNode->hasTagName(liTag))
listChildNode = listChildNode->nextSibling();
- if (listChildNode && listChildNode->renderer() && listChildNode->renderer()->isListItem())
- setNodeAttribute(clonedChild, startAttr, String::number(toRenderListItem(listChildNode->renderer())->value()));
+ if (listChildNode && is<RenderListItem>(listChildNode->renderer()))
+ setNodeAttribute(clonedChild, startAttr, AtomicString::number(downcast<RenderListItem>(*listChildNode->renderer()).value()));
}
appendNode(clonedChild.get(), clonedAncestor.get());