OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 } | 943 } |
944 } | 944 } |
945 | 945 |
946 if (visibleParagraphEnd.isNull()) | 946 if (visibleParagraphEnd.isNull()) |
947 return nullptr; | 947 return nullptr; |
948 | 948 |
949 RefPtrWillBeRawPtr<Node> newBlock = insertNewDefaultParagraphElementAt(upstr
eamStart); | 949 RefPtrWillBeRawPtr<Node> newBlock = insertNewDefaultParagraphElementAt(upstr
eamStart); |
950 | 950 |
951 bool endWasBr = isHTMLBRElement(*visibleParagraphEnd.deepEquivalent().deprec
atedNode()); | 951 bool endWasBr = isHTMLBRElement(*visibleParagraphEnd.deepEquivalent().deprec
atedNode()); |
952 | 952 |
| 953 // Inserting default paragraph element can change visible position. We |
| 954 // should update visible positions before use them. |
| 955 visiblePos = VisiblePosition(pos, VP_DEFAULT_AFFINITY); |
| 956 visibleParagraphStart = VisiblePosition(startOfParagraph(visiblePos)); |
| 957 visibleParagraphEnd = VisiblePosition(endOfParagraph(visiblePos)); |
953 moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition(f
irstPositionInNode(newBlock.get()))); | 958 moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition(f
irstPositionInNode(newBlock.get()))); |
954 | 959 |
955 if (newBlock->lastChild() && isHTMLBRElement(*newBlock->lastChild()) && !end
WasBr) | 960 if (newBlock->lastChild() && isHTMLBRElement(*newBlock->lastChild()) && !end
WasBr) |
956 removeNode(newBlock->lastChild()); | 961 removeNode(newBlock->lastChild()); |
957 | 962 |
958 return newBlock.release(); | 963 return newBlock.release(); |
959 } | 964 } |
960 | 965 |
961 void CompositeEditCommand::pushAnchorElementDown(Node* anchorNode) | 966 void CompositeEditCommand::pushAnchorElementDown(Node* anchorNode) |
962 { | 967 { |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 } | 1497 } |
1493 | 1498 |
1494 void CompositeEditCommand::trace(Visitor* visitor) | 1499 void CompositeEditCommand::trace(Visitor* visitor) |
1495 { | 1500 { |
1496 visitor->trace(m_commands); | 1501 visitor->trace(m_commands); |
1497 visitor->trace(m_composition); | 1502 visitor->trace(m_composition); |
1498 EditCommand::trace(visitor); | 1503 EditCommand::trace(visitor); |
1499 } | 1504 } |
1500 | 1505 |
1501 } // namespace WebCore | 1506 } // namespace WebCore |
OLD | NEW |