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

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

Issue 1307803003: Introduce nextPositionOf() for VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-28T18:13:02 Created 5 years, 3 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 ASSERT(listChildNode); 287 ASSERT(listChildNode);
288 if (isHTMLLIElement(*listChildNode)) { 288 if (isHTMLLIElement(*listChildNode)) {
289 start = VisiblePosition(firstPositionInNode(listChildNode)); 289 start = VisiblePosition(firstPositionInNode(listChildNode));
290 end = VisiblePosition(lastPositionInNode(listChildNode)); 290 end = VisiblePosition(lastPositionInNode(listChildNode));
291 nextListChild = listChildNode->nextSibling(); 291 nextListChild = listChildNode->nextSibling();
292 previousListChild = listChildNode->previousSibling(); 292 previousListChild = listChildNode->previousSibling();
293 } else { 293 } else {
294 // A paragraph is visually a list item minus a list marker. The paragra ph will be moved. 294 // A paragraph is visually a list item minus a list marker. The paragra ph will be moved.
295 start = startOfParagraph(originalStart, CanSkipOverEditingBoundary); 295 start = startOfParagraph(originalStart, CanSkipOverEditingBoundary);
296 end = endOfParagraph(start, CanSkipOverEditingBoundary); 296 end = endOfParagraph(start, CanSkipOverEditingBoundary);
297 nextListChild = enclosingListChild(end.next().deepEquivalent().anchorNod e(), listElement); 297 nextListChild = enclosingListChild(nextPositionOf(end).deepEquivalent(). anchorNode(), listElement);
298 ASSERT(nextListChild != listChildNode); 298 ASSERT(nextListChild != listChildNode);
299 previousListChild = enclosingListChild(previousPositionOf(start).deepEqu ivalent().anchorNode(), listElement); 299 previousListChild = enclosingListChild(previousPositionOf(start).deepEqu ivalent().anchorNode(), listElement);
300 ASSERT(previousListChild != listChildNode); 300 ASSERT(previousListChild != listChildNode);
301 } 301 }
302 // When removing a list, we must always create a placeholder to act as a poi nt of insertion 302 // When removing a list, we must always create a placeholder to act as a poi nt of insertion
303 // for the list content being removed. 303 // for the list content being removed.
304 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document( )); 304 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document( ));
305 RefPtrWillBeRawPtr<HTMLElement> elementToInsert = placeholder; 305 RefPtrWillBeRawPtr<HTMLElement> elementToInsert = placeholder;
306 // If the content of the list item will be moved into another list, put it i n a list item 306 // If the content of the list item will be moved into another list, put it i n a list item
307 // so that we don't create an orphaned list child. 307 // so that we don't create an orphaned list child.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (start.isNull() || end.isNull()) 363 if (start.isNull() || end.isNull())
364 return nullptr; 364 return nullptr;
365 365
366 // Check for adjoining lists. 366 // Check for adjoining lists.
367 RefPtrWillBeRawPtr<HTMLElement> listItemElement = createListItemElement(docu ment()); 367 RefPtrWillBeRawPtr<HTMLElement> listItemElement = createListItemElement(docu ment());
368 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document( )); 368 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document( ));
369 appendNode(placeholder, listItemElement); 369 appendNode(placeholder, listItemElement);
370 370
371 // Place list item into adjoining lists. 371 // Place list item into adjoining lists.
372 HTMLElement* previousList = adjacentEnclosingList(start, previousPositionOf( start, CannotCrossEditingBoundary), listTag); 372 HTMLElement* previousList = adjacentEnclosingList(start, previousPositionOf( start, CannotCrossEditingBoundary), listTag);
373 HTMLElement* nextList = adjacentEnclosingList(start, end.next(CannotCrossEdi tingBoundary), listTag); 373 HTMLElement* nextList = adjacentEnclosingList(start, nextPositionOf(end, Can notCrossEditingBoundary), listTag);
374 RefPtrWillBeRawPtr<HTMLElement> listElement = nullptr; 374 RefPtrWillBeRawPtr<HTMLElement> listElement = nullptr;
375 if (previousList) { 375 if (previousList) {
376 appendNode(listItemElement, previousList); 376 appendNode(listItemElement, previousList);
377 } else if (nextList) { 377 } else if (nextList) {
378 insertNodeAt(listItemElement, positionBeforeNode(nextList)); 378 insertNodeAt(listItemElement, positionBeforeNode(nextList));
379 } else { 379 } else {
380 // Create the list. 380 // Create the list.
381 listElement = createHTMLElement(document(), listTag); 381 listElement = createHTMLElement(document(), listTag);
382 appendNode(listItemElement, listElement); 382 appendNode(listItemElement, listElement);
383 383
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return listElement; 427 return listElement;
428 } 428 }
429 429
430 DEFINE_TRACE(InsertListCommand) 430 DEFINE_TRACE(InsertListCommand)
431 { 431 {
432 visitor->trace(m_listElement); 432 visitor->trace(m_listElement);
433 CompositeEditCommand::trace(visitor); 433 CompositeEditCommand::trace(visitor);
434 } 434 }
435 435
436 } 436 }
OLDNEW
« no previous file with comments | « Source/core/editing/commands/IndentOutdentCommand.cpp ('k') | Source/core/editing/commands/ReplaceSelectionCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698