OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2010 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 11 matching lines...) Expand all Loading... |
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/InsertListCommand.h" | 27 #include "core/editing/InsertListCommand.h" |
28 | 28 |
29 #include "HTMLNames.h" | 29 #include "HTMLNames.h" |
30 #include "bindings/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/v8/ExceptionStatePlaceholder.h" |
31 #include "core/dom/Element.h" | 31 #include "core/dom/Element.h" |
| 32 #include "core/dom/ElementTraversal.h" |
32 #include "core/editing/TextIterator.h" | 33 #include "core/editing/TextIterator.h" |
33 #include "core/editing/VisibleUnits.h" | 34 #include "core/editing/VisibleUnits.h" |
34 #include "core/editing/htmlediting.h" | 35 #include "core/editing/htmlediting.h" |
35 #include "core/html/HTMLElement.h" | 36 #include "core/html/HTMLElement.h" |
36 | 37 |
37 namespace WebCore { | 38 namespace WebCore { |
38 | 39 |
39 using namespace HTMLNames; | 40 using namespace HTMLNames; |
40 | 41 |
41 static Node* enclosingListChild(Node* node, Node* listNode) | 42 static Node* enclosingListChild(Node* node, Node* listNode) |
(...skipping 10 matching lines...) Expand all Loading... |
52 insertNodeBefore(listElement, node); | 53 insertNodeBefore(listElement, node); |
53 removeNode(node); | 54 removeNode(node); |
54 appendNode(node, listElement); | 55 appendNode(node, listElement); |
55 m_listElement = listElement; | 56 m_listElement = listElement; |
56 return listElement.get(); | 57 return listElement.get(); |
57 } | 58 } |
58 | 59 |
59 PassRefPtr<HTMLElement> InsertListCommand::mergeWithNeighboringLists(PassRefPtr<
HTMLElement> passedList) | 60 PassRefPtr<HTMLElement> InsertListCommand::mergeWithNeighboringLists(PassRefPtr<
HTMLElement> passedList) |
60 { | 61 { |
61 RefPtr<HTMLElement> list = passedList; | 62 RefPtr<HTMLElement> list = passedList; |
62 Element* previousList = list->previousElementSibling(); | 63 Element* previousList = ElementTraversal::previousSibling(*list); |
63 if (canMergeLists(previousList, list.get())) | 64 if (canMergeLists(previousList, list.get())) |
64 mergeIdenticalElements(previousList, list); | 65 mergeIdenticalElements(previousList, list); |
65 | 66 |
66 if (!list || !list->nextElementSibling() || !list->nextElementSibling()->isH
TMLElement()) | 67 if (!list) |
| 68 return 0; |
| 69 |
| 70 Element* nextSibling = ElementTraversal::nextSibling(*list); |
| 71 if (!nextSibling || !nextSibling->isHTMLElement()) |
67 return list.release(); | 72 return list.release(); |
68 | 73 |
69 RefPtr<HTMLElement> nextList = toHTMLElement(list->nextElementSibling()); | 74 RefPtr<HTMLElement> nextList = toHTMLElement(nextSibling); |
70 if (canMergeLists(list.get(), nextList.get())) { | 75 if (canMergeLists(list.get(), nextList.get())) { |
71 mergeIdenticalElements(list, nextList); | 76 mergeIdenticalElements(list, nextList); |
72 return nextList.release(); | 77 return nextList.release(); |
73 } | 78 } |
74 return list.release(); | 79 return list.release(); |
75 } | 80 } |
76 | 81 |
77 bool InsertListCommand::selectionHasListOfType(const VisibleSelection& selection
, const QualifiedName& listTag) | 82 bool InsertListCommand::selectionHasListOfType(const VisibleSelection& selection
, const QualifiedName& listTag) |
78 { | 83 { |
79 VisiblePosition start = selection.visibleStart(); | 84 VisiblePosition start = selection.visibleStart(); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 if (listElement) | 391 if (listElement) |
387 return mergeWithNeighboringLists(listElement); | 392 return mergeWithNeighboringLists(listElement); |
388 | 393 |
389 if (canMergeLists(previousList, nextList)) | 394 if (canMergeLists(previousList, nextList)) |
390 mergeIdenticalElements(previousList, nextList); | 395 mergeIdenticalElements(previousList, nextList); |
391 | 396 |
392 return listElement; | 397 return listElement; |
393 } | 398 } |
394 | 399 |
395 } | 400 } |
OLD | NEW |