| OLD | NEW |
| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 | 152 |
| 153 VisiblePosition endOfContents = createVisiblePositionDeprecated(end); | 153 VisiblePosition endOfContents = createVisiblePositionDeprecated(end); |
| 154 if (startOfContents.isNull() || endOfContents.isNull()) | 154 if (startOfContents.isNull() || endOfContents.isNull()) |
| 155 return; | 155 return; |
| 156 moveParagraphWithClones(startOfContents, endOfContents, targetBlockquote, ou
terBlock, editingState); | 156 moveParagraphWithClones(startOfContents, endOfContents, targetBlockquote, ou
terBlock, editingState); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void IndentOutdentCommand::outdentParagraph(EditingState* editingState) | 159 void IndentOutdentCommand::outdentParagraph(EditingState* editingState) |
| 160 { | 160 { |
| 161 VisiblePosition visibleStartOfParagraph = startOfParagraph(endingSelection()
.visibleStart()); | 161 VisiblePosition visibleStartOfParagraph = startOfParagraphDeprecated(endingS
election().visibleStart()); |
| 162 VisiblePosition visibleEndOfParagraph = endOfParagraph(visibleStartOfParagra
ph); | 162 VisiblePosition visibleEndOfParagraph = endOfParagraphDeprecated(visibleStar
tOfParagraph); |
| 163 | 163 |
| 164 HTMLElement* enclosingElement = toHTMLElement(enclosingNodeOfType(visibleSta
rtOfParagraph.deepEquivalent(), &isHTMLListOrBlockquoteElement)); | 164 HTMLElement* enclosingElement = toHTMLElement(enclosingNodeOfType(visibleSta
rtOfParagraph.deepEquivalent(), &isHTMLListOrBlockquoteElement)); |
| 165 if (!enclosingElement || !hasEditableStyle(*enclosingElement->parentNode()))
// We can't outdent if there is no place to go! | 165 if (!enclosingElement || !hasEditableStyle(*enclosingElement->parentNode()))
// We can't outdent if there is no place to go! |
| 166 return; | 166 return; |
| 167 | 167 |
| 168 // Use InsertListCommand to remove the selection from the list | 168 // Use InsertListCommand to remove the selection from the list |
| 169 if (isHTMLOListElement(*enclosingElement)) { | 169 if (isHTMLOListElement(*enclosingElement)) { |
| 170 applyCommandToComposite(InsertListCommand::create(document(), InsertList
Command::OrderedList), editingState); | 170 applyCommandToComposite(InsertListCommand::create(document(), InsertList
Command::OrderedList), editingState); |
| 171 return; | 171 return; |
| 172 } | 172 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 196 if (splitPointParent->hasTagName(blockquoteTag) | 196 if (splitPointParent->hasTagName(blockquoteTag) |
| 197 && !splitPoint->hasTagName(blockquoteTag) | 197 && !splitPoint->hasTagName(blockquoteTag) |
| 198 && hasEditableStyle(*splitPointParent->parentNode())) // We
can't outdent if there is no place to go! | 198 && hasEditableStyle(*splitPointParent->parentNode())) // We
can't outdent if there is no place to go! |
| 199 splitElement(splitPointParent, splitPoint); | 199 splitElement(splitPointParent, splitPoint); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 203 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 204 visibleStartOfParagraph = createVisiblePositionDeprecated(visibleStartOf
Paragraph.deepEquivalent()); | 204 visibleStartOfParagraph = createVisiblePositionDeprecated(visibleStartOf
Paragraph.deepEquivalent()); |
| 205 visibleEndOfParagraph = createVisiblePositionDeprecated(visibleEndOfPara
graph.deepEquivalent()); | 205 visibleEndOfParagraph = createVisiblePositionDeprecated(visibleEndOfPara
graph.deepEquivalent()); |
| 206 if (visibleStartOfParagraph.isNotNull() && !isStartOfParagraph(visibleSt
artOfParagraph)) { | 206 if (visibleStartOfParagraph.isNotNull() && !isStartOfParagraphDeprecated
(visibleStartOfParagraph)) { |
| 207 insertNodeAt(HTMLBRElement::create(document()), visibleStartOfParagr
aph.deepEquivalent(), editingState); | 207 insertNodeAt(HTMLBRElement::create(document()), visibleStartOfParagr
aph.deepEquivalent(), editingState); |
| 208 if (editingState->isAborted()) | 208 if (editingState->isAborted()) |
| 209 return; | 209 return; |
| 210 } | 210 } |
| 211 if (visibleEndOfParagraph.isNotNull() && !isEndOfParagraph(visibleEndOfP
aragraph)) | 211 if (visibleEndOfParagraph.isNotNull() && !isEndOfParagraphDeprecated(vis
ibleEndOfParagraph)) |
| 212 insertNodeAt(HTMLBRElement::create(document()), visibleEndOfParagrap
h.deepEquivalent(), editingState); | 212 insertNodeAt(HTMLBRElement::create(document()), visibleEndOfParagrap
h.deepEquivalent(), editingState); |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 Node* splitBlockquoteNode = enclosingElement; | 215 Node* splitBlockquoteNode = enclosingElement; |
| 216 if (Element* enclosingBlockFlow = enclosingBlock(visibleStartOfParagraph.dee
pEquivalent().anchorNode())) { | 216 if (Element* enclosingBlockFlow = enclosingBlock(visibleStartOfParagraph.dee
pEquivalent().anchorNode())) { |
| 217 if (enclosingBlockFlow != enclosingElement) { | 217 if (enclosingBlockFlow != enclosingElement) { |
| 218 splitBlockquoteNode = splitTreeToNode(enclosingBlockFlow, enclosingE
lement, true); | 218 splitBlockquoteNode = splitTreeToNode(enclosingBlockFlow, enclosingE
lement, true); |
| 219 } else { | 219 } else { |
| 220 // We split the blockquote at where we start outdenting. | 220 // We split the blockquote at where we start outdenting. |
| 221 Node* highestInlineNode = highestEnclosingNodeOfType(visibleStartOfP
aragraph.deepEquivalent(), isInline, CannotCrossEditingBoundary, enclosingBlockF
low); | 221 Node* highestInlineNode = highestEnclosingNodeOfType(visibleStartOfP
aragraph.deepEquivalent(), isInline, CannotCrossEditingBoundary, enclosingBlockF
low); |
| 222 splitElement(enclosingElement, highestInlineNode ? highestInlineNode
: visibleStartOfParagraph.deepEquivalent().anchorNode()); | 222 splitElement(enclosingElement, highestInlineNode ? highestInlineNode
: visibleStartOfParagraph.deepEquivalent().anchorNode()); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 VisiblePosition startOfParagraphToMove = startOfParagraph(visibleStartOfPara
graph); | 225 VisiblePosition startOfParagraphToMove = startOfParagraphDeprecated(visibleS
tartOfParagraph); |
| 226 VisiblePosition endOfParagraphToMove = endOfParagraph(visibleEndOfParagraph)
; | 226 VisiblePosition endOfParagraphToMove = endOfParagraphDeprecated(visibleEndOf
Paragraph); |
| 227 if (startOfParagraphToMove.isNull() || endOfParagraphToMove.isNull()) | 227 if (startOfParagraphToMove.isNull() || endOfParagraphToMove.isNull()) |
| 228 return; | 228 return; |
| 229 HTMLBRElement* placeholder = HTMLBRElement::create(document()); | 229 HTMLBRElement* placeholder = HTMLBRElement::create(document()); |
| 230 insertNodeBefore(placeholder, splitBlockquoteNode, editingState); | 230 insertNodeBefore(placeholder, splitBlockquoteNode, editingState); |
| 231 if (editingState->isAborted()) | 231 if (editingState->isAborted()) |
| 232 return; | 232 return; |
| 233 moveParagraph(startOfParagraphToMove, endOfParagraphToMove, VisiblePosition:
:beforeNode(placeholder), editingState, PreserveSelection); | 233 moveParagraph(startOfParagraphToMove, endOfParagraphToMove, VisiblePosition:
:beforeNode(placeholder), editingState, PreserveSelection); |
| 234 } | 234 } |
| 235 | 235 |
| 236 // FIXME: We should merge this function with ApplyBlockElementCommand::formatSel
ection | 236 // FIXME: We should merge this function with ApplyBlockElementCommand::formatSel
ection |
| 237 void IndentOutdentCommand::outdentRegion(const VisiblePosition& startOfSelection
, const VisiblePosition& endOfSelection, EditingState* editingState) | 237 void IndentOutdentCommand::outdentRegion(const VisiblePosition& startOfSelection
, const VisiblePosition& endOfSelection, EditingState* editingState) |
| 238 { | 238 { |
| 239 VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection); | 239 VisiblePosition endOfCurrentParagraph = endOfParagraphDeprecated(startOfSele
ction); |
| 240 VisiblePosition endOfLastParagraph = endOfParagraph(endOfSelection); | 240 VisiblePosition endOfLastParagraph = endOfParagraphDeprecated(endOfSelection
); |
| 241 | 241 |
| 242 if (endOfCurrentParagraph.deepEquivalent() == endOfLastParagraph.deepEquival
ent()) { | 242 if (endOfCurrentParagraph.deepEquivalent() == endOfLastParagraph.deepEquival
ent()) { |
| 243 outdentParagraph(editingState); | 243 outdentParagraph(editingState); |
| 244 return; | 244 return; |
| 245 } | 245 } |
| 246 | 246 |
| 247 Position originalSelectionEnd = endingSelection().end(); | 247 Position originalSelectionEnd = endingSelection().end(); |
| 248 VisiblePosition endAfterSelection = endOfParagraph(nextPositionOf(endOfLastP
aragraph)); | 248 VisiblePosition endAfterSelection = endOfParagraphDeprecated(nextPositionOf(
endOfLastParagraph)); |
| 249 | 249 |
| 250 while (endOfCurrentParagraph.deepEquivalent() != endAfterSelection.deepEquiv
alent()) { | 250 while (endOfCurrentParagraph.deepEquivalent() != endAfterSelection.deepEquiv
alent()) { |
| 251 VisiblePosition endOfNextParagraph = endOfParagraph(nextPositionOf(endOf
CurrentParagraph)); | 251 VisiblePosition endOfNextParagraph = endOfParagraphDeprecated(nextPositi
onOf(endOfCurrentParagraph)); |
| 252 if (endOfCurrentParagraph.deepEquivalent() == endOfLastParagraph.deepEqu
ivalent()) | 252 if (endOfCurrentParagraph.deepEquivalent() == endOfLastParagraph.deepEqu
ivalent()) |
| 253 setEndingSelection(VisibleSelection(originalSelectionEnd, TextAffini
ty::Downstream)); | 253 setEndingSelection(VisibleSelection(originalSelectionEnd, TextAffini
ty::Downstream)); |
| 254 else | 254 else |
| 255 setEndingSelection(endOfCurrentParagraph); | 255 setEndingSelection(endOfCurrentParagraph); |
| 256 | 256 |
| 257 outdentParagraph(editingState); | 257 outdentParagraph(editingState); |
| 258 if (editingState->isAborted()) | 258 if (editingState->isAborted()) |
| 259 return; | 259 return; |
| 260 | 260 |
| 261 // outdentParagraph could move more than one paragraph if the paragraph | 261 // outdentParagraph could move more than one paragraph if the paragraph |
| 262 // is in a list item. As a result, endAfterSelection and endOfNextParagr
aph | 262 // is in a list item. As a result, endAfterSelection and endOfNextParagr
aph |
| 263 // could refer to positions no longer in the document. | 263 // could refer to positions no longer in the document. |
| 264 if (endAfterSelection.isNotNull() && !endAfterSelection.deepEquivalent()
.isConnected()) | 264 if (endAfterSelection.isNotNull() && !endAfterSelection.deepEquivalent()
.isConnected()) |
| 265 break; | 265 break; |
| 266 | 266 |
| 267 if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent
().isConnected()) { | 267 if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent
().isConnected()) { |
| 268 endOfCurrentParagraph = createVisiblePositionDeprecated(endingSelect
ion().end()); | 268 endOfCurrentParagraph = createVisiblePositionDeprecated(endingSelect
ion().end()); |
| 269 endOfNextParagraph = endOfParagraph(nextPositionOf(endOfCurrentParag
raph)); | 269 endOfNextParagraph = endOfParagraphDeprecated(nextPositionOf(endOfCu
rrentParagraph)); |
| 270 } | 270 } |
| 271 endOfCurrentParagraph = endOfNextParagraph; | 271 endOfCurrentParagraph = endOfNextParagraph; |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 void IndentOutdentCommand::formatSelection(const VisiblePosition& startOfSelecti
on, const VisiblePosition& endOfSelection, EditingState* editingState) | 275 void IndentOutdentCommand::formatSelection(const VisiblePosition& startOfSelecti
on, const VisiblePosition& endOfSelection, EditingState* editingState) |
| 276 { | 276 { |
| 277 if (m_typeOfAction == Indent) | 277 if (m_typeOfAction == Indent) |
| 278 ApplyBlockElementCommand::formatSelection(startOfSelection, endOfSelecti
on, editingState); | 278 ApplyBlockElementCommand::formatSelection(startOfSelection, endOfSelecti
on, editingState); |
| 279 else | 279 else |
| (...skipping 10 matching lines...) Expand all Loading... |
| 290 else | 290 else |
| 291 indentIntoBlockquote(start, end, blockquoteForNextIndent, editingState); | 291 indentIntoBlockquote(start, end, blockquoteForNextIndent, editingState); |
| 292 } | 292 } |
| 293 | 293 |
| 294 InputEvent::InputType IndentOutdentCommand::inputType() const | 294 InputEvent::InputType IndentOutdentCommand::inputType() const |
| 295 { | 295 { |
| 296 return m_typeOfAction == Indent ? InputEvent::InputType::Indent : InputEvent
::InputType::Outdent; | 296 return m_typeOfAction == Indent ? InputEvent::InputType::Indent : InputEvent
::InputType::Outdent; |
| 297 } | 297 } |
| 298 | 298 |
| 299 } // namespace blink | 299 } // namespace blink |
| OLD | NEW |