| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 MarkupFormatter::appendCharactersReplacingEntities(m_result, str, start, len
gth, m_formatter.entityMaskForText(text)); | 93 MarkupFormatter::appendCharactersReplacingEntities(m_result, str, start, len
gth, m_formatter.entityMaskForText(text)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void StyledMarkupAccumulator::appendTextWithInlineStyle(Text& text, EditingStyle
* inlineStyle) | 96 void StyledMarkupAccumulator::appendTextWithInlineStyle(Text& text, EditingStyle
* inlineStyle) |
| 97 { | 97 { |
| 98 if (inlineStyle) { | 98 if (inlineStyle) { |
| 99 // wrappingStyleForAnnotatedSerialization should have removed -webkit-te
xt-decorations-in-effect | 99 // wrappingStyleForAnnotatedSerialization should have removed -webkit-te
xt-decorations-in-effect |
| 100 DCHECK(!shouldAnnotate() || propertyMissingOrEqualToNone(inlineStyle->st
yle(), CSSPropertyWebkitTextDecorationsInEffect)); | 100 DCHECK(!shouldAnnotate() || propertyMissingOrEqualToNone(inlineStyle->st
yle(), CSSPropertyWebkitTextDecorationsInEffect)); |
| 101 DCHECK(m_document); | 101 DCHECK(m_document); |
| 102 | 102 |
| 103 m_result.appendLiteral("<span style=\""); | 103 m_result.append("<span style=\""); |
| 104 MarkupFormatter::appendAttributeValue(m_result, inlineStyle->style()->as
Text(), m_document->isHTMLDocument()); | 104 MarkupFormatter::appendAttributeValue(m_result, inlineStyle->style()->as
Text(), m_document->isHTMLDocument()); |
| 105 m_result.appendLiteral("\">"); | 105 m_result.append("\">"); |
| 106 } | 106 } |
| 107 if (!shouldAnnotate()) { | 107 if (!shouldAnnotate()) { |
| 108 appendText(text); | 108 appendText(text); |
| 109 } else { | 109 } else { |
| 110 const bool useRenderedText = !enclosingElementWithTag(Position::firstPos
itionInNode(&text), selectTag); | 110 const bool useRenderedText = !enclosingElementWithTag(Position::firstPos
itionInNode(&text), selectTag); |
| 111 String content = useRenderedText ? renderedText(text) : stringValueForRa
nge(text); | 111 String content = useRenderedText ? renderedText(text) : stringValueForRa
nge(text); |
| 112 StringBuilder buffer; | 112 StringBuilder buffer; |
| 113 MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, c
ontent.length(), EntityMaskInPCDATA); | 113 MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, c
ontent.length(), EntityMaskInPCDATA); |
| 114 m_result.append(convertHTMLTextToInterchangeFormat(buffer.toString(), te
xt)); | 114 m_result.append(convertHTMLTextToInterchangeFormat(buffer.toString(), te
xt)); |
| 115 } | 115 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 127 const bool documentIsHTML = element.document().isHTMLDocument(); | 127 const bool documentIsHTML = element.document().isHTMLDocument(); |
| 128 m_formatter.appendOpenTag(out, element, nullptr); | 128 m_formatter.appendOpenTag(out, element, nullptr); |
| 129 AttributeCollection attributes = element.attributes(); | 129 AttributeCollection attributes = element.attributes(); |
| 130 for (const auto& attribute : attributes) { | 130 for (const auto& attribute : attributes) { |
| 131 // We'll handle the style attribute separately, below. | 131 // We'll handle the style attribute separately, below. |
| 132 if (attribute.name() == styleAttr) | 132 if (attribute.name() == styleAttr) |
| 133 continue; | 133 continue; |
| 134 m_formatter.appendAttribute(out, element, attribute, nullptr); | 134 m_formatter.appendAttribute(out, element, attribute, nullptr); |
| 135 } | 135 } |
| 136 if (style && !style->isEmpty()) { | 136 if (style && !style->isEmpty()) { |
| 137 out.appendLiteral(" style=\""); | 137 out.append(" style=\""); |
| 138 MarkupFormatter::appendAttributeValue(out, style->style()->asText(), doc
umentIsHTML); | 138 MarkupFormatter::appendAttributeValue(out, style->style()->asText(), doc
umentIsHTML); |
| 139 out.append('\"'); | 139 out.append('\"'); |
| 140 } | 140 } |
| 141 m_formatter.appendCloseTag(out, element); | 141 m_formatter.appendCloseTag(out, element); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void StyledMarkupAccumulator::appendElement(const Element& element) | 144 void StyledMarkupAccumulator::appendElement(const Element& element) |
| 145 { | 145 { |
| 146 appendElement(m_result, element); | 146 appendElement(m_result, element); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void StyledMarkupAccumulator::appendElement(StringBuilder& out, const Element& e
lement) | 149 void StyledMarkupAccumulator::appendElement(StringBuilder& out, const Element& e
lement) |
| 150 { | 150 { |
| 151 m_formatter.appendOpenTag(out, element, nullptr); | 151 m_formatter.appendOpenTag(out, element, nullptr); |
| 152 AttributeCollection attributes = element.attributes(); | 152 AttributeCollection attributes = element.attributes(); |
| 153 for (const auto& attribute : attributes) | 153 for (const auto& attribute : attributes) |
| 154 m_formatter.appendAttribute(out, element, attribute, nullptr); | 154 m_formatter.appendAttribute(out, element, attribute, nullptr); |
| 155 m_formatter.appendCloseTag(out, element); | 155 m_formatter.appendCloseTag(out, element); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void StyledMarkupAccumulator::wrapWithStyleNode(StylePropertySet* style) | 158 void StyledMarkupAccumulator::wrapWithStyleNode(StylePropertySet* style) |
| 159 { | 159 { |
| 160 // wrappingStyleForSerialization should have removed -webkit-text-decoration
s-in-effect | 160 // wrappingStyleForSerialization should have removed -webkit-text-decoration
s-in-effect |
| 161 DCHECK(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI
nEffect)); | 161 DCHECK(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI
nEffect)); |
| 162 DCHECK(m_document); | 162 DCHECK(m_document); |
| 163 | 163 |
| 164 StringBuilder openTag; | 164 StringBuilder openTag; |
| 165 openTag.appendLiteral("<div style=\""); | 165 openTag.append("<div style=\""); |
| 166 MarkupFormatter::appendAttributeValue(openTag, style->asText(), m_document->
isHTMLDocument()); | 166 MarkupFormatter::appendAttributeValue(openTag, style->asText(), m_document->
isHTMLDocument()); |
| 167 openTag.appendLiteral("\">"); | 167 openTag.append("\">"); |
| 168 m_reversedPrecedingMarkup.append(openTag.toString()); | 168 m_reversedPrecedingMarkup.append(openTag.toString()); |
| 169 | 169 |
| 170 m_result.append("</div>"); | 170 m_result.append("</div>"); |
| 171 } | 171 } |
| 172 | 172 |
| 173 String StyledMarkupAccumulator::takeResults() | 173 String StyledMarkupAccumulator::takeResults() |
| 174 { | 174 { |
| 175 StringBuilder result; | 175 StringBuilder result; |
| 176 result.reserveCapacity(totalLength(m_reversedPrecedingMarkup) + m_result.len
gth()); | 176 result.reserveCapacity(totalLength(m_reversedPrecedingMarkup) + m_result.len
gth()); |
| 177 | 177 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 m_reversedPrecedingMarkup.append(str); | 218 m_reversedPrecedingMarkup.append(str); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void StyledMarkupAccumulator::appendInterchangeNewline() | 221 void StyledMarkupAccumulator::appendInterchangeNewline() |
| 222 { | 222 { |
| 223 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); | 223 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); |
| 224 m_result.append(interchangeNewlineString); | 224 m_result.append(interchangeNewlineString); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // namespace blink | 227 } // namespace blink |
| OLD | NEW |