Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp

Issue 2415613003: Ensure clean layout for all (but deprecated) functions creating VisiblePositions (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 return; 620 return;
621 continue; 621 continue;
622 } 622 }
623 removeElementAttribute(element, styleAttr); 623 removeElementAttribute(element, styleAttr);
624 } else if (newInlineStyle->style()->propertyCount() != 624 } else if (newInlineStyle->style()->propertyCount() !=
625 inlineStyle->propertyCount()) { 625 inlineStyle->propertyCount()) {
626 setNodeAttribute(element, styleAttr, 626 setNodeAttribute(element, styleAttr,
627 AtomicString(newInlineStyle->style()->asText())); 627 AtomicString(newInlineStyle->style()->asText()));
628 } 628 }
629 629
630 document().updateStyleAndLayoutIgnorePendingStylesheets();
631
630 // FIXME: Tolerate differences in id, class, and style attributes. 632 // FIXME: Tolerate differences in id, class, and style attributes.
631 if (element->parentNode() && isNonTableCellHTMLBlockElement(element) && 633 if (element->parentNode() && isNonTableCellHTMLBlockElement(element) &&
632 areIdenticalElements(*element, *element->parentNode()) && 634 areIdenticalElements(*element, *element->parentNode()) &&
633 VisiblePosition::firstPositionInNode(element->parentNode()) 635 VisiblePosition::firstPositionInNode(element->parentNode())
634 .deepEquivalent() == 636 .deepEquivalent() ==
635 VisiblePosition::firstPositionInNode(element).deepEquivalent() && 637 VisiblePosition::firstPositionInNode(element).deepEquivalent() &&
636 VisiblePosition::lastPositionInNode(element->parentNode()) 638 VisiblePosition::lastPositionInNode(element->parentNode())
637 .deepEquivalent() == 639 .deepEquivalent() ==
638 VisiblePosition::lastPositionInNode(element).deepEquivalent()) { 640 VisiblePosition::lastPositionInNode(element).deepEquivalent()) {
639 insertedNodes.willRemoveNodePreservingChildren(*element); 641 insertedNodes.willRemoveNodePreservingChildren(*element);
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 insertionPos.anchorNode() == enclosingBlockOfInsertionPos->parentNode() && 1470 insertionPos.anchorNode() == enclosingBlockOfInsertionPos->parentNode() &&
1469 (unsigned)insertionPos.computeEditingOffset() < 1471 (unsigned)insertionPos.computeEditingOffset() <
1470 enclosingBlockOfInsertionPos->nodeIndex() && 1472 enclosingBlockOfInsertionPos->nodeIndex() &&
1471 !isStartOfParagraph(startOfInsertedContent)) { 1473 !isStartOfParagraph(startOfInsertedContent)) {
1472 insertNodeAt(HTMLBRElement::create(document()), 1474 insertNodeAt(HTMLBRElement::create(document()),
1473 startOfInsertedContent.deepEquivalent(), editingState); 1475 startOfInsertedContent.deepEquivalent(), editingState);
1474 if (editingState->isAborted()) 1476 if (editingState->isAborted())
1475 return; 1477 return;
1476 } 1478 }
1477 1479
1480 document().updateStyleAndLayoutIgnorePendingStylesheets();
1478 if (endBR && 1481 if (endBR &&
1479 (plainTextFragment || 1482 (plainTextFragment ||
1480 (shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR) && 1483 (shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR) &&
1481 !(fragment.hasInterchangeNewlineAtEnd() && selectionIsPlainText)))) { 1484 !(fragment.hasInterchangeNewlineAtEnd() && selectionIsPlainText)))) {
1482 ContainerNode* parent = endBR->parentNode(); 1485 ContainerNode* parent = endBR->parentNode();
1483 insertedNodes.willRemoveNode(*endBR); 1486 insertedNodes.willRemoveNode(*endBR);
1484 removeNode(endBR, editingState); 1487 removeNode(endBR, editingState);
1485 if (editingState->isAborted()) 1488 if (editingState->isAborted())
1486 return; 1489 return;
1487 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent)) { 1490 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent)) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 if (selectionEndWasEndOfParagraph || 1607 if (selectionEndWasEndOfParagraph ||
1605 !isEndOfParagraph(endOfInsertedContent) || next.isNull()) { 1608 !isEndOfParagraph(endOfInsertedContent) || next.isNull()) {
1606 if (HTMLTextFormControlElement* textControl = 1609 if (HTMLTextFormControlElement* textControl =
1607 enclosingTextFormControl(currentRoot)) { 1610 enclosingTextFormControl(currentRoot)) {
1608 if (!insertedNodes.lastLeafInserted()->nextSibling()) { 1611 if (!insertedNodes.lastLeafInserted()->nextSibling()) {
1609 insertNodeAfter(textControl->createPlaceholderBreakElement(), 1612 insertNodeAfter(textControl->createPlaceholderBreakElement(),
1610 insertedNodes.lastLeafInserted(), editingState); 1613 insertedNodes.lastLeafInserted(), editingState);
1611 if (editingState->isAborted()) 1614 if (editingState->isAborted())
1612 return; 1615 return;
1613 } 1616 }
1617 document().updateStyleAndLayoutIgnorePendingStylesheets();
1614 setEndingSelection( 1618 setEndingSelection(
1615 VisiblePosition::afterNode(insertedNodes.lastLeafInserted())); 1619 VisiblePosition::afterNode(insertedNodes.lastLeafInserted()));
1616 // Select up to the paragraph separator that was added. 1620 // Select up to the paragraph separator that was added.
1617 lastPositionToSelect = 1621 lastPositionToSelect =
1618 endingSelection().visibleStart().deepEquivalent(); 1622 endingSelection().visibleStart().deepEquivalent();
1619 } else if (!isStartOfParagraph(endOfInsertedContent)) { 1623 } else if (!isStartOfParagraph(endOfInsertedContent)) {
1620 setEndingSelection(endOfInsertedContent); 1624 setEndingSelection(endOfInsertedContent);
1621 Element* enclosingBlockElement = 1625 Element* enclosingBlockElement =
1622 enclosingBlock(endOfInsertedContent.deepEquivalent().anchorNode()); 1626 enclosingBlock(endOfInsertedContent.deepEquivalent().anchorNode());
1623 if (isListItem(enclosingBlockElement)) { 1627 if (isListItem(enclosingBlockElement)) {
1624 HTMLLIElement* newListItem = HTMLLIElement::create(document()); 1628 HTMLLIElement* newListItem = HTMLLIElement::create(document());
1625 insertNodeAfter(newListItem, enclosingBlockElement, editingState); 1629 insertNodeAfter(newListItem, enclosingBlockElement, editingState);
1626 if (editingState->isAborted()) 1630 if (editingState->isAborted())
1627 return; 1631 return;
1632 document().updateStyleAndLayoutIgnorePendingStylesheets();
1628 setEndingSelection(VisiblePosition::firstPositionInNode(newListItem)); 1633 setEndingSelection(VisiblePosition::firstPositionInNode(newListItem));
1629 } else { 1634 } else {
1630 // Use a default paragraph element (a plain div) for the empty 1635 // Use a default paragraph element (a plain div) for the empty
1631 // paragraph, using the last paragraph block's style seems to annoy 1636 // paragraph, using the last paragraph block's style seems to annoy
1632 // users. 1637 // users.
1633 insertParagraphSeparator( 1638 insertParagraphSeparator(
1634 editingState, true, 1639 editingState, true,
1635 !startIsInsideMailBlockquote && 1640 !startIsInsideMailBlockquote &&
1636 highestEnclosingNodeOfType( 1641 highestEnclosingNodeOfType(
1637 endOfInsertedContent.deepEquivalent(), 1642 endOfInsertedContent.deepEquivalent(),
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 visitor->trace(m_startOfInsertedContent); 2080 visitor->trace(m_startOfInsertedContent);
2076 visitor->trace(m_endOfInsertedContent); 2081 visitor->trace(m_endOfInsertedContent);
2077 visitor->trace(m_insertionStyle); 2082 visitor->trace(m_insertionStyle);
2078 visitor->trace(m_documentFragment); 2083 visitor->trace(m_documentFragment);
2079 visitor->trace(m_startOfInsertedRange); 2084 visitor->trace(m_startOfInsertedRange);
2080 visitor->trace(m_endOfInsertedRange); 2085 visitor->trace(m_endOfInsertedRange);
2081 CompositeEditCommand::trace(visitor); 2086 CompositeEditCommand::trace(visitor);
2082 } 2087 }
2083 2088
2084 } // namespace blink 2089 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698