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

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

Issue 1162113004: Refactoring: Change some functions in MarkupFormatter static (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/MarkupFormatter.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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 m_accumulator.appendOpenTag(out, element, 0); 153 m_accumulator.appendOpenTag(out, element, 0);
154 154
155 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA nnotate() || addDisplayInline); 155 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA nnotate() || addDisplayInline);
156 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp plyWrappingStyle(element); 156 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp plyWrappingStyle(element);
157 157
158 AttributeCollection attributes = element.attributes(); 158 AttributeCollection attributes = element.attributes();
159 for (const auto& attribute : attributes) { 159 for (const auto& attribute : attributes) {
160 // We'll handle the style attribute separately, below. 160 // We'll handle the style attribute separately, below.
161 if (attribute.name() == styleAttr && shouldOverrideStyleAttr) 161 if (attribute.name() == styleAttr && shouldOverrideStyleAttr)
162 continue; 162 continue;
163 m_accumulator.appendAttribute(out, element, attribute, 0); 163 m_accumulator.appendAttribute(out, element, attribute, nullptr);
164 } 164 }
165 165
166 if (shouldOverrideStyleAttr) { 166 if (shouldOverrideStyleAttr) {
167 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = nullptr; 167 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = nullptr;
168 168
169 if (shouldApplyWrappingStyle(element)) { 169 if (shouldApplyWrappingStyle(element)) {
170 newInlineStyle = m_wrappingStyle->copy(); 170 newInlineStyle = m_wrappingStyle->copy();
171 newInlineStyle->removePropertiesInElementDefaultStyle(&element); 171 newInlineStyle->removePropertiesInElementDefaultStyle(&element);
172 newInlineStyle->removeStyleConflictingWithStyleOfElement(&element); 172 newInlineStyle->removeStyleConflictingWithStyleOfElement(&element);
173 } else { 173 } else {
(...skipping 11 matching lines...) Expand all
185 newInlineStyle->forceInline(); 185 newInlineStyle->forceInline();
186 186
187 // If the node is not fully selected by the range, then we don't wan t to keep styles that affect its relationship to the nodes around it 187 // If the node is not fully selected by the range, then we don't wan t to keep styles that affect its relationship to the nodes around it
188 // only the ones that affect it and the nodes within it. 188 // only the ones that affect it and the nodes within it.
189 if (rangeFullySelectsNode == DoesNotFullySelectNode && newInlineStyl e->style()) 189 if (rangeFullySelectsNode == DoesNotFullySelectNode && newInlineStyl e->style())
190 newInlineStyle->style()->removeProperty(CSSPropertyFloat); 190 newInlineStyle->style()->removeProperty(CSSPropertyFloat);
191 } 191 }
192 192
193 if (!newInlineStyle->isEmpty()) { 193 if (!newInlineStyle->isEmpty()) {
194 out.appendLiteral(" style=\""); 194 out.appendLiteral(" style=\"");
195 m_accumulator.appendAttributeValue(out, newInlineStyle->style()->asT ext(), documentIsHTML); 195 MarkupFormatter::appendAttributeValue(out, newInlineStyle->style()-> asText(), documentIsHTML);
196 out.append('\"'); 196 out.append('\"');
197 } 197 }
198 } 198 }
199 199
200 m_accumulator.appendCloseTag(out, element); 200 m_accumulator.appendCloseTag(out, element);
201 } 201 }
202 202
203 void StyledMarkupAccumulator::appendStyleNodeOpenTag(StringBuilder& out, StylePr opertySet* style, bool isBlock) 203 void StyledMarkupAccumulator::appendStyleNodeOpenTag(StringBuilder& out, StylePr opertySet* style, bool isBlock)
204 { 204 {
205 // wrappingStyleForSerialization should have removed -webkit-text-decoration s-in-effect 205 // wrappingStyleForSerialization should have removed -webkit-text-decoration s-in-effect
206 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI nEffect)); 206 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI nEffect));
207 if (isBlock) 207 if (isBlock)
208 out.appendLiteral("<div style=\""); 208 out.appendLiteral("<div style=\"");
209 else 209 else
210 out.appendLiteral("<span style=\""); 210 out.appendLiteral("<span style=\"");
211 ASSERT(m_document); 211 ASSERT(m_document);
212 m_accumulator.appendAttributeValue(out, style->asText(), m_document->isHTMLD ocument()); 212 MarkupFormatter::appendAttributeValue(out, style->asText(), m_document->isHT MLDocument());
213 out.appendLiteral("\">"); 213 out.appendLiteral("\">");
214 } 214 }
215 215
216 void StyledMarkupAccumulator::wrapWithNode(ContainerNode& node, RangeFullySelect sNode rangeFullySelectsNode) 216 void StyledMarkupAccumulator::wrapWithNode(ContainerNode& node, RangeFullySelect sNode rangeFullySelectsNode)
217 { 217 {
218 StringBuilder markup; 218 StringBuilder markup;
219 if (node.isElementNode()) 219 if (node.isElementNode())
220 appendElement(markup, toElement(node), convertBlocksToInlines() && isBlo ck(&node), rangeFullySelectsNode); 220 appendElement(markup, toElement(node), convertBlocksToInlines() && isBlo ck(&node), rangeFullySelectsNode);
221 else 221 else
222 appendStartMarkup(markup, node); 222 appendStartMarkup(markup, node);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNod e() == node.parentNode() 277 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNod e() == node.parentNode()
278 && m_wrappingStyle && m_wrappingStyle->style(); 278 && m_wrappingStyle && m_wrappingStyle->style();
279 } 279 }
280 280
281 bool StyledMarkupAccumulator::shouldAnnotate() const 281 bool StyledMarkupAccumulator::shouldAnnotate() const
282 { 282 {
283 return m_shouldAnnotate == AnnotateForInterchange; 283 return m_shouldAnnotate == AnnotateForInterchange;
284 } 284 }
285 285
286 } // namespace blink 286 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/MarkupFormatter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698