OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 // 6) Select the replacement if requested, and match style if requested. | 1089 // 6) Select the replacement if requested, and match style if requested. |
1090 | 1090 |
1091 InsertedNodes insertedNodes; | 1091 InsertedNodes insertedNodes; |
1092 RefPtrWillBeRawPtr<Node> refNode = fragment.firstChild(); | 1092 RefPtrWillBeRawPtr<Node> refNode = fragment.firstChild(); |
1093 ASSERT(refNode); | 1093 ASSERT(refNode); |
1094 RefPtrWillBeRawPtr<Node> node = refNode->nextSibling(); | 1094 RefPtrWillBeRawPtr<Node> node = refNode->nextSibling(); |
1095 | 1095 |
1096 fragment.removeNode(refNode); | 1096 fragment.removeNode(refNode); |
1097 | 1097 |
1098 Node* blockStart = enclosingBlock(insertionPos.deprecatedNode()); | 1098 Node* blockStart = enclosingBlock(insertionPos.deprecatedNode()); |
1099 if ((isListElement(refNode.get()) || (isLegacyAppleStyleSpan(refNode.get())
&& isListElement(refNode->firstChild()))) | 1099 if ((isHTMLListElement(refNode.get()) || (isLegacyAppleStyleSpan(refNode.get
()) && isHTMLListElement(refNode->firstChild()))) |
1100 && blockStart && blockStart->renderer()->isListItem()) | 1100 && blockStart && blockStart->renderer()->isListItem()) |
1101 refNode = insertAsListItems(toHTMLElement(refNode), blockStart, insertio
nPos, insertedNodes); | 1101 refNode = insertAsListItems(toHTMLElement(refNode), blockStart, insertio
nPos, insertedNodes); |
1102 else { | 1102 else { |
1103 insertNodeAt(refNode, insertionPos); | 1103 insertNodeAt(refNode, insertionPos); |
1104 insertedNodes.respondToNodeInsertion(*refNode); | 1104 insertedNodes.respondToNodeInsertion(*refNode); |
1105 } | 1105 } |
1106 | 1106 |
1107 // Mutation events (bug 22634) may have already removed the inserted content | 1107 // Mutation events (bug 22634) may have already removed the inserted content |
1108 if (!refNode->inDocument()) | 1108 if (!refNode->inDocument()) |
1109 return; | 1109 return; |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 { | 1434 { |
1435 return m_editAction; | 1435 return m_editAction; |
1436 } | 1436 } |
1437 | 1437 |
1438 // If the user is inserting a list into an existing list, instead of nesting the
list, | 1438 // If the user is inserting a list into an existing list, instead of nesting the
list, |
1439 // we put the list items into the existing list. | 1439 // we put the list items into the existing list. |
1440 Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtrWillBeRawPtr<HTMLElem
ent> prpListElement, Node* insertionBlock, const Position& insertPos, InsertedNo
des& insertedNodes) | 1440 Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtrWillBeRawPtr<HTMLElem
ent> prpListElement, Node* insertionBlock, const Position& insertPos, InsertedNo
des& insertedNodes) |
1441 { | 1441 { |
1442 RefPtrWillBeRawPtr<HTMLElement> listElement = prpListElement; | 1442 RefPtrWillBeRawPtr<HTMLElement> listElement = prpListElement; |
1443 | 1443 |
1444 while (listElement->hasChildren() && isListElement(listElement->firstChild()
) && listElement->hasOneChild()) | 1444 while (listElement->hasOneChild() && isHTMLListElement(listElement->firstChi
ld())) |
1445 listElement = toHTMLElement(listElement->firstChild()); | 1445 listElement = toHTMLElement(listElement->firstChild()); |
1446 | 1446 |
1447 bool isStart = isStartOfParagraph(VisiblePosition(insertPos)); | 1447 bool isStart = isStartOfParagraph(VisiblePosition(insertPos)); |
1448 bool isEnd = isEndOfParagraph(VisiblePosition(insertPos)); | 1448 bool isEnd = isEndOfParagraph(VisiblePosition(insertPos)); |
1449 bool isMiddle = !isStart && !isEnd; | 1449 bool isMiddle = !isStart && !isEnd; |
1450 Node* lastNode = insertionBlock; | 1450 Node* lastNode = insertionBlock; |
1451 | 1451 |
1452 // If we're in the middle of a list item, we should split it into two separa
te | 1452 // If we're in the middle of a list item, we should split it into two separa
te |
1453 // list items and insert these nodes between them. | 1453 // list items and insert these nodes between them. |
1454 if (isMiddle) { | 1454 if (isMiddle) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 void ReplaceSelectionCommand::trace(Visitor* visitor) | 1528 void ReplaceSelectionCommand::trace(Visitor* visitor) |
1529 { | 1529 { |
1530 visitor->trace(m_startOfInsertedContent); | 1530 visitor->trace(m_startOfInsertedContent); |
1531 visitor->trace(m_endOfInsertedContent); | 1531 visitor->trace(m_endOfInsertedContent); |
1532 visitor->trace(m_insertionStyle); | 1532 visitor->trace(m_insertionStyle); |
1533 visitor->trace(m_documentFragment); | 1533 visitor->trace(m_documentFragment); |
1534 CompositeEditCommand::trace(visitor); | 1534 CompositeEditCommand::trace(visitor); |
1535 } | 1535 } |
1536 | 1536 |
1537 } // namespace blink | 1537 } // namespace blink |
OLD | NEW |