| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 { | 43 { |
| 44 DEFINE_STATIC_LOCAL(const String, divClose, ("</div>")); | 44 DEFINE_STATIC_LOCAL(const String, divClose, ("</div>")); |
| 45 DEFINE_STATIC_LOCAL(const String, styleSpanClose, ("</span>")); | 45 DEFINE_STATIC_LOCAL(const String, styleSpanClose, ("</span>")); |
| 46 return isBlock ? divClose : styleSpanClose; | 46 return isBlock ? divClose : styleSpanClose; |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 using namespace HTMLNames; | 51 using namespace HTMLNames; |
| 52 | 52 |
| 53 StyledMarkupAccumulator::StyledMarkupAccumulator(EAbsoluteURLs shouldResolveURLs
, const TextOffset& start, const TextOffset& end, const PassRefPtrWillBeRawPtr<D
ocument> document, EAnnotateForInterchange shouldAnnotate, Node* highestNodeToBe
Serialized) | 53 StyledMarkupAccumulator::StyledMarkupAccumulator(EAbsoluteURLs shouldResolveURLs
, const TextOffset& start, const TextOffset& end, const PassRefPtrWillBeRawPtr<D
ocument> document, EAnnotateForInterchange shouldAnnotate, Node* highestNodeToBe
Serialized, ConvertBlocksToInlines convertBlocksToInlines) |
| 54 : m_accumulator(shouldResolveURLs) | 54 : m_accumulator(shouldResolveURLs) |
| 55 , m_start(start) | 55 , m_start(start) |
| 56 , m_end(end) | 56 , m_end(end) |
| 57 , m_document(document) | 57 , m_document(document) |
| 58 , m_shouldAnnotate(shouldAnnotate) | 58 , m_shouldAnnotate(shouldAnnotate) |
| 59 , m_convertBlocksToInlines(convertBlocksToInlines) |
| 59 , m_highestNodeToBeSerialized(highestNodeToBeSerialized) | 60 , m_highestNodeToBeSerialized(highestNodeToBeSerialized) |
| 60 { | 61 { |
| 61 } | 62 } |
| 62 | 63 |
| 63 void StyledMarkupAccumulator::appendString(const String& str) | 64 void StyledMarkupAccumulator::appendString(const String& str) |
| 64 { | 65 { |
| 65 m_accumulator.appendString(str); | 66 m_accumulator.appendString(str); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void StyledMarkupAccumulator::appendStartTag(Node& node) | 69 void StyledMarkupAccumulator::appendStartTag(Node& node) |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI
nEffect)); | 206 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI
nEffect)); |
| 206 if (isBlock) | 207 if (isBlock) |
| 207 out.appendLiteral("<div style=\""); | 208 out.appendLiteral("<div style=\""); |
| 208 else | 209 else |
| 209 out.appendLiteral("<span style=\""); | 210 out.appendLiteral("<span style=\""); |
| 210 ASSERT(m_document); | 211 ASSERT(m_document); |
| 211 m_accumulator.appendAttributeValue(out, style->asText(), m_document->isHTMLD
ocument()); | 212 m_accumulator.appendAttributeValue(out, style->asText(), m_document->isHTMLD
ocument()); |
| 212 out.appendLiteral("\">"); | 213 out.appendLiteral("\">"); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void StyledMarkupAccumulator::concatenateMarkup(StringBuilder& result) const | 216 void StyledMarkupAccumulator::wrapWithNode(ContainerNode& node, RangeFullySelect
sNode rangeFullySelectsNode) |
| 216 { | 217 { |
| 218 StringBuilder markup; |
| 219 if (node.isElementNode()) |
| 220 appendElement(markup, toElement(node), convertBlocksToInlines() && isBlo
ck(&node), rangeFullySelectsNode); |
| 221 else |
| 222 appendStartMarkup(markup, node); |
| 223 m_reversedPrecedingMarkup.append(markup.toString()); |
| 224 if (node.isElementNode()) |
| 225 appendEndTag(toElement(node)); |
| 226 } |
| 227 |
| 228 void StyledMarkupAccumulator::wrapWithStyleNode(StylePropertySet* style, bool is
Block) |
| 229 { |
| 230 StringBuilder openTag; |
| 231 appendStyleNodeOpenTag(openTag, style, isBlock); |
| 232 m_reversedPrecedingMarkup.append(openTag.toString()); |
| 233 appendString(styleNodeCloseTag(isBlock)); |
| 234 } |
| 235 |
| 236 String StyledMarkupAccumulator::takeResults() |
| 237 { |
| 238 StringBuilder result; |
| 239 result.reserveCapacity(MarkupAccumulator::totalLength(m_reversedPrecedingMar
kup) + m_accumulator.length()); |
| 240 |
| 241 for (size_t i = m_reversedPrecedingMarkup.size(); i > 0; --i) |
| 242 result.append(m_reversedPrecedingMarkup[i - 1]); |
| 243 |
| 217 m_accumulator.concatenateMarkup(result); | 244 m_accumulator.concatenateMarkup(result); |
| 245 |
| 246 // We remove '\0' characters because they are not visibly rendered to the us
er. |
| 247 return result.toString().replace(0, ""); |
| 218 } | 248 } |
| 219 | 249 |
| 220 String StyledMarkupAccumulator::renderedText(Text& textNode) | 250 String StyledMarkupAccumulator::renderedText(Text& textNode) |
| 221 { | 251 { |
| 222 int startOffset = 0; | 252 int startOffset = 0; |
| 223 int endOffset = textNode.length(); | 253 int endOffset = textNode.length(); |
| 224 if (m_start.text() == textNode) | 254 if (m_start.text() == textNode) |
| 225 startOffset = m_start.offset(); | 255 startOffset = m_start.offset(); |
| 226 if (m_end.text() == textNode) | 256 if (m_end.text() == textNode) |
| 227 endOffset = m_end.offset(); | 257 endOffset = m_end.offset(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 247 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNod
e() == node.parentNode() | 277 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNod
e() == node.parentNode() |
| 248 && m_wrappingStyle && m_wrappingStyle->style(); | 278 && m_wrappingStyle && m_wrappingStyle->style(); |
| 249 } | 279 } |
| 250 | 280 |
| 251 bool StyledMarkupAccumulator::shouldAnnotate() const | 281 bool StyledMarkupAccumulator::shouldAnnotate() const |
| 252 { | 282 { |
| 253 return m_shouldAnnotate == AnnotateForInterchange; | 283 return m_shouldAnnotate == AnnotateForInterchange; |
| 254 } | 284 } |
| 255 | 285 |
| 256 } // namespace blink | 286 } // namespace blink |
| OLD | NEW |