| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2009 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 VisiblePosition visibleStart(start); | 247 VisiblePosition visibleStart(start); |
| 248 VisiblePosition visibleEnd(end); | 248 VisiblePosition visibleEnd(end); |
| 249 | 249 |
| 250 if (visibleStart.isNull() || visibleStart.isOrphan() || visibleEnd.isNull()
|| visibleEnd.isOrphan()) | 250 if (visibleStart.isNull() || visibleStart.isOrphan() || visibleEnd.isNull()
|| visibleEnd.isOrphan()) |
| 251 return; | 251 return; |
| 252 | 252 |
| 253 // Save and restore the selection endpoints using their indices in the docum
ent, since | 253 // Save and restore the selection endpoints using their indices in the docum
ent, since |
| 254 // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoint
s. | 254 // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoint
s. |
| 255 // Calculate start and end indices from the start of the tree that they're i
n. | 255 // Calculate start and end indices from the start of the tree that they're i
n. |
| 256 Node* scope = visibleStart.deepEquivalent().deprecatedNode()->highestAncesto
r(); | 256 Node& scope = visibleStart.deepEquivalent().deprecatedNode()->highestAncesto
r(); |
| 257 RefPtr<Range> startRange = Range::create(document(), firstPositionInNode(sco
pe), visibleStart.deepEquivalent().parentAnchoredEquivalent()); | 257 RefPtr<Range> startRange = Range::create(document(), firstPositionInNode(&sc
ope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); |
| 258 RefPtr<Range> endRange = Range::create(document(), firstPositionInNode(scope
), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); | 258 RefPtr<Range> endRange = Range::create(document(), firstPositionInNode(&scop
e), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); |
| 259 int startIndex = TextIterator::rangeLength(startRange.get(), true); | 259 int startIndex = TextIterator::rangeLength(startRange.get(), true); |
| 260 int endIndex = TextIterator::rangeLength(endRange.get(), true); | 260 int endIndex = TextIterator::rangeLength(endRange.get(), true); |
| 261 | 261 |
| 262 VisiblePosition paragraphStart(startOfParagraph(visibleStart)); | 262 VisiblePosition paragraphStart(startOfParagraph(visibleStart)); |
| 263 VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next()); | 263 VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next()); |
| 264 VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next()); | 264 VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next()); |
| 265 while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) { | 265 while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) { |
| 266 StyleChange styleChange(style, paragraphStart.deepEquivalent()); | 266 StyleChange styleChange(style, paragraphStart.deepEquivalent()); |
| 267 if (styleChange.cssStyle().length() || m_removeOnly) { | 267 if (styleChange.cssStyle().length() || m_removeOnly) { |
| 268 RefPtr<Node> block = enclosingBlock(paragraphStart.deepEquivalent().
deprecatedNode()); | 268 RefPtr<Node> block = enclosingBlock(paragraphStart.deepEquivalent().
deprecatedNode()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 279 } | 279 } |
| 280 | 280 |
| 281 if (nextParagraphStart.isOrphan()) | 281 if (nextParagraphStart.isOrphan()) |
| 282 nextParagraphStart = endOfParagraph(paragraphStart).next(); | 282 nextParagraphStart = endOfParagraph(paragraphStart).next(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 paragraphStart = nextParagraphStart; | 285 paragraphStart = nextParagraphStart; |
| 286 nextParagraphStart = endOfParagraph(paragraphStart).next(); | 286 nextParagraphStart = endOfParagraph(paragraphStart).next(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 startRange = PlainTextRange(startIndex).createRangeForSelection(*toContainer
Node(scope)); | 289 startRange = PlainTextRange(startIndex).createRangeForSelection(toContainerN
ode(scope)); |
| 290 endRange = PlainTextRange(endIndex).createRangeForSelection(*toContainerNode
(scope)); | 290 endRange = PlainTextRange(endIndex).createRangeForSelection(toContainerNode(
scope)); |
| 291 if (startRange && endRange) | 291 if (startRange && endRange) |
| 292 updateStartEnd(startRange->startPosition(), endRange->startPosition()); | 292 updateStartEnd(startRange->startPosition(), endRange->startPosition()); |
| 293 } | 293 } |
| 294 | 294 |
| 295 static PassRefPtr<MutableStylePropertySet> copyStyleOrCreateEmpty(const StylePro
pertySet* style) | 295 static PassRefPtr<MutableStylePropertySet> copyStyleOrCreateEmpty(const StylePro
pertySet* style) |
| 296 { | 296 { |
| 297 if (!style) | 297 if (!style) |
| 298 return MutableStylePropertySet::create(); | 298 return MutableStylePropertySet::create(); |
| 299 return style->mutableCopy(); | 299 return style->mutableCopy(); |
| 300 } | 300 } |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 String textToMove = nextText->data(); | 1539 String textToMove = nextText->data(); |
| 1540 insertTextIntoNode(childText, childText->length(), textToMove); | 1540 insertTextIntoNode(childText, childText->length(), textToMove); |
| 1541 removeNode(next); | 1541 removeNode(next); |
| 1542 // don't move child node pointer. it may want to merge with more text no
des. | 1542 // don't move child node pointer. it may want to merge with more text no
des. |
| 1543 } | 1543 } |
| 1544 | 1544 |
| 1545 updateStartEnd(newStart, newEnd); | 1545 updateStartEnd(newStart, newEnd); |
| 1546 } | 1546 } |
| 1547 | 1547 |
| 1548 } | 1548 } |
| OLD | NEW |