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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 , m_shouldResolveURLs(shouldResolveURLs) | 129 , m_shouldResolveURLs(shouldResolveURLs) |
130 , m_shouldAnnotate(shouldAnnotate) | 130 , m_shouldAnnotate(shouldAnnotate) |
131 , m_highestNodeToBeSerialized(highestNodeToBeSerialized) | 131 , m_highestNodeToBeSerialized(highestNodeToBeSerialized) |
132 , m_convertBlocksToInlines(convertBlocksToInlines) | 132 , m_convertBlocksToInlines(convertBlocksToInlines) |
133 , m_lastClosed(highestNodeToBeSerialized) | 133 , m_lastClosed(highestNodeToBeSerialized) |
134 { | 134 { |
135 } | 135 } |
136 | 136 |
137 static bool needInterchangeNewlineAfter(const VisiblePosition& v) | 137 static bool needInterchangeNewlineAfter(const VisiblePosition& v) |
138 { | 138 { |
139 VisiblePosition next = v.next(); | 139 VisiblePosition next = nextPositionOf(v); |
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 // TODO(yosin) |previousPositionOf(v)| works on a DOM tree. We need to fix | 148 // TODO(yosin) |previousPositionOf(v)| works on a DOM tree. We need to fix |
149 // this to work on a composed tree. | 149 // this to work on a composed tree. |
(...skipping 25 matching lines...) Expand all Loading... |
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() == previousPositionOf(visibleEnd).deep
Equivalent()) | 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 = nextPositionOf(visibleStart).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 |
193 if (!m_lastClosed) | 193 if (!m_lastClosed) |
194 m_lastClosed = StyledMarkupTraverser<Strategy>().traverse(firstNode, pas
tEnd); | 194 m_lastClosed = StyledMarkupTraverser<Strategy>().traverse(firstNode, pas
tEnd); |
195 StyledMarkupTraverser<Strategy> traverser(&markupAccumulator, m_lastClosed); | 195 StyledMarkupTraverser<Strategy> traverser(&markupAccumulator, m_lastClosed); |
(...skipping 279 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 |