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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp

Issue 1679253002: Editing: Add EditingState* argument to EditCommand::doApply. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005, 2006 Apple Computer, 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Whether we should insert a break element or a '\n'. 56 // Whether we should insert a break element or a '\n'.
57 bool InsertLineBreakCommand::shouldUseBreakElement(const Position& insertionPos) 57 bool InsertLineBreakCommand::shouldUseBreakElement(const Position& insertionPos)
58 { 58 {
59 // An editing position like [input, 0] actually refers to the position befor e 59 // An editing position like [input, 0] actually refers to the position befor e
60 // the input element, and in that case we need to check the input element's 60 // the input element, and in that case we need to check the input element's
61 // parent's layoutObject. 61 // parent's layoutObject.
62 Position p(insertionPos.parentAnchoredEquivalent()); 62 Position p(insertionPos.parentAnchoredEquivalent());
63 return p.anchorNode()->layoutObject() && !p.anchorNode()->layoutObject()->st yle()->preserveNewline(); 63 return p.anchorNode()->layoutObject() && !p.anchorNode()->layoutObject()->st yle()->preserveNewline();
64 } 64 }
65 65
66 void InsertLineBreakCommand::doApply() 66 void InsertLineBreakCommand::doApply(EditingState*)
67 { 67 {
68 deleteSelection(); 68 deleteSelection();
69 VisibleSelection selection = endingSelection(); 69 VisibleSelection selection = endingSelection();
70 if (!selection.isNonOrphanedCaretOrRange()) 70 if (!selection.isNonOrphanedCaretOrRange())
71 return; 71 return;
72 72
73 VisiblePosition caret(selection.visibleStart()); 73 VisiblePosition caret(selection.visibleStart());
74 // FIXME: If the node is hidden, we should still be able to insert text. 74 // FIXME: If the node is hidden, we should still be able to insert text.
75 // For now, we return to avoid a crash. https://bugs.webkit.org/show_bug.cg i?id=40342 75 // For now, we return to avoid a crash. https://bugs.webkit.org/show_bug.cg i?id=40342
76 if (caret.isNull()) 76 if (caret.isNull())
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // before the line break (if the line break is at the end of a block it isn't selectable). 158 // before the line break (if the line break is at the end of a block it isn't selectable).
159 // So, this next call sets the endingSelection() to a caret just after t he line break 159 // So, this next call sets the endingSelection() to a caret just after t he line break
160 // that we inserted, or just before it if it's at the end of a block. 160 // that we inserted, or just before it if it's at the end of a block.
161 setEndingSelection(endingSelection().visibleEnd()); 161 setEndingSelection(endingSelection().visibleEnd());
162 } 162 }
163 163
164 rebalanceWhitespace(); 164 rebalanceWhitespace();
165 } 165 }
166 166
167 } // namespace blink 167 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698