| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element->inlin
eStyle()); | 110 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element->inlin
eStyle()); |
| 111 // FIXME: Having to const_cast here is ugly, but it is quite a bit of work t
o untangle | 111 // FIXME: Having to const_cast here is ugly, but it is quite a bit of work t
o untangle |
| 112 // the non-const-ness of styleFromMatchedRulesForElement. | 112 // the non-const-ness of styleFromMatchedRulesForElement. |
| 113 style->mergeStyleFromRules(const_cast<HTMLElement*>(element)); | 113 style->mergeStyleFromRules(const_cast<HTMLElement*>(element)); |
| 114 return style.release(); | 114 return style.release(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 template<typename Strategy> | 117 template<typename Strategy> |
| 118 String StyledMarkupSerializer<Strategy>::createMarkup() | 118 String StyledMarkupSerializer<Strategy>::createMarkup() |
| 119 { | 119 { |
| 120 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); | |
| 121 | |
| 122 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()); |
| 123 | 121 |
| 124 Node* pastEnd = m_end.nodeAsRangePastLastNode(); | 122 Node* pastEnd = m_end.nodeAsRangePastLastNode(); |
| 125 | 123 |
| 126 Node* firstNode = m_start.nodeAsRangeFirstNode(); | 124 Node* firstNode = m_start.nodeAsRangeFirstNode(); |
| 127 VisiblePosition visibleStart(toPositionInDOMTree(m_start), VP_DEFAULT_AFFINI
TY); | 125 VisiblePosition visibleStart(toPositionInDOMTree(m_start), VP_DEFAULT_AFFINI
TY); |
| 128 VisiblePosition visibleEnd(toPositionInDOMTree(m_end), VP_DEFAULT_AFFINITY); | 126 VisiblePosition visibleEnd(toPositionInDOMTree(m_end), VP_DEFAULT_AFFINITY); |
| 129 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfte
r(visibleStart)) { | 127 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfte
r(visibleStart)) { |
| 128 markupAccumulator.appendInterchangeNewline(); |
| 130 if (visibleStart == visibleEnd.previous()) | 129 if (visibleStart == visibleEnd.previous()) |
| 131 return interchangeNewlineString; | 130 return markupAccumulator.takeResults(); |
| 132 | 131 |
| 133 markupAccumulator.appendString(interchangeNewlineString); | |
| 134 firstNode = visibleStart.next().deepEquivalent().deprecatedNode(); | 132 firstNode = visibleStart.next().deepEquivalent().deprecatedNode(); |
| 135 | 133 |
| 136 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) { |
| 137 // This condition hits in editing/pasteboard/copy-display-none.html. | 135 // This condition hits in editing/pasteboard/copy-display-none.html. |
| 138 return interchangeNewlineString; | 136 return markupAccumulator.takeResults(); |
| 139 } | 137 } |
| 140 } | 138 } |
| 141 | 139 |
| 142 Node* lastClosed = serializeNodes(firstNode, pastEnd, &markupAccumulator); | 140 Node* lastClosed = serializeNodes(firstNode, pastEnd, &markupAccumulator); |
| 143 | 141 |
| 144 if (m_highestNodeToBeSerialized && lastClosed) { | 142 if (m_highestNodeToBeSerialized && lastClosed) { |
| 145 // TODO(hajimehoshi): This is calculated at createMarkupInternal too. | 143 // TODO(hajimehoshi): This is calculated at createMarkupInternal too. |
| 146 Node* commonAncestor = Strategy::commonAncestor(*m_start.containerNode()
, *m_end.containerNode()); | 144 Node* commonAncestor = Strategy::commonAncestor(*m_start.containerNode()
, *m_end.containerNode()); |
| 147 ASSERT(commonAncestor); | 145 ASSERT(commonAncestor); |
| 148 HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(firstP
ositionInNode(commonAncestor), bodyTag)); | 146 HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(firstP
ositionInNode(commonAncestor), bodyTag)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 179 wrapWithNode(markupAccumulator, *ancestor, StyledMarkupAccumulat
or::DoesNotFullySelectNode); | 177 wrapWithNode(markupAccumulator, *ancestor, StyledMarkupAccumulat
or::DoesNotFullySelectNode); |
| 180 } | 178 } |
| 181 | 179 |
| 182 if (ancestor == m_highestNodeToBeSerialized) | 180 if (ancestor == m_highestNodeToBeSerialized) |
| 183 break; | 181 break; |
| 184 } | 182 } |
| 185 } | 183 } |
| 186 | 184 |
| 187 // FIXME: The interchange newline should be placed in the block that it's in
, not after all of the content, unconditionally. | 185 // FIXME: The interchange newline should be placed in the block that it's in
, not after all of the content, unconditionally. |
| 188 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAt(v
isibleEnd)) | 186 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAt(v
isibleEnd)) |
| 189 markupAccumulator.appendString(interchangeNewlineString); | 187 markupAccumulator.appendInterchangeNewline(); |
| 190 | 188 |
| 191 return markupAccumulator.takeResults(); | 189 return markupAccumulator.takeResults(); |
| 192 } | 190 } |
| 193 | 191 |
| 194 template<typename Strategy> | 192 template<typename Strategy> |
| 195 Node* StyledMarkupSerializer<Strategy>::serializeNodes(Node* startNode, Node* pa
stEnd, StyledMarkupAccumulator* markupAccumulator) | 193 Node* StyledMarkupSerializer<Strategy>::serializeNodes(Node* startNode, Node* pa
stEnd, StyledMarkupAccumulator* markupAccumulator) |
| 196 { | 194 { |
| 197 if (!markupAccumulator->highestNodeToBeSerialized()) { | 195 if (!markupAccumulator->highestNodeToBeSerialized()) { |
| 198 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, nul
lptr); | 196 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, nul
lptr); |
| 199 markupAccumulator->setHighestNodeToBeSerialized(lastClosed); | 197 markupAccumulator->setHighestNodeToBeSerialized(lastClosed); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 accumulator.appendStartMarkup(markup, node); | 299 accumulator.appendStartMarkup(markup, node); |
| 302 accumulator.pushMarkup(markup.toString()); | 300 accumulator.pushMarkup(markup.toString()); |
| 303 if (!node.isElementNode()) | 301 if (!node.isElementNode()) |
| 304 return; | 302 return; |
| 305 accumulator.appendEndTag(toElement(node)); | 303 accumulator.appendEndTag(toElement(node)); |
| 306 } | 304 } |
| 307 | 305 |
| 308 template class StyledMarkupSerializer<EditingStrategy>; | 306 template class StyledMarkupSerializer<EditingStrategy>; |
| 309 | 307 |
| 310 } // namespace blink | 308 } // namespace blink |
| OLD | NEW |