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

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

Issue 20681004: Make first-letter style to work with editing Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-08-08T13:29:08 Created 7 years, 4 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 | Annotate | Revision Log
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 insertNodeBefore(node, pos.deprecatedNode()); 77 insertNodeBefore(node, pos.deprecatedNode());
78 } 78 }
79 79
80 // Whether we should insert a break element or a '\n'. 80 // Whether we should insert a break element or a '\n'.
81 bool InsertLineBreakCommand::shouldUseBreakElement(const Position& insertionPos) 81 bool InsertLineBreakCommand::shouldUseBreakElement(const Position& insertionPos)
82 { 82 {
83 // An editing position like [input, 0] actually refers to the position befor e 83 // An editing position like [input, 0] actually refers to the position befor e
84 // the input element, and in that case we need to check the input element's 84 // the input element, and in that case we need to check the input element's
85 // parent's renderer. 85 // parent's renderer.
86 Position p(insertionPos.parentAnchoredEquivalent()); 86 Position p(insertionPos.parentAnchoredEquivalent());
87 return p.deprecatedNode()->renderer() && !p.deprecatedNode()->renderer()->st yle()->preserveNewline(); 87 return p.renderer() && !p.renderer()->style()->preserveNewline();
88 } 88 }
89 89
90 void InsertLineBreakCommand::doApply() 90 void InsertLineBreakCommand::doApply()
91 { 91 {
92 deleteSelection(); 92 deleteSelection();
93 VisibleSelection selection = endingSelection(); 93 VisibleSelection selection = endingSelection();
94 if (!selection.isNonOrphanedCaretOrRange()) 94 if (!selection.isNonOrphanedCaretOrRange())
95 return; 95 return;
96 96
97 VisiblePosition caret(selection.visibleStart()); 97 VisiblePosition caret(selection.visibleStart());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // before the line break (if the line break is at the end of a block it isn't selectable). 180 // before the line break (if the line break is at the end of a block it isn't selectable).
181 // So, this next call sets the endingSelection() to a caret just after t he line break 181 // So, this next call sets the endingSelection() to a caret just after t he line break
182 // that we inserted, or just before it if it's at the end of a block. 182 // that we inserted, or just before it if it's at the end of a block.
183 setEndingSelection(endingSelection().visibleEnd()); 183 setEndingSelection(endingSelection().visibleEnd());
184 } 184 }
185 185
186 rebalanceWhitespace(); 186 rebalanceWhitespace();
187 } 187 }
188 188
189 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698