| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 void StyledMarkupAccumulator::appendEndMarkup(StringBuilder& result, const Eleme
nt& element) | 92 void StyledMarkupAccumulator::appendEndMarkup(StringBuilder& result, const Eleme
nt& element) |
| 93 { | 93 { |
| 94 m_formatter.appendEndMarkup(result, element); | 94 m_formatter.appendEndMarkup(result, element); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void StyledMarkupAccumulator::appendText(Text& text) | 97 void StyledMarkupAccumulator::appendText(Text& text) |
| 98 { | 98 { |
| 99 appendText(m_result, text); | 99 if (text.parentElement() && text.parentElement()->tagQName() == textareaTag)
{ |
| 100 appendText(m_result, text); |
| 101 return; |
| 102 } |
| 103 appendTextWithInlineStyle(m_result, text); |
| 100 } | 104 } |
| 101 | 105 |
| 102 void StyledMarkupAccumulator::appendText(StringBuilder& out, Text& text) | 106 void StyledMarkupAccumulator::appendText(StringBuilder& out, Text& text) |
| 103 { | 107 { |
| 104 const bool parentIsTextarea = text.parentElement() && text.parentElement()->
tagQName() == textareaTag; | 108 const String& str = text.data(); |
| 105 const bool wrappingSpan = shouldApplyWrappingStyle(text) && !parentIsTextare
a; | 109 unsigned length = str.length(); |
| 110 unsigned start = 0; |
| 111 if (m_end.isNotNull()) { |
| 112 if (text == m_end.text()) |
| 113 length = m_end.offset(); |
| 114 } |
| 115 if (m_start.isNotNull()) { |
| 116 if (text == m_start.text()) { |
| 117 start = m_start.offset(); |
| 118 length -= start; |
| 119 } |
| 120 } |
| 121 MarkupFormatter::appendCharactersReplacingEntities(out, str, start, length,
m_formatter.entityMaskForText(text)); |
| 122 } |
| 123 |
| 124 void StyledMarkupAccumulator::appendTextWithInlineStyle(StringBuilder& out, Text
& text) |
| 125 { |
| 126 const bool wrappingSpan = shouldApplyWrappingStyle(text); |
| 106 if (wrappingSpan) { | 127 if (wrappingSpan) { |
| 107 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = m_wrappingStyle->copy()
; | 128 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = m_wrappingStyle->copy()
; |
| 108 // FIXME: <rdar://problem/5371536> Style rules that match pasted content
can change it's appearance | 129 // FIXME: <rdar://problem/5371536> Style rules that match pasted content
can change it's appearance |
| 109 // Make sure spans are inline style in paste side e.g. span { display: b
lock }. | 130 // Make sure spans are inline style in paste side e.g. span { display: b
lock }. |
| 110 wrappingStyle->forceInline(); | 131 wrappingStyle->forceInline(); |
| 111 // FIXME: Should this be included in forceInline? | 132 // FIXME: Should this be included in forceInline? |
| 112 wrappingStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone); | 133 wrappingStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone); |
| 113 | 134 |
| 114 // wrappingStyleForSerialization should have removed -webkit-text-decora
tions-in-effect | 135 // wrappingStyleForSerialization should have removed -webkit-text-decora
tions-in-effect |
| 115 ASSERT(propertyMissingOrEqualToNone(wrappingStyle->style(), CSSPropertyW
ebkitTextDecorationsInEffect)); | 136 ASSERT(propertyMissingOrEqualToNone(wrappingStyle->style(), CSSPropertyW
ebkitTextDecorationsInEffect)); |
| 116 ASSERT(m_document); | 137 ASSERT(m_document); |
| 117 | 138 |
| 118 out.appendLiteral("<span style=\""); | 139 out.appendLiteral("<span style=\""); |
| 119 MarkupFormatter::appendAttributeValue(out, wrappingStyle->style()->asTex
t(), m_document->isHTMLDocument()); | 140 MarkupFormatter::appendAttributeValue(out, wrappingStyle->style()->asTex
t(), m_document->isHTMLDocument()); |
| 120 out.appendLiteral("\">"); | 141 out.appendLiteral("\">"); |
| 121 } | 142 } |
| 122 | 143 |
| 123 if (!shouldAnnotate() || parentIsTextarea) { | 144 if (!shouldAnnotate()) { |
| 124 const String& str = text.data(); | 145 appendText(out, text); |
| 125 unsigned length = str.length(); | |
| 126 unsigned start = 0; | |
| 127 if (m_end.isNotNull()) { | |
| 128 if (text == m_end.text()) | |
| 129 length = m_end.offset(); | |
| 130 } | |
| 131 if (m_start.isNotNull()) { | |
| 132 if (text == m_start.text()) { | |
| 133 start = m_start.offset(); | |
| 134 length -= start; | |
| 135 } | |
| 136 } | |
| 137 MarkupFormatter::appendCharactersReplacingEntities(out, str, start, leng
th, m_formatter.entityMaskForText(text)); | |
| 138 } else { | 146 } else { |
| 139 const bool useRenderedText = !enclosingElementWithTag(firstPositionInNod
e(&text), selectTag); | 147 const bool useRenderedText = !enclosingElementWithTag(firstPositionInNod
e(&text), selectTag); |
| 140 String content = useRenderedText ? renderedText(text) : stringValueForRa
nge(text); | 148 String content = useRenderedText ? renderedText(text) : stringValueForRa
nge(text); |
| 141 StringBuilder buffer; | 149 StringBuilder buffer; |
| 142 MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, c
ontent.length(), EntityMaskInPCDATA); | 150 MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, c
ontent.length(), EntityMaskInPCDATA); |
| 143 out.append(convertHTMLTextToInterchangeFormat(buffer.toString(), text)); | 151 out.append(convertHTMLTextToInterchangeFormat(buffer.toString(), text)); |
| 144 } | 152 } |
| 145 | 153 |
| 146 if (wrappingSpan) | 154 if (wrappingSpan) |
| 147 out.append("</span>"); | 155 out.append("</span>"); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 m_reversedPrecedingMarkup.append(str); | 283 m_reversedPrecedingMarkup.append(str); |
| 276 } | 284 } |
| 277 | 285 |
| 278 void StyledMarkupAccumulator::appendInterchangeNewline() | 286 void StyledMarkupAccumulator::appendInterchangeNewline() |
| 279 { | 287 { |
| 280 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); | 288 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); |
| 281 m_result.append(interchangeNewlineString); | 289 m_result.append(interchangeNewlineString); |
| 282 } | 290 } |
| 283 | 291 |
| 284 } // namespace blink | 292 } // namespace blink |
| OLD | NEW |