| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple 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 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 void CompositeEditCommand::cloneParagraphUnderNewElement(const Position& start,
const Position& end, Node* passedOuterNode, Element* blockElement, EditingState*
editingState) | 1058 void CompositeEditCommand::cloneParagraphUnderNewElement(const Position& start,
const Position& end, Node* passedOuterNode, Element* blockElement, EditingState*
editingState) |
| 1059 { | 1059 { |
| 1060 DCHECK_LE(start, end); | 1060 DCHECK_LE(start, end); |
| 1061 DCHECK(passedOuterNode); | 1061 DCHECK(passedOuterNode); |
| 1062 DCHECK(blockElement); | 1062 DCHECK(blockElement); |
| 1063 | 1063 |
| 1064 // First we clone the outerNode | 1064 // First we clone the outerNode |
| 1065 Node* lastNode = nullptr; | 1065 Node* lastNode = nullptr; |
| 1066 Node* outerNode = passedOuterNode; | 1066 Node* outerNode = passedOuterNode; |
| 1067 | 1067 |
| 1068 if (outerNode->isRootEditableElement()) { | 1068 if (isRootEditableElement(*outerNode)) { |
| 1069 lastNode = blockElement; | 1069 lastNode = blockElement; |
| 1070 } else { | 1070 } else { |
| 1071 lastNode = outerNode->cloneNode(isDisplayInsideTable(outerNode)); | 1071 lastNode = outerNode->cloneNode(isDisplayInsideTable(outerNode)); |
| 1072 appendNode(lastNode, blockElement, editingState); | 1072 appendNode(lastNode, blockElement, editingState); |
| 1073 if (editingState->isAborted()) | 1073 if (editingState->isAborted()) |
| 1074 return; | 1074 return; |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 if (start.anchorNode() != outerNode && lastNode->isElementNode() && start.an
chorNode()->isDescendantOf(outerNode)) { | 1077 if (start.anchorNode() != outerNode && lastNode->isElementNode() && start.an
chorNode()->isDescendantOf(outerNode)) { |
| 1078 HeapVector<Member<Node>> ancestors; | 1078 HeapVector<Member<Node>> ancestors; |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 return false; | 1387 return false; |
| 1388 | 1388 |
| 1389 EditingStyle* style = EditingStyle::create(endingSelection().start()); | 1389 EditingStyle* style = EditingStyle::create(endingSelection().start()); |
| 1390 style->mergeTypingStyle(&document()); | 1390 style->mergeTypingStyle(&document()); |
| 1391 | 1391 |
| 1392 ContainerNode* listNode = emptyListItem->parentNode(); | 1392 ContainerNode* listNode = emptyListItem->parentNode(); |
| 1393 // FIXME: Can't we do something better when the immediate parent wasn't a li
st node? | 1393 // FIXME: Can't we do something better when the immediate parent wasn't a li
st node? |
| 1394 if (!listNode | 1394 if (!listNode |
| 1395 || (!isHTMLUListElement(*listNode) && !isHTMLOListElement(*listNode)) | 1395 || (!isHTMLUListElement(*listNode) && !isHTMLOListElement(*listNode)) |
| 1396 || !listNode->hasEditableStyle() | 1396 || !listNode->hasEditableStyle() |
| 1397 || listNode == emptyListItem->rootEditableElement()) | 1397 || listNode == rootEditableElement(*emptyListItem)) |
| 1398 return false; | 1398 return false; |
| 1399 | 1399 |
| 1400 HTMLElement* newBlock = nullptr; | 1400 HTMLElement* newBlock = nullptr; |
| 1401 if (ContainerNode* blockEnclosingList = listNode->parentNode()) { | 1401 if (ContainerNode* blockEnclosingList = listNode->parentNode()) { |
| 1402 if (isHTMLLIElement(*blockEnclosingList)) { // listNode is inside anothe
r list item | 1402 if (isHTMLLIElement(*blockEnclosingList)) { // listNode is inside anothe
r list item |
| 1403 if (visiblePositionAfterNode(*blockEnclosingList).deepEquivalent() =
= visiblePositionAfterNode(*listNode).deepEquivalent()) { | 1403 if (visiblePositionAfterNode(*blockEnclosingList).deepEquivalent() =
= visiblePositionAfterNode(*listNode).deepEquivalent()) { |
| 1404 // If listNode appears at the end of the outer list item, then m
ove listNode outside of this list item | 1404 // If listNode appears at the end of the outer list item, then m
ove listNode outside of this list item |
| 1405 // e.g. <ul><li>hello <ul><li><br></li></ul> </li></ul> should b
ecome <ul><li>hello</li> <ul><li><br></li></ul> </ul> after this section | 1405 // e.g. <ul><li>hello <ul><li><br></li></ul> </li></ul> should b
ecome <ul><li>hello</li> <ul><li><br></li></ul> </ul> after this section |
| 1406 // If listNode does NOT appear at the end, then we should consid
er it as a regular paragraph. | 1406 // If listNode does NOT appear at the end, then we should consid
er it as a regular paragraph. |
| 1407 // e.g. <ul><li> <ul><li><br></li></ul> hello</li></ul> should b
ecome <ul><li> <div><br></div> hello</li></ul> at the end | 1407 // e.g. <ul><li> <ul><li><br></li></ul> hello</li></ul> should b
ecome <ul><li> <div><br></div> hello</li></ul> at the end |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 } | 1619 } |
| 1620 | 1620 |
| 1621 DEFINE_TRACE(CompositeEditCommand) | 1621 DEFINE_TRACE(CompositeEditCommand) |
| 1622 { | 1622 { |
| 1623 visitor->trace(m_commands); | 1623 visitor->trace(m_commands); |
| 1624 visitor->trace(m_composition); | 1624 visitor->trace(m_composition); |
| 1625 EditCommand::trace(visitor); | 1625 EditCommand::trace(visitor); |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 } // namespace blink | 1628 } // namespace blink |
| OLD | NEW |