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

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

Issue 2405223002: Ensure valid input for CompositeEditCommand::moveParagraph[s] (Closed)
Patch Set: Remove the dirty hacks 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) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // Re-canonicalize visible{Start,End}OfParagraph, make them valid again 288 // Re-canonicalize visible{Start,End}OfParagraph, make them valid again
289 // after DOM change. 289 // after DOM change.
290 // TODO(xiaochengh): We should not store a VisiblePosition and later inspect 290 // TODO(xiaochengh): We should not store a VisiblePosition and later inspect
291 // its properties when it is already invalidated. 291 // its properties when it is already invalidated.
292 visibleStartOfParagraph = 292 visibleStartOfParagraph =
293 createVisiblePosition(visibleStartOfParagraph.toPositionWithAffinity()); 293 createVisiblePosition(visibleStartOfParagraph.toPositionWithAffinity());
294 visibleEndOfParagraph = 294 visibleEndOfParagraph =
295 createVisiblePosition(visibleEndOfParagraph.toPositionWithAffinity()); 295 createVisiblePosition(visibleEndOfParagraph.toPositionWithAffinity());
296 } 296 }
297 297
298 // TODO(xiaochengh): We should not store a VisiblePosition and later inspect
299 // its properties when it is already invalidated.
298 VisiblePosition startOfParagraphToMove = 300 VisiblePosition startOfParagraphToMove =
299 startOfParagraph(visibleStartOfParagraph); 301 startOfParagraph(visibleStartOfParagraph);
300 VisiblePosition endOfParagraphToMove = endOfParagraph(visibleEndOfParagraph); 302 VisiblePosition endOfParagraphToMove = endOfParagraph(visibleEndOfParagraph);
301 if (startOfParagraphToMove.isNull() || endOfParagraphToMove.isNull()) 303 if (startOfParagraphToMove.isNull() || endOfParagraphToMove.isNull())
302 return; 304 return;
303 HTMLBRElement* placeholder = HTMLBRElement::create(document()); 305 HTMLBRElement* placeholder = HTMLBRElement::create(document());
304 insertNodeBefore(placeholder, splitBlockquoteNode, editingState); 306 insertNodeBefore(placeholder, splitBlockquoteNode, editingState);
305 if (editingState->isAborted()) 307 if (editingState->isAborted())
306 return; 308 return;
307 309
308 document().updateStyleAndLayoutIgnorePendingStylesheets(); 310 document().updateStyleAndLayoutIgnorePendingStylesheets();
311 startOfParagraphToMove =
312 createVisiblePosition(startOfParagraphToMove.toPositionWithAffinity());
313 endOfParagraphToMove =
314 createVisiblePosition(endOfParagraphToMove.toPositionWithAffinity());
309 moveParagraph(startOfParagraphToMove, endOfParagraphToMove, 315 moveParagraph(startOfParagraphToMove, endOfParagraphToMove,
310 VisiblePosition::beforeNode(placeholder), editingState, 316 VisiblePosition::beforeNode(placeholder), editingState,
311 PreserveSelection); 317 PreserveSelection);
312 } 318 }
313 319
314 // FIXME: We should merge this function with 320 // FIXME: We should merge this function with
315 // ApplyBlockElementCommand::formatSelection 321 // ApplyBlockElementCommand::formatSelection
316 void IndentOutdentCommand::outdentRegion( 322 void IndentOutdentCommand::outdentRegion(
317 const VisiblePosition& startOfSelection, 323 const VisiblePosition& startOfSelection,
318 const VisiblePosition& endOfSelection, 324 const VisiblePosition& endOfSelection,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 else 394 else
389 indentIntoBlockquote(start, end, blockquoteForNextIndent, editingState); 395 indentIntoBlockquote(start, end, blockquoteForNextIndent, editingState);
390 } 396 }
391 397
392 InputEvent::InputType IndentOutdentCommand::inputType() const { 398 InputEvent::InputType IndentOutdentCommand::inputType() const {
393 return m_typeOfAction == Indent ? InputEvent::InputType::Indent 399 return m_typeOfAction == Indent ? InputEvent::InputType::Indent
394 : InputEvent::InputType::Outdent; 400 : InputEvent::InputType::Outdent;
395 } 401 }
396 402
397 } // namespace blink 403 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698