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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.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) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 DCHECK(!endOfSelection.isNull()); 87 DCHECK(!endOfSelection.isNull());
88 ContainerNode* startScope = nullptr; 88 ContainerNode* startScope = nullptr;
89 int startIndex = indexForVisiblePosition(startOfSelection, startScope); 89 int startIndex = indexForVisiblePosition(startOfSelection, startScope);
90 ContainerNode* endScope = nullptr; 90 ContainerNode* endScope = nullptr;
91 int endIndex = indexForVisiblePosition(endOfSelection, endScope); 91 int endIndex = indexForVisiblePosition(endOfSelection, endScope);
92 92
93 formatSelection(startOfSelection, endOfSelection, editingState); 93 formatSelection(startOfSelection, endOfSelection, editingState);
94 if (editingState->isAborted()) 94 if (editingState->isAborted())
95 return; 95 return;
96 96
97 document().updateLayoutIgnorePendingStylesheets(); 97 document().updateStyleAndLayoutIgnorePendingStylesheets();
98 98
99 DCHECK_EQ(startScope, endScope); 99 DCHECK_EQ(startScope, endScope);
100 DCHECK_GE(startIndex, 0); 100 DCHECK_GE(startIndex, 0);
101 DCHECK_LE(startIndex, endIndex); 101 DCHECK_LE(startIndex, endIndex);
102 if (startScope == endScope && startIndex >= 0 && startIndex <= endIndex) { 102 if (startScope == endScope && startIndex >= 0 && startIndex <= endIndex) {
103 VisiblePosition start(visiblePositionForIndex(startIndex, startScope)); 103 VisiblePosition start(visiblePositionForIndex(startIndex, startScope));
104 VisiblePosition end(visiblePositionForIndex(endIndex, endScope)); 104 VisiblePosition end(visiblePositionForIndex(endIndex, endScope));
105 if (start.isNotNull() && end.isNotNull()) 105 if (start.isNotNull() && end.isNotNull())
106 setEndingSelection(VisibleSelection(start, end, endingSelection().is Directional())); 106 setEndingSelection(VisibleSelection(start, end, endingSelection().is Directional()));
107 } 107 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (!position.isOffsetInAnchor() || !position.computeContainerNode() || !pos ition.computeContainerNode()->isTextNode()) 185 if (!position.isOffsetInAnchor() || !position.computeContainerNode() || !pos ition.computeContainerNode()->isTextNode())
186 return 0; 186 return 0;
187 return position.computeContainerNode()->computedStyle(); 187 return position.computeContainerNode()->computedStyle();
188 } 188 }
189 189
190 void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const VisiblePosition& endOfCurrentParagraph, Position& start, Position& end) 190 void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const VisiblePosition& endOfCurrentParagraph, Position& start, Position& end)
191 { 191 {
192 start = startOfParagraph(endOfCurrentParagraph).deepEquivalent(); 192 start = startOfParagraph(endOfCurrentParagraph).deepEquivalent();
193 end = endOfCurrentParagraph.deepEquivalent(); 193 end = endOfCurrentParagraph.deepEquivalent();
194 194
195 document().updateLayoutTree(); 195 document().updateStyleAndLayoutTree();
196 196
197 bool isStartAndEndOnSameNode = false; 197 bool isStartAndEndOnSameNode = false;
198 if (const ComputedStyle* startStyle = computedStyleOfEnclosingTextNode(start )) { 198 if (const ComputedStyle* startStyle = computedStyleOfEnclosingTextNode(start )) {
199 isStartAndEndOnSameNode = computedStyleOfEnclosingTextNode(end) && start .computeContainerNode() == end.computeContainerNode(); 199 isStartAndEndOnSameNode = computedStyleOfEnclosingTextNode(end) && start .computeContainerNode() == end.computeContainerNode();
200 bool isStartAndEndOfLastParagraphOnSameNode = computedStyleOfEnclosingTe xtNode(m_endOfLastParagraph) && start.computeContainerNode() == m_endOfLastParag raph.computeContainerNode(); 200 bool isStartAndEndOfLastParagraphOnSameNode = computedStyleOfEnclosingTe xtNode(m_endOfLastParagraph) && start.computeContainerNode() == m_endOfLastParag raph.computeContainerNode();
201 201
202 // Avoid obtanining the start of next paragraph for start 202 // Avoid obtanining the start of next paragraph for start
203 // TODO(yosin) We should use |PositionMoveType::CodePoint| for 203 // TODO(yosin) We should use |PositionMoveType::CodePoint| for
204 // |previousPositionOf()|. 204 // |previousPositionOf()|.
205 if (startStyle->preserveNewline() && isNewLineAtPosition(start) && !isNe wLineAtPosition(previousPositionOf(start, PositionMoveType::CodeUnit)) && start. offsetInContainerNode() > 0) 205 if (startStyle->preserveNewline() && isNewLineAtPosition(start) && !isNe wLineAtPosition(previousPositionOf(start, PositionMoveType::CodeUnit)) && start. offsetInContainerNode() > 0)
206 start = startOfParagraph(createVisiblePosition(previousPositionOf(en d, PositionMoveType::CodeUnit))).deepEquivalent(); 206 start = startOfParagraph(createVisiblePosition(previousPositionOf(en d, PositionMoveType::CodeUnit))).deepEquivalent();
207 207
208 // If start is in the middle of a text node, split. 208 // If start is in the middle of a text node, split.
209 if (!startStyle->collapseWhiteSpace() && start.offsetInContainerNode() > 0) { 209 if (!startStyle->collapseWhiteSpace() && start.offsetInContainerNode() > 0) {
210 int startOffset = start.offsetInContainerNode(); 210 int startOffset = start.offsetInContainerNode();
211 Text* startText = toText(start.computeContainerNode()); 211 Text* startText = toText(start.computeContainerNode());
212 splitTextNode(startText, startOffset); 212 splitTextNode(startText, startOffset);
213 start = Position::firstPositionInNode(startText); 213 start = Position::firstPositionInNode(startText);
214 if (isStartAndEndOnSameNode) { 214 if (isStartAndEndOnSameNode) {
215 DCHECK_GE(end.offsetInContainerNode(), startOffset); 215 DCHECK_GE(end.offsetInContainerNode(), startOffset);
216 end = Position(startText, end.offsetInContainerNode() - startOff set); 216 end = Position(startText, end.offsetInContainerNode() - startOff set);
217 } 217 }
218 if (isStartAndEndOfLastParagraphOnSameNode) { 218 if (isStartAndEndOfLastParagraphOnSameNode) {
219 DCHECK_GE(m_endOfLastParagraph.offsetInContainerNode(), startOff set); 219 DCHECK_GE(m_endOfLastParagraph.offsetInContainerNode(), startOff set);
220 m_endOfLastParagraph = Position(startText, m_endOfLastParagraph. offsetInContainerNode() - startOffset); 220 m_endOfLastParagraph = Position(startText, m_endOfLastParagraph. offsetInContainerNode() - startOffset);
221 } 221 }
222 } 222 }
223 } 223 }
224 224
225 document().updateLayoutTree(); 225 document().updateStyleAndLayoutTree();
226 226
227 if (const ComputedStyle* endStyle = computedStyleOfEnclosingTextNode(end)) { 227 if (const ComputedStyle* endStyle = computedStyleOfEnclosingTextNode(end)) {
228 bool isEndAndEndOfLastParagraphOnSameNode = computedStyleOfEnclosingText Node(m_endOfLastParagraph) && end.anchorNode() == m_endOfLastParagraph.anchorNod e(); 228 bool isEndAndEndOfLastParagraphOnSameNode = computedStyleOfEnclosingText Node(m_endOfLastParagraph) && end.anchorNode() == m_endOfLastParagraph.anchorNod e();
229 // Include \n at the end of line if we're at an empty paragraph 229 // Include \n at the end of line if we're at an empty paragraph
230 if (endStyle->preserveNewline() && start == end && end.offsetInContainer Node() < end.computeContainerNode()->maxCharacterOffset()) { 230 if (endStyle->preserveNewline() && start == end && end.offsetInContainer Node() < end.computeContainerNode()->maxCharacterOffset()) {
231 int endOffset = end.offsetInContainerNode(); 231 int endOffset = end.offsetInContainerNode();
232 // TODO(yosin) We should use |PositionMoveType::CodePoint| for 232 // TODO(yosin) We should use |PositionMoveType::CodePoint| for
233 // |previousPositionOf()|. 233 // |previousPositionOf()|.
234 if (!isNewLineAtPosition(previousPositionOf(end, PositionMoveType::C odeUnit)) && isNewLineAtPosition(end)) 234 if (!isNewLineAtPosition(previousPositionOf(end, PositionMoveType::C odeUnit)) && isNewLineAtPosition(end))
235 end = Position(end.computeContainerNode(), endOffset + 1); 235 end = Position(end.computeContainerNode(), endOffset + 1);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 return element; 301 return element;
302 } 302 }
303 303
304 DEFINE_TRACE(ApplyBlockElementCommand) 304 DEFINE_TRACE(ApplyBlockElementCommand)
305 { 305 {
306 visitor->trace(m_endOfLastParagraph); 306 visitor->trace(m_endOfLastParagraph);
307 CompositeEditCommand::trace(visitor); 307 CompositeEditCommand::trace(visitor);
308 } 308 }
309 309
310 } // namespace blink 310 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698