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

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

Issue 1896793002: Rename (updateLayout/updateStyle).*.() to updateStyleAndLayout.*.() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 void EditCommandComposition::unapply() 103 void EditCommandComposition::unapply()
104 { 104 {
105 DCHECK(m_document); 105 DCHECK(m_document);
106 LocalFrame* frame = m_document->frame(); 106 LocalFrame* frame = m_document->frame();
107 DCHECK(frame); 107 DCHECK(frame);
108 108
109 // Changes to the document may have been made since the last editing operati on that require a layout, as in <rdar://problem/5658603>. 109 // Changes to the document may have been made since the last editing operati on that require a layout, as in <rdar://problem/5658603>.
110 // Low level operations, like RemoveNodeCommand, don't require a layout beca use the high level operations that use them perform one 110 // Low level operations, like RemoveNodeCommand, don't require a layout beca use the high level operations that use them perform one
111 // if one is necessary (like for the creation of VisiblePositions). 111 // if one is necessary (like for the creation of VisiblePositions).
112 m_document->updateLayoutIgnorePendingStylesheets(); 112 m_document->updateStyleAndLayoutIgnorePendingStylesheets();
113 113
114 { 114 {
115 size_t size = m_commands.size(); 115 size_t size = m_commands.size();
116 for (size_t i = size; i; --i) 116 for (size_t i = size; i; --i)
117 m_commands[i - 1]->doUnapply(); 117 m_commands[i - 1]->doUnapply();
118 } 118 }
119 119
120 frame->editor().unappliedEditing(this); 120 frame->editor().unappliedEditing(this);
121 } 121 }
122 122
123 void EditCommandComposition::reapply() 123 void EditCommandComposition::reapply()
124 { 124 {
125 DCHECK(m_document); 125 DCHECK(m_document);
126 LocalFrame* frame = m_document->frame(); 126 LocalFrame* frame = m_document->frame();
127 DCHECK(frame); 127 DCHECK(frame);
128 128
129 // Changes to the document may have been made since the last editing operati on that require a layout, as in <rdar://problem/5658603>. 129 // Changes to the document may have been made since the last editing operati on that require a layout, as in <rdar://problem/5658603>.
130 // Low level operations, like RemoveNodeCommand, don't require a layout beca use the high level operations that use them perform one 130 // Low level operations, like RemoveNodeCommand, don't require a layout beca use the high level operations that use them perform one
131 // if one is necessary (like for the creation of VisiblePositions). 131 // if one is necessary (like for the creation of VisiblePositions).
132 m_document->updateLayoutIgnorePendingStylesheets(); 132 m_document->updateStyleAndLayoutIgnorePendingStylesheets();
133 133
134 { 134 {
135 for (const auto& command : m_commands) 135 for (const auto& command : m_commands)
136 command->doReapply(); 136 command->doReapply();
137 } 137 }
138 138
139 frame->editor().reappliedEditing(this); 139 frame->editor().reappliedEditing(this);
140 } 140 }
141 141
142 void EditCommandComposition::append(SimpleEditCommand* command) 142 void EditCommandComposition::append(SimpleEditCommand* command)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 default: 191 default:
192 ASSERT_NOT_REACHED(); 192 ASSERT_NOT_REACHED();
193 return false; 193 return false;
194 } 194 }
195 } 195 }
196 ensureComposition(); 196 ensureComposition();
197 197
198 // Changes to the document may have been made since the last editing operati on that require a layout, as in <rdar://problem/5658603>. 198 // Changes to the document may have been made since the last editing operati on that require a layout, as in <rdar://problem/5658603>.
199 // Low level operations, like RemoveNodeCommand, don't require a layout beca use the high level operations that use them perform one 199 // Low level operations, like RemoveNodeCommand, don't require a layout beca use the high level operations that use them perform one
200 // if one is necessary (like for the creation of VisiblePositions). 200 // if one is necessary (like for the creation of VisiblePositions).
201 document().updateLayoutIgnorePendingStylesheets(); 201 document().updateStyleAndLayoutIgnorePendingStylesheets();
202 202
203 LocalFrame* frame = document().frame(); 203 LocalFrame* frame = document().frame();
204 DCHECK(frame); 204 DCHECK(frame);
205 EditingState editingState; 205 EditingState editingState;
206 { 206 {
207 EventQueueScope eventQueueScope; 207 EventQueueScope eventQueueScope;
208 doApply(&editingState); 208 doApply(&editingState);
209 } 209 }
210 210
211 // Only need to call appliedEditing for top-level commands, 211 // Only need to call appliedEditing for top-level commands,
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 rebalanceWhitespaceAt(selection.start()); 769 rebalanceWhitespaceAt(selection.start());
770 if (selection.isRange()) 770 if (selection.isRange())
771 rebalanceWhitespaceAt(selection.end()); 771 rebalanceWhitespaceAt(selection.end());
772 } 772 }
773 773
774 void CompositeEditCommand::deleteInsignificantText(Text* textNode, unsigned star t, unsigned end) 774 void CompositeEditCommand::deleteInsignificantText(Text* textNode, unsigned star t, unsigned end)
775 { 775 {
776 if (!textNode || start >= end) 776 if (!textNode || start >= end)
777 return; 777 return;
778 778
779 document().updateLayout(); 779 document().updateStyleAndLayout();
780 780
781 LayoutText* textLayoutObject = textNode->layoutObject(); 781 LayoutText* textLayoutObject = textNode->layoutObject();
782 if (!textLayoutObject) 782 if (!textLayoutObject)
783 return; 783 return;
784 784
785 Vector<InlineTextBox*> sortedTextBoxes; 785 Vector<InlineTextBox*> sortedTextBoxes;
786 size_t sortedTextBoxesPosition = 0; 786 size_t sortedTextBoxesPosition = 0;
787 787
788 for (InlineTextBox* textBox = textLayoutObject->firstTextBox(); textBox; tex tBox = textBox->nextTextBox()) 788 for (InlineTextBox* textBox = textLayoutObject->firstTextBox(); textBox; tex tBox = textBox->nextTextBox())
789 sortedTextBoxes.append(textBox); 789 sortedTextBoxes.append(textBox);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 { 881 {
882 Position end = mostForwardCaretPosition(nextPositionOf(createVisiblePosition (pos, VP_DEFAULT_AFFINITY)).deepEquivalent()); 882 Position end = mostForwardCaretPosition(nextPositionOf(createVisiblePosition (pos, VP_DEFAULT_AFFINITY)).deepEquivalent());
883 deleteInsignificantText(pos, end); 883 deleteInsignificantText(pos, end);
884 } 884 }
885 885
886 HTMLBRElement* CompositeEditCommand::appendBlockPlaceholder(Element* container, EditingState* editingState) 886 HTMLBRElement* CompositeEditCommand::appendBlockPlaceholder(Element* container, EditingState* editingState)
887 { 887 {
888 if (!container) 888 if (!container)
889 return nullptr; 889 return nullptr;
890 890
891 document().updateLayoutIgnorePendingStylesheets(); 891 document().updateStyleAndLayoutIgnorePendingStylesheets();
892 892
893 // Should assert isLayoutBlockFlow || isInlineFlow when deletion improves. S ee 4244964. 893 // Should assert isLayoutBlockFlow || isInlineFlow when deletion improves. S ee 4244964.
894 DCHECK(container->layoutObject()) << container; 894 DCHECK(container->layoutObject()) << container;
895 895
896 HTMLBRElement* placeholder = HTMLBRElement::create(document()); 896 HTMLBRElement* placeholder = HTMLBRElement::create(document());
897 appendNode(placeholder, container, editingState); 897 appendNode(placeholder, container, editingState);
898 if (editingState->isAborted()) 898 if (editingState->isAborted())
899 return nullptr; 899 return nullptr;
900 return placeholder; 900 return placeholder;
901 } 901 }
(...skipping 11 matching lines...) Expand all
913 if (editingState->isAborted()) 913 if (editingState->isAborted())
914 return nullptr; 914 return nullptr;
915 return placeholder; 915 return placeholder;
916 } 916 }
917 917
918 HTMLBRElement* CompositeEditCommand::addBlockPlaceholderIfNeeded(Element* contai ner, EditingState* editingState) 918 HTMLBRElement* CompositeEditCommand::addBlockPlaceholderIfNeeded(Element* contai ner, EditingState* editingState)
919 { 919 {
920 if (!container) 920 if (!container)
921 return nullptr; 921 return nullptr;
922 922
923 document().updateLayoutIgnorePendingStylesheets(); 923 document().updateStyleAndLayoutIgnorePendingStylesheets();
924 924
925 LayoutObject* layoutObject = container->layoutObject(); 925 LayoutObject* layoutObject = container->layoutObject();
926 if (!layoutObject || !layoutObject->isLayoutBlockFlow()) 926 if (!layoutObject || !layoutObject->isLayoutBlockFlow())
927 return nullptr; 927 return nullptr;
928 928
929 // append the placeholder to make sure it follows 929 // append the placeholder to make sure it follows
930 // any unrendered blocks 930 // any unrendered blocks
931 LayoutBlockFlow* block = toLayoutBlockFlow(layoutObject); 931 LayoutBlockFlow* block = toLayoutBlockFlow(layoutObject);
932 if (block->size().height() == 0 || (block->isListItem() && toLayoutListItem( block)->isEmpty())) 932 if (block->size().height() == 0 || (block->isListItem() && toLayoutListItem( block)->isEmpty()))
933 return appendBlockPlaceholder(container, editingState); 933 return appendBlockPlaceholder(container, editingState);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br . 1327 // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br .
1328 // Must recononicalize these two VisiblePositions after the pruning above. 1328 // Must recononicalize these two VisiblePositions after the pruning above.
1329 beforeParagraph = createVisiblePosition(beforeParagraph.deepEquivalent()); 1329 beforeParagraph = createVisiblePosition(beforeParagraph.deepEquivalent());
1330 afterParagraph = createVisiblePosition(afterParagraph.deepEquivalent()); 1330 afterParagraph = createVisiblePosition(afterParagraph.deepEquivalent());
1331 if (beforeParagraph.isNotNull() && (!isEndOfParagraph(beforeParagraph) || be foreParagraph.deepEquivalent() == afterParagraph.deepEquivalent())) { 1331 if (beforeParagraph.isNotNull() && (!isEndOfParagraph(beforeParagraph) || be foreParagraph.deepEquivalent() == afterParagraph.deepEquivalent())) {
1332 // FIXME: Trim text between beforeParagraph and afterParagraph if they a ren't equal. 1332 // FIXME: Trim text between beforeParagraph and afterParagraph if they a ren't equal.
1333 insertNodeAt(HTMLBRElement::create(document()), beforeParagraph.deepEqui valent(), editingState); 1333 insertNodeAt(HTMLBRElement::create(document()), beforeParagraph.deepEqui valent(), editingState);
1334 if (editingState->isAborted()) 1334 if (editingState->isAborted())
1335 return; 1335 return;
1336 // Need an updateLayout here in case inserting the br has split a text n ode. 1336 // Need an updateLayout here in case inserting the br has split a text n ode.
1337 document().updateLayoutIgnorePendingStylesheets(); 1337 document().updateStyleAndLayoutIgnorePendingStylesheets();
1338 } 1338 }
1339 1339
1340 destinationIndex = TextIterator::rangeLength(Position::firstPositionInNode(d ocument().documentElement()), destination.toParentAnchoredPosition(), true); 1340 destinationIndex = TextIterator::rangeLength(Position::firstPositionInNode(d ocument().documentElement()), destination.toParentAnchoredPosition(), true);
1341 1341
1342 setEndingSelection(VisibleSelection(destination, originalIsDirectional)); 1342 setEndingSelection(VisibleSelection(destination, originalIsDirectional));
1343 DCHECK(endingSelection().isCaretOrRange()); 1343 DCHECK(endingSelection().isCaretOrRange());
1344 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S electReplacement | ReplaceSelectionCommand::MovingParagraph; 1344 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S electReplacement | ReplaceSelectionCommand::MovingParagraph;
1345 if (!preserveStyle) 1345 if (!preserveStyle)
1346 options |= ReplaceSelectionCommand::MatchStyle; 1346 options |= ReplaceSelectionCommand::MatchStyle;
1347 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment , options), editingState); 1347 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment , options), editingState);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 } 1617 }
1618 1618
1619 DEFINE_TRACE(CompositeEditCommand) 1619 DEFINE_TRACE(CompositeEditCommand)
1620 { 1620 {
1621 visitor->trace(m_commands); 1621 visitor->trace(m_commands);
1622 visitor->trace(m_composition); 1622 visitor->trace(m_composition);
1623 EditCommand::trace(visitor); 1623 EditCommand::trace(visitor);
1624 } 1624 }
1625 1625
1626 } // namespace blink 1626 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698