| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/editing/StyledMarkupAccumulator.h" | 30 #include "core/editing/StyledMarkupAccumulator.h" |
| 31 | 31 |
| 32 #include "core/css/StylePropertySet.h" | 32 #include "core/css/StylePropertySet.h" |
| 33 #include "core/dom/Text.h" | 33 #include "core/dom/Text.h" |
| 34 #include "core/editing/htmlediting.h" | 34 #include "core/editing/htmlediting.h" |
| 35 #include "core/editing/iterators/TextIterator.h" | 35 #include "core/editing/iterators/TextIterator.h" |
| 36 #include "wtf/text/StringBuilder.h" | 36 #include "wtf/text/StringBuilder.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 namespace { |
| 41 |
| 42 size_t totalLength(const Vector<String>& strings) |
| 43 { |
| 44 size_t length = 0; |
| 45 for (const auto& string : strings) |
| 46 length += string.length(); |
| 47 return length; |
| 48 } |
| 49 |
| 50 } // namespace |
| 51 |
| 40 using namespace HTMLNames; | 52 using namespace HTMLNames; |
| 41 | 53 |
| 42 StyledMarkupAccumulator::StyledMarkupAccumulator(EAbsoluteURLs shouldResolveURLs
, const TextOffset& start, const TextOffset& end, const PassRefPtrWillBeRawPtr<D
ocument> document, EAnnotateForInterchange shouldAnnotate, Node* highestNodeToBe
Serialized) | 54 StyledMarkupAccumulator::StyledMarkupAccumulator(EAbsoluteURLs shouldResolveURLs
, const TextOffset& start, const TextOffset& end, const PassRefPtrWillBeRawPtr<D
ocument> document, EAnnotateForInterchange shouldAnnotate, Node* highestNodeToBe
Serialized) |
| 43 : m_formatter(shouldResolveURLs) | 55 : m_formatter(shouldResolveURLs) |
| 44 , m_start(start) | 56 , m_start(start) |
| 45 , m_end(end) | 57 , m_end(end) |
| 46 , m_document(document) | 58 , m_document(document) |
| 47 , m_shouldAnnotate(shouldAnnotate) | 59 , m_shouldAnnotate(shouldAnnotate) |
| 48 , m_highestNodeToBeSerialized(highestNodeToBeSerialized) | 60 , m_highestNodeToBeSerialized(highestNodeToBeSerialized) |
| 49 { | 61 { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 MarkupFormatter::appendAttributeValue(openTag, style->asText(), m_document->
isHTMLDocument()); | 210 MarkupFormatter::appendAttributeValue(openTag, style->asText(), m_document->
isHTMLDocument()); |
| 199 openTag.appendLiteral("\">"); | 211 openTag.appendLiteral("\">"); |
| 200 m_reversedPrecedingMarkup.append(openTag.toString()); | 212 m_reversedPrecedingMarkup.append(openTag.toString()); |
| 201 | 213 |
| 202 m_result.append("</div>"); | 214 m_result.append("</div>"); |
| 203 } | 215 } |
| 204 | 216 |
| 205 String StyledMarkupAccumulator::takeResults() | 217 String StyledMarkupAccumulator::takeResults() |
| 206 { | 218 { |
| 207 StringBuilder result; | 219 StringBuilder result; |
| 208 result.reserveCapacity(MarkupFormatter::totalLength(m_reversedPrecedingMarku
p) + m_result.length()); | 220 result.reserveCapacity(totalLength(m_reversedPrecedingMarkup) + m_result.len
gth()); |
| 209 | 221 |
| 210 for (size_t i = m_reversedPrecedingMarkup.size(); i > 0; --i) | 222 for (size_t i = m_reversedPrecedingMarkup.size(); i > 0; --i) |
| 211 result.append(m_reversedPrecedingMarkup[i - 1]); | 223 result.append(m_reversedPrecedingMarkup[i - 1]); |
| 212 | 224 |
| 213 result.append(m_result); | 225 result.append(m_result); |
| 214 | 226 |
| 215 // We remove '\0' characters because they are not visibly rendered to the us
er. | 227 // We remove '\0' characters because they are not visibly rendered to the us
er. |
| 216 return result.toString().replace(0, ""); | 228 return result.toString().replace(0, ""); |
| 217 } | 229 } |
| 218 | 230 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 m_reversedPrecedingMarkup.append(str); | 269 m_reversedPrecedingMarkup.append(str); |
| 258 } | 270 } |
| 259 | 271 |
| 260 void StyledMarkupAccumulator::appendInterchangeNewline() | 272 void StyledMarkupAccumulator::appendInterchangeNewline() |
| 261 { | 273 { |
| 262 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); | 274 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); |
| 263 m_result.append(interchangeNewlineString); | 275 m_result.append(interchangeNewlineString); |
| 264 } | 276 } |
| 265 | 277 |
| 266 } // namespace blink | 278 } // namespace blink |
| OLD | NEW |