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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // CSS selector. | 84 // CSS selector. |
85 HTMLElement* newList = toHTMLElement(document().createElement(listElement->t
agQName(), CreatedByCloneNode)); | 85 HTMLElement* newList = toHTMLElement(document().createElement(listElement->t
agQName(), CreatedByCloneNode)); |
86 insertNodeBefore(newList, selectedListItem, editingState); | 86 insertNodeBefore(newList, selectedListItem, editingState); |
87 if (editingState->isAborted()) | 87 if (editingState->isAborted()) |
88 return false; | 88 return false; |
89 | 89 |
90 // We should clone all the children of the list item for indenting purposes.
However, in case the current | 90 // We should clone all the children of the list item for indenting purposes.
However, in case the current |
91 // selection does not encompass all its children, we need to explicitally ha
ndle the same. The original | 91 // selection does not encompass all its children, we need to explicitally ha
ndle the same. The original |
92 // list item too would require proper deletion in that case. | 92 // list item too would require proper deletion in that case. |
93 if (end.anchorNode() == selectedListItem || end.anchorNode()->isDescendantOf
(selectedListItem->lastChild())) { | 93 if (end.anchorNode() == selectedListItem || end.anchorNode()->isDescendantOf
(selectedListItem->lastChild())) { |
94 moveParagraphWithClones(createVisiblePosition(start), createVisiblePosit
ion(end), newList, selectedListItem, editingState); | 94 moveParagraphWithClones(createVisiblePositionDeprecated(start), createVi
siblePositionDeprecated(end), newList, selectedListItem, editingState); |
95 } else { | 95 } else { |
96 moveParagraphWithClones(createVisiblePosition(start), VisiblePosition::a
fterNode(selectedListItem->lastChild()), newList, selectedListItem, editingState
); | 96 moveParagraphWithClones(createVisiblePositionDeprecated(start), VisibleP
osition::afterNode(selectedListItem->lastChild()), newList, selectedListItem, ed
itingState); |
97 if (editingState->isAborted()) | 97 if (editingState->isAborted()) |
98 return false; | 98 return false; |
99 removeNode(selectedListItem, editingState); | 99 removeNode(selectedListItem, editingState); |
100 } | 100 } |
101 if (editingState->isAborted()) | 101 if (editingState->isAborted()) |
102 return false; | 102 return false; |
103 | 103 |
104 if (canMergeLists(previousList, newList)) { | 104 if (canMergeLists(previousList, newList)) { |
105 mergeIdenticalElements(previousList, newList, editingState); | 105 mergeIdenticalElements(previousList, newList, editingState); |
106 if (editingState->isAborted()) | 106 if (editingState->isAborted()) |
(...skipping 17 matching lines...) Expand all Loading... |
124 else if (enclosingList(start.computeContainerNode())) | 124 else if (enclosingList(start.computeContainerNode())) |
125 elementToSplitTo = enclosingBlock(start.computeContainerNode()); | 125 elementToSplitTo = enclosingBlock(start.computeContainerNode()); |
126 else | 126 else |
127 elementToSplitTo = rootEditableElementOf(start); | 127 elementToSplitTo = rootEditableElementOf(start); |
128 | 128 |
129 if (!elementToSplitTo) | 129 if (!elementToSplitTo) |
130 return; | 130 return; |
131 | 131 |
132 Node* outerBlock = (start.computeContainerNode() == elementToSplitTo) ? star
t.computeContainerNode() : splitTreeToNode(start.computeContainerNode(), element
ToSplitTo); | 132 Node* outerBlock = (start.computeContainerNode() == elementToSplitTo) ? star
t.computeContainerNode() : splitTreeToNode(start.computeContainerNode(), element
ToSplitTo); |
133 | 133 |
134 VisiblePosition startOfContents = createVisiblePosition(start); | 134 VisiblePosition startOfContents = createVisiblePositionDeprecated(start); |
135 if (!targetBlockquote) { | 135 if (!targetBlockquote) { |
136 // Create a new blockquote and insert it as a child of the root editable
element. We accomplish | 136 // Create a new blockquote and insert it as a child of the root editable
element. We accomplish |
137 // this by splitting all parents of the current paragraph up to that poi
nt. | 137 // this by splitting all parents of the current paragraph up to that poi
nt. |
138 targetBlockquote = createBlockElement(); | 138 targetBlockquote = createBlockElement(); |
139 if (outerBlock == start.computeContainerNode()) { | 139 if (outerBlock == start.computeContainerNode()) { |
140 // When we apply indent to an empty <blockquote>, we should call ins
ertNodeAfter(). | 140 // When we apply indent to an empty <blockquote>, we should call ins
ertNodeAfter(). |
141 // See http://crbug.com/625802 for more details. | 141 // See http://crbug.com/625802 for more details. |
142 if (outerBlock->hasTagName(blockquoteTag)) | 142 if (outerBlock->hasTagName(blockquoteTag)) |
143 insertNodeAfter(targetBlockquote, outerBlock, editingState); | 143 insertNodeAfter(targetBlockquote, outerBlock, editingState); |
144 else | 144 else |
145 insertNodeAt(targetBlockquote, start, editingState); | 145 insertNodeAt(targetBlockquote, start, editingState); |
146 } else | 146 } else |
147 insertNodeBefore(targetBlockquote, outerBlock, editingState); | 147 insertNodeBefore(targetBlockquote, outerBlock, editingState); |
148 if (editingState->isAborted()) | 148 if (editingState->isAborted()) |
149 return; | 149 return; |
150 startOfContents = VisiblePosition::inParentAfterNode(*targetBlockquote); | 150 startOfContents = VisiblePosition::inParentAfterNode(*targetBlockquote); |
151 } | 151 } |
152 | 152 |
153 VisiblePosition endOfContents = createVisiblePosition(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 = startOfParagraph(endingSelection()
.visibleStart()); |
162 VisiblePosition visibleEndOfParagraph = endOfParagraph(visibleStartOfParagra
ph); | 162 VisiblePosition visibleEndOfParagraph = endOfParagraph(visibleStartOfParagra
ph); |
163 | 163 |
(...skipping 30 matching lines...) Expand all Loading... |
194 if (splitPoint) { | 194 if (splitPoint) { |
195 if (Element* splitPointParent = splitPoint->parentElement()) { | 195 if (Element* splitPointParent = splitPoint->parentElement()) { |
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 = createVisiblePosition(visibleStartOfParagraph.
deepEquivalent()); | 204 visibleStartOfParagraph = createVisiblePositionDeprecated(visibleStartOf
Paragraph.deepEquivalent()); |
205 visibleEndOfParagraph = createVisiblePosition(visibleEndOfParagraph.deep
Equivalent()); | 205 visibleEndOfParagraph = createVisiblePositionDeprecated(visibleEndOfPara
graph.deepEquivalent()); |
206 if (visibleStartOfParagraph.isNotNull() && !isStartOfParagraph(visibleSt
artOfParagraph)) { | 206 if (visibleStartOfParagraph.isNotNull() && !isStartOfParagraph(visibleSt
artOfParagraph)) { |
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() && !isEndOfParagraph(visibleEndOfP
aragraph)) |
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; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = createVisiblePosition(endingSelection().end(
)); | 268 endOfCurrentParagraph = createVisiblePositionDeprecated(endingSelect
ion().end()); |
269 endOfNextParagraph = endOfParagraph(nextPositionOf(endOfCurrentParag
raph)); | 269 endOfNextParagraph = endOfParagraph(nextPositionOf(endOfCurrentParag
raph)); |
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); |
(...skipping 11 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 |