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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 } | 601 } |
602 | 602 |
603 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 603 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
604 | 604 |
605 // Insert the list at a position visually equivalent to start of the | 605 // Insert the list at a position visually equivalent to start of the |
606 // paragraph that is being moved into the list. | 606 // paragraph that is being moved into the list. |
607 // Try to avoid inserting it somewhere where it will be surrounded by | 607 // Try to avoid inserting it somewhere where it will be surrounded by |
608 // inline ancestors of start, since it is easier for editing to produce | 608 // inline ancestors of start, since it is easier for editing to produce |
609 // clean markup when inline elements are pushed down as far as possible. | 609 // clean markup when inline elements are pushed down as far as possible. |
610 Position insertionPos(mostBackwardCaretPosition(startPos)); | 610 Position insertionPos(mostBackwardCaretPosition(startPos)); |
| 611 // Also avoid the temporary <span> element created by 'unlistifyParagraph'. |
| 612 // This element can be selected by mostBackwardCaretPosition when startPor |
| 613 // points to a element with previous siblings or ancestors with siblings. |
| 614 // |-A |
| 615 // | |-B |
| 616 // | +-C (insertion point) |
| 617 // | |-D (*) |
| 618 if (isHTMLSpanElement(insertionPos.anchorNode())) { |
| 619 insertionPos = |
| 620 Position::inParentBeforeNode(*insertionPos.computeContainerNode()); |
| 621 } |
611 // Also avoid the containing list item. | 622 // Also avoid the containing list item. |
612 Node* const listChild = enclosingListChild(insertionPos.anchorNode()); | 623 Node* const listChild = enclosingListChild(insertionPos.anchorNode()); |
613 if (isHTMLLIElement(listChild)) | 624 if (isHTMLLIElement(listChild)) |
614 insertionPos = Position::inParentBeforeNode(*listChild); | 625 insertionPos = Position::inParentBeforeNode(*listChild); |
615 | 626 |
616 HTMLElement* listElement = createHTMLElement(document(), listTag); | 627 HTMLElement* listElement = createHTMLElement(document(), listTag); |
617 insertNodeAt(listElement, insertionPos, editingState); | 628 insertNodeAt(listElement, insertionPos, editingState); |
618 if (editingState->isAborted()) | 629 if (editingState->isAborted()) |
619 return; | 630 return; |
620 HTMLLIElement* listItemElement = HTMLLIElement::create(document()); | 631 HTMLLIElement* listItemElement = HTMLLIElement::create(document()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 endOfParagraph(validPos, CanSkipOverEditingBoundary); | 674 endOfParagraph(validPos, CanSkipOverEditingBoundary); |
664 moveParagraph(start, end, VisiblePosition::beforeNode(placeholder), | 675 moveParagraph(start, end, VisiblePosition::beforeNode(placeholder), |
665 editingState, PreserveSelection); | 676 editingState, PreserveSelection); |
666 } | 677 } |
667 | 678 |
668 DEFINE_TRACE(InsertListCommand) { | 679 DEFINE_TRACE(InsertListCommand) { |
669 CompositeEditCommand::trace(visitor); | 680 CompositeEditCommand::trace(visitor); |
670 } | 681 } |
671 | 682 |
672 } // namespace blink | 683 } // namespace blink |
OLD | NEW |