| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 template<typename Strategy> | 117 template<typename Strategy> |
| 118 String StyledMarkupSerializer<Strategy>::createMarkup() | 118 String StyledMarkupSerializer<Strategy>::createMarkup() |
| 119 { | 119 { |
| 120 StyledMarkupAccumulator markupAccumulator(m_shouldResolveURLs, toTextOffset(
m_start.parentAnchoredEquivalent()), toTextOffset(m_end.parentAnchoredEquivalent
()), m_start.document(), m_shouldAnnotate, m_highestNodeToBeSerialized.get()); | 120 StyledMarkupAccumulator markupAccumulator(m_shouldResolveURLs, toTextOffset(
m_start.parentAnchoredEquivalent()), toTextOffset(m_end.parentAnchoredEquivalent
()), m_start.document(), m_shouldAnnotate, m_highestNodeToBeSerialized.get()); |
| 121 | 121 |
| 122 Node* pastEnd = m_end.nodeAsRangePastLastNode(); | 122 Node* pastEnd = m_end.nodeAsRangePastLastNode(); |
| 123 | 123 |
| 124 Node* firstNode = m_start.nodeAsRangeFirstNode(); | 124 Node* firstNode = m_start.nodeAsRangeFirstNode(); |
| 125 VisiblePosition visibleStart(toPositionInDOMTree(m_start), VP_DEFAULT_AFFINI
TY); | 125 VisiblePosition visibleStart(toPositionInDOMTree(m_start), VP_DEFAULT_AFFINI
TY); |
| 126 VisiblePosition visibleEnd(toPositionInDOMTree(m_end), VP_DEFAULT_AFFINITY); | 126 VisiblePosition visibleEnd(toPositionInDOMTree(m_end), VP_DEFAULT_AFFINITY); |
| 127 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfte
r(visibleStart)) { | 127 if (shouldAnnotate() && needInterchangeNewlineAfter(visibleStart)) { |
| 128 markupAccumulator.appendInterchangeNewline(); | 128 markupAccumulator.appendInterchangeNewline(); |
| 129 if (visibleStart == visibleEnd.previous()) | 129 if (visibleStart == visibleEnd.previous()) |
| 130 return markupAccumulator.takeResults(); | 130 return markupAccumulator.takeResults(); |
| 131 | 131 |
| 132 firstNode = visibleStart.next().deepEquivalent().deprecatedNode(); | 132 firstNode = visibleStart.next().deepEquivalent().deprecatedNode(); |
| 133 | 133 |
| 134 if (pastEnd && Strategy::PositionType::beforeNode(firstNode).compareTo(S
trategy::PositionType::beforeNode(pastEnd)) >= 0) { | 134 if (pastEnd && Strategy::PositionType::beforeNode(firstNode).compareTo(S
trategy::PositionType::beforeNode(pastEnd)) >= 0) { |
| 135 // This condition hits in editing/pasteboard/copy-display-none.html. | 135 // This condition hits in editing/pasteboard/copy-display-none.html. |
| 136 return markupAccumulator.takeResults(); | 136 return markupAccumulator.takeResults(); |
| 137 } | 137 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 style->style()->removeProperty(CSSPropertyFloat); | 181 style->style()->removeProperty(CSSPropertyFloat); |
| 182 wrapWithNode(markupAccumulator, *ancestor, style); | 182 wrapWithNode(markupAccumulator, *ancestor, style); |
| 183 } | 183 } |
| 184 | 184 |
| 185 if (ancestor == m_highestNodeToBeSerialized) | 185 if (ancestor == m_highestNodeToBeSerialized) |
| 186 break; | 186 break; |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 // FIXME: The interchange newline should be placed in the block that it's in
, not after all of the content, unconditionally. | 190 // FIXME: The interchange newline should be placed in the block that it's in
, not after all of the content, unconditionally. |
| 191 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAt(v
isibleEnd)) | 191 if (shouldAnnotate() && needInterchangeNewlineAt(visibleEnd)) |
| 192 markupAccumulator.appendInterchangeNewline(); | 192 markupAccumulator.appendInterchangeNewline(); |
| 193 | 193 |
| 194 return markupAccumulator.takeResults(); | 194 return markupAccumulator.takeResults(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 template<typename Strategy> | 197 template<typename Strategy> |
| 198 Node* StyledMarkupSerializer<Strategy>::serializeNodes(Node* startNode, Node* pa
stEnd, StyledMarkupAccumulator* markupAccumulator) | 198 Node* StyledMarkupSerializer<Strategy>::serializeNodes(Node* startNode, Node* pa
stEnd, StyledMarkupAccumulator* markupAccumulator) |
| 199 { | 199 { |
| 200 if (!markupAccumulator->highestNodeToBeSerialized()) { | 200 if (!markupAccumulator->highestNodeToBeSerialized()) { |
| 201 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, nul
lptr); | 201 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, nul
lptr); |
| 202 markupAccumulator->setHighestNodeToBeSerialized(lastClosed); | 202 markupAccumulator->setHighestNodeToBeSerialized(lastClosed); |
| 203 } | 203 } |
| 204 | 204 |
| 205 Node* highestNodeToBeSerialized = markupAccumulator->highestNodeToBeSerializ
ed(); | 205 Node* highestNodeToBeSerialized = markupAccumulator->highestNodeToBeSerializ
ed(); |
| 206 if (highestNodeToBeSerialized && Strategy::parent(*highestNodeToBeSerialized
)) { | 206 if (highestNodeToBeSerialized && Strategy::parent(*highestNodeToBeSerialized
)) { |
| 207 bool shouldAnnotate = m_shouldAnnotate == AnnotateForInterchange; | 207 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = EditingStyle::wrappingS
tyleForSerialization(Strategy::parent(*highestNodeToBeSerialized), shouldAnnotat
e()); |
| 208 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = EditingStyle::wrappingS
tyleForSerialization(Strategy::parent(*highestNodeToBeSerialized), shouldAnnotat
e); | |
| 209 markupAccumulator->setWrappingStyle(wrappingStyle.release()); | 208 markupAccumulator->setWrappingStyle(wrappingStyle.release()); |
| 210 } | 209 } |
| 211 return traverseNodesForSerialization(startNode, pastEnd, markupAccumulator); | 210 return traverseNodesForSerialization(startNode, pastEnd, markupAccumulator); |
| 212 } | 211 } |
| 213 | 212 |
| 214 template<typename Strategy> | 213 template<typename Strategy> |
| 215 Node* StyledMarkupSerializer<Strategy>::traverseNodesForSerialization(Node* star
tNode, Node* pastEnd, StyledMarkupAccumulator* markupAccumulator) | 214 Node* StyledMarkupSerializer<Strategy>::traverseNodesForSerialization(Node* star
tNode, Node* pastEnd, StyledMarkupAccumulator* markupAccumulator) |
| 216 { | 215 { |
| 217 WillBeHeapVector<RawPtrWillBeMember<ContainerNode>> ancestorsToClose; | 216 WillBeHeapVector<RawPtrWillBeMember<ContainerNode>> ancestorsToClose; |
| 218 Node* next; | 217 Node* next; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 293 } |
| 295 | 294 |
| 296 return lastClosed; | 295 return lastClosed; |
| 297 } | 296 } |
| 298 | 297 |
| 299 template<typename Strategy> | 298 template<typename Strategy> |
| 300 bool StyledMarkupSerializer<Strategy>::needsInlineStyle(const Element& element) | 299 bool StyledMarkupSerializer<Strategy>::needsInlineStyle(const Element& element) |
| 301 { | 300 { |
| 302 if (!element.isHTMLElement()) | 301 if (!element.isHTMLElement()) |
| 303 return false; | 302 return false; |
| 304 if (m_shouldAnnotate == AnnotateForInterchange) | 303 if (shouldAnnotate()) |
| 305 return true; | 304 return true; |
| 306 return convertBlocksToInlines() && isBlock(&element); | 305 return convertBlocksToInlines() && isBlock(&element); |
| 307 } | 306 } |
| 308 | 307 |
| 309 template<typename Strategy> | 308 template<typename Strategy> |
| 310 void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& acc
umulator, ContainerNode& node, PassRefPtrWillBeRawPtr<EditingStyle> style) | 309 void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& acc
umulator, ContainerNode& node, PassRefPtrWillBeRawPtr<EditingStyle> style) |
| 311 { | 310 { |
| 312 StringBuilder markup; | 311 StringBuilder markup; |
| 313 if (node.isDocumentNode()) { | 312 if (node.isDocumentNode()) { |
| 314 MarkupFormatter::appendXMLDeclaration(markup, toDocument(node)); | 313 MarkupFormatter::appendXMLDeclaration(markup, toDocument(node)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 333 return nullptr; | 332 return nullptr; |
| 334 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = accumulator.createInlineStyle
(toElement(node)); | 333 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = accumulator.createInlineStyle
(toElement(node)); |
| 335 if (convertBlocksToInlines() && isBlock(&node)) | 334 if (convertBlocksToInlines() && isBlock(&node)) |
| 336 inlineStyle->forceInline(); | 335 inlineStyle->forceInline(); |
| 337 return inlineStyle; | 336 return inlineStyle; |
| 338 } | 337 } |
| 339 | 338 |
| 340 template class StyledMarkupSerializer<EditingStrategy>; | 339 template class StyledMarkupSerializer<EditingStrategy>; |
| 341 | 340 |
| 342 } // namespace blink | 341 } // namespace blink |
| OLD | NEW |