Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: Source/core/editing/StyledMarkupAccumulator.cpp

Issue 1183363003: Refactoring: Remove first parameters from StyledMarkupAccumulator::appendText* (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/StyledMarkupAccumulator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 void StyledMarkupAccumulator::appendEndTag(const Element& element) 69 void StyledMarkupAccumulator::appendEndTag(const Element& element)
70 { 70 {
71 appendEndMarkup(m_result, element); 71 appendEndMarkup(m_result, element);
72 } 72 }
73 73
74 void StyledMarkupAccumulator::appendStartMarkup(Node& node) 74 void StyledMarkupAccumulator::appendStartMarkup(Node& node)
75 { 75 {
76 switch (node.nodeType()) { 76 switch (node.nodeType()) {
77 case Node::TEXT_NODE: 77 case Node::TEXT_NODE: {
78 appendText(toText(node)); 78 Text& text = toText(node);
79 if (text.parentElement() && text.parentElement()->tagQName() == textarea Tag) {
80 appendText(text);
81 break;
82 }
83 appendTextWithInlineStyle(text);
79 break; 84 break;
85 }
80 case Node::ELEMENT_NODE: { 86 case Node::ELEMENT_NODE: {
81 Element& element = toElement(node); 87 Element& element = toElement(node);
82 RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyle(element); 88 RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyle(element);
83 appendElement(element, style); 89 appendElement(element, style);
84 break; 90 break;
85 } 91 }
86 default: 92 default:
87 m_formatter.appendStartMarkup(m_result, node, nullptr); 93 m_formatter.appendStartMarkup(m_result, node, nullptr);
88 break; 94 break;
89 } 95 }
90 } 96 }
91 97
92 void StyledMarkupAccumulator::appendEndMarkup(StringBuilder& result, const Eleme nt& element) 98 void StyledMarkupAccumulator::appendEndMarkup(StringBuilder& result, const Eleme nt& element)
93 { 99 {
94 m_formatter.appendEndMarkup(result, element); 100 m_formatter.appendEndMarkup(result, element);
95 } 101 }
96 102
97 void StyledMarkupAccumulator::appendText(Text& text) 103 void StyledMarkupAccumulator::appendText(Text& text)
98 { 104 {
99 if (text.parentElement() && text.parentElement()->tagQName() == textareaTag) {
100 appendText(m_result, text);
101 return;
102 }
103 appendTextWithInlineStyle(m_result, text);
104 }
105
106 void StyledMarkupAccumulator::appendText(StringBuilder& out, Text& text)
107 {
108 const String& str = text.data(); 105 const String& str = text.data();
109 unsigned length = str.length(); 106 unsigned length = str.length();
110 unsigned start = 0; 107 unsigned start = 0;
111 if (m_end.isNotNull()) { 108 if (m_end.isNotNull()) {
112 if (text == m_end.text()) 109 if (text == m_end.text())
113 length = m_end.offset(); 110 length = m_end.offset();
114 } 111 }
115 if (m_start.isNotNull()) { 112 if (m_start.isNotNull()) {
116 if (text == m_start.text()) { 113 if (text == m_start.text()) {
117 start = m_start.offset(); 114 start = m_start.offset();
118 length -= start; 115 length -= start;
119 } 116 }
120 } 117 }
121 MarkupFormatter::appendCharactersReplacingEntities(out, str, start, length, m_formatter.entityMaskForText(text)); 118 MarkupFormatter::appendCharactersReplacingEntities(m_result, str, start, len gth, m_formatter.entityMaskForText(text));
122 } 119 }
123 120
124 void StyledMarkupAccumulator::appendTextWithInlineStyle(StringBuilder& out, Text & text) 121 void StyledMarkupAccumulator::appendTextWithInlineStyle(Text& text)
125 { 122 {
126 const bool wrappingSpan = shouldApplyWrappingStyle(text); 123 const bool wrappingSpan = shouldApplyWrappingStyle(text);
127 if (wrappingSpan) { 124 if (wrappingSpan) {
128 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = m_wrappingStyle->copy() ; 125 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = m_wrappingStyle->copy() ;
129 // FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance 126 // FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance
130 // Make sure spans are inline style in paste side e.g. span { display: b lock }. 127 // Make sure spans are inline style in paste side e.g. span { display: b lock }.
131 wrappingStyle->forceInline(); 128 wrappingStyle->forceInline();
132 // FIXME: Should this be included in forceInline? 129 // FIXME: Should this be included in forceInline?
133 wrappingStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone); 130 wrappingStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone);
134 131
135 // wrappingStyleForSerialization should have removed -webkit-text-decora tions-in-effect 132 // wrappingStyleForSerialization should have removed -webkit-text-decora tions-in-effect
136 ASSERT(propertyMissingOrEqualToNone(wrappingStyle->style(), CSSPropertyW ebkitTextDecorationsInEffect)); 133 ASSERT(propertyMissingOrEqualToNone(wrappingStyle->style(), CSSPropertyW ebkitTextDecorationsInEffect));
137 ASSERT(m_document); 134 ASSERT(m_document);
138 135
139 out.appendLiteral("<span style=\""); 136 m_result.appendLiteral("<span style=\"");
140 MarkupFormatter::appendAttributeValue(out, wrappingStyle->style()->asTex t(), m_document->isHTMLDocument()); 137 MarkupFormatter::appendAttributeValue(m_result, wrappingStyle->style()-> asText(), m_document->isHTMLDocument());
141 out.appendLiteral("\">"); 138 m_result.appendLiteral("\">");
142 } 139 }
143 140
144 if (!shouldAnnotate()) { 141 if (!shouldAnnotate()) {
145 appendText(out, text); 142 appendText(text);
146 } else { 143 } else {
147 const bool useRenderedText = !enclosingElementWithTag(firstPositionInNod e(&text), selectTag); 144 const bool useRenderedText = !enclosingElementWithTag(firstPositionInNod e(&text), selectTag);
148 String content = useRenderedText ? renderedText(text) : stringValueForRa nge(text); 145 String content = useRenderedText ? renderedText(text) : stringValueForRa nge(text);
149 StringBuilder buffer; 146 StringBuilder buffer;
150 MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, c ontent.length(), EntityMaskInPCDATA); 147 MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, c ontent.length(), EntityMaskInPCDATA);
151 out.append(convertHTMLTextToInterchangeFormat(buffer.toString(), text)); 148 m_result.append(convertHTMLTextToInterchangeFormat(buffer.toString(), te xt));
152 } 149 }
153 150
154 if (wrappingSpan) 151 if (wrappingSpan)
155 out.append("</span>"); 152 m_result.append("</span>");
156 } 153 }
157 154
158 void StyledMarkupAccumulator::appendElement(const Element& element, PassRefPtrWi llBeRawPtr<EditingStyle> style) 155 void StyledMarkupAccumulator::appendElement(const Element& element, PassRefPtrWi llBeRawPtr<EditingStyle> style)
159 { 156 {
160 if ((element.isHTMLElement() && shouldAnnotate()) || shouldApplyWrappingStyl e(element)) { 157 if ((element.isHTMLElement() && shouldAnnotate()) || shouldApplyWrappingStyl e(element)) {
161 appendElementWithInlineStyle(m_result, element, style); 158 appendElementWithInlineStyle(m_result, element, style);
162 return; 159 return;
163 } 160 }
164 appendElement(m_result, element); 161 appendElement(m_result, element);
165 } 162 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 m_reversedPrecedingMarkup.append(str); 280 m_reversedPrecedingMarkup.append(str);
284 } 281 }
285 282
286 void StyledMarkupAccumulator::appendInterchangeNewline() 283 void StyledMarkupAccumulator::appendInterchangeNewline()
287 { 284 {
288 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\"" AppleInterchangeNewline "\">")); 285 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\"" AppleInterchangeNewline "\">"));
289 m_result.append(interchangeNewlineString); 286 m_result.append(interchangeNewlineString);
290 } 287 }
291 288
292 } // namespace blink 289 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/StyledMarkupAccumulator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698