| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. |
| 4 * Copyright (C) 2011 Igalia S.L. | 4 * Copyright (C) 2011 Igalia S.L. |
| 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 { | 138 { |
| 139 VisiblePosition next = v.next(); | 139 VisiblePosition next = v.next(); |
| 140 Node* upstreamNode = mostBackwardCaretPosition(next.deepEquivalent()).anchor
Node(); | 140 Node* upstreamNode = mostBackwardCaretPosition(next.deepEquivalent()).anchor
Node(); |
| 141 Node* downstreamNode = mostForwardCaretPosition(v.deepEquivalent()).anchorNo
de(); | 141 Node* downstreamNode = mostForwardCaretPosition(v.deepEquivalent()).anchorNo
de(); |
| 142 // Add an interchange newline if a paragraph break is selected and a br won'
t already be added to the markup to represent it. | 142 // Add an interchange newline if a paragraph break is selected and a br won'
t already be added to the markup to represent it. |
| 143 return isEndOfParagraph(v) && isStartOfParagraph(next) && !(isHTMLBRElement(
*upstreamNode) && upstreamNode == downstreamNode); | 143 return isEndOfParagraph(v) && isStartOfParagraph(next) && !(isHTMLBRElement(
*upstreamNode) && upstreamNode == downstreamNode); |
| 144 } | 144 } |
| 145 | 145 |
| 146 static bool needInterchangeNewlineAt(const VisiblePosition& v) | 146 static bool needInterchangeNewlineAt(const VisiblePosition& v) |
| 147 { | 147 { |
| 148 // FIXME: |v.previous()| works on a DOM tree. We need to fix this to work on | 148 // TODO(yosin) |previousPositionOf(v)| works on a DOM tree. We need to fix |
| 149 // a composed tree. | 149 // this to work on a composed tree. |
| 150 return needInterchangeNewlineAfter(v.previous()); | 150 return needInterchangeNewlineAfter(previousPositionOf(v)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 template<typename Strategy> | 153 template<typename Strategy> |
| 154 static bool areSameRanges(Node* node, const PositionAlgorithm<Strategy>& startPo
sition, const PositionAlgorithm<Strategy>& endPosition) | 154 static bool areSameRanges(Node* node, const PositionAlgorithm<Strategy>& startPo
sition, const PositionAlgorithm<Strategy>& endPosition) |
| 155 { | 155 { |
| 156 ASSERT(node); | 156 ASSERT(node); |
| 157 const EphemeralRange range = VisibleSelection::selectionFromContentsOfNode(n
ode).toNormalizedEphemeralRange(); | 157 const EphemeralRange range = VisibleSelection::selectionFromContentsOfNode(n
ode).toNormalizedEphemeralRange(); |
| 158 return toPositionInDOMTree(startPosition) == range.startPosition() && toPosi
tionInDOMTree(endPosition) == range.endPosition(); | 158 return toPositionInDOMTree(startPosition) == range.startPosition() && toPosi
tionInDOMTree(endPosition) == range.endPosition(); |
| 159 } | 159 } |
| 160 | 160 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 172 { | 172 { |
| 173 StyledMarkupAccumulator markupAccumulator(m_shouldResolveURLs, toTextOffset(
m_start.parentAnchoredEquivalent()), toTextOffset(m_end.parentAnchoredEquivalent
()), m_start.document(), m_shouldAnnotate, m_convertBlocksToInlines); | 173 StyledMarkupAccumulator markupAccumulator(m_shouldResolveURLs, toTextOffset(
m_start.parentAnchoredEquivalent()), toTextOffset(m_end.parentAnchoredEquivalent
()), m_start.document(), m_shouldAnnotate, m_convertBlocksToInlines); |
| 174 | 174 |
| 175 Node* pastEnd = m_end.nodeAsRangePastLastNode(); | 175 Node* pastEnd = m_end.nodeAsRangePastLastNode(); |
| 176 | 176 |
| 177 Node* firstNode = m_start.nodeAsRangeFirstNode(); | 177 Node* firstNode = m_start.nodeAsRangeFirstNode(); |
| 178 VisiblePosition visibleStart(m_start); | 178 VisiblePosition visibleStart(m_start); |
| 179 VisiblePosition visibleEnd(m_end); | 179 VisiblePosition visibleEnd(m_end); |
| 180 if (shouldAnnotate() && needInterchangeNewlineAfter(visibleStart)) { | 180 if (shouldAnnotate() && needInterchangeNewlineAfter(visibleStart)) { |
| 181 markupAccumulator.appendInterchangeNewline(); | 181 markupAccumulator.appendInterchangeNewline(); |
| 182 if (visibleStart.deepEquivalent() == visibleEnd.previous().deepEquivalen
t()) | 182 if (visibleStart.deepEquivalent() == previousPositionOf(visibleEnd).deep
Equivalent()) |
| 183 return markupAccumulator.takeResults(); | 183 return markupAccumulator.takeResults(); |
| 184 | 184 |
| 185 firstNode = visibleStart.next().deepEquivalent().anchorNode(); | 185 firstNode = visibleStart.next().deepEquivalent().anchorNode(); |
| 186 | 186 |
| 187 if (pastEnd && PositionAlgorithm<Strategy>::beforeNode(firstNode).compar
eTo(PositionAlgorithm<Strategy>::beforeNode(pastEnd)) >= 0) { | 187 if (pastEnd && PositionAlgorithm<Strategy>::beforeNode(firstNode).compar
eTo(PositionAlgorithm<Strategy>::beforeNode(pastEnd)) >= 0) { |
| 188 // This condition hits in editing/pasteboard/copy-display-none.html. | 188 // This condition hits in editing/pasteboard/copy-display-none.html. |
| 189 return markupAccumulator.takeResults(); | 189 return markupAccumulator.takeResults(); |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 if (element.isHTMLElement() && shouldAnnotate()) | 475 if (element.isHTMLElement() && shouldAnnotate()) |
| 476 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)
); | 476 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)
); |
| 477 | 477 |
| 478 return inlineStyle; | 478 return inlineStyle; |
| 479 } | 479 } |
| 480 | 480 |
| 481 template class StyledMarkupSerializer<EditingStrategy>; | 481 template class StyledMarkupSerializer<EditingStrategy>; |
| 482 template class StyledMarkupSerializer<EditingInComposedTreeStrategy>; | 482 template class StyledMarkupSerializer<EditingInComposedTreeStrategy>; |
| 483 | 483 |
| 484 } // namespace blink | 484 } // namespace blink |
| OLD | NEW |