| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // Save and restore the selection endpoints using their indices in the docum
ent, since | 259 // Save and restore the selection endpoints using their indices in the docum
ent, since |
| 260 // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoint
s. | 260 // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoint
s. |
| 261 // Calculate start and end indices from the start of the tree that they're i
n. | 261 // Calculate start and end indices from the start of the tree that they're i
n. |
| 262 Node& scope = NodeTraversal::highestAncestorOrSelf(*visibleStart.deepEquival
ent().anchorNode()); | 262 Node& scope = NodeTraversal::highestAncestorOrSelf(*visibleStart.deepEquival
ent().anchorNode()); |
| 263 RefPtrWillBeRawPtr<Range> startRange = Range::create(document(), firstPositi
onInNode(&scope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); | 263 RefPtrWillBeRawPtr<Range> startRange = Range::create(document(), firstPositi
onInNode(&scope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); |
| 264 RefPtrWillBeRawPtr<Range> endRange = Range::create(document(), firstPosition
InNode(&scope), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); | 264 RefPtrWillBeRawPtr<Range> endRange = Range::create(document(), firstPosition
InNode(&scope), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); |
| 265 int startIndex = TextIterator::rangeLength(startRange->startPosition(), star
tRange->endPosition(), true); | 265 int startIndex = TextIterator::rangeLength(startRange->startPosition(), star
tRange->endPosition(), true); |
| 266 int endIndex = TextIterator::rangeLength(endRange->startPosition(), endRange
->endPosition(), true); | 266 int endIndex = TextIterator::rangeLength(endRange->startPosition(), endRange
->endPosition(), true); |
| 267 | 267 |
| 268 VisiblePosition paragraphStart(startOfParagraph(visibleStart)); | 268 VisiblePosition paragraphStart(startOfParagraph(visibleStart)); |
| 269 VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next()); | 269 VisiblePosition nextParagraphStart(nextPositionOf(endOfParagraph(paragraphSt
art))); |
| 270 VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next()); | 270 VisiblePosition beyondEnd(nextPositionOf(endOfParagraph(visibleEnd))); |
| 271 while (paragraphStart.isNotNull() && paragraphStart.deepEquivalent() != beyo
ndEnd.deepEquivalent()) { | 271 while (paragraphStart.isNotNull() && paragraphStart.deepEquivalent() != beyo
ndEnd.deepEquivalent()) { |
| 272 StyleChange styleChange(style, paragraphStart.deepEquivalent()); | 272 StyleChange styleChange(style, paragraphStart.deepEquivalent()); |
| 273 if (styleChange.cssStyle().length() || m_removeOnly) { | 273 if (styleChange.cssStyle().length() || m_removeOnly) { |
| 274 RefPtrWillBeRawPtr<Element> block = enclosingBlock(paragraphStart.de
epEquivalent().anchorNode()); | 274 RefPtrWillBeRawPtr<Element> block = enclosingBlock(paragraphStart.de
epEquivalent().anchorNode()); |
| 275 const Position& paragraphStartToMove = paragraphStart.deepEquivalent
(); | 275 const Position& paragraphStartToMove = paragraphStart.deepEquivalent
(); |
| 276 if (!m_removeOnly && isEditablePosition(paragraphStartToMove)) { | 276 if (!m_removeOnly && isEditablePosition(paragraphStartToMove)) { |
| 277 RefPtrWillBeRawPtr<HTMLElement> newBlock = moveParagraphContents
ToNewBlockIfNecessary(paragraphStartToMove); | 277 RefPtrWillBeRawPtr<HTMLElement> newBlock = moveParagraphContents
ToNewBlockIfNecessary(paragraphStartToMove); |
| 278 if (newBlock) | 278 if (newBlock) |
| 279 block = newBlock; | 279 block = newBlock; |
| 280 } | 280 } |
| 281 if (block && block->isHTMLElement()) { | 281 if (block && block->isHTMLElement()) { |
| 282 removeCSSStyle(style, toHTMLElement(block)); | 282 removeCSSStyle(style, toHTMLElement(block)); |
| 283 if (!m_removeOnly) | 283 if (!m_removeOnly) |
| 284 addBlockStyle(styleChange, toHTMLElement(block)); | 284 addBlockStyle(styleChange, toHTMLElement(block)); |
| 285 } | 285 } |
| 286 | 286 |
| 287 if (nextParagraphStart.isOrphan()) | 287 if (nextParagraphStart.isOrphan()) |
| 288 nextParagraphStart = endOfParagraph(paragraphStart).next(); | 288 nextParagraphStart = nextPositionOf(endOfParagraph(paragraphStar
t)); |
| 289 } | 289 } |
| 290 | 290 |
| 291 paragraphStart = nextParagraphStart; | 291 paragraphStart = nextParagraphStart; |
| 292 nextParagraphStart = endOfParagraph(paragraphStart).next(); | 292 nextParagraphStart = nextPositionOf(endOfParagraph(paragraphStart)); |
| 293 } | 293 } |
| 294 | 294 |
| 295 EphemeralRange startEphemeralRange = PlainTextRange(startIndex).createRangeF
orSelection(toContainerNode(scope)); | 295 EphemeralRange startEphemeralRange = PlainTextRange(startIndex).createRangeF
orSelection(toContainerNode(scope)); |
| 296 if (startEphemeralRange.isNull()) | 296 if (startEphemeralRange.isNull()) |
| 297 return; | 297 return; |
| 298 EphemeralRange endEphemeralRange = PlainTextRange(endIndex).createRangeForSe
lection(toContainerNode(scope)); | 298 EphemeralRange endEphemeralRange = PlainTextRange(endIndex).createRangeForSe
lection(toContainerNode(scope)); |
| 299 if (endEphemeralRange.isNull()) | 299 if (endEphemeralRange.isNull()) |
| 300 return; | 300 return; |
| 301 updateStartEnd(startEphemeralRange.startPosition(), endEphemeralRange.startP
osition()); | 301 updateStartEnd(startEphemeralRange.startPosition(), endEphemeralRange.startP
osition()); |
| 302 } | 302 } |
| (...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1594 DEFINE_TRACE(ApplyStyleCommand) | 1594 DEFINE_TRACE(ApplyStyleCommand) |
| 1595 { | 1595 { |
| 1596 visitor->trace(m_style); | 1596 visitor->trace(m_style); |
| 1597 visitor->trace(m_start); | 1597 visitor->trace(m_start); |
| 1598 visitor->trace(m_end); | 1598 visitor->trace(m_end); |
| 1599 visitor->trace(m_styledInlineElement); | 1599 visitor->trace(m_styledInlineElement); |
| 1600 CompositeEditCommand::trace(visitor); | 1600 CompositeEditCommand::trace(visitor); |
| 1601 } | 1601 } |
| 1602 | 1602 |
| 1603 } | 1603 } |
| OLD | NEW |