| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = v.next(); |
| 140 Node* upstreamNode = next.deepEquivalent().upstream().deprecatedNode(); | 140 Node* upstreamNode = next.deepEquivalent().upstream().anchorNode(); |
| 141 Node* downstreamNode = v.deepEquivalent().downstream().deprecatedNode(); | 141 Node* downstreamNode = v.deepEquivalent().downstream().anchorNode(); |
| 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 // FIXME: |v.previous()| works on a DOM tree. We need to fix this to work on |
| 149 // a composed tree. | 149 // a composed tree. |
| 150 return needInterchangeNewlineAfter(v.previous()); | 150 return needInterchangeNewlineAfter(v.previous()); |
| 151 } | 151 } |
| (...skipping 23 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 == visibleEnd.previous()) | 182 if (visibleStart == visibleEnd.previous()) |
| 183 return markupAccumulator.takeResults(); | 183 return markupAccumulator.takeResults(); |
| 184 | 184 |
| 185 firstNode = visibleStart.next().deepEquivalent().deprecatedNode(); | 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 |
| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 if (element.isHTMLElement() && shouldAnnotate()) | 483 if (element.isHTMLElement() && shouldAnnotate()) |
| 484 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)
); | 484 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)
); |
| 485 | 485 |
| 486 return inlineStyle; | 486 return inlineStyle; |
| 487 } | 487 } |
| 488 | 488 |
| 489 template class StyledMarkupSerializer<EditingStrategy>; | 489 template class StyledMarkupSerializer<EditingStrategy>; |
| 490 template class StyledMarkupSerializer<EditingInComposedTreeStrategy>; | 490 template class StyledMarkupSerializer<EditingInComposedTreeStrategy>; |
| 491 | 491 |
| 492 } // namespace blink | 492 } // namespace blink |
| OLD | NEW |