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

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

Issue 1159033006: Refactoring: Replace boolean parameters with enum classes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename values 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
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 MarkupAccumulator::appendCharactersReplacingEntities(buffer, content, 0, content.length(), EntityMaskInPCDATA); 136 MarkupAccumulator::appendCharactersReplacingEntities(buffer, content, 0, content.length(), EntityMaskInPCDATA);
137 out.append(convertHTMLTextToInterchangeFormat(buffer.toString(), text)); 137 out.append(convertHTMLTextToInterchangeFormat(buffer.toString(), text));
138 } 138 }
139 139
140 if (wrappingSpan) 140 if (wrappingSpan)
141 out.append(styleNodeCloseTag(false)); 141 out.append(styleNodeCloseTag(false));
142 } 142 }
143 143
144 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element , Namespaces*) 144 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element , Namespaces*)
145 { 145 {
146 appendElement(out, element, false, DoesFullySelectNode); 146 appendElement(out, element, AddDisplayInline::DoesNotAdd, RangeFullySelectsN ode::DoesSelect);
147 } 147 }
148 148
149 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element , bool addDisplayInline, StyledMarkupAccumulator::RangeFullySelectsNode rangeFul lySelectsNode) 149 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element , AddDisplayInline addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode )
150 { 150 {
151 const bool documentIsHTML = element.document().isHTMLDocument(); 151 const bool documentIsHTML = element.document().isHTMLDocument();
152 m_accumulator.appendOpenTag(out, element, 0); 152 m_accumulator.appendOpenTag(out, element, 0);
153 153
154 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA nnotate() || addDisplayInline); 154 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA nnotate() || addDisplayInline == AddDisplayInline::DoesAdd);
155 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp plyWrappingStyle(element); 155 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp plyWrappingStyle(element);
156 156
157 AttributeCollection attributes = element.attributes(); 157 AttributeCollection attributes = element.attributes();
158 for (const auto& attribute : attributes) { 158 for (const auto& attribute : attributes) {
159 // We'll handle the style attribute separately, below. 159 // We'll handle the style attribute separately, below.
160 if (attribute.name() == styleAttr && shouldOverrideStyleAttr) 160 if (attribute.name() == styleAttr && shouldOverrideStyleAttr)
161 continue; 161 continue;
162 m_accumulator.appendAttribute(out, element, attribute, 0); 162 m_accumulator.appendAttribute(out, element, attribute, 0);
163 } 163 }
164 164
165 if (shouldOverrideStyleAttr) { 165 if (shouldOverrideStyleAttr) {
166 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = nullptr; 166 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = nullptr;
167 167
168 if (shouldApplyWrappingStyle(element)) { 168 if (shouldApplyWrappingStyle(element)) {
169 newInlineStyle = m_wrappingStyle->copy(); 169 newInlineStyle = m_wrappingStyle->copy();
170 newInlineStyle->removePropertiesInElementDefaultStyle(&element); 170 newInlineStyle->removePropertiesInElementDefaultStyle(&element);
171 newInlineStyle->removeStyleConflictingWithStyleOfElement(&element); 171 newInlineStyle->removeStyleConflictingWithStyleOfElement(&element);
172 } else { 172 } else {
173 newInlineStyle = EditingStyle::create(); 173 newInlineStyle = EditingStyle::create();
174 } 174 }
175 175
176 if (element.isStyledElement() && element.inlineStyle()) 176 if (element.isStyledElement() && element.inlineStyle())
177 newInlineStyle->overrideWithStyle(element.inlineStyle()); 177 newInlineStyle->overrideWithStyle(element.inlineStyle());
178 178
179 if (shouldAnnotateOrForceInline) { 179 if (shouldAnnotateOrForceInline) {
180 if (shouldAnnotate()) 180 if (shouldAnnotate())
181 newInlineStyle->mergeStyleFromRulesForSerialization(&toHTMLEleme nt(element)); 181 newInlineStyle->mergeStyleFromRulesForSerialization(&toHTMLEleme nt(element));
182 182
183 if (addDisplayInline) 183 if (addDisplayInline == AddDisplayInline::DoesAdd)
184 newInlineStyle->forceInline(); 184 newInlineStyle->forceInline();
185 185
186 // 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 186 // 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 // only the ones that affect it and the nodes within it. 187 // only the ones that affect it and the nodes within it.
188 if (rangeFullySelectsNode == DoesNotFullySelectNode && newInlineStyl e->style()) 188 if (rangeFullySelectsNode == RangeFullySelectsNode::DoesNotSelect && newInlineStyle->style())
189 newInlineStyle->style()->removeProperty(CSSPropertyFloat); 189 newInlineStyle->style()->removeProperty(CSSPropertyFloat);
190 } 190 }
191 191
192 if (!newInlineStyle->isEmpty()) { 192 if (!newInlineStyle->isEmpty()) {
193 out.appendLiteral(" style=\""); 193 out.appendLiteral(" style=\"");
194 m_accumulator.appendAttributeValue(out, newInlineStyle->style()->asT ext(), documentIsHTML); 194 m_accumulator.appendAttributeValue(out, newInlineStyle->style()->asT ext(), documentIsHTML);
195 out.append('\"'); 195 out.append('\"');
196 } 196 }
197 } 197 }
198 198
199 m_accumulator.appendCloseTag(out, element); 199 m_accumulator.appendCloseTag(out, element);
200 } 200 }
201 201
202 void StyledMarkupAccumulator::appendStyleNodeOpenTag(StringBuilder& out, StylePr opertySet* style, bool isBlock) 202 void StyledMarkupAccumulator::appendStyleNodeOpenTag(StringBuilder& out, StylePr opertySet* style, StyleTagType isBlock)
203 { 203 {
204 // wrappingStyleForSerialization should have removed -webkit-text-decoration s-in-effect 204 // wrappingStyleForSerialization should have removed -webkit-text-decoration s-in-effect
205 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI nEffect)); 205 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI nEffect));
206 if (isBlock) 206 if (isBlock == StyleTagType::Block)
207 out.appendLiteral("<div style=\""); 207 out.appendLiteral("<div style=\"");
208 else 208 else
209 out.appendLiteral("<span style=\""); 209 out.appendLiteral("<span style=\"");
210 ASSERT(m_document); 210 ASSERT(m_document);
211 m_accumulator.appendAttributeValue(out, style->asText(), m_document->isHTMLD ocument()); 211 m_accumulator.appendAttributeValue(out, style->asText(), m_document->isHTMLD ocument());
212 out.appendLiteral("\">"); 212 out.appendLiteral("\">");
213 } 213 }
214 214
215 void StyledMarkupAccumulator::concatenateMarkup(StringBuilder& result) const 215 void StyledMarkupAccumulator::concatenateMarkup(StringBuilder& result) const
216 { 216 {
(...skipping 30 matching lines...) Expand all
247 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNod e() == node.parentNode() 247 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNod e() == node.parentNode()
248 && m_wrappingStyle && m_wrappingStyle->style(); 248 && m_wrappingStyle && m_wrappingStyle->style();
249 } 249 }
250 250
251 bool StyledMarkupAccumulator::shouldAnnotate() const 251 bool StyledMarkupAccumulator::shouldAnnotate() const
252 { 252 {
253 return m_shouldAnnotate == AnnotateForInterchange; 253 return m_shouldAnnotate == AnnotateForInterchange;
254 } 254 }
255 255
256 } // namespace blink 256 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/StyledMarkupAccumulator.h ('k') | Source/core/editing/StyledMarkupSerializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698