| 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 m_inputType(inputType), | 454 m_inputType(inputType), |
| 455 m_sanitizeFragment(options & SanitizeFragment), | 455 m_sanitizeFragment(options & SanitizeFragment), |
| 456 m_shouldMergeEnd(false) {} | 456 m_shouldMergeEnd(false) {} |
| 457 | 457 |
| 458 static bool hasMatchingQuoteLevel(VisiblePosition endOfExistingContent, | 458 static bool hasMatchingQuoteLevel(VisiblePosition endOfExistingContent, |
| 459 VisiblePosition endOfInsertedContent) { | 459 VisiblePosition endOfInsertedContent) { |
| 460 Position existing = endOfExistingContent.deepEquivalent(); | 460 Position existing = endOfExistingContent.deepEquivalent(); |
| 461 Position inserted = endOfInsertedContent.deepEquivalent(); | 461 Position inserted = endOfInsertedContent.deepEquivalent(); |
| 462 bool isInsideMailBlockquote = enclosingNodeOfType( | 462 bool isInsideMailBlockquote = enclosingNodeOfType( |
| 463 inserted, isMailHTMLBlockquoteElement, CanCrossEditingBoundary); | 463 inserted, isMailHTMLBlockquoteElement, CanCrossEditingBoundary); |
| 464 return isInsideMailBlockquote && (numEnclosingMailBlockquotes(existing) == | 464 return isInsideMailBlockquote && |
| 465 numEnclosingMailBlockquotes(inserted)); | 465 (numEnclosingMailBlockquotes(existing) == |
| 466 numEnclosingMailBlockquotes(inserted)); |
| 466 } | 467 } |
| 467 | 468 |
| 468 bool ReplaceSelectionCommand::shouldMergeStart( | 469 bool ReplaceSelectionCommand::shouldMergeStart( |
| 469 bool selectionStartWasStartOfParagraph, | 470 bool selectionStartWasStartOfParagraph, |
| 470 bool fragmentHasInterchangeNewlineAtStart, | 471 bool fragmentHasInterchangeNewlineAtStart, |
| 471 bool selectionStartWasInsideMailBlockquote) { | 472 bool selectionStartWasInsideMailBlockquote) { |
| 472 if (m_movingParagraph) | 473 if (m_movingParagraph) |
| 473 return false; | 474 return false; |
| 474 | 475 |
| 475 VisiblePosition startOfInsertedContent = positionAtStartOfInsertedContent(); | 476 VisiblePosition startOfInsertedContent = positionAtStartOfInsertedContent(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 const VisiblePosition& destination) { | 544 const VisiblePosition& destination) { |
| 544 if (source.isNull() || destination.isNull()) | 545 if (source.isNull() || destination.isNull()) |
| 545 return false; | 546 return false; |
| 546 | 547 |
| 547 Node* sourceNode = source.deepEquivalent().anchorNode(); | 548 Node* sourceNode = source.deepEquivalent().anchorNode(); |
| 548 Node* destinationNode = destination.deepEquivalent().anchorNode(); | 549 Node* destinationNode = destination.deepEquivalent().anchorNode(); |
| 549 Element* sourceBlock = enclosingBlock(sourceNode); | 550 Element* sourceBlock = enclosingBlock(sourceNode); |
| 550 Element* destinationBlock = enclosingBlock(destinationNode); | 551 Element* destinationBlock = enclosingBlock(destinationNode); |
| 551 return !enclosingNodeOfType(source.deepEquivalent(), | 552 return !enclosingNodeOfType(source.deepEquivalent(), |
| 552 &isMailPasteAsQuotationHTMLBlockQuoteElement) && | 553 &isMailPasteAsQuotationHTMLBlockQuoteElement) && |
| 553 sourceBlock && (!sourceBlock->hasTagName(blockquoteTag) || | 554 sourceBlock && |
| 554 isMailHTMLBlockquoteElement(sourceBlock)) && | 555 (!sourceBlock->hasTagName(blockquoteTag) || |
| 556 isMailHTMLBlockquoteElement(sourceBlock)) && |
| 555 enclosingListChild(sourceBlock) == | 557 enclosingListChild(sourceBlock) == |
| 556 enclosingListChild(destinationNode) && | 558 enclosingListChild(destinationNode) && |
| 557 enclosingTableCell(source.deepEquivalent()) == | 559 enclosingTableCell(source.deepEquivalent()) == |
| 558 enclosingTableCell(destination.deepEquivalent()) && | 560 enclosingTableCell(destination.deepEquivalent()) && |
| 559 (!isHTMLHeaderElement(sourceBlock) || | 561 (!isHTMLHeaderElement(sourceBlock) || |
| 560 haveSameTagName(sourceBlock, destinationBlock)) | 562 haveSameTagName(sourceBlock, destinationBlock)) |
| 561 // Don't merge to or from a position before or after a block because it | 563 // Don't merge to or from a position before or after a block because it |
| 562 // would be a no-op and cause infinite recursion. | 564 // would be a no-op and cause infinite recursion. |
| 563 && !isEnclosingBlock(sourceNode) && !isEnclosingBlock(destinationNode); | 565 && !isEnclosingBlock(sourceNode) && !isEnclosingBlock(destinationNode); |
| 564 } | 566 } |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 | 1959 |
| 1958 if (positionIsOffsetInAnchor) | 1960 if (positionIsOffsetInAnchor) |
| 1959 position = | 1961 position = |
| 1960 Position(position.computeContainerNode(), | 1962 Position(position.computeContainerNode(), |
| 1961 previous->length() + position.offsetInContainerNode()); | 1963 previous->length() + position.offsetInContainerNode()); |
| 1962 else | 1964 else |
| 1963 updatePositionForNodeRemoval(position, *previous); | 1965 updatePositionForNodeRemoval(position, *previous); |
| 1964 | 1966 |
| 1965 if (positionOnlyToBeUpdatedIsOffsetInAnchor) { | 1967 if (positionOnlyToBeUpdatedIsOffsetInAnchor) { |
| 1966 if (positionOnlyToBeUpdated.computeContainerNode() == text) | 1968 if (positionOnlyToBeUpdated.computeContainerNode() == text) |
| 1967 positionOnlyToBeUpdated = Position( | 1969 positionOnlyToBeUpdated = |
| 1968 text, previous->length() + | 1970 Position(text, |
| 1969 positionOnlyToBeUpdated.offsetInContainerNode()); | 1971 previous->length() + |
| 1972 positionOnlyToBeUpdated.offsetInContainerNode()); |
| 1970 else if (positionOnlyToBeUpdated.computeContainerNode() == previous) | 1973 else if (positionOnlyToBeUpdated.computeContainerNode() == previous) |
| 1971 positionOnlyToBeUpdated = | 1974 positionOnlyToBeUpdated = |
| 1972 Position(text, positionOnlyToBeUpdated.offsetInContainerNode()); | 1975 Position(text, positionOnlyToBeUpdated.offsetInContainerNode()); |
| 1973 } else { | 1976 } else { |
| 1974 updatePositionForNodeRemoval(positionOnlyToBeUpdated, *previous); | 1977 updatePositionForNodeRemoval(positionOnlyToBeUpdated, *previous); |
| 1975 } | 1978 } |
| 1976 | 1979 |
| 1977 removeNode(previous, editingState); | 1980 removeNode(previous, editingState); |
| 1978 if (editingState->isAborted()) | 1981 if (editingState->isAborted()) |
| 1979 return; | 1982 return; |
| 1980 } | 1983 } |
| 1981 } | 1984 } |
| 1982 if (text->nextSibling() && text->nextSibling()->isTextNode()) { | 1985 if (text->nextSibling() && text->nextSibling()->isTextNode()) { |
| 1983 Text* next = toText(text->nextSibling()); | 1986 Text* next = toText(text->nextSibling()); |
| 1984 if (!hasIncompleteSurrogate && next->data().length() > kMergeSizeLimit) | 1987 if (!hasIncompleteSurrogate && next->data().length() > kMergeSizeLimit) |
| 1985 return; | 1988 return; |
| 1986 unsigned originalLength = text->length(); | 1989 unsigned originalLength = text->length(); |
| 1987 insertTextIntoNode(text, originalLength, next->data()); | 1990 insertTextIntoNode(text, originalLength, next->data()); |
| 1988 | 1991 |
| 1989 if (!positionIsOffsetInAnchor) | 1992 if (!positionIsOffsetInAnchor) |
| 1990 updatePositionForNodeRemoval(position, *next); | 1993 updatePositionForNodeRemoval(position, *next); |
| 1991 | 1994 |
| 1992 if (positionOnlyToBeUpdatedIsOffsetInAnchor && | 1995 if (positionOnlyToBeUpdatedIsOffsetInAnchor && |
| 1993 positionOnlyToBeUpdated.computeContainerNode() == next) | 1996 positionOnlyToBeUpdated.computeContainerNode() == next) |
| 1994 positionOnlyToBeUpdated = | 1997 positionOnlyToBeUpdated = Position( |
| 1995 Position(text, originalLength + | 1998 text, |
| 1996 positionOnlyToBeUpdated.offsetInContainerNode()); | 1999 originalLength + positionOnlyToBeUpdated.offsetInContainerNode()); |
| 1997 else | 2000 else |
| 1998 updatePositionForNodeRemoval(positionOnlyToBeUpdated, *next); | 2001 updatePositionForNodeRemoval(positionOnlyToBeUpdated, *next); |
| 1999 | 2002 |
| 2000 removeNode(next, editingState); | 2003 removeNode(next, editingState); |
| 2001 if (editingState->isAborted()) | 2004 if (editingState->isAborted()) |
| 2002 return; | 2005 return; |
| 2003 } | 2006 } |
| 2004 } | 2007 } |
| 2005 | 2008 |
| 2006 InputEvent::InputType ReplaceSelectionCommand::inputType() const { | 2009 InputEvent::InputType ReplaceSelectionCommand::inputType() const { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 visitor->trace(m_startOfInsertedContent); | 2143 visitor->trace(m_startOfInsertedContent); |
| 2141 visitor->trace(m_endOfInsertedContent); | 2144 visitor->trace(m_endOfInsertedContent); |
| 2142 visitor->trace(m_insertionStyle); | 2145 visitor->trace(m_insertionStyle); |
| 2143 visitor->trace(m_documentFragment); | 2146 visitor->trace(m_documentFragment); |
| 2144 visitor->trace(m_startOfInsertedRange); | 2147 visitor->trace(m_startOfInsertedRange); |
| 2145 visitor->trace(m_endOfInsertedRange); | 2148 visitor->trace(m_endOfInsertedRange); |
| 2146 CompositeEditCommand::trace(visitor); | 2149 CompositeEditCommand::trace(visitor); |
| 2147 } | 2150 } |
| 2148 | 2151 |
| 2149 } // namespace blink | 2152 } // namespace blink |
| OLD | NEW |