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

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

Issue 2955823002: Make VisiblePosition::FirstPositionInNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-26T17:50:06 Created 3 years, 6 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, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2010 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 CreateVisiblePosition(current_selection.EndPosition()) 377 CreateVisiblePosition(current_selection.EndPosition())
378 .DeepEquivalent(); 378 .DeepEquivalent();
379 379
380 HTMLElement* new_list = CreateHTMLElement(GetDocument(), list_tag); 380 HTMLElement* new_list = CreateHTMLElement(GetDocument(), list_tag);
381 InsertNodeBefore(new_list, list_element, editing_state); 381 InsertNodeBefore(new_list, list_element, editing_state);
382 if (editing_state->IsAborted()) 382 if (editing_state->IsAborted())
383 return false; 383 return false;
384 384
385 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 385 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
386 Node* first_child_in_list = 386 Node* first_child_in_list =
387 EnclosingListChild(VisiblePosition::FirstPositionInNode(list_element) 387 EnclosingListChild(VisiblePosition::FirstPositionInNode(*list_element)
388 .DeepEquivalent() 388 .DeepEquivalent()
389 .AnchorNode(), 389 .AnchorNode(),
390 list_element); 390 list_element);
391 Element* outer_block = 391 Element* outer_block =
392 first_child_in_list && IsBlockFlowElement(*first_child_in_list) 392 first_child_in_list && IsBlockFlowElement(*first_child_in_list)
393 ? ToElement(first_child_in_list) 393 ? ToElement(first_child_in_list)
394 : list_element; 394 : list_element;
395 395
396 MoveParagraphWithClones( 396 MoveParagraphWithClones(
397 VisiblePosition::FirstPositionInNode(list_element), 397 VisiblePosition::FirstPositionInNode(*list_element),
398 VisiblePosition::LastPositionInNode(list_element), new_list, 398 VisiblePosition::LastPositionInNode(list_element), new_list,
399 outer_block, editing_state); 399 outer_block, editing_state);
400 if (editing_state->IsAborted()) 400 if (editing_state->IsAborted())
401 return false; 401 return false;
402 402
403 // Manually remove listNode because moveParagraphWithClones sometimes 403 // Manually remove listNode because moveParagraphWithClones sometimes
404 // leaves it behind in the document. See the bug 33668 and 404 // leaves it behind in the document. See the bug 33668 and
405 // editing/execCommand/insert-list-orphaned-item-with-nested-lists.html. 405 // editing/execCommand/insert-list-orphaned-item-with-nested-lists.html.
406 // FIXME: This might be a bug in moveParagraphWithClones or 406 // FIXME: This might be a bug in moveParagraphWithClones or
407 // deleteSelection. 407 // deleteSelection.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 EditingState* editing_state) { 453 EditingState* editing_state) {
454 // Since, unlistify paragraph inserts nodes into parent and removes node 454 // Since, unlistify paragraph inserts nodes into parent and removes node
455 // from parent, if parent of |listElement| should be editable. 455 // from parent, if parent of |listElement| should be editable.
456 DCHECK(HasEditableStyle(*list_element->parentNode())); 456 DCHECK(HasEditableStyle(*list_element->parentNode()));
457 Node* next_list_child; 457 Node* next_list_child;
458 Node* previous_list_child; 458 Node* previous_list_child;
459 VisiblePosition start; 459 VisiblePosition start;
460 VisiblePosition end; 460 VisiblePosition end;
461 DCHECK(list_child_node); 461 DCHECK(list_child_node);
462 if (isHTMLLIElement(*list_child_node)) { 462 if (isHTMLLIElement(*list_child_node)) {
463 start = VisiblePosition::FirstPositionInNode(list_child_node); 463 start = VisiblePosition::FirstPositionInNode(*list_child_node);
464 end = VisiblePosition::LastPositionInNode(list_child_node); 464 end = VisiblePosition::LastPositionInNode(list_child_node);
465 next_list_child = list_child_node->nextSibling(); 465 next_list_child = list_child_node->nextSibling();
466 previous_list_child = list_child_node->previousSibling(); 466 previous_list_child = list_child_node->previousSibling();
467 } else { 467 } else {
468 // A paragraph is visually a list item minus a list marker. The paragraph 468 // A paragraph is visually a list item minus a list marker. The paragraph
469 // will be moved. 469 // will be moved.
470 start = StartOfParagraph(original_start, kCanSkipOverEditingBoundary); 470 start = StartOfParagraph(original_start, kCanSkipOverEditingBoundary);
471 end = EndOfParagraph(start, kCanSkipOverEditingBoundary); 471 end = EndOfParagraph(start, kCanSkipOverEditingBoundary);
472 next_list_child = EnclosingListChild( 472 next_list_child = EnclosingListChild(
473 NextPositionOf(end).DeepEquivalent().AnchorNode(), list_element); 473 NextPositionOf(end).DeepEquivalent().AnchorNode(), list_element);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 EndOfParagraph(valid_pos, kCanSkipOverEditingBoundary); 683 EndOfParagraph(valid_pos, kCanSkipOverEditingBoundary);
684 MoveParagraph(start, end, VisiblePosition::BeforeNode(*placeholder), 684 MoveParagraph(start, end, VisiblePosition::BeforeNode(*placeholder),
685 editing_state, kPreserveSelection); 685 editing_state, kPreserveSelection);
686 } 686 }
687 687
688 DEFINE_TRACE(InsertListCommand) { 688 DEFINE_TRACE(InsertListCommand) {
689 CompositeEditCommand::Trace(visitor); 689 CompositeEditCommand::Trace(visitor);
690 } 690 }
691 691
692 } // namespace blink 692 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698