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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // CSS selector. | 74 // CSS selector. |
75 RefPtr<Element> newList = document().createElement(listNode->tagQName(), fal
se); | 75 RefPtr<Element> newList = document().createElement(listNode->tagQName(), fal
se); |
76 insertNodeBefore(newList, selectedListItem.get()); | 76 insertNodeBefore(newList, selectedListItem.get()); |
77 | 77 |
78 // We should clone all the children of the list item for indenting purposes.
However, in case the current | 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 | 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. | 80 // list item too would require proper deletion in that case. |
81 if (end.anchorNode() == selectedListItem.get() || end.anchorNode()->isDescen
dantOf(selectedListItem->lastChild())) { | 81 if (end.anchorNode() == selectedListItem.get() || end.anchorNode()->isDescen
dantOf(selectedListItem->lastChild())) { |
82 moveParagraphWithClones(VisiblePosition(start), VisiblePosition(end), ne
wList.get(), selectedListItem.get()); | 82 moveParagraphWithClones(VisiblePosition(start), VisiblePosition(end), ne
wList.get(), selectedListItem.get()); |
83 } else { | 83 } else { |
84 moveParagraphWithClones(VisiblePosition(start), VisiblePosition(position
AfterNode(selectedListItem->lastChild())), newList.get(), selectedListItem.get()
); | 84 moveParagraphWithClones(VisiblePosition(start), VisiblePosition(position
AfterNode(*selectedListItem->lastChild())), newList.get(), selectedListItem.get(
)); |
85 removeNode(selectedListItem.get()); | 85 removeNode(selectedListItem.get()); |
86 } | 86 } |
87 | 87 |
88 if (canMergeLists(previousList.get(), newList.get())) | 88 if (canMergeLists(previousList.get(), newList.get())) |
89 mergeIdenticalElements(previousList.get(), newList.get()); | 89 mergeIdenticalElements(previousList.get(), newList.get()); |
90 if (canMergeLists(newList.get(), nextList.get())) | 90 if (canMergeLists(newList.get(), nextList.get())) |
91 mergeIdenticalElements(newList.get(), nextList.get()); | 91 mergeIdenticalElements(newList.get(), nextList.get()); |
92 | 92 |
93 return true; | 93 return true; |
94 } | 94 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 RefPtr<Node> splitBlockquoteNode = enclosingNode; | 180 RefPtr<Node> splitBlockquoteNode = enclosingNode; |
181 if (enclosingBlockFlow != enclosingNode) | 181 if (enclosingBlockFlow != enclosingNode) |
182 splitBlockquoteNode = splitTreeToNode(enclosingBlockFlow, enclosingNode,
true); | 182 splitBlockquoteNode = splitTreeToNode(enclosingBlockFlow, enclosingNode,
true); |
183 else { | 183 else { |
184 // We split the blockquote at where we start outdenting. | 184 // We split the blockquote at where we start outdenting. |
185 Node* highestInlineNode = highestEnclosingNodeOfType(visibleStartOfParag
raph.deepEquivalent(), isInline, CannotCrossEditingBoundary, enclosingBlockFlow)
; | 185 Node* highestInlineNode = highestEnclosingNodeOfType(visibleStartOfParag
raph.deepEquivalent(), isInline, CannotCrossEditingBoundary, enclosingBlockFlow)
; |
186 splitElement(toElement(enclosingNode), (highestInlineNode) ? highestInli
neNode : visibleStartOfParagraph.deepEquivalent().deprecatedNode()); | 186 splitElement(toElement(enclosingNode), (highestInlineNode) ? highestInli
neNode : visibleStartOfParagraph.deepEquivalent().deprecatedNode()); |
187 } | 187 } |
188 RefPtr<Node> placeholder = createBreakElement(document()); | 188 RefPtr<Node> placeholder = createBreakElement(document()); |
189 insertNodeBefore(placeholder, splitBlockquoteNode); | 189 insertNodeBefore(placeholder, splitBlockquoteNode); |
190 moveParagraph(startOfParagraph(visibleStartOfParagraph), endOfParagraph(visi
bleEndOfParagraph), VisiblePosition(positionBeforeNode(placeholder.get())), true
); | 190 moveParagraph(startOfParagraph(visibleStartOfParagraph), endOfParagraph(visi
bleEndOfParagraph), VisiblePosition(positionBeforeNode(*placeholder)), true); |
191 } | 191 } |
192 | 192 |
193 // FIXME: We should merge this function with ApplyBlockElementCommand::formatSel
ection | 193 // FIXME: We should merge this function with ApplyBlockElementCommand::formatSel
ection |
194 void IndentOutdentCommand::outdentRegion(const VisiblePosition& startOfSelection
, const VisiblePosition& endOfSelection) | 194 void IndentOutdentCommand::outdentRegion(const VisiblePosition& startOfSelection
, const VisiblePosition& endOfSelection) |
195 { | 195 { |
196 VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection); | 196 VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection); |
197 VisiblePosition endOfLastParagraph = endOfParagraph(endOfSelection); | 197 VisiblePosition endOfLastParagraph = endOfParagraph(endOfSelection); |
198 | 198 |
199 if (endOfCurrentParagraph == endOfLastParagraph) { | 199 if (endOfCurrentParagraph == endOfLastParagraph) { |
200 outdentParagraph(); | 200 outdentParagraph(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 void IndentOutdentCommand::formatRange(const Position& start, const Position& en
d, const Position&, RefPtr<Element>& blockquoteForNextIndent) | 238 void IndentOutdentCommand::formatRange(const Position& start, const Position& en
d, const Position&, RefPtr<Element>& blockquoteForNextIndent) |
239 { | 239 { |
240 if (tryIndentingAsListItem(start, end)) | 240 if (tryIndentingAsListItem(start, end)) |
241 blockquoteForNextIndent = nullptr; | 241 blockquoteForNextIndent = nullptr; |
242 else | 242 else |
243 indentIntoBlockquote(start, end, blockquoteForNextIndent); | 243 indentIntoBlockquote(start, end, blockquoteForNextIndent); |
244 } | 244 } |
245 | 245 |
246 } | 246 } |
OLD | NEW |