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

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

Issue 166033005: Port Node's previousElementSibling() / nextElementSibling() to ElementTraversal (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase 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
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/editing/IndentOutdentCommand.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/editing/CompositeEditCommand.h" 27 #include "core/editing/CompositeEditCommand.h"
28 28
29 #include "HTMLNames.h" 29 #include "HTMLNames.h"
30 #include "bindings/v8/ExceptionStatePlaceholder.h" 30 #include "bindings/v8/ExceptionStatePlaceholder.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/DocumentFragment.h" 32 #include "core/dom/DocumentFragment.h"
33 #include "core/dom/DocumentMarkerController.h" 33 #include "core/dom/DocumentMarkerController.h"
34 #include "core/dom/ElementTraversal.h"
34 #include "core/dom/NodeTraversal.h" 35 #include "core/dom/NodeTraversal.h"
35 #include "core/dom/Range.h" 36 #include "core/dom/Range.h"
36 #include "core/events/ScopedEventQueue.h"
37 #include "core/dom/Text.h" 37 #include "core/dom/Text.h"
38 #include "core/editing/AppendNodeCommand.h" 38 #include "core/editing/AppendNodeCommand.h"
39 #include "core/editing/ApplyStyleCommand.h" 39 #include "core/editing/ApplyStyleCommand.h"
40 #include "core/editing/DeleteFromTextNodeCommand.h" 40 #include "core/editing/DeleteFromTextNodeCommand.h"
41 #include "core/editing/DeleteSelectionCommand.h" 41 #include "core/editing/DeleteSelectionCommand.h"
42 #include "core/editing/Editor.h" 42 #include "core/editing/Editor.h"
43 #include "core/editing/InsertIntoTextNodeCommand.h" 43 #include "core/editing/InsertIntoTextNodeCommand.h"
44 #include "core/editing/InsertLineBreakCommand.h" 44 #include "core/editing/InsertLineBreakCommand.h"
45 #include "core/editing/InsertNodeBeforeCommand.h" 45 #include "core/editing/InsertNodeBeforeCommand.h"
46 #include "core/editing/InsertParagraphSeparatorCommand.h" 46 #include "core/editing/InsertParagraphSeparatorCommand.h"
47 #include "core/editing/MergeIdenticalElementsCommand.h" 47 #include "core/editing/MergeIdenticalElementsCommand.h"
48 #include "core/editing/PlainTextRange.h" 48 #include "core/editing/PlainTextRange.h"
49 #include "core/editing/RemoveCSSPropertyCommand.h" 49 #include "core/editing/RemoveCSSPropertyCommand.h"
50 #include "core/editing/RemoveNodeCommand.h" 50 #include "core/editing/RemoveNodeCommand.h"
51 #include "core/editing/RemoveNodePreservingChildrenCommand.h" 51 #include "core/editing/RemoveNodePreservingChildrenCommand.h"
52 #include "core/editing/ReplaceNodeWithSpanCommand.h" 52 #include "core/editing/ReplaceNodeWithSpanCommand.h"
53 #include "core/editing/ReplaceSelectionCommand.h" 53 #include "core/editing/ReplaceSelectionCommand.h"
54 #include "core/editing/SetNodeAttributeCommand.h" 54 #include "core/editing/SetNodeAttributeCommand.h"
55 #include "core/editing/SpellChecker.h" 55 #include "core/editing/SpellChecker.h"
56 #include "core/editing/SplitElementCommand.h" 56 #include "core/editing/SplitElementCommand.h"
57 #include "core/editing/SplitTextNodeCommand.h" 57 #include "core/editing/SplitTextNodeCommand.h"
58 #include "core/editing/SplitTextNodeContainingElementCommand.h" 58 #include "core/editing/SplitTextNodeContainingElementCommand.h"
59 #include "core/editing/TextIterator.h" 59 #include "core/editing/TextIterator.h"
60 #include "core/editing/VisibleUnits.h" 60 #include "core/editing/VisibleUnits.h"
61 #include "core/editing/WrapContentsInDummySpanCommand.h" 61 #include "core/editing/WrapContentsInDummySpanCommand.h"
62 #include "core/editing/htmlediting.h" 62 #include "core/editing/htmlediting.h"
63 #include "core/editing/markup.h" 63 #include "core/editing/markup.h"
64 #include "core/events/ScopedEventQueue.h"
64 #include "core/html/HTMLElement.h" 65 #include "core/html/HTMLElement.h"
65 #include "core/frame/Frame.h" 66 #include "core/frame/Frame.h"
66 #include "core/rendering/InlineTextBox.h" 67 #include "core/rendering/InlineTextBox.h"
67 #include "core/rendering/RenderBlock.h" 68 #include "core/rendering/RenderBlock.h"
68 #include "core/rendering/RenderText.h" 69 #include "core/rendering/RenderText.h"
69 70
70 using namespace std; 71 using namespace std;
71 72
72 namespace WebCore { 73 namespace WebCore {
73 74
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 newBlock = createListItemElement(document()); 1277 newBlock = createListItemElement(document());
1277 } 1278 }
1278 // If listNode does NOT appear at the end of the outer list item, th en behave as if in a regular paragraph. 1279 // If listNode does NOT appear at the end of the outer list item, th en behave as if in a regular paragraph.
1279 } else if (blockEnclosingList->hasTagName(olTag) || blockEnclosingList-> hasTagName(ulTag)) { 1280 } else if (blockEnclosingList->hasTagName(olTag) || blockEnclosingList-> hasTagName(ulTag)) {
1280 newBlock = createListItemElement(document()); 1281 newBlock = createListItemElement(document());
1281 } 1282 }
1282 } 1283 }
1283 if (!newBlock) 1284 if (!newBlock)
1284 newBlock = createDefaultParagraphElement(document()); 1285 newBlock = createDefaultParagraphElement(document());
1285 1286
1286 RefPtr<Node> previousListNode = emptyListItem->isElementNode() ? toElement(e mptyListItem)->previousElementSibling(): emptyListItem->previousSibling(); 1287 RefPtr<Node> previousListNode = emptyListItem->isElementNode() ? ElementTrav ersal::previousSibling(*emptyListItem): emptyListItem->previousSibling();
1287 RefPtr<Node> nextListNode = emptyListItem->isElementNode() ? toElement(empty ListItem)->nextElementSibling(): emptyListItem->nextSibling(); 1288 RefPtr<Node> nextListNode = emptyListItem->isElementNode() ? ElementTraversa l::nextSibling(*emptyListItem): emptyListItem->nextSibling();
1288 if (isListItem(nextListNode.get()) || isListElement(nextListNode.get())) { 1289 if (isListItem(nextListNode.get()) || isListElement(nextListNode.get())) {
1289 // If emptyListItem follows another list item or nested list, split the list node. 1290 // If emptyListItem follows another list item or nested list, split the list node.
1290 if (isListItem(previousListNode.get()) || isListElement(previousListNode .get())) 1291 if (isListItem(previousListNode.get()) || isListElement(previousListNode .get()))
1291 splitElement(toElement(listNode), emptyListItem); 1292 splitElement(toElement(listNode), emptyListItem);
1292 1293
1293 // If emptyListItem is followed by other list item or nested list, then insert newBlock before the list node. 1294 // If emptyListItem is followed by other list item or nested list, then insert newBlock before the list node.
1294 // Because we have splitted the element, emptyListItem is the first elem ent in the list node. 1295 // Because we have splitted the element, emptyListItem is the first elem ent in the list node.
1295 // i.e. insert newBlock before ul or ol whose first element is emptyList Item 1296 // i.e. insert newBlock before ul or ol whose first element is emptyList Item
1296 insertNodeBefore(newBlock, listNode); 1297 insertNodeBefore(newBlock, listNode);
1297 removeNode(emptyListItem); 1298 removeNode(emptyListItem);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 return node.release(); 1454 return node.release();
1454 } 1455 }
1455 1456
1456 PassRefPtr<Element> createBlockPlaceholderElement(Document& document) 1457 PassRefPtr<Element> createBlockPlaceholderElement(Document& document)
1457 { 1458 {
1458 RefPtr<Element> breakNode = document.createElement(brTag, false); 1459 RefPtr<Element> breakNode = document.createElement(brTag, false);
1459 return breakNode.release(); 1460 return breakNode.release();
1460 } 1461 }
1461 1462
1462 } // namespace WebCore 1463 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/editing/IndentOutdentCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698