summaryrefslogtreecommitdiffstats
path: root/WebCore/editing/ModifySelectionListLevel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/editing/ModifySelectionListLevel.cpp')
-rw-r--r--WebCore/editing/ModifySelectionListLevel.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/WebCore/editing/ModifySelectionListLevel.cpp b/WebCore/editing/ModifySelectionListLevel.cpp
index 0b1123b..9bc73c6 100644
--- a/WebCore/editing/ModifySelectionListLevel.cpp
+++ b/WebCore/editing/ModifySelectionListLevel.cpp
@@ -119,7 +119,7 @@ void ModifySelectionListLevelCommand::insertSiblingNodeRangeAfter(Node* startNod
}
}
-void ModifySelectionListLevelCommand::appendSiblingNodeRange(Node* startNode, Node* endNode, Node* newParent)
+void ModifySelectionListLevelCommand::appendSiblingNodeRange(Node* startNode, Node* endNode, Element* newParent)
{
Node* node = startNode;
while (1) {
@@ -178,14 +178,16 @@ void IncreaseSelectionListLevelCommand::doApply()
Node* previousItem = startListChild->renderer()->previousSibling()->element();
if (isListElement(previousItem)) {
// move nodes up into preceding list
- appendSiblingNodeRange(startListChild, endListChild, previousItem);
+ appendSiblingNodeRange(startListChild, endListChild, static_cast<Element*>(previousItem));
m_listElement = previousItem;
} else {
// create a sublist for the preceding element and move nodes there
- RefPtr<Node> newParent;
+ RefPtr<Element> newParent;
switch (m_listType) {
case InheritedListType:
- newParent = startListChild->parentNode()->cloneNode(false);
+ newParent = startListChild->parentElement();
+ if (newParent)
+ newParent = newParent->cloneElement();
break;
case OrderedList:
newParent = createOrderedListElement(document());
@@ -194,9 +196,9 @@ void IncreaseSelectionListLevelCommand::doApply()
newParent = createUnorderedListElement(document());
break;
}
- insertNodeBefore(newParent.get(), startListChild);
+ insertNodeBefore(newParent, startListChild);
appendSiblingNodeRange(startListChild, endListChild, newParent.get());
- m_listElement = newParent.get();
+ m_listElement = newParent.release();
}
}
@@ -258,7 +260,7 @@ void DecreaseSelectionListLevelCommand::doApply()
Node* previousItem = startListChild->renderer()->previousSibling() ? startListChild->renderer()->previousSibling()->element() : 0;
Node* nextItem = endListChild->renderer()->nextSibling() ? endListChild->renderer()->nextSibling()->element() : 0;
- Node* listNode = startListChild->parentNode();
+ Element* listNode = startListChild->parentElement();
if (!previousItem) {
// at start of sublist, move the child(ren) to before the sublist
@@ -269,9 +271,9 @@ void DecreaseSelectionListLevelCommand::doApply()
} else if (!nextItem) {
// at end of list, move the child(ren) to after the sublist
insertSiblingNodeRangeAfter(startListChild, endListChild, listNode);
- } else {
+ } else if (listNode) {
// in the middle of list, split the list and move the children to the divide
- splitElement(static_cast<Element*>(listNode), startListChild);
+ splitElement(listNode, startListChild);
insertSiblingNodeRangeBefore(startListChild, endListChild, listNode);
}
}