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 |
3 * reserved. | |
3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. | 4 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. |
4 * Copyright (C) 2011 Igalia S.L. | 5 * Copyright (C) 2011 Igalia S.L. |
5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
6 * | 7 * |
7 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
9 * are met: | 10 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 11 * 1. Redistributions of source code must retain the above copyright |
11 * notice, this list of conditions and the following disclaimer. | 12 * notice, this list of conditions and the following disclaimer. |
12 * 2. Redistributions in binary form must reproduce the above copyright | 13 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 } | 92 } |
92 } | 93 } |
93 MarkupFormatter::appendCharactersReplacingEntities( | 94 MarkupFormatter::appendCharactersReplacingEntities( |
94 m_result, str, start, length, m_formatter.entityMaskForText(text)); | 95 m_result, str, start, length, m_formatter.entityMaskForText(text)); |
95 } | 96 } |
96 | 97 |
97 void StyledMarkupAccumulator::appendTextWithInlineStyle( | 98 void StyledMarkupAccumulator::appendTextWithInlineStyle( |
98 Text& text, | 99 Text& text, |
99 EditingStyle* inlineStyle) { | 100 EditingStyle* inlineStyle) { |
100 if (inlineStyle) { | 101 if (inlineStyle) { |
101 // wrappingStyleForAnnotatedSerialization should have removed -webkit-text-d ecorations-in-effect | 102 // wrappingStyleForAnnotatedSerialization should have removed |
103 // -webkit-text-decorations-in-effect | |
Nico
2016/10/06 03:26:21
nit: .
dcheng
2016/10/06 03:59:23
Done.
| |
102 DCHECK(!shouldAnnotate() || | 104 DCHECK(!shouldAnnotate() || |
103 propertyMissingOrEqualToNone( | 105 propertyMissingOrEqualToNone( |
104 inlineStyle->style(), CSSPropertyWebkitTextDecorationsInEffect)); | 106 inlineStyle->style(), CSSPropertyWebkitTextDecorationsInEffect)); |
105 DCHECK(m_document); | 107 DCHECK(m_document); |
106 | 108 |
107 m_result.append("<span style=\""); | 109 m_result.append("<span style=\""); |
108 MarkupFormatter::appendAttributeValue( | 110 MarkupFormatter::appendAttributeValue( |
109 m_result, inlineStyle->style()->asText(), m_document->isHTMLDocument()); | 111 m_result, inlineStyle->style()->asText(), m_document->isHTMLDocument()); |
110 m_result.append("\">"); | 112 m_result.append("\">"); |
111 } | 113 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 void StyledMarkupAccumulator::appendElement(StringBuilder& out, | 163 void StyledMarkupAccumulator::appendElement(StringBuilder& out, |
162 const Element& element) { | 164 const Element& element) { |
163 m_formatter.appendOpenTag(out, element, nullptr); | 165 m_formatter.appendOpenTag(out, element, nullptr); |
164 AttributeCollection attributes = element.attributes(); | 166 AttributeCollection attributes = element.attributes(); |
165 for (const auto& attribute : attributes) | 167 for (const auto& attribute : attributes) |
166 m_formatter.appendAttribute(out, element, attribute, nullptr); | 168 m_formatter.appendAttribute(out, element, attribute, nullptr); |
167 m_formatter.appendCloseTag(out, element); | 169 m_formatter.appendCloseTag(out, element); |
168 } | 170 } |
169 | 171 |
170 void StyledMarkupAccumulator::wrapWithStyleNode(StylePropertySet* style) { | 172 void StyledMarkupAccumulator::wrapWithStyleNode(StylePropertySet* style) { |
171 // wrappingStyleForSerialization should have removed -webkit-text-decorations- in-effect | 173 // wrappingStyleForSerialization should have removed |
174 // -webkit-text-decorations-in-effect | |
Nico
2016/10/06 03:26:21
nit: .
dcheng
2016/10/06 03:59:23
Done.
| |
172 DCHECK(propertyMissingOrEqualToNone( | 175 DCHECK(propertyMissingOrEqualToNone( |
173 style, CSSPropertyWebkitTextDecorationsInEffect)); | 176 style, CSSPropertyWebkitTextDecorationsInEffect)); |
174 DCHECK(m_document); | 177 DCHECK(m_document); |
175 | 178 |
176 StringBuilder openTag; | 179 StringBuilder openTag; |
177 openTag.append("<div style=\""); | 180 openTag.append("<div style=\""); |
178 MarkupFormatter::appendAttributeValue(openTag, style->asText(), | 181 MarkupFormatter::appendAttributeValue(openTag, style->asText(), |
179 m_document->isHTMLDocument()); | 182 m_document->isHTMLDocument()); |
180 openTag.append("\">"); | 183 openTag.append("\">"); |
181 m_reversedPrecedingMarkup.append(openTag.toString()); | 184 m_reversedPrecedingMarkup.append(openTag.toString()); |
182 | 185 |
183 m_result.append("</div>"); | 186 m_result.append("</div>"); |
184 } | 187 } |
185 | 188 |
186 String StyledMarkupAccumulator::takeResults() { | 189 String StyledMarkupAccumulator::takeResults() { |
187 StringBuilder result; | 190 StringBuilder result; |
188 result.reserveCapacity(totalLength(m_reversedPrecedingMarkup) + | 191 result.reserveCapacity(totalLength(m_reversedPrecedingMarkup) + |
189 m_result.length()); | 192 m_result.length()); |
190 | 193 |
191 for (size_t i = m_reversedPrecedingMarkup.size(); i > 0; --i) | 194 for (size_t i = m_reversedPrecedingMarkup.size(); i > 0; --i) |
192 result.append(m_reversedPrecedingMarkup[i - 1]); | 195 result.append(m_reversedPrecedingMarkup[i - 1]); |
193 | 196 |
194 result.append(m_result); | 197 result.append(m_result); |
195 | 198 |
196 // We remove '\0' characters because they are not visibly rendered to the user . | 199 // We remove '\0' characters because they are not visibly rendered to the |
200 // user. | |
197 return result.toString().replace(0, ""); | 201 return result.toString().replace(0, ""); |
198 } | 202 } |
199 | 203 |
200 String StyledMarkupAccumulator::renderedText(Text& textNode) { | 204 String StyledMarkupAccumulator::renderedText(Text& textNode) { |
201 int startOffset = 0; | 205 int startOffset = 0; |
202 int endOffset = textNode.length(); | 206 int endOffset = textNode.length(); |
203 if (m_start.text() == textNode) | 207 if (m_start.text() == textNode) |
204 startOffset = m_start.offset(); | 208 startOffset = m_start.offset(); |
205 if (m_end.text() == textNode) | 209 if (m_end.text() == textNode) |
206 endOffset = m_end.offset(); | 210 endOffset = m_end.offset(); |
(...skipping 21 matching lines...) Expand all Loading... | |
228 m_reversedPrecedingMarkup.append(str); | 232 m_reversedPrecedingMarkup.append(str); |
229 } | 233 } |
230 | 234 |
231 void StyledMarkupAccumulator::appendInterchangeNewline() { | 235 void StyledMarkupAccumulator::appendInterchangeNewline() { |
232 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, | 236 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, |
233 ("<br class=\"" AppleInterchangeNewline "\">")); | 237 ("<br class=\"" AppleInterchangeNewline "\">")); |
234 m_result.append(interchangeNewlineString); | 238 m_result.append(interchangeNewlineString); |
235 } | 239 } |
236 | 240 |
237 } // namespace blink | 241 } // namespace blink |
OLD | NEW |