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

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

Issue 2705373002: Remove unnecessary layout updates from InsertInto/DeleteFromTextNodeCommand (Closed)
Patch Set: Add layout updates for clients requiring that explicitly Created 3 years, 10 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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 // Merging forward could result in deleting the destination anchor node. 943 // Merging forward could result in deleting the destination anchor node.
944 // To avoid this, we add a placeholder node before the start of the paragraph. 944 // To avoid this, we add a placeholder node before the start of the paragraph.
945 if (endOfParagraph(startOfParagraphToMove).deepEquivalent() == 945 if (endOfParagraph(startOfParagraphToMove).deepEquivalent() ==
946 destination.deepEquivalent()) { 946 destination.deepEquivalent()) {
947 HTMLBRElement* placeholder = HTMLBRElement::create(document()); 947 HTMLBRElement* placeholder = HTMLBRElement::create(document());
948 insertNodeBefore(placeholder, 948 insertNodeBefore(placeholder,
949 startOfParagraphToMove.deepEquivalent().anchorNode(), 949 startOfParagraphToMove.deepEquivalent().anchorNode(),
950 editingState); 950 editingState);
951 if (editingState->isAborted()) 951 if (editingState->isAborted())
952 return; 952 return;
953
954 // TODO(editing-dev): Use of updateStyleAndLayoutIgnorePendingStylesheets()
955 // needs to be audited. See http://crbug.com/590369 for more details.
953 document().updateStyleAndLayoutIgnorePendingStylesheets(); 956 document().updateStyleAndLayoutIgnorePendingStylesheets();
957
954 destination = VisiblePosition::beforeNode(placeholder); 958 destination = VisiblePosition::beforeNode(placeholder);
955 startOfParagraphToMove = 959 startOfParagraphToMove =
956 createVisiblePosition(startOfParagraphToMove.toPositionWithAffinity()); 960 createVisiblePosition(startOfParagraphToMove.toPositionWithAffinity());
957 } 961 }
958 962
959 moveParagraph(startOfParagraphToMove, endOfParagraph(startOfParagraphToMove), 963 moveParagraph(startOfParagraphToMove, endOfParagraph(startOfParagraphToMove),
960 destination, editingState); 964 destination, editingState);
961 if (editingState->isAborted()) 965 if (editingState->isAborted())
962 return; 966 return;
963 967
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 mostForwardCaretPosition(endingSelection().end()).anchorNode(); 1985 mostForwardCaretPosition(endingSelection().end()).anchorNode();
1982 Text* textNode = toText(fragment.firstChild()); 1986 Text* textNode = toText(fragment.firstChild());
1983 // Our fragment creation code handles tabs, spaces, and newlines, so we don't 1987 // Our fragment creation code handles tabs, spaces, and newlines, so we don't
1984 // have to worry about those here. 1988 // have to worry about those here.
1985 1989
1986 Position start = endingSelection().start(); 1990 Position start = endingSelection().start();
1987 Position end = replaceSelectedTextInNode(textNode->data()); 1991 Position end = replaceSelectedTextInNode(textNode->data());
1988 if (end.isNull()) 1992 if (end.isNull())
1989 return false; 1993 return false;
1990 1994
1995 document().updateStyleAndLayoutIgnorePendingStylesheets();
1996
1991 if (nodeAfterInsertionPos && nodeAfterInsertionPos->parentNode() && 1997 if (nodeAfterInsertionPos && nodeAfterInsertionPos->parentNode() &&
1992 isHTMLBRElement(*nodeAfterInsertionPos) && 1998 isHTMLBRElement(*nodeAfterInsertionPos) &&
1993 shouldRemoveEndBR(toHTMLBRElement(nodeAfterInsertionPos), 1999 shouldRemoveEndBR(toHTMLBRElement(nodeAfterInsertionPos),
1994 VisiblePosition::beforeNode(nodeAfterInsertionPos))) { 2000 VisiblePosition::beforeNode(nodeAfterInsertionPos))) {
1995 removeNodeAndPruneAncestors(nodeAfterInsertionPos, editingState); 2001 removeNodeAndPruneAncestors(nodeAfterInsertionPos, editingState);
1996 if (editingState->isAborted()) 2002 if (editingState->isAborted())
1997 return false; 2003 return false;
1998 } 2004 }
1999 2005
2000 m_startOfInsertedRange = start; 2006 m_startOfInsertedRange = start;
(...skipping 19 matching lines...) Expand all
2020 visitor->trace(m_startOfInsertedContent); 2026 visitor->trace(m_startOfInsertedContent);
2021 visitor->trace(m_endOfInsertedContent); 2027 visitor->trace(m_endOfInsertedContent);
2022 visitor->trace(m_insertionStyle); 2028 visitor->trace(m_insertionStyle);
2023 visitor->trace(m_documentFragment); 2029 visitor->trace(m_documentFragment);
2024 visitor->trace(m_startOfInsertedRange); 2030 visitor->trace(m_startOfInsertedRange);
2025 visitor->trace(m_endOfInsertedRange); 2031 visitor->trace(m_endOfInsertedRange);
2026 CompositeEditCommand::trace(visitor); 2032 CompositeEditCommand::trace(visitor);
2027 } 2033 }
2028 2034
2029 } // namespace blink 2035 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698