| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 if (!selectedListItem->hasTagName(liTag)) | 65 if (!selectedListItem->hasTagName(liTag)) |
| 66 return false; | 66 return false; |
| 67 | 67 |
| 68 // FIXME: previousElementSibling does not ignore non-rendered content like <
span></span>. Should we? | 68 // FIXME: previousElementSibling does not ignore non-rendered content like <
span></span>. Should we? |
| 69 RefPtr<Element> previousList = selectedListItem->previousElementSibling(); | 69 RefPtr<Element> previousList = selectedListItem->previousElementSibling(); |
| 70 RefPtr<Element> nextList = selectedListItem->nextElementSibling(); | 70 RefPtr<Element> nextList = selectedListItem->nextElementSibling(); |
| 71 | 71 |
| 72 // We should calculate visible range in list item because inserting new | 72 // We should calculate visible range in list item because inserting new |
| 73 // list element will change visibility of list item, e.g. :first-child | 73 // list element will change visibility of list item, e.g. :first-child |
| 74 // CSS selector. | 74 // CSS selector. |
| 75 VisiblePosition startOfMove(start); | |
| 76 VisiblePosition endOfMove(end); | |
| 77 | |
| 78 RefPtr<Element> newList = document().createElement(listNode->tagQName(), fal
se); | 75 RefPtr<Element> newList = document().createElement(listNode->tagQName(), fal
se); |
| 79 insertNodeBefore(newList, selectedListItem.get()); | 76 insertNodeBefore(newList, selectedListItem.get()); |
| 80 | 77 |
| 81 moveParagraphWithClones(startOfMove, endOfMove, newList.get(), selectedListI
tem.get()); | 78 // We should clone all the children of the list item for indenting purposes.
However, in case the current |
| 79 // selection does not encompass all its children, we need to explicitally ha
ndle the same. The original |
| 80 // list item too would require proper deletion in that case. |
| 81 if (end.anchorNode() == selectedListItem.get() || end.anchorNode()->isDescen
dantOf(selectedListItem->lastChild())) { |
| 82 moveParagraphWithClones(start, end, newList.get(), selectedListItem.get(
)); |
| 83 } else { |
| 84 moveParagraphWithClones(start, positionAfterNode(selectedListItem->lastC
hild()), newList.get(), selectedListItem.get()); |
| 85 removeNode(selectedListItem.get()); |
| 86 } |
| 82 | 87 |
| 83 if (canMergeLists(previousList.get(), newList.get())) | 88 if (canMergeLists(previousList.get(), newList.get())) |
| 84 mergeIdenticalElements(previousList.get(), newList.get()); | 89 mergeIdenticalElements(previousList.get(), newList.get()); |
| 85 if (canMergeLists(newList.get(), nextList.get())) | 90 if (canMergeLists(newList.get(), nextList.get())) |
| 86 mergeIdenticalElements(newList.get(), nextList.get()); | 91 mergeIdenticalElements(newList.get(), nextList.get()); |
| 87 | 92 |
| 88 return true; | 93 return true; |
| 89 } | 94 } |
| 90 | 95 |
| 91 void IndentOutdentCommand::indentIntoBlockquote(const Position& start, const Pos
ition& end, RefPtr<Element>& targetBlockquote) | 96 void IndentOutdentCommand::indentIntoBlockquote(const Position& start, const Pos
ition& end, RefPtr<Element>& targetBlockquote) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 238 |
| 234 void IndentOutdentCommand::formatRange(const Position& start, const Position& en
d, const Position&, RefPtr<Element>& blockquoteForNextIndent) | 239 void IndentOutdentCommand::formatRange(const Position& start, const Position& en
d, const Position&, RefPtr<Element>& blockquoteForNextIndent) |
| 235 { | 240 { |
| 236 if (tryIndentingAsListItem(start, end)) | 241 if (tryIndentingAsListItem(start, end)) |
| 237 blockquoteForNextIndent = 0; | 242 blockquoteForNextIndent = 0; |
| 238 else | 243 else |
| 239 indentIntoBlockquote(start, end, blockquoteForNextIndent); | 244 indentIntoBlockquote(start, end, blockquoteForNextIndent); |
| 240 } | 245 } |
| 241 | 246 |
| 242 } | 247 } |
| OLD | NEW |