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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = insertBlockPlacehold
er(start.deepEquivalent()); | 388 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = insertBlockPlacehold
er(start.deepEquivalent()); |
389 start = VisiblePosition(positionBeforeNode(placeholder.get())); | 389 start = VisiblePosition(positionBeforeNode(placeholder.get())); |
390 end = start; | 390 end = start; |
391 } | 391 } |
392 | 392 |
393 // Insert the list at a position visually equivalent to start of the | 393 // Insert the list at a position visually equivalent to start of the |
394 // paragraph that is being moved into the list. | 394 // paragraph that is being moved into the list. |
395 // Try to avoid inserting it somewhere where it will be surrounded by | 395 // Try to avoid inserting it somewhere where it will be surrounded by |
396 // inline ancestors of start, since it is easier for editing to produce | 396 // inline ancestors of start, since it is easier for editing to produce |
397 // clean markup when inline elements are pushed down as far as possible. | 397 // clean markup when inline elements are pushed down as far as possible. |
398 Position insertionPos(start.deepEquivalent().upstream()); | 398 Position insertionPos(mostBackwardCaretPosition(start.deepEquivalent()))
; |
399 // Also avoid the containing list item. | 399 // Also avoid the containing list item. |
400 Node* listChild = enclosingListChild(insertionPos.anchorNode()); | 400 Node* listChild = enclosingListChild(insertionPos.anchorNode()); |
401 if (isHTMLLIElement(listChild)) | 401 if (isHTMLLIElement(listChild)) |
402 insertionPos = positionInParentBeforeNode(*listChild); | 402 insertionPos = positionInParentBeforeNode(*listChild); |
403 | 403 |
404 insertNodeAt(listElement, insertionPos); | 404 insertNodeAt(listElement, insertionPos); |
405 | 405 |
406 // We inserted the list at the start of the content we're about to move | 406 // We inserted the list at the start of the content we're about to move |
407 // Update the start of content, so we don't try to move the list into it
self. bug 19066 | 407 // Update the start of content, so we don't try to move the list into it
self. bug 19066 |
408 // Layout is necessary since start's node's inline layoutObjects may hav
e been destroyed by the insertion | 408 // Layout is necessary since start's node's inline layoutObjects may hav
e been destroyed by the insertion |
(...skipping 18 matching lines...) Expand all Loading... |
427 return listElement; | 427 return listElement; |
428 } | 428 } |
429 | 429 |
430 DEFINE_TRACE(InsertListCommand) | 430 DEFINE_TRACE(InsertListCommand) |
431 { | 431 { |
432 visitor->trace(m_listElement); | 432 visitor->trace(m_listElement); |
433 CompositeEditCommand::trace(visitor); | 433 CompositeEditCommand::trace(visitor); |
434 } | 434 } |
435 | 435 |
436 } | 436 } |
OLD | NEW |