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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/editing/IndentOutdentCommand.h" | 27 #include "core/editing/IndentOutdentCommand.h" |
28 | 28 |
29 #include "HTMLNames.h" | 29 #include "HTMLNames.h" |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/dom/ElementTraversal.h" |
31 #include "core/editing/InsertListCommand.h" | 32 #include "core/editing/InsertListCommand.h" |
32 #include "core/editing/VisibleUnits.h" | 33 #include "core/editing/VisibleUnits.h" |
33 #include "core/editing/htmlediting.h" | 34 #include "core/editing/htmlediting.h" |
34 #include "core/html/HTMLElement.h" | 35 #include "core/html/HTMLElement.h" |
35 #include "core/rendering/RenderObject.h" | 36 #include "core/rendering/RenderObject.h" |
36 | 37 |
37 namespace WebCore { | 38 namespace WebCore { |
38 | 39 |
39 using namespace HTMLNames; | 40 using namespace HTMLNames; |
40 | 41 |
(...skipping 17 matching lines...) Expand all Loading... |
58 return false; | 59 return false; |
59 | 60 |
60 // Find the block that we want to indent. If it's not a list item (e.g., a
div inside a list item), we bail out. | 61 // Find the block that we want to indent. If it's not a list item (e.g., a
div inside a list item), we bail out. |
61 RefPtr<Element> selectedListItem = enclosingBlock(lastNodeInSelectedParagrap
h.get()); | 62 RefPtr<Element> selectedListItem = enclosingBlock(lastNodeInSelectedParagrap
h.get()); |
62 | 63 |
63 // FIXME: we need to deal with the case where there is no li (malformed HTML
) | 64 // FIXME: we need to deal with the case where there is no li (malformed HTML
) |
64 if (!selectedListItem->hasTagName(liTag)) | 65 if (!selectedListItem->hasTagName(liTag)) |
65 return false; | 66 return false; |
66 | 67 |
67 // 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? |
68 RefPtr<Element> previousList = selectedListItem->previousElementSibling(); | 69 RefPtr<Element> previousList = ElementTraversal::previousSibling(*selectedLi
stItem); |
69 RefPtr<Element> nextList = selectedListItem->nextElementSibling(); | 70 RefPtr<Element> nextList = ElementTraversal::nextSibling(*selectedListItem); |
70 | 71 |
71 // We should calculate visible range in list item because inserting new | 72 // We should calculate visible range in list item because inserting new |
72 // 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 |
73 // CSS selector. | 74 // CSS selector. |
74 RefPtr<Element> newList = document().createElement(listNode->tagQName(), fal
se); | 75 RefPtr<Element> newList = document().createElement(listNode->tagQName(), fal
se); |
75 insertNodeBefore(newList, selectedListItem.get()); | 76 insertNodeBefore(newList, selectedListItem.get()); |
76 | 77 |
77 // 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 |
78 // 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 |
79 // list item too would require proper deletion in that case. | 80 // list item too would require proper deletion in that case. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 237 |
237 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) |
238 { | 239 { |
239 if (tryIndentingAsListItem(start, end)) | 240 if (tryIndentingAsListItem(start, end)) |
240 blockquoteForNextIndent = 0; | 241 blockquoteForNextIndent = 0; |
241 else | 242 else |
242 indentIntoBlockquote(start, end, blockquoteForNextIndent); | 243 indentIntoBlockquote(start, end, blockquoteForNextIndent); |
243 } | 244 } |
244 | 245 |
245 } | 246 } |
OLD | NEW |