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

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

Issue 1245843003: [CodeHealth] Use Position::anchorNode instead of deprecatedNode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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/editing/FrameSelection.cpp ('k') | Source/core/editing/InputMethodController.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) 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 IndentOutdentCommand::IndentOutdentCommand(Document& document, EIndentType typeO fAction) 51 IndentOutdentCommand::IndentOutdentCommand(Document& document, EIndentType typeO fAction)
52 : ApplyBlockElementCommand(document, blockquoteTag, "margin: 0 0 0 40px; bor der: none; padding: 0px;") 52 : ApplyBlockElementCommand(document, blockquoteTag, "margin: 0 0 0 40px; bor der: none; padding: 0px;")
53 , m_typeOfAction(typeOfAction) 53 , m_typeOfAction(typeOfAction)
54 { 54 {
55 } 55 }
56 56
57 bool IndentOutdentCommand::tryIndentingAsListItem(const Position& start, const P osition& end) 57 bool IndentOutdentCommand::tryIndentingAsListItem(const Position& start, const P osition& end)
58 { 58 {
59 // If our selection is not inside a list, bail out. 59 // If our selection is not inside a list, bail out.
60 RefPtrWillBeRawPtr<Node> lastNodeInSelectedParagraph = start.deprecatedNode( ); 60 RefPtrWillBeRawPtr<Node> lastNodeInSelectedParagraph = start.anchorNode();
61 RefPtrWillBeRawPtr<HTMLElement> listElement = enclosingList(lastNodeInSelect edParagraph.get()); 61 RefPtrWillBeRawPtr<HTMLElement> listElement = enclosingList(lastNodeInSelect edParagraph.get());
62 if (!listElement) 62 if (!listElement)
63 return false; 63 return false;
64 64
65 // Find the block that we want to indent. If it's not a list item (e.g., a div inside a list item), we bail out. 65 // Find the block that we want to indent. If it's not a list item (e.g., a div inside a list item), we bail out.
66 RefPtrWillBeRawPtr<Element> selectedListItem = enclosingBlock(lastNodeInSele ctedParagraph.get()); 66 RefPtrWillBeRawPtr<Element> selectedListItem = enclosingBlock(lastNodeInSele ctedParagraph.get());
67 67
68 // FIXME: we need to deal with the case where there is no li (malformed HTML ) 68 // FIXME: we need to deal with the case where there is no li (malformed HTML )
69 if (!isHTMLLIElement(selectedListItem)) 69 if (!isHTMLLIElement(selectedListItem))
70 return false; 70 return false;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 visibleStartOfParagraph = VisiblePosition(visibleStartOfParagraph.deepEq uivalent()); 177 visibleStartOfParagraph = VisiblePosition(visibleStartOfParagraph.deepEq uivalent());
178 visibleEndOfParagraph = VisiblePosition(visibleEndOfParagraph.deepEquiva lent()); 178 visibleEndOfParagraph = VisiblePosition(visibleEndOfParagraph.deepEquiva lent());
179 if (visibleStartOfParagraph.isNotNull() && !isStartOfParagraph(visibleSt artOfParagraph)) 179 if (visibleStartOfParagraph.isNotNull() && !isStartOfParagraph(visibleSt artOfParagraph))
180 insertNodeAt(createBreakElement(document()), visibleStartOfParagraph .deepEquivalent()); 180 insertNodeAt(createBreakElement(document()), visibleStartOfParagraph .deepEquivalent());
181 if (visibleEndOfParagraph.isNotNull() && !isEndOfParagraph(visibleEndOfP aragraph)) 181 if (visibleEndOfParagraph.isNotNull() && !isEndOfParagraph(visibleEndOfP aragraph))
182 insertNodeAt(createBreakElement(document()), visibleEndOfParagraph.d eepEquivalent()); 182 insertNodeAt(createBreakElement(document()), visibleEndOfParagraph.d eepEquivalent());
183 183
184 return; 184 return;
185 } 185 }
186 RefPtrWillBeRawPtr<Node> splitBlockquoteNode = enclosingElement; 186 RefPtrWillBeRawPtr<Node> splitBlockquoteNode = enclosingElement;
187 if (Element* enclosingBlockFlow = enclosingBlock(visibleStartOfParagraph.dee pEquivalent().deprecatedNode())) { 187 if (Element* enclosingBlockFlow = enclosingBlock(visibleStartOfParagraph.dee pEquivalent().anchorNode())) {
188 if (enclosingBlockFlow != enclosingElement) { 188 if (enclosingBlockFlow != enclosingElement) {
189 splitBlockquoteNode = splitTreeToNode(enclosingBlockFlow, enclosingE lement, true); 189 splitBlockquoteNode = splitTreeToNode(enclosingBlockFlow, enclosingE lement, true);
190 } else { 190 } else {
191 // We split the blockquote at where we start outdenting. 191 // We split the blockquote at where we start outdenting.
192 Node* highestInlineNode = highestEnclosingNodeOfType(visibleStartOfP aragraph.deepEquivalent(), isInline, CannotCrossEditingBoundary, enclosingBlockF low); 192 Node* highestInlineNode = highestEnclosingNodeOfType(visibleStartOfP aragraph.deepEquivalent(), isInline, CannotCrossEditingBoundary, enclosingBlockF low);
193 splitElement(enclosingElement, highestInlineNode ? highestInlineNode : visibleStartOfParagraph.deepEquivalent().deprecatedNode()); 193 splitElement(enclosingElement, highestInlineNode ? highestInlineNode : visibleStartOfParagraph.deepEquivalent().anchorNode());
194 } 194 }
195 } 195 }
196 VisiblePosition startOfParagraphToMove(startOfParagraph(visibleStartOfParagr aph)); 196 VisiblePosition startOfParagraphToMove(startOfParagraph(visibleStartOfParagr aph));
197 VisiblePosition endOfParagraphToMove(endOfParagraph(visibleEndOfParagraph)); 197 VisiblePosition endOfParagraphToMove(endOfParagraph(visibleEndOfParagraph));
198 if (startOfParagraphToMove.isNull() || endOfParagraphToMove.isNull()) 198 if (startOfParagraphToMove.isNull() || endOfParagraphToMove.isNull())
199 return; 199 return;
200 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document( )); 200 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document( ));
201 insertNodeBefore(placeholder, splitBlockquoteNode); 201 insertNodeBefore(placeholder, splitBlockquoteNode);
202 moveParagraph(startOfParagraphToMove, endOfParagraphToMove, VisiblePosition( positionBeforeNode(placeholder.get())), true); 202 moveParagraph(startOfParagraphToMove, endOfParagraphToMove, VisiblePosition( positionBeforeNode(placeholder.get())), true);
203 } 203 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 void IndentOutdentCommand::formatRange(const Position& start, const Position& en d, const Position&, RefPtrWillBeRawPtr<HTMLElement>& blockquoteForNextIndent) 250 void IndentOutdentCommand::formatRange(const Position& start, const Position& en d, const Position&, RefPtrWillBeRawPtr<HTMLElement>& blockquoteForNextIndent)
251 { 251 {
252 if (tryIndentingAsListItem(start, end)) 252 if (tryIndentingAsListItem(start, end))
253 blockquoteForNextIndent = nullptr; 253 blockquoteForNextIndent = nullptr;
254 else 254 else
255 indentIntoBlockquote(start, end, blockquoteForNextIndent); 255 indentIntoBlockquote(start, end, blockquoteForNextIndent);
256 } 256 }
257 257
258 } 258 }
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | Source/core/editing/InputMethodController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698