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

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

Issue 1292303005: Make core/editing/ files to match Blink coding style (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-18T10:48:50 Created 5 years, 4 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 bool switchListType = false; 211 bool switchListType = false;
212 if (listChildNode) { 212 if (listChildNode) {
213 if (!listChildNode->parentNode()->hasEditableStyle()) 213 if (!listChildNode->parentNode()->hasEditableStyle())
214 return false; 214 return false;
215 // Remove the list child. 215 // Remove the list child.
216 RefPtrWillBeRawPtr<HTMLElement> listElement = enclosingList(listChildNod e); 216 RefPtrWillBeRawPtr<HTMLElement> listElement = enclosingList(listChildNod e);
217 if (!listElement) { 217 if (!listElement) {
218 listElement = fixOrphanedListChild(listChildNode); 218 listElement = fixOrphanedListChild(listChildNode);
219 listElement = mergeWithNeighboringLists(listElement); 219 listElement = mergeWithNeighboringLists(listElement);
220 } 220 }
221 if (!listElement->hasTagName(listTag)) 221 if (!listElement->hasTagName(listTag)) {
222 // listChildNode will be removed from the list and a list of type m_ type will be created. 222 // |listChildNode| will be removed from the list and a list of type
223 // |m_type| will be created.
223 switchListType = true; 224 switchListType = true;
225 }
224 226
225 // If the list is of the desired type, and we are not removing the list, then exit early. 227 // If the list is of the desired type, and we are not removing the list,
228 // then exit early.
226 if (!switchListType && forceCreateList) 229 if (!switchListType && forceCreateList)
227 return true; 230 return true;
228 231
229 // If the entire list is selected, then convert the whole list. 232 // If the entire list is selected, then convert the whole list.
230 if (switchListType && isNodeVisiblyContainedWithin(*listElement, current Selection)) { 233 if (switchListType && isNodeVisiblyContainedWithin(*listElement, current Selection)) {
231 bool rangeStartIsInList = visiblePositionBeforeNode(*listElement).de epEquivalent() == VisiblePosition(currentSelection.startPosition()).deepEquivale nt(); 234 bool rangeStartIsInList = visiblePositionBeforeNode(*listElement).de epEquivalent() == VisiblePosition(currentSelection.startPosition()).deepEquivale nt();
232 bool rangeEndIsInList = visiblePositionAfterNode(*listElement).deepE quivalent() == VisiblePosition(currentSelection.endPosition()).deepEquivalent(); 235 bool rangeEndIsInList = visiblePositionAfterNode(*listElement).deepE quivalent() == VisiblePosition(currentSelection.endPosition()).deepEquivalent();
233 236
234 RefPtrWillBeRawPtr<HTMLElement> newList = createHTMLElement(document (), listTag); 237 RefPtrWillBeRawPtr<HTMLElement> newList = createHTMLElement(document (), listTag);
235 insertNodeBefore(newList, listElement); 238 insertNodeBefore(newList, listElement);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 358
356 // Check for adjoining lists. 359 // Check for adjoining lists.
357 RefPtrWillBeRawPtr<HTMLElement> listItemElement = createListItemElement(docu ment()); 360 RefPtrWillBeRawPtr<HTMLElement> listItemElement = createListItemElement(docu ment());
358 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document( )); 361 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document( ));
359 appendNode(placeholder, listItemElement); 362 appendNode(placeholder, listItemElement);
360 363
361 // Place list item into adjoining lists. 364 // Place list item into adjoining lists.
362 HTMLElement* previousList = adjacentEnclosingList(start, start.previous(Cann otCrossEditingBoundary), listTag); 365 HTMLElement* previousList = adjacentEnclosingList(start, start.previous(Cann otCrossEditingBoundary), listTag);
363 HTMLElement* nextList = adjacentEnclosingList(start, end.next(CannotCrossEdi tingBoundary), listTag); 366 HTMLElement* nextList = adjacentEnclosingList(start, end.next(CannotCrossEdi tingBoundary), listTag);
364 RefPtrWillBeRawPtr<HTMLElement> listElement = nullptr; 367 RefPtrWillBeRawPtr<HTMLElement> listElement = nullptr;
365 if (previousList) 368 if (previousList) {
366 appendNode(listItemElement, previousList); 369 appendNode(listItemElement, previousList);
367 else if (nextList) 370 } else if (nextList) {
368 insertNodeAt(listItemElement, positionBeforeNode(nextList)); 371 insertNodeAt(listItemElement, positionBeforeNode(nextList));
369 else { 372 } else {
370 // Create the list. 373 // Create the list.
371 listElement = createHTMLElement(document(), listTag); 374 listElement = createHTMLElement(document(), listTag);
372 appendNode(listItemElement, listElement); 375 appendNode(listItemElement, listElement);
373 376
374 if (start.deepEquivalent() == end.deepEquivalent() && isBlock(start.deep Equivalent().anchorNode())) { 377 if (start.deepEquivalent() == end.deepEquivalent() && isBlock(start.deep Equivalent().anchorNode())) {
375 // Inserting the list into an empty paragraph that isn't held open 378 // Inserting the list into an empty paragraph that isn't held open
376 // by a br or a '\n', will invalidate start and end. Insert 379 // by a br or a '\n', will invalidate start and end. Insert
377 // a placeholder and then recompute start and end. 380 // a placeholder and then recompute start and end.
378 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = insertBlockPlacehold er(start.deepEquivalent()); 381 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = insertBlockPlacehold er(start.deepEquivalent());
379 start = VisiblePosition(positionBeforeNode(placeholder.get())); 382 start = VisiblePosition(positionBeforeNode(placeholder.get()));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 return listElement; 420 return listElement;
418 } 421 }
419 422
420 DEFINE_TRACE(InsertListCommand) 423 DEFINE_TRACE(InsertListCommand)
421 { 424 {
422 visitor->trace(m_listElement); 425 visitor->trace(m_listElement);
423 CompositeEditCommand::trace(visitor); 426 CompositeEditCommand::trace(visitor);
424 } 427 }
425 428
426 } 429 }
OLDNEW
« no previous file with comments | « Source/core/editing/InsertLineBreakCommand.cpp ('k') | Source/core/editing/InsertParagraphSeparatorCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698