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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 PassRefPtr<HTMLElement> InsertListCommand::mergeWithNeighboringLists(PassRefPtr<
HTMLElement> passedList) | 60 PassRefPtr<HTMLElement> InsertListCommand::mergeWithNeighboringLists(PassRefPtr<
HTMLElement> passedList) |
61 { | 61 { |
62 RefPtr<HTMLElement> list = passedList; | 62 RefPtr<HTMLElement> list = passedList; |
63 Element* previousList = ElementTraversal::previousSibling(*list); | 63 Element* previousList = ElementTraversal::previousSibling(*list); |
64 if (canMergeLists(previousList, list.get())) | 64 if (canMergeLists(previousList, list.get())) |
65 mergeIdenticalElements(previousList, list); | 65 mergeIdenticalElements(previousList, list); |
66 | 66 |
67 if (!list) | 67 if (!list) |
68 return 0; | 68 return nullptr; |
69 | 69 |
70 Element* nextSibling = ElementTraversal::nextSibling(*list); | 70 Element* nextSibling = ElementTraversal::nextSibling(*list); |
71 if (!nextSibling || !nextSibling->isHTMLElement()) | 71 if (!nextSibling || !nextSibling->isHTMLElement()) |
72 return list.release(); | 72 return list.release(); |
73 | 73 |
74 RefPtr<HTMLElement> nextList = toHTMLElement(nextSibling); | 74 RefPtr<HTMLElement> nextList = toHTMLElement(nextSibling); |
75 if (canMergeLists(list.get(), nextList.get())) { | 75 if (canMergeLists(list.get(), nextList.get())) { |
76 mergeIdenticalElements(list, nextList); | 76 mergeIdenticalElements(list, nextList); |
77 return nextList.release(); | 77 return nextList.release(); |
78 } | 78 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 326 |
327 return listNode; | 327 return listNode; |
328 } | 328 } |
329 | 329 |
330 PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePositio
n& originalStart, const QualifiedName& listTag) | 330 PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePositio
n& originalStart, const QualifiedName& listTag) |
331 { | 331 { |
332 VisiblePosition start = startOfParagraph(originalStart, CanSkipOverEditingBo
undary); | 332 VisiblePosition start = startOfParagraph(originalStart, CanSkipOverEditingBo
undary); |
333 VisiblePosition end = endOfParagraph(start, CanSkipOverEditingBoundary); | 333 VisiblePosition end = endOfParagraph(start, CanSkipOverEditingBoundary); |
334 | 334 |
335 if (start.isNull() || end.isNull()) | 335 if (start.isNull() || end.isNull()) |
336 return 0; | 336 return nullptr; |
337 | 337 |
338 // Check for adjoining lists. | 338 // Check for adjoining lists. |
339 RefPtr<HTMLElement> listItemElement = createListItemElement(document()); | 339 RefPtr<HTMLElement> listItemElement = createListItemElement(document()); |
340 RefPtr<HTMLElement> placeholder = createBreakElement(document()); | 340 RefPtr<HTMLElement> placeholder = createBreakElement(document()); |
341 appendNode(placeholder, listItemElement); | 341 appendNode(placeholder, listItemElement); |
342 | 342 |
343 // Place list item into adjoining lists. | 343 // Place list item into adjoining lists. |
344 Element* previousList = adjacentEnclosingList(start.deepEquivalent(), start.
previous(CannotCrossEditingBoundary), listTag); | 344 Element* previousList = adjacentEnclosingList(start.deepEquivalent(), start.
previous(CannotCrossEditingBoundary), listTag); |
345 Element* nextList = adjacentEnclosingList(start.deepEquivalent(), end.next(C
annotCrossEditingBoundary), listTag); | 345 Element* nextList = adjacentEnclosingList(start.deepEquivalent(), end.next(C
annotCrossEditingBoundary), listTag); |
346 RefPtr<HTMLElement> listElement; | 346 RefPtr<HTMLElement> listElement; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 if (listElement) | 391 if (listElement) |
392 return mergeWithNeighboringLists(listElement); | 392 return mergeWithNeighboringLists(listElement); |
393 | 393 |
394 if (canMergeLists(previousList, nextList)) | 394 if (canMergeLists(previousList, nextList)) |
395 mergeIdenticalElements(previousList, nextList); | 395 mergeIdenticalElements(previousList, nextList); |
396 | 396 |
397 return listElement; | 397 return listElement; |
398 } | 398 } |
399 | 399 |
400 } | 400 } |
OLD | NEW |