| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 264 |
| 265 // Save and restore the selection endpoints using their indices in the docum
ent, since | 265 // Save and restore the selection endpoints using their indices in the docum
ent, since |
| 266 // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoint
s. | 266 // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoint
s. |
| 267 // Calculate start and end indices from the start of the tree that they're i
n. | 267 // Calculate start and end indices from the start of the tree that they're i
n. |
| 268 Node& scope = NodeTraversal::highestAncestorOrSelf(*visibleStart.deepEquival
ent().anchorNode()); | 268 Node& scope = NodeTraversal::highestAncestorOrSelf(*visibleStart.deepEquival
ent().anchorNode()); |
| 269 Range* startRange = Range::create(document(), Position::firstPositionInNode(
&scope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); | 269 Range* startRange = Range::create(document(), Position::firstPositionInNode(
&scope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); |
| 270 Range* endRange = Range::create(document(), Position::firstPositionInNode(&s
cope), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); | 270 Range* endRange = Range::create(document(), Position::firstPositionInNode(&s
cope), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); |
| 271 int startIndex = TextIterator::rangeLength(startRange->startPosition(), star
tRange->endPosition(), true); | 271 int startIndex = TextIterator::rangeLength(startRange->startPosition(), star
tRange->endPosition(), true); |
| 272 int endIndex = TextIterator::rangeLength(endRange->startPosition(), endRange
->endPosition(), true); | 272 int endIndex = TextIterator::rangeLength(endRange->startPosition(), endRange
->endPosition(), true); |
| 273 | 273 |
| 274 VisiblePosition paragraphStart(startOfParagraph(visibleStart)); | 274 VisiblePosition paragraphStart(startOfParagraphDeprecated(visibleStart)); |
| 275 VisiblePosition nextParagraphStart(nextPositionOf(endOfParagraph(paragraphSt
art))); | 275 VisiblePosition nextParagraphStart(nextPositionOf(endOfParagraphDeprecated(p
aragraphStart))); |
| 276 VisiblePosition beyondEnd(nextPositionOf(endOfParagraph(visibleEnd))); | 276 VisiblePosition beyondEnd(nextPositionOf(endOfParagraphDeprecated(visibleEnd
))); |
| 277 while (paragraphStart.isNotNull() && paragraphStart.deepEquivalent() != beyo
ndEnd.deepEquivalent()) { | 277 while (paragraphStart.isNotNull() && paragraphStart.deepEquivalent() != beyo
ndEnd.deepEquivalent()) { |
| 278 DCHECK(!paragraphStart.isOrphan()) << paragraphStart; | 278 DCHECK(!paragraphStart.isOrphan()) << paragraphStart; |
| 279 StyleChange styleChange(style, paragraphStart.deepEquivalent()); | 279 StyleChange styleChange(style, paragraphStart.deepEquivalent()); |
| 280 if (styleChange.cssStyle().length() || m_removeOnly) { | 280 if (styleChange.cssStyle().length() || m_removeOnly) { |
| 281 Element* block = enclosingBlock(paragraphStart.deepEquivalent().anch
orNode()); | 281 Element* block = enclosingBlock(paragraphStart.deepEquivalent().anch
orNode()); |
| 282 const Position& paragraphStartToMove = paragraphStart.deepEquivalent
(); | 282 const Position& paragraphStartToMove = paragraphStart.deepEquivalent
(); |
| 283 if (!m_removeOnly && isEditablePosition(paragraphStartToMove)) { | 283 if (!m_removeOnly && isEditablePosition(paragraphStartToMove)) { |
| 284 HTMLElement* newBlock = moveParagraphContentsToNewBlockIfNecessa
ry(paragraphStartToMove, editingState); | 284 HTMLElement* newBlock = moveParagraphContentsToNewBlockIfNecessa
ry(paragraphStartToMove, editingState); |
| 285 if (editingState->isAborted()) | 285 if (editingState->isAborted()) |
| 286 return; | 286 return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 297 return; | 297 return; |
| 298 DCHECK(!paragraphStart.isOrphan()) << paragraphStart; | 298 DCHECK(!paragraphStart.isOrphan()) << paragraphStart; |
| 299 if (!m_removeOnly) { | 299 if (!m_removeOnly) { |
| 300 addBlockStyle(styleChange, toHTMLElement(block)); | 300 addBlockStyle(styleChange, toHTMLElement(block)); |
| 301 DCHECK(!paragraphStart.isOrphan()) << paragraphStart; | 301 DCHECK(!paragraphStart.isOrphan()) << paragraphStart; |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 DCHECK(!paragraphStart.isOrphan()) << paragraphStart; | 305 DCHECK(!paragraphStart.isOrphan()) << paragraphStart; |
| 306 if (nextParagraphStart.isOrphan()) | 306 if (nextParagraphStart.isOrphan()) |
| 307 nextParagraphStart = nextPositionOf(endOfParagraph(paragraphStar
t)); | 307 nextParagraphStart = nextPositionOf(endOfParagraphDeprecated(par
agraphStart)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 DCHECK(!nextParagraphStart.isOrphan()) << nextParagraphStart; | 310 DCHECK(!nextParagraphStart.isOrphan()) << nextParagraphStart; |
| 311 paragraphStart = nextParagraphStart; | 311 paragraphStart = nextParagraphStart; |
| 312 nextParagraphStart = nextPositionOf(endOfParagraph(paragraphStart)); | 312 nextParagraphStart = nextPositionOf(endOfParagraphDeprecated(paragraphSt
art)); |
| 313 } | 313 } |
| 314 | 314 |
| 315 // Update style and layout again, since added or removed styles could have | 315 // Update style and layout again, since added or removed styles could have |
| 316 // affected the layout. We need clean layout in order to compute | 316 // affected the layout. We need clean layout in order to compute |
| 317 // plain-text ranges below. | 317 // plain-text ranges below. |
| 318 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 318 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 319 | 319 |
| 320 EphemeralRange startEphemeralRange = PlainTextRange(startIndex).createRangeF
orSelection(toContainerNode(scope)); | 320 EphemeralRange startEphemeralRange = PlainTextRange(startIndex).createRangeF
orSelection(toContainerNode(scope)); |
| 321 if (startEphemeralRange.isNull()) | 321 if (startEphemeralRange.isNull()) |
| 322 return; | 322 return; |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 DEFINE_TRACE(ApplyStyleCommand) | 1756 DEFINE_TRACE(ApplyStyleCommand) |
| 1757 { | 1757 { |
| 1758 visitor->trace(m_style); | 1758 visitor->trace(m_style); |
| 1759 visitor->trace(m_start); | 1759 visitor->trace(m_start); |
| 1760 visitor->trace(m_end); | 1760 visitor->trace(m_end); |
| 1761 visitor->trace(m_styledInlineElement); | 1761 visitor->trace(m_styledInlineElement); |
| 1762 CompositeEditCommand::trace(visitor); | 1762 CompositeEditCommand::trace(visitor); |
| 1763 } | 1763 } |
| 1764 | 1764 |
| 1765 } // namespace blink | 1765 } // namespace blink |
| OLD | NEW |