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

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

Issue 1180653005: Refactoring: Remove addDisplayInline parameter of createInlineStyle (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tkent's review 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 61
62 void StyledMarkupAccumulator::appendStartMarkup(StringBuilder& result, Node& nod e) 62 void StyledMarkupAccumulator::appendStartMarkup(StringBuilder& result, Node& nod e)
63 { 63 {
64 switch (node.nodeType()) { 64 switch (node.nodeType()) {
65 case Node::TEXT_NODE: 65 case Node::TEXT_NODE:
66 appendText(toText(node)); 66 appendText(toText(node));
67 break; 67 break;
68 case Node::ELEMENT_NODE: { 68 case Node::ELEMENT_NODE: {
69 Element& element = toElement(node); 69 Element& element = toElement(node);
70 RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyle(element, fals e); 70 RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyle(element);
71 appendElement(element, style); 71 appendElement(element, style);
72 break; 72 break;
73 } 73 }
74 default: 74 default:
75 m_formatter.appendStartMarkup(result, node, nullptr); 75 m_formatter.appendStartMarkup(result, node, nullptr);
76 break; 76 break;
77 } 77 }
78 } 78 }
79 79
80 void StyledMarkupAccumulator::appendEndMarkup(StringBuilder& result, const Eleme nt& element) 80 void StyledMarkupAccumulator::appendEndMarkup(StringBuilder& result, const Eleme nt& element)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 if (wrappingSpan) 134 if (wrappingSpan)
135 out.append("</span>"); 135 out.append("</span>");
136 } 136 }
137 137
138 void StyledMarkupAccumulator::appendElement(Element& element, PassRefPtrWillBeRa wPtr<EditingStyle> style) 138 void StyledMarkupAccumulator::appendElement(Element& element, PassRefPtrWillBeRa wPtr<EditingStyle> style)
139 { 139 {
140 appendElement(m_result, element, false, style); 140 appendElement(m_result, element, false, style);
141 } 141 }
142 142
143 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupAccumulator::createInlineStyle(Elem ent& element, bool addDisplayInline) 143 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupAccumulator::createInlineStyle(Elem ent& element)
144 { 144 {
145 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA nnotate() || addDisplayInline);
146
147 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = nullptr; 145 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = nullptr;
148 146
149 if (shouldApplyWrappingStyle(element)) { 147 if (shouldApplyWrappingStyle(element)) {
150 inlineStyle = m_wrappingStyle->copy(); 148 inlineStyle = m_wrappingStyle->copy();
151 inlineStyle->removePropertiesInElementDefaultStyle(&element); 149 inlineStyle->removePropertiesInElementDefaultStyle(&element);
152 inlineStyle->removeStyleConflictingWithStyleOfElement(&element); 150 inlineStyle->removeStyleConflictingWithStyleOfElement(&element);
153 } else { 151 } else {
154 inlineStyle = EditingStyle::create(); 152 inlineStyle = EditingStyle::create();
155 } 153 }
156 154
157 if (element.isStyledElement() && element.inlineStyle()) 155 if (element.isStyledElement() && element.inlineStyle())
158 inlineStyle->overrideWithStyle(element.inlineStyle()); 156 inlineStyle->overrideWithStyle(element.inlineStyle());
159 157
160 if (!shouldAnnotateOrForceInline) 158 if (element.isHTMLElement() && shouldAnnotate())
161 return inlineStyle;
162
163 if (shouldAnnotate())
164 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element) ); 159 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element) );
165 160
166 if (addDisplayInline)
167 inlineStyle->forceInline();
168
169 return inlineStyle; 161 return inlineStyle;
170 } 162 }
171 163
172 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element , bool addDisplayInline, PassRefPtrWillBeRawPtr<EditingStyle> style) 164 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element , bool addDisplayInline, PassRefPtrWillBeRawPtr<EditingStyle> style)
173 { 165 {
174 const bool documentIsHTML = element.document().isHTMLDocument(); 166 const bool documentIsHTML = element.document().isHTMLDocument();
175 m_formatter.appendOpenTag(out, element, nullptr); 167 m_formatter.appendOpenTag(out, element, nullptr);
176 168
177 const bool shouldOverrideStyleAttr = (element.isHTMLElement() && (shouldAnno tate() || addDisplayInline)) || shouldApplyWrappingStyle(element); 169 const bool shouldOverrideStyleAttr = (element.isHTMLElement() && (shouldAnno tate() || addDisplayInline)) || shouldApplyWrappingStyle(element);
178 170
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 m_reversedPrecedingMarkup.append(str); 257 m_reversedPrecedingMarkup.append(str);
266 } 258 }
267 259
268 void StyledMarkupAccumulator::appendInterchangeNewline() 260 void StyledMarkupAccumulator::appendInterchangeNewline()
269 { 261 {
270 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\"" AppleInterchangeNewline "\">")); 262 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\"" AppleInterchangeNewline "\">"));
271 m_result.append(interchangeNewlineString); 263 m_result.append(interchangeNewlineString);
272 } 264 }
273 265
274 } // namespace blink 266 } // 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