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

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

Issue 180003007: Fixing crash in doApplyForSingleParagraph(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressing review comments Created 6 years, 10 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 // If the entire list is selected, then convert the whole list. 215 // If the entire list is selected, then convert the whole list.
216 if (switchListType && isNodeVisiblyContainedWithin(listNode.get(), curre ntSelection)) { 216 if (switchListType && isNodeVisiblyContainedWithin(listNode.get(), curre ntSelection)) {
217 bool rangeStartIsInList = visiblePositionBeforeNode(listNode.get()) == VisiblePosition(currentSelection->startPosition()); 217 bool rangeStartIsInList = visiblePositionBeforeNode(listNode.get()) == VisiblePosition(currentSelection->startPosition());
218 bool rangeEndIsInList = visiblePositionAfterNode(listNode.get()) == VisiblePosition(currentSelection->endPosition()); 218 bool rangeEndIsInList = visiblePositionAfterNode(listNode.get()) == VisiblePosition(currentSelection->endPosition());
219 219
220 RefPtr<HTMLElement> newList = createHTMLElement(document(), listTag) ; 220 RefPtr<HTMLElement> newList = createHTMLElement(document(), listTag) ;
221 insertNodeBefore(newList, listNode); 221 insertNodeBefore(newList, listNode);
222 222
223 Node* firstChildInList = enclosingListChild(VisiblePosition(firstPos itionInNode(listNode.get())).deepEquivalent().deprecatedNode(), listNode.get()); 223 Node* firstChildInList = enclosingListChild(VisiblePosition(firstPos itionInNode(listNode.get())).deepEquivalent().deprecatedNode(), listNode.get());
224 Node* outerBlock = firstChildInList->isBlockFlowElement() ? firstChi ldInList : listNode.get(); 224 Node* outerBlock = firstChildInList ? (firstChildInList->isBlockFlow Element() ? firstChildInList : listNode.get()) : listNode.get();
Yuta Kitamura 2014/02/27 01:59:14 This can be simplified as: firstChildInList &&
arpitab_ 2014/02/27 05:10:07 Done.
225 225
226 moveParagraphWithClones(VisiblePosition(firstPositionInNode(listNode .get())), VisiblePosition(lastPositionInNode(listNode.get())), newList.get(), ou terBlock); 226 moveParagraphWithClones(VisiblePosition(firstPositionInNode(listNode .get())), VisiblePosition(lastPositionInNode(listNode.get())), newList.get(), ou terBlock);
227 227
228 // Manually remove listNode because moveParagraphWithClones sometime s leaves it behind in the document. 228 // Manually remove listNode because moveParagraphWithClones sometime s leaves it behind in the document.
229 // See the bug 33668 and editing/execCommand/insert-list-orphaned-it em-with-nested-lists.html. 229 // See the bug 33668 and editing/execCommand/insert-list-orphaned-it em-with-nested-lists.html.
230 // FIXME: This might be a bug in moveParagraphWithClones or deleteSe lection. 230 // FIXME: This might be a bug in moveParagraphWithClones or deleteSe lection.
231 if (listNode && listNode->inDocument()) 231 if (listNode && listNode->inDocument())
232 removeNode(listNode); 232 removeNode(listNode);
233 233
234 newList = mergeWithNeighboringLists(newList); 234 newList = mergeWithNeighboringLists(newList);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (listElement) 391 if (listElement)
392 return mergeWithNeighboringLists(listElement); 392 return mergeWithNeighboringLists(listElement);
393 393
394 if (canMergeLists(previousList, nextList)) 394 if (canMergeLists(previousList, nextList))
395 mergeIdenticalElements(previousList, nextList); 395 mergeIdenticalElements(previousList, nextList);
396 396
397 return listElement; 397 return listElement;
398 } 398 }
399 399
400 } 400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698