Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: Source/core/editing/StyledMarkupSerializer.cpp

Issue 1174873002: Refactoring: Remove StyledMarkupAccumulator::appendString and add appendNewLine (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 Node* pastEnd = m_end.nodeAsRangePastLastNode(); 124 Node* pastEnd = m_end.nodeAsRangePastLastNode();
125 125
126 Node* firstNode = m_start.nodeAsRangeFirstNode(); 126 Node* firstNode = m_start.nodeAsRangeFirstNode();
127 VisiblePosition visibleStart(toPositionInDOMTree(m_start), VP_DEFAULT_AFFINI TY); 127 VisiblePosition visibleStart(toPositionInDOMTree(m_start), VP_DEFAULT_AFFINI TY);
128 VisiblePosition visibleEnd(toPositionInDOMTree(m_end), VP_DEFAULT_AFFINITY); 128 VisiblePosition visibleEnd(toPositionInDOMTree(m_end), VP_DEFAULT_AFFINITY);
129 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfte r(visibleStart)) { 129 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfte r(visibleStart)) {
130 if (visibleStart == visibleEnd.previous()) 130 if (visibleStart == visibleEnd.previous())
131 return interchangeNewlineString; 131 return interchangeNewlineString;
132 132
133 markupAccumulator.appendString(interchangeNewlineString); 133 markupAccumulator.appendNewLine();
yosin_UTC9 2015/06/10 07:17:32 If we move this before L130 and change |return int
hajimehoshi 2015/06/10 07:28:31 Good catch. Done.
134 firstNode = visibleStart.next().deepEquivalent().deprecatedNode(); 134 firstNode = visibleStart.next().deepEquivalent().deprecatedNode();
135 135
136 if (pastEnd && Strategy::PositionType::beforeNode(firstNode).compareTo(S trategy::PositionType::beforeNode(pastEnd)) >= 0) { 136 if (pastEnd && Strategy::PositionType::beforeNode(firstNode).compareTo(S trategy::PositionType::beforeNode(pastEnd)) >= 0) {
137 // This condition hits in editing/pasteboard/copy-display-none.html. 137 // This condition hits in editing/pasteboard/copy-display-none.html.
138 return interchangeNewlineString; 138 return interchangeNewlineString;
139 } 139 }
140 } 140 }
141 141
142 Node* lastClosed = serializeNodes(firstNode, pastEnd, &markupAccumulator); 142 Node* lastClosed = serializeNodes(firstNode, pastEnd, &markupAccumulator);
143 143
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 markupAccumulator.wrapWithNode(*ancestor, StyledMarkupAccumulato r::DoesNotFullySelectNode); 179 markupAccumulator.wrapWithNode(*ancestor, StyledMarkupAccumulato r::DoesNotFullySelectNode);
180 } 180 }
181 181
182 if (ancestor == m_highestNodeToBeSerialized) 182 if (ancestor == m_highestNodeToBeSerialized)
183 break; 183 break;
184 } 184 }
185 } 185 }
186 186
187 // FIXME: The interchange newline should be placed in the block that it's in , not after all of the content, unconditionally. 187 // 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)) 188 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAt(v isibleEnd))
189 markupAccumulator.appendString(interchangeNewlineString); 189 markupAccumulator.appendNewLine();
190 190
191 return markupAccumulator.takeResults(); 191 return markupAccumulator.takeResults();
192 } 192 }
193 193
194 template<typename Strategy> 194 template<typename Strategy>
195 Node* StyledMarkupSerializer<Strategy>::serializeNodes(Node* startNode, Node* pa stEnd, StyledMarkupAccumulator* markupAccumulator) 195 Node* StyledMarkupSerializer<Strategy>::serializeNodes(Node* startNode, Node* pa stEnd, StyledMarkupAccumulator* markupAccumulator)
196 { 196 {
197 if (!markupAccumulator->highestNodeToBeSerialized()) { 197 if (!markupAccumulator->highestNodeToBeSerialized()) {
198 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, nul lptr); 198 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, nul lptr);
199 markupAccumulator->setHighestNodeToBeSerialized(lastClosed); 199 markupAccumulator->setHighestNodeToBeSerialized(lastClosed);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 lastClosed = parent; 287 lastClosed = parent;
288 } 288 }
289 } 289 }
290 290
291 return lastClosed; 291 return lastClosed;
292 } 292 }
293 293
294 template class StyledMarkupSerializer<EditingStrategy>; 294 template class StyledMarkupSerializer<EditingStrategy>;
295 295
296 } // namespace blink 296 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698