| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // Likewise for the root editable element. | 367 // Likewise for the root editable element. |
| 368 Node* child = node->firstChild(); | 368 Node* child = node->firstChild(); |
| 369 while (child) { | 369 while (child) { |
| 370 Node* remove = child; | 370 Node* remove = child; |
| 371 child = child->nextSibling(); | 371 child = child->nextSibling(); |
| 372 removeNode(remove, shouldAssumeContentIsAlwaysEditable); | 372 removeNode(remove, shouldAssumeContentIsAlwaysEditable); |
| 373 } | 373 } |
| 374 | 374 |
| 375 // Make sure empty cell has some height, if a placeholder can be inserte
d. | 375 // Make sure empty cell has some height, if a placeholder can be inserte
d. |
| 376 document().updateLayoutIgnorePendingStylesheets(); | 376 document().updateLayoutIgnorePendingStylesheets(); |
| 377 LayoutObject* r = node->renderer(); | 377 LayoutObject* r = node->layoutObject(); |
| 378 if (r && r->isTableCell() && toLayoutTableCell(r)->contentHeight() <= 0)
{ | 378 if (r && r->isTableCell() && toLayoutTableCell(r)->contentHeight() <= 0)
{ |
| 379 Position firstEditablePosition = firstEditablePositionInNode(node.ge
t()); | 379 Position firstEditablePosition = firstEditablePositionInNode(node.ge
t()); |
| 380 if (firstEditablePosition.isNotNull()) | 380 if (firstEditablePosition.isNotNull()) |
| 381 insertBlockPlaceholder(firstEditablePosition); | 381 insertBlockPlaceholder(firstEditablePosition); |
| 382 } | 382 } |
| 383 return; | 383 return; |
| 384 } | 384 } |
| 385 | 385 |
| 386 if (node == m_startBlock) { | 386 if (node == m_startBlock) { |
| 387 VisiblePosition previous = VisiblePosition(firstPositionInNode(m_startBl
ock.get())).previous(); | 387 VisiblePosition previous = VisiblePosition(firstPositionInNode(m_startBl
ock.get())).previous(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 // in a text node that needs to be trimmed | 482 // in a text node that needs to be trimmed |
| 483 Text* text = toText(startNode); | 483 Text* text = toText(startNode); |
| 484 deleteTextFromNode(text, startOffset, m_downstreamEnd.deprecated
EditingOffset() - startOffset); | 484 deleteTextFromNode(text, startOffset, m_downstreamEnd.deprecated
EditingOffset() - startOffset); |
| 485 } else { | 485 } else { |
| 486 removeChildrenInRange(startNode, startOffset, m_downstreamEnd.de
precatedEditingOffset()); | 486 removeChildrenInRange(startNode, startOffset, m_downstreamEnd.de
precatedEditingOffset()); |
| 487 m_endingPosition = m_upstreamStart; | 487 m_endingPosition = m_upstreamStart; |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 | 490 |
| 491 // The selection to delete is all in one node. | 491 // The selection to delete is all in one node. |
| 492 if (!startNode->renderer() || (!startOffset && m_downstreamEnd.atLastEdi
tingPositionForNode())) | 492 if (!startNode->layoutObject() || (!startOffset && m_downstreamEnd.atLas
tEditingPositionForNode())) |
| 493 removeNode(startNode); | 493 removeNode(startNode); |
| 494 } | 494 } |
| 495 else { | 495 else { |
| 496 bool startNodeWasDescendantOfEndNode = m_upstreamStart.deprecatedNode()-
>isDescendantOf(m_downstreamEnd.deprecatedNode()); | 496 bool startNodeWasDescendantOfEndNode = m_upstreamStart.deprecatedNode()-
>isDescendantOf(m_downstreamEnd.deprecatedNode()); |
| 497 // The selection to delete spans more than one node. | 497 // The selection to delete spans more than one node. |
| 498 RefPtrWillBeRawPtr<Node> node(startNode); | 498 RefPtrWillBeRawPtr<Node> node(startNode); |
| 499 | 499 |
| 500 if (startOffset > 0) { | 500 if (startOffset > 0) { |
| 501 if (startNode->isTextNode()) { | 501 if (startNode->isTextNode()) { |
| 502 // in a text node that needs to be trimmed | 502 // in a text node that needs to be trimmed |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 } | 567 } |
| 568 } | 568 } |
| 569 } | 569 } |
| 570 | 570 |
| 571 void DeleteSelectionCommand::fixupWhitespace() | 571 void DeleteSelectionCommand::fixupWhitespace() |
| 572 { | 572 { |
| 573 document().updateLayoutIgnorePendingStylesheets(); | 573 document().updateLayoutIgnorePendingStylesheets(); |
| 574 // FIXME: isRenderedCharacter should be removed, and we should use VisiblePo
sition::characterAfter and VisiblePosition::characterBefore | 574 // FIXME: isRenderedCharacter should be removed, and we should use VisiblePo
sition::characterAfter and VisiblePosition::characterBefore |
| 575 if (m_leadingWhitespace.isNotNull() && !m_leadingWhitespace.isRenderedCharac
ter() && m_leadingWhitespace.deprecatedNode()->isTextNode()) { | 575 if (m_leadingWhitespace.isNotNull() && !m_leadingWhitespace.isRenderedCharac
ter() && m_leadingWhitespace.deprecatedNode()->isTextNode()) { |
| 576 Text* textNode = toText(m_leadingWhitespace.deprecatedNode()); | 576 Text* textNode = toText(m_leadingWhitespace.deprecatedNode()); |
| 577 ASSERT(!textNode->renderer() || textNode->renderer()->style()->collapseW
hiteSpace()); | 577 ASSERT(!textNode->layoutObject() || textNode->layoutObject()->style()->c
ollapseWhiteSpace()); |
| 578 replaceTextInNodePreservingMarkers(textNode, m_leadingWhitespace.depreca
tedEditingOffset(), 1, nonBreakingSpaceString()); | 578 replaceTextInNodePreservingMarkers(textNode, m_leadingWhitespace.depreca
tedEditingOffset(), 1, nonBreakingSpaceString()); |
| 579 } | 579 } |
| 580 if (m_trailingWhitespace.isNotNull() && !m_trailingWhitespace.isRenderedChar
acter() && m_trailingWhitespace.deprecatedNode()->isTextNode()) { | 580 if (m_trailingWhitespace.isNotNull() && !m_trailingWhitespace.isRenderedChar
acter() && m_trailingWhitespace.deprecatedNode()->isTextNode()) { |
| 581 Text* textNode = toText(m_trailingWhitespace.deprecatedNode()); | 581 Text* textNode = toText(m_trailingWhitespace.deprecatedNode()); |
| 582 ASSERT(!textNode->renderer() ||textNode->renderer()->style()->collapseWh
iteSpace()); | 582 ASSERT(!textNode->layoutObject() || textNode->layoutObject()->style()->c
ollapseWhiteSpace()); |
| 583 replaceTextInNodePreservingMarkers(textNode, m_trailingWhitespace.deprec
atedEditingOffset(), 1, nonBreakingSpaceString()); | 583 replaceTextInNodePreservingMarkers(textNode, m_trailingWhitespace.deprec
atedEditingOffset(), 1, nonBreakingSpaceString()); |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 | 586 |
| 587 // If a selection starts in one block and ends in another, we have to merge to b
ring content before the | 587 // If a selection starts in one block and ends in another, we have to merge to b
ring content before the |
| 588 // start together with content after the end. | 588 // start together with content after the end. |
| 589 void DeleteSelectionCommand::mergeParagraphs() | 589 void DeleteSelectionCommand::mergeParagraphs() |
| 590 { | 590 { |
| 591 if (!m_mergeBlocksAfterDelete) { | 591 if (!m_mergeBlocksAfterDelete) { |
| 592 if (m_pruneStartBlockIfNecessary) { | 592 if (m_pruneStartBlockIfNecessary) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 visitor->trace(m_deleteIntoBlockquoteStyle); | 891 visitor->trace(m_deleteIntoBlockquoteStyle); |
| 892 visitor->trace(m_startRoot); | 892 visitor->trace(m_startRoot); |
| 893 visitor->trace(m_endRoot); | 893 visitor->trace(m_endRoot); |
| 894 visitor->trace(m_startTableRow); | 894 visitor->trace(m_startTableRow); |
| 895 visitor->trace(m_endTableRow); | 895 visitor->trace(m_endTableRow); |
| 896 visitor->trace(m_temporaryPlaceholder); | 896 visitor->trace(m_temporaryPlaceholder); |
| 897 CompositeEditCommand::trace(visitor); | 897 CompositeEditCommand::trace(visitor); |
| 898 } | 898 } |
| 899 | 899 |
| 900 } // namespace blink | 900 } // namespace blink |
| OLD | NEW |