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

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

Issue 67063005: Fixing indent/outdent for <li> elements containing children spanning across (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (!selectedListItem->hasTagName(liTag)) 65 if (!selectedListItem->hasTagName(liTag))
66 return false; 66 return false;
67 67
68 // FIXME: previousElementSibling does not ignore non-rendered content like < span></span>. Should we? 68 // FIXME: previousElementSibling does not ignore non-rendered content like < span></span>. Should we?
69 RefPtr<Element> previousList = selectedListItem->previousElementSibling(); 69 RefPtr<Element> previousList = selectedListItem->previousElementSibling();
70 RefPtr<Element> nextList = selectedListItem->nextElementSibling(); 70 RefPtr<Element> nextList = selectedListItem->nextElementSibling();
71 71
72 // We should calculate visible range in list item because inserting new 72 // We should calculate visible range in list item because inserting new
73 // list element will change visibility of list item, e.g. :first-child 73 // list element will change visibility of list item, e.g. :first-child
74 // CSS selector. 74 // CSS selector.
75 VisiblePosition startOfMove(start);
yosin_UTC9 2013/11/20 05:01:49 Since r162080, we don't need to take care about in
76 VisiblePosition endOfMove(end);
77
78 RefPtr<Element> newList = document().createElement(listNode->tagQName(), fal se); 75 RefPtr<Element> newList = document().createElement(listNode->tagQName(), fal se);
79 insertNodeBefore(newList, selectedListItem.get()); 76 insertNodeBefore(newList, selectedListItem.get());
80 77
81 moveParagraphWithClones(startOfMove, endOfMove, newList.get(), selectedListI tem.get()); 78 // We should clone all the children of the list item for indenting purposes. However, in case the current
79 // selection does not encompass all its children, we need to explicitally ha ndle the same. The original
80 // list item too would require proper deletion in that case.
81 if (end.deprecatedNode() == selectedListItem.get() || end.deprecatedNode()-> isDescendantOf(selectedListItem->lastChild())) {
yosin_UTC9 2013/11/20 05:01:49 nit: s/deprecatedNode/anchorNode/g
arpitab_ 2013/11/20 13:07:52 Done.
82 moveParagraphWithClones(start, end, newList.get(), selectedListItem.get( ));
83 } else {
84 moveParagraphWithClones(start, positionAfterNode(selectedListItem->lastC hild()), newList.get(), selectedListItem.get());
85 removeNode(selectedListItem.get());
86 }
82 87
83 if (canMergeLists(previousList.get(), newList.get())) 88 if (canMergeLists(previousList.get(), newList.get()))
84 mergeIdenticalElements(previousList.get(), newList.get()); 89 mergeIdenticalElements(previousList.get(), newList.get());
85 if (canMergeLists(newList.get(), nextList.get())) 90 if (canMergeLists(newList.get(), nextList.get()))
86 mergeIdenticalElements(newList.get(), nextList.get()); 91 mergeIdenticalElements(newList.get(), nextList.get());
87 92
88 return true; 93 return true;
89 } 94 }
90 95
91 void IndentOutdentCommand::indentIntoBlockquote(const Position& start, const Pos ition& end, RefPtr<Element>& targetBlockquote) 96 void IndentOutdentCommand::indentIntoBlockquote(const Position& start, const Pos ition& end, RefPtr<Element>& targetBlockquote)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 238
234 void IndentOutdentCommand::formatRange(const Position& start, const Position& en d, const Position&, RefPtr<Element>& blockquoteForNextIndent) 239 void IndentOutdentCommand::formatRange(const Position& start, const Position& en d, const Position&, RefPtr<Element>& blockquoteForNextIndent)
235 { 240 {
236 if (tryIndentingAsListItem(start, end)) 241 if (tryIndentingAsListItem(start, end))
237 blockquoteForNextIndent = 0; 242 blockquoteForNextIndent = 0;
238 else 243 else
239 indentIntoBlockquote(start, end, blockquoteForNextIndent); 244 indentIntoBlockquote(start, end, blockquoteForNextIndent);
240 } 245 }
241 246
242 } 247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698