| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 Position end; | 123 Position end; |
| 124 while (endOfCurrentParagraph != endAfterSelection && !atEnd) { | 124 while (endOfCurrentParagraph != endAfterSelection && !atEnd) { |
| 125 HandleScope scope; | 125 HandleScope scope; |
| 126 if (endOfCurrentParagraph.deepEquivalent() == m_endOfLastParagraph) | 126 if (endOfCurrentParagraph.deepEquivalent() == m_endOfLastParagraph) |
| 127 atEnd = true; | 127 atEnd = true; |
| 128 | 128 |
| 129 rangeForParagraphSplittingTextNodesIfNeeded(endOfCurrentParagraph, start
, end); | 129 rangeForParagraphSplittingTextNodesIfNeeded(endOfCurrentParagraph, start
, end); |
| 130 endOfCurrentParagraph = end; | 130 endOfCurrentParagraph = end; |
| 131 | 131 |
| 132 Position afterEnd = end.next(); | 132 Position afterEnd = end.next(); |
| 133 Node* enclosingCell = enclosingNodeOfType(start, &isTableCell); | 133 Handle<Node> enclosingCell = enclosingNodeOfType(start, &isTableCell); |
| 134 VisiblePosition endOfNextParagraph = endOfNextParagrahSplittingTextNodes
IfNeeded(endOfCurrentParagraph, start, end); | 134 VisiblePosition endOfNextParagraph = endOfNextParagrahSplittingTextNodes
IfNeeded(endOfCurrentParagraph, start, end); |
| 135 | 135 |
| 136 formatRange(start, end, m_endOfLastParagraph, blockquoteForNextIndent); | 136 formatRange(start, end, m_endOfLastParagraph, blockquoteForNextIndent); |
| 137 | 137 |
| 138 // Don't put the next paragraph in the blockquote we just created for th
is paragraph unless | 138 // Don't put the next paragraph in the blockquote we just created for th
is paragraph unless |
| 139 // the next paragraph is in the same cell. | 139 // the next paragraph is in the same cell. |
| 140 if (enclosingCell && enclosingCell != enclosingNodeOfType(endOfNextParag
raph.deepEquivalent(), &isTableCell)) | 140 if (enclosingCell && enclosingCell != enclosingNodeOfType(endOfNextParag
raph.deepEquivalent(), &isTableCell)) |
| 141 blockquoteForNextIndent = nullptr; | 141 blockquoteForNextIndent = nullptr; |
| 142 | 142 |
| 143 // indentIntoBlockquote could move more than one paragraph if the paragr
aph | 143 // indentIntoBlockquote could move more than one paragraph if the paragr
aph |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 end = Position(end.containerText(), endOffset + 1); | 220 end = Position(end.containerText(), endOffset + 1); |
| 221 if (isEndAndEndOfLastParagraphOnSameNode && end.offsetInContainerNod
e() >= m_endOfLastParagraph.offsetInContainerNode()) | 221 if (isEndAndEndOfLastParagraphOnSameNode && end.offsetInContainerNod
e() >= m_endOfLastParagraph.offsetInContainerNode()) |
| 222 m_endOfLastParagraph = end; | 222 m_endOfLastParagraph = end; |
| 223 } | 223 } |
| 224 | 224 |
| 225 // If end is in the middle of a text node, split. | 225 // If end is in the middle of a text node, split. |
| 226 if (!endStyle->collapseWhiteSpace() && end.offsetInContainerNode() && en
d.offsetInContainerNode() < end.containerNode()->maxCharacterOffset()) { | 226 if (!endStyle->collapseWhiteSpace() && end.offsetInContainerNode() && en
d.offsetInContainerNode() < end.containerNode()->maxCharacterOffset()) { |
| 227 Handle<Text> endContainer = end.containerText(); | 227 Handle<Text> endContainer = end.containerText(); |
| 228 splitTextNode(endContainer, end.offsetInContainerNode()); | 228 splitTextNode(endContainer, end.offsetInContainerNode()); |
| 229 if (isStartAndEndOnSameNode) | 229 if (isStartAndEndOnSameNode) |
| 230 start = firstPositionInOrBeforeNode(endContainer->previousSiblin
g().handle().raw()); | 230 start = firstPositionInOrBeforeNode(endContainer->previousSiblin
g()); |
| 231 if (isEndAndEndOfLastParagraphOnSameNode) { | 231 if (isEndAndEndOfLastParagraphOnSameNode) { |
| 232 if (m_endOfLastParagraph.offsetInContainerNode() == end.offsetIn
ContainerNode()) | 232 if (m_endOfLastParagraph.offsetInContainerNode() == end.offsetIn
ContainerNode()) |
| 233 m_endOfLastParagraph = lastPositionInOrAfterNode(endContaine
r->previousSibling().handle().raw()); | 233 m_endOfLastParagraph = lastPositionInOrAfterNode(endContaine
r->previousSibling()); |
| 234 else | 234 else |
| 235 m_endOfLastParagraph = Position(endContainer, m_endOfLastPar
agraph.offsetInContainerNode() - end.offsetInContainerNode()); | 235 m_endOfLastParagraph = Position(endContainer, m_endOfLastPar
agraph.offsetInContainerNode() - end.offsetInContainerNode()); |
| 236 } | 236 } |
| 237 end = lastPositionInNode(endContainer->previousSibling()); | 237 end = lastPositionInNode(endContainer->previousSibling()); |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 VisiblePosition ApplyBlockElementCommand::endOfNextParagrahSplittingTextNodesIfN
eeded(VisiblePosition& endOfCurrentParagraph, Position& start, Position& end) | 242 VisiblePosition ApplyBlockElementCommand::endOfNextParagrahSplittingTextNodesIfN
eeded(VisiblePosition& endOfCurrentParagraph, Position& start, Position& end) |
| 243 { | 243 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 Result<Element> ApplyBlockElementCommand::createBlockElement() const | 280 Result<Element> ApplyBlockElementCommand::createBlockElement() const |
| 281 { | 281 { |
| 282 Handle<Element> element = createHTMLElement(document(), m_tagName); | 282 Handle<Element> element = createHTMLElement(document(), m_tagName); |
| 283 if (m_inlineStyle.length()) | 283 if (m_inlineStyle.length()) |
| 284 element->setAttribute(styleAttr, m_inlineStyle); | 284 element->setAttribute(styleAttr, m_inlineStyle); |
| 285 return element; | 285 return element; |
| 286 } | 286 } |
| 287 | 287 |
| 288 } | 288 } |
| OLD | NEW |