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

Unified 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: Modifications as per review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/editing/execCommand/indent-pre-list-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/IndentOutdentCommand.cpp
diff --git a/Source/core/editing/IndentOutdentCommand.cpp b/Source/core/editing/IndentOutdentCommand.cpp
index 934840573ecebe15d190519e1fbaabc16746f267..940f54b5546107a2f907f135e289d3c20cea8e30 100644
--- a/Source/core/editing/IndentOutdentCommand.cpp
+++ b/Source/core/editing/IndentOutdentCommand.cpp
@@ -72,13 +72,18 @@ bool IndentOutdentCommand::tryIndentingAsListItem(const Position& start, const P
// We should calculate visible range in list item because inserting new
// list element will change visibility of list item, e.g. :first-child
// CSS selector.
- VisiblePosition startOfMove(start);
- VisiblePosition endOfMove(end);
-
RefPtr<Element> newList = document().createElement(listNode->tagQName(), false);
insertNodeBefore(newList, selectedListItem.get());
- moveParagraphWithClones(startOfMove, endOfMove, newList.get(), selectedListItem.get());
+ // We should clone all the children of the list item for indenting purposes. However, in case the current
+ // selection does not encompass all its children, we need to explicitally handle the same. The original
+ // list item too would require proper deletion in that case.
+ if (end.anchorNode() == selectedListItem.get() || end.anchorNode()->isDescendantOf(selectedListItem->lastChild())) {
+ moveParagraphWithClones(start, end, newList.get(), selectedListItem.get());
+ } else {
+ moveParagraphWithClones(start, positionAfterNode(selectedListItem->lastChild()), newList.get(), selectedListItem.get());
+ removeNode(selectedListItem.get());
+ }
if (canMergeLists(previousList.get(), newList.get()))
mergeIdenticalElements(previousList.get(), newList.get());
« no previous file with comments | « LayoutTests/editing/execCommand/indent-pre-list-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698