| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006 Apple Computer, 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 381 |
| 382 document().updateLayoutIgnorePendingStylesheets(); | 382 document().updateLayoutIgnorePendingStylesheets(); |
| 383 | 383 |
| 384 // If the paragraph separator was inserted at the end of a paragraph, an emp
ty line must be | 384 // If the paragraph separator was inserted at the end of a paragraph, an emp
ty line must be |
| 385 // created. All of the nodes, starting at visiblePos, are about to be added
to the new paragraph | 385 // created. All of the nodes, starting at visiblePos, are about to be added
to the new paragraph |
| 386 // element. If the first node to be inserted won't be one that will hold an
empty line open, add a br. | 386 // element. If the first node to be inserted won't be one that will hold an
empty line open, add a br. |
| 387 if (isEndOfParagraph(visiblePos) && !lineBreakExistsAtVisiblePosition(visibl
ePos)) | 387 if (isEndOfParagraph(visiblePos) && !lineBreakExistsAtVisiblePosition(visibl
ePos)) |
| 388 appendNode(createBreakElement(document()).get(), blockToInsert.get()); | 388 appendNode(createBreakElement(document()).get(), blockToInsert.get()); |
| 389 | 389 |
| 390 // Move the start node and the siblings of the start node. | 390 // Move the start node and the siblings of the start node. |
| 391 if (VisiblePosition(insertionPosition) != VisiblePosition(positionBeforeNode
(blockToInsert.get()))) { | 391 if (VisiblePosition(insertionPosition) != VisiblePosition(positionBeforeNode
(*blockToInsert))) { |
| 392 Node* n; | 392 Node* n; |
| 393 if (insertionPosition.containerNode() == startBlock) | 393 if (insertionPosition.containerNode() == startBlock) |
| 394 n = insertionPosition.computeNodeAfterPosition(); | 394 n = insertionPosition.computeNodeAfterPosition(); |
| 395 else { | 395 else { |
| 396 Node* splitTo = insertionPosition.containerNode(); | 396 Node* splitTo = insertionPosition.containerNode(); |
| 397 if (splitTo->isTextNode() && insertionPosition.offsetInContainerNode
() >= caretMaxOffset(splitTo)) | 397 if (splitTo->isTextNode() && insertionPosition.offsetInContainerNode
() >= caretMaxOffset(splitTo)) |
| 398 splitTo = NodeTraversal::next(*splitTo, startBlock.get()); | 398 splitTo = NodeTraversal::next(*splitTo, startBlock.get()); |
| 399 ASSERT(splitTo); | 399 ASSERT(splitTo); |
| 400 splitTreeToNode(splitTo, startBlock.get()); | 400 splitTreeToNode(splitTo, startBlock.get()); |
| 401 | 401 |
| 402 for (n = startBlock->firstChild(); n; n = n->nextSibling()) { | 402 for (n = startBlock->firstChild(); n; n = n->nextSibling()) { |
| 403 VisiblePosition beforeNodePosition(positionBeforeNode(n)); | 403 VisiblePosition beforeNodePosition(positionBeforeNode(*n)); |
| 404 if (!beforeNodePosition.isNull() && comparePositions(VisiblePosi
tion(insertionPosition), beforeNodePosition) <= 0) | 404 if (!beforeNodePosition.isNull() && comparePositions(VisiblePosi
tion(insertionPosition), beforeNodePosition) <= 0) |
| 405 break; | 405 break; |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 | 408 |
| 409 moveRemainingSiblingsToNewParent(n, blockToInsert.get(), blockToInsert); | 409 moveRemainingSiblingsToNewParent(n, blockToInsert.get(), blockToInsert); |
| 410 } | 410 } |
| 411 | 411 |
| 412 // Handle whitespace that occurs after the split | 412 // Handle whitespace that occurs after the split |
| 413 if (positionAfterSplit.isNotNull()) { | 413 if (positionAfterSplit.isNotNull()) { |
| 414 document().updateLayoutIgnorePendingStylesheets(); | 414 document().updateLayoutIgnorePendingStylesheets(); |
| 415 if (!positionAfterSplit.isRenderedCharacter()) { | 415 if (!positionAfterSplit.isRenderedCharacter()) { |
| 416 // Clear out all whitespace and insert one non-breaking space | 416 // Clear out all whitespace and insert one non-breaking space |
| 417 ASSERT(!positionAfterSplit.containerNode()->renderer() || positionAf
terSplit.containerNode()->renderer()->style()->collapseWhiteSpace()); | 417 ASSERT(!positionAfterSplit.containerNode()->renderer() || positionAf
terSplit.containerNode()->renderer()->style()->collapseWhiteSpace()); |
| 418 deleteInsignificantTextDownstream(positionAfterSplit); | 418 deleteInsignificantTextDownstream(positionAfterSplit); |
| 419 if (positionAfterSplit.deprecatedNode()->isTextNode()) | 419 if (positionAfterSplit.deprecatedNode()->isTextNode()) |
| 420 insertTextIntoNode(toText(positionAfterSplit.containerNode()), 0
, nonBreakingSpaceString()); | 420 insertTextIntoNode(toText(positionAfterSplit.containerNode()), 0
, nonBreakingSpaceString()); |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 | 423 |
| 424 setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert.get())
, DOWNSTREAM, endingSelection().isDirectional())); | 424 setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert.get())
, DOWNSTREAM, endingSelection().isDirectional())); |
| 425 applyStyleAfterInsertion(startBlock.get()); | 425 applyStyleAfterInsertion(startBlock.get()); |
| 426 } | 426 } |
| 427 | 427 |
| 428 } // namespace WebCore | 428 } // namespace WebCore |
| OLD | NEW |