OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return; | 102 return; |
103 | 103 |
104 RefPtrWillBeRawPtr<HTMLBRElement> breakElement = createBreakElement(document
()); | 104 RefPtrWillBeRawPtr<HTMLBRElement> breakElement = createBreakElement(document
()); |
105 | 105 |
106 bool isLastVisPosInNode = isLastVisiblePositionInNode(visiblePos, topBlockqu
ote); | 106 bool isLastVisPosInNode = isLastVisiblePositionInNode(visiblePos, topBlockqu
ote); |
107 | 107 |
108 // If the position is at the beginning of the top quoted content, we don't n
eed to break the quote. | 108 // If the position is at the beginning of the top quoted content, we don't n
eed to break the quote. |
109 // Instead, insert the break before the blockquote, unless the position is a
s the end of the the quoted content. | 109 // Instead, insert the break before the blockquote, unless the position is a
s the end of the the quoted content. |
110 if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && !isLastVisPos
InNode) { | 110 if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && !isLastVisPos
InNode) { |
111 insertNodeBefore(breakElement.get(), topBlockquote); | 111 insertNodeBefore(breakElement.get(), topBlockquote); |
112 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get(
)), DOWNSTREAM, endingSelection().isDirectional())); | 112 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get(
)), TextAffinity::Downstream, endingSelection().isDirectional())); |
113 rebalanceWhitespace(); | 113 rebalanceWhitespace(); |
114 return; | 114 return; |
115 } | 115 } |
116 | 116 |
117 // Insert a break after the top blockquote. | 117 // Insert a break after the top blockquote. |
118 insertNodeAfter(breakElement.get(), topBlockquote); | 118 insertNodeAfter(breakElement.get(), topBlockquote); |
119 | 119 |
120 // If we're inserting the break at the end of the quoted content, we don't n
eed to break the quote. | 120 // If we're inserting the break at the end of the quoted content, we don't n
eed to break the quote. |
121 if (isLastVisPosInNode) { | 121 if (isLastVisPosInNode) { |
122 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get(
)), DOWNSTREAM, endingSelection().isDirectional())); | 122 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get(
)), TextAffinity::Downstream, endingSelection().isDirectional())); |
123 rebalanceWhitespace(); | 123 rebalanceWhitespace(); |
124 return; | 124 return; |
125 } | 125 } |
126 | 126 |
127 // Don't move a line break just after the caret. Doing so would create an e
xtra, empty paragraph | 127 // Don't move a line break just after the caret. Doing so would create an e
xtra, empty paragraph |
128 // in the new blockquote. | 128 // in the new blockquote. |
129 if (lineBreakExistsAtVisiblePosition(visiblePos)) | 129 if (lineBreakExistsAtVisiblePosition(visiblePos)) |
130 pos = pos.next(); | 130 pos = pos.next(); |
131 | 131 |
132 // Adjust the position so we don't split at the beginning of a quote. | 132 // Adjust the position so we don't split at the beginning of a quote. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // If the startNode's original parent is now empty, remove it | 207 // If the startNode's original parent is now empty, remove it |
208 Element* originalParent = ancestors.first().get(); | 208 Element* originalParent = ancestors.first().get(); |
209 if (!originalParent->hasChildren()) | 209 if (!originalParent->hasChildren()) |
210 removeNode(originalParent); | 210 removeNode(originalParent); |
211 } | 211 } |
212 | 212 |
213 // Make sure the cloned block quote renders. | 213 // Make sure the cloned block quote renders. |
214 addBlockPlaceholderIfNeeded(clonedBlockquote.get()); | 214 addBlockPlaceholderIfNeeded(clonedBlockquote.get()); |
215 | 215 |
216 // Put the selection right before the break. | 216 // Put the selection right before the break. |
217 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()),
DOWNSTREAM, endingSelection().isDirectional())); | 217 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()),
TextAffinity::Downstream, endingSelection().isDirectional())); |
218 rebalanceWhitespace(); | 218 rebalanceWhitespace(); |
219 } | 219 } |
220 | 220 |
221 } // namespace blink | 221 } // namespace blink |
OLD | NEW |