| 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 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 | 102 |
| 103 void ApplyBlockElementCommand::formatSelection(const VisiblePosition& startOfSel
ection, const VisiblePosition& endOfSelection) | 103 void ApplyBlockElementCommand::formatSelection(const VisiblePosition& startOfSel
ection, const VisiblePosition& endOfSelection) |
| 104 { | 104 { |
| 105 // Special case empty unsplittable elements because there's nothing to split | 105 // Special case empty unsplittable elements because there's nothing to split |
| 106 // and there's nothing to move. | 106 // and there's nothing to move. |
| 107 Position start = startOfSelection.deepEquivalent().downstream(); | 107 Position start = startOfSelection.deepEquivalent().downstream(); |
| 108 if (isAtUnsplittableElement(start)) { | 108 if (isAtUnsplittableElement(start)) { |
| 109 RefPtr<Element> blockquote = createBlockElement(); | 109 RefPtr<Element> blockquote = createBlockElement(); |
| 110 insertNodeAt(blockquote, start); | 110 insertNodeAt(blockquote, start); |
| 111 RefPtr<Element> placeholder = createBreakElement(&document()); | 111 RefPtr<Element> placeholder = createBreakElement(document()); |
| 112 appendNode(placeholder, blockquote); | 112 appendNode(placeholder, blockquote); |
| 113 setEndingSelection(VisibleSelection(positionBeforeNode(placeholder.get()
), DOWNSTREAM, endingSelection().isDirectional())); | 113 setEndingSelection(VisibleSelection(positionBeforeNode(placeholder.get()
), DOWNSTREAM, endingSelection().isDirectional())); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 | 116 |
| 117 RefPtr<Element> blockquoteForNextIndent; | 117 RefPtr<Element> blockquoteForNextIndent; |
| 118 VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection); | 118 VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection); |
| 119 VisiblePosition endAfterSelection = endOfParagraph(endOfParagraph(endOfSelec
tion).next()); | 119 VisiblePosition endAfterSelection = endOfParagraph(endOfParagraph(endOfSelec
tion).next()); |
| 120 m_endOfLastParagraph = endOfParagraph(endOfSelection).deepEquivalent(); | 120 m_endOfLastParagraph = endOfParagraph(endOfSelection).deepEquivalent(); |
| 121 | 121 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 m_endOfLastParagraph = Position(toText(text->previousSibling()),
m_endOfLastParagraph.offsetInContainerNode()); | 271 m_endOfLastParagraph = Position(toText(text->previousSibling()),
m_endOfLastParagraph.offsetInContainerNode()); |
| 272 } else | 272 } else |
| 273 m_endOfLastParagraph = Position(text.get(), m_endOfLastParagraph.off
setInContainerNode() - 1); | 273 m_endOfLastParagraph = Position(text.get(), m_endOfLastParagraph.off
setInContainerNode() - 1); |
| 274 } | 274 } |
| 275 | 275 |
| 276 return Position(text.get(), position.offsetInContainerNode() - 1); | 276 return Position(text.get(), position.offsetInContainerNode() - 1); |
| 277 } | 277 } |
| 278 | 278 |
| 279 PassRefPtr<Element> ApplyBlockElementCommand::createBlockElement() const | 279 PassRefPtr<Element> ApplyBlockElementCommand::createBlockElement() const |
| 280 { | 280 { |
| 281 RefPtr<Element> element = createHTMLElement(&document(), m_tagName); | 281 RefPtr<Element> element = createHTMLElement(document(), m_tagName); |
| 282 if (m_inlineStyle.length()) | 282 if (m_inlineStyle.length()) |
| 283 element->setAttribute(styleAttr, m_inlineStyle); | 283 element->setAttribute(styleAttr, m_inlineStyle); |
| 284 return element.release(); | 284 return element.release(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 } | 287 } |
| OLD | NEW |