OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |