Chromium Code Reviews| 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) { |
|
yosin_UTC9
2015/06/12 12:05:17
Just FYI, for checking text in TEXTAREA, we should
| |
| 100 appendText(m_result, text); | |
| 101 return; | |
| 102 } | |
| 103 appendTextWithWrappingStyle(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 { |
| 108 const String& str = text.data(); | |
| 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::appendTextWithWrappingStyle(StringBuilder& out, Te xt& text) | |
| 125 { | |
| 104 const bool parentIsTextarea = text.parentElement() && text.parentElement()-> tagQName() == textareaTag; | 126 const bool parentIsTextarea = text.parentElement() && text.parentElement()-> tagQName() == textareaTag; |
|
yosin_UTC9
2015/06/12 11:49:30
it seems that when |appendTextWithWrappingStyle()|
hajimehoshi
2015/06/16 06:32:06
Done.
| |
| 105 const bool wrappingSpan = shouldApplyWrappingStyle(text) && !parentIsTextare a; | 127 const bool wrappingSpan = shouldApplyWrappingStyle(text) && !parentIsTextare a; |
| 106 if (wrappingSpan) { | 128 if (wrappingSpan) { |
| 107 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = m_wrappingStyle->copy() ; | 129 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = m_wrappingStyle->copy() ; |
| 108 // FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance | 130 // 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 }. | 131 // Make sure spans are inline style in paste side e.g. span { display: b lock }. |
| 110 wrappingStyle->forceInline(); | 132 wrappingStyle->forceInline(); |
| 111 // FIXME: Should this be included in forceInline? | 133 // FIXME: Should this be included in forceInline? |
| 112 wrappingStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone); | 134 wrappingStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone); |
| 113 | 135 |
| 114 // wrappingStyleForSerialization should have removed -webkit-text-decora tions-in-effect | 136 // wrappingStyleForSerialization should have removed -webkit-text-decora tions-in-effect |
| 115 ASSERT(propertyMissingOrEqualToNone(wrappingStyle->style(), CSSPropertyW ebkitTextDecorationsInEffect)); | 137 ASSERT(propertyMissingOrEqualToNone(wrappingStyle->style(), CSSPropertyW ebkitTextDecorationsInEffect)); |
| 116 ASSERT(m_document); | 138 ASSERT(m_document); |
| 117 | 139 |
| 118 out.appendLiteral("<span style=\""); | 140 out.appendLiteral("<span style=\""); |
| 119 MarkupFormatter::appendAttributeValue(out, wrappingStyle->style()->asTex t(), m_document->isHTMLDocument()); | 141 MarkupFormatter::appendAttributeValue(out, wrappingStyle->style()->asTex t(), m_document->isHTMLDocument()); |
| 120 out.appendLiteral("\">"); | 142 out.appendLiteral("\">"); |
| 121 } | 143 } |
| 122 | 144 |
| 123 if (!shouldAnnotate() || parentIsTextarea) { | 145 if (!shouldAnnotate() || parentIsTextarea) { |
| 124 const String& str = text.data(); | 146 appendText(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 { | 147 } else { |
| 139 const bool useRenderedText = !enclosingElementWithTag(firstPositionInNod e(&text), selectTag); | 148 const bool useRenderedText = !enclosingElementWithTag(firstPositionInNod e(&text), selectTag); |
| 140 String content = useRenderedText ? renderedText(text) : stringValueForRa nge(text); | 149 String content = useRenderedText ? renderedText(text) : stringValueForRa nge(text); |
| 141 StringBuilder buffer; | 150 StringBuilder buffer; |
| 142 MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, c ontent.length(), EntityMaskInPCDATA); | 151 MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, c ontent.length(), EntityMaskInPCDATA); |
| 143 out.append(convertHTMLTextToInterchangeFormat(buffer.toString(), text)); | 152 out.append(convertHTMLTextToInterchangeFormat(buffer.toString(), text)); |
| 144 } | 153 } |
| 145 | 154 |
| 146 if (wrappingSpan) | 155 if (wrappingSpan) |
| 147 out.append("</span>"); | 156 out.append("</span>"); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 m_reversedPrecedingMarkup.append(str); | 284 m_reversedPrecedingMarkup.append(str); |
| 276 } | 285 } |
| 277 | 286 |
| 278 void StyledMarkupAccumulator::appendInterchangeNewline() | 287 void StyledMarkupAccumulator::appendInterchangeNewline() |
| 279 { | 288 { |
| 280 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\"" AppleInterchangeNewline "\">")); | 289 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\"" AppleInterchangeNewline "\">")); |
| 281 m_result.append(interchangeNewlineString); | 290 m_result.append(interchangeNewlineString); |
| 282 } | 291 } |
| 283 | 292 |
| 284 } // namespace blink | 293 } // namespace blink |
| OLD | NEW |