OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment
, options)); | 1227 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment
, options)); |
1228 | 1228 |
1229 document().frame()->spellChecker().markMisspellingsAndBadGrammar(endingSelec
tion()); | 1229 document().frame()->spellChecker().markMisspellingsAndBadGrammar(endingSelec
tion()); |
1230 | 1230 |
1231 // If the selection is in an empty paragraph, restore styles from the old em
pty paragraph to the new empty paragraph. | 1231 // If the selection is in an empty paragraph, restore styles from the old em
pty paragraph to the new empty paragraph. |
1232 bool selectionIsEmptyParagraph = endingSelection().isCaret() && isStartOfPar
agraph(endingSelection().visibleStart()) && isEndOfParagraph(endingSelection().v
isibleStart()); | 1232 bool selectionIsEmptyParagraph = endingSelection().isCaret() && isStartOfPar
agraph(endingSelection().visibleStart()) && isEndOfParagraph(endingSelection().v
isibleStart()); |
1233 if (styleInEmptyParagraph && selectionIsEmptyParagraph) | 1233 if (styleInEmptyParagraph && selectionIsEmptyParagraph) |
1234 applyStyle(styleInEmptyParagraph.get()); | 1234 applyStyle(styleInEmptyParagraph.get()); |
1235 | 1235 |
1236 if (preserveSelection && startIndex != -1) { | 1236 if (preserveSelection && startIndex != -1) { |
1237 // Fragment creation (using createMarkup) incorrectly uses regular | 1237 if (Element* documentElement = document().documentElement()) { |
1238 // spaces instead of nbsps for some spaces that were rendered (11475), w
hich | 1238 // Fragment creation (using createMarkup) incorrectly uses regular |
1239 // causes spaces to be collapsed during the move operation. This result
s | 1239 // spaces instead of nbsps for some spaces that were rendered (11475
), which |
1240 // in a call to rangeFromLocationAndLength with a location past the end | 1240 // causes spaces to be collapsed during the move operation. This res
ults |
1241 // of the document (which will return null). | 1241 // in a call to rangeFromLocationAndLength with a location past the
end |
1242 RefPtr<Range> start = PlainTextRange(destinationIndex + startIndex).crea
teRangeForSelection(*document().documentElement()); | 1242 // of the document (which will return null). |
1243 RefPtr<Range> end = PlainTextRange(destinationIndex + endIndex).createRa
ngeForSelection(*document().documentElement()); | 1243 RefPtr<Range> start = PlainTextRange(destinationIndex + startIndex).
createRangeForSelection(*documentElement); |
1244 if (start && end) | 1244 RefPtr<Range> end = PlainTextRange(destinationIndex + endIndex).crea
teRangeForSelection(*documentElement); |
1245 setEndingSelection(VisibleSelection(start->startPosition(), end->sta
rtPosition(), DOWNSTREAM, originalIsDirectional)); | 1245 if (start && end) |
| 1246 setEndingSelection(VisibleSelection(start->startPosition(), end-
>startPosition(), DOWNSTREAM, originalIsDirectional)); |
| 1247 } |
1246 } | 1248 } |
1247 } | 1249 } |
1248 | 1250 |
1249 // FIXME: Send an appropriate shouldDeleteRange call. | 1251 // FIXME: Send an appropriate shouldDeleteRange call. |
1250 bool CompositeEditCommand::breakOutOfEmptyListItem() | 1252 bool CompositeEditCommand::breakOutOfEmptyListItem() |
1251 { | 1253 { |
1252 RefPtr<Node> emptyListItem = enclosingEmptyListItem(endingSelection().visibl
eStart()); | 1254 RefPtr<Node> emptyListItem = enclosingEmptyListItem(endingSelection().visibl
eStart()); |
1253 if (!emptyListItem) | 1255 if (!emptyListItem) |
1254 return false; | 1256 return false; |
1255 | 1257 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 return node.release(); | 1456 return node.release(); |
1455 } | 1457 } |
1456 | 1458 |
1457 PassRefPtr<Element> createBlockPlaceholderElement(Document& document) | 1459 PassRefPtr<Element> createBlockPlaceholderElement(Document& document) |
1458 { | 1460 { |
1459 RefPtr<Element> breakNode = document.createElement(brTag, false); | 1461 RefPtr<Element> breakNode = document.createElement(brTag, false); |
1460 return breakNode.release(); | 1462 return breakNode.release(); |
1461 } | 1463 } |
1462 | 1464 |
1463 } // namespace WebCore | 1465 } // namespace WebCore |
OLD | NEW |