| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "core/editing/HTMLInterchange.h" | 42 #include "core/editing/HTMLInterchange.h" |
| 43 #include "core/editing/SimplifyMarkupCommand.h" | 43 #include "core/editing/SimplifyMarkupCommand.h" |
| 44 #include "core/editing/SmartReplace.h" | 44 #include "core/editing/SmartReplace.h" |
| 45 #include "core/editing/TextIterator.h" | 45 #include "core/editing/TextIterator.h" |
| 46 #include "core/editing/VisibleUnits.h" | 46 #include "core/editing/VisibleUnits.h" |
| 47 #include "core/editing/htmlediting.h" | 47 #include "core/editing/htmlediting.h" |
| 48 #include "core/editing/markup.h" | 48 #include "core/editing/markup.h" |
| 49 #include "core/events/BeforeTextInsertedEvent.h" | 49 #include "core/events/BeforeTextInsertedEvent.h" |
| 50 #include "core/frame/LocalFrame.h" | 50 #include "core/frame/LocalFrame.h" |
| 51 #include "core/frame/UseCounter.h" | 51 #include "core/frame/UseCounter.h" |
| 52 #include "core/html/HTMLBRElement.h" |
| 52 #include "core/html/HTMLElement.h" | 53 #include "core/html/HTMLElement.h" |
| 53 #include "core/html/HTMLInputElement.h" | 54 #include "core/html/HTMLInputElement.h" |
| 54 #include "core/rendering/RenderObject.h" | 55 #include "core/rendering/RenderObject.h" |
| 55 #include "core/rendering/RenderText.h" | 56 #include "core/rendering/RenderText.h" |
| 56 #include "wtf/StdLibExtras.h" | 57 #include "wtf/StdLibExtras.h" |
| 57 #include "wtf/Vector.h" | 58 #include "wtf/Vector.h" |
| 58 | 59 |
| 59 namespace blink { | 60 namespace blink { |
| 60 | 61 |
| 61 using namespace HTMLNames; | 62 using namespace HTMLNames; |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 // include the what was the start of the selection that was pasted into, so
that we preserve that paragraph's | 829 // include the what was the start of the selection that was pasted into, so
that we preserve that paragraph's |
| 829 // block styles. | 830 // block styles. |
| 830 bool mergeForward = !(inSameParagraph(startOfInsertedContent, endOfInsertedC
ontent) && !isStartOfParagraph(startOfInsertedContent)); | 831 bool mergeForward = !(inSameParagraph(startOfInsertedContent, endOfInsertedC
ontent) && !isStartOfParagraph(startOfInsertedContent)); |
| 831 | 832 |
| 832 VisiblePosition destination = mergeForward ? endOfInsertedContent.next() : e
ndOfInsertedContent; | 833 VisiblePosition destination = mergeForward ? endOfInsertedContent.next() : e
ndOfInsertedContent; |
| 833 VisiblePosition startOfParagraphToMove = mergeForward ? startOfParagraph(end
OfInsertedContent) : endOfInsertedContent.next(); | 834 VisiblePosition startOfParagraphToMove = mergeForward ? startOfParagraph(end
OfInsertedContent) : endOfInsertedContent.next(); |
| 834 | 835 |
| 835 // Merging forward could result in deleting the destination anchor node. | 836 // Merging forward could result in deleting the destination anchor node. |
| 836 // To avoid this, we add a placeholder node before the start of the paragrap
h. | 837 // To avoid this, we add a placeholder node before the start of the paragrap
h. |
| 837 if (endOfParagraph(startOfParagraphToMove) == destination) { | 838 if (endOfParagraph(startOfParagraphToMove) == destination) { |
| 838 RefPtrWillBeRawPtr<Node> placeholder = createBreakElement(document()); | 839 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(docum
ent()); |
| 839 insertNodeBefore(placeholder, startOfParagraphToMove.deepEquivalent().de
precatedNode()); | 840 insertNodeBefore(placeholder, startOfParagraphToMove.deepEquivalent().de
precatedNode()); |
| 840 destination = VisiblePosition(positionBeforeNode(placeholder.get())); | 841 destination = VisiblePosition(positionBeforeNode(placeholder.get())); |
| 841 } | 842 } |
| 842 | 843 |
| 843 moveParagraph(startOfParagraphToMove, endOfParagraph(startOfParagraphToMove)
, destination); | 844 moveParagraph(startOfParagraphToMove, endOfParagraph(startOfParagraphToMove)
, destination); |
| 844 | 845 |
| 845 // Merging forward will remove m_endOfInsertedContent from the document. | 846 // Merging forward will remove m_endOfInsertedContent from the document. |
| 846 if (mergeForward) { | 847 if (mergeForward) { |
| 847 if (m_startOfInsertedContent.isOrphan()) | 848 if (m_startOfInsertedContent.isOrphan()) |
| 848 m_startOfInsertedContent = endingSelection().visibleStart().deepEqui
valent(); | 849 m_startOfInsertedContent = endingSelection().visibleStart().deepEqui
valent(); |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1529 void ReplaceSelectionCommand::trace(Visitor* visitor) | 1530 void ReplaceSelectionCommand::trace(Visitor* visitor) |
| 1530 { | 1531 { |
| 1531 visitor->trace(m_startOfInsertedContent); | 1532 visitor->trace(m_startOfInsertedContent); |
| 1532 visitor->trace(m_endOfInsertedContent); | 1533 visitor->trace(m_endOfInsertedContent); |
| 1533 visitor->trace(m_insertionStyle); | 1534 visitor->trace(m_insertionStyle); |
| 1534 visitor->trace(m_documentFragment); | 1535 visitor->trace(m_documentFragment); |
| 1535 CompositeEditCommand::trace(visitor); | 1536 CompositeEditCommand::trace(visitor); |
| 1536 } | 1537 } |
| 1537 | 1538 |
| 1538 } // namespace blink | 1539 } // namespace blink |
| OLD | NEW |