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

Side by Side Diff: Source/core/editing/StyledMarkupSerializer.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
« no previous file with comments | « Source/core/editing/StyledMarkupSerializer.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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Reset the CSS properties to avoid an assertion error in a ddStyleMarkup(). 165 // Reset the CSS properties to avoid an assertion error in a ddStyleMarkup().
166 // This assertion is caused at least when we select all text of a <body> element whose 166 // This assertion is caused at least when we select all text of a <body> element whose
167 // 'text-decoration' property is "inherit", and copy it. 167 // 'text-decoration' property is "inherit", and copy it.
168 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyTextDecoration)) 168 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyTextDecoration))
169 fullySelectedRootStyle->style()->setProperty(CSSProperty TextDecoration, CSSValueNone); 169 fullySelectedRootStyle->style()->setProperty(CSSProperty TextDecoration, CSSValueNone);
170 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyWebkitTextDecorationsInEffect)) 170 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyWebkitTextDecorationsInEffect))
171 fullySelectedRootStyle->style()->setProperty(CSSProperty WebkitTextDecorationsInEffect, CSSValueNone); 171 fullySelectedRootStyle->style()->setProperty(CSSProperty WebkitTextDecorationsInEffect, CSSValueNone);
172 markupAccumulator.wrapWithStyleNode(fullySelectedRootStyle-> style()); 172 markupAccumulator.wrapWithStyleNode(fullySelectedRootStyle-> style());
173 } 173 }
174 } else { 174 } else {
175 RefPtrWillBeRawPtr<EditingStyle> style = nullptr; 175 RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyleIfNeed ed(markupAccumulator, *ancestor);
176 if (ancestor->isElementNode())
177 style = markupAccumulator.createInlineStyle(toElement(*ances tor), convertBlocksToInlines() && isBlock(ancestor));
178 // Since this node and all the other ancestors are not in the se lection we want 176 // Since this node and all the other ancestors are not in the se lection we want
179 // styles that affect the exterior of the node not to be not inc luded. 177 // styles that affect the exterior of the node not to be not inc luded.
180 // If the node is not fully selected by the range, then we don't want to keep styles that affect its relationship to the nodes around it 178 // If the node is not fully selected by the range, then we don't want to keep styles that affect its relationship to the nodes around it
181 // only the ones that affect it and the nodes within it. 179 // only the ones that affect it and the nodes within it.
182 if (style && style->style()) 180 if (style && style->style())
183 style->style()->removeProperty(CSSPropertyFloat); 181 style->style()->removeProperty(CSSPropertyFloat);
184 wrapWithNode(markupAccumulator, *ancestor, style); 182 wrapWithNode(markupAccumulator, *ancestor, style);
185 } 183 }
186 184
187 if (ancestor == m_highestNodeToBeSerialized) 185 if (ancestor == m_highestNodeToBeSerialized)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 ASSERT(n); 279 ASSERT(n);
282 Node* lastAncestorClosedOrSelf = Strategy::isDescendantOf(*n, *lastClose d) ? lastClosed : n; 280 Node* lastAncestorClosedOrSelf = Strategy::isDescendantOf(*n, *lastClose d) ? lastClosed : n;
283 for (ContainerNode* parent = Strategy::parent(*lastAncestorClosedOrSelf) ; parent && parent != nextParent; parent = Strategy::parent(*parent)) { 281 for (ContainerNode* parent = Strategy::parent(*lastAncestorClosedOrSelf) ; parent && parent != nextParent; parent = Strategy::parent(*parent)) {
284 // All ancestors that aren't in the ancestorsToClose list should eit her be a) unrendered: 282 // All ancestors that aren't in the ancestorsToClose list should eit her be a) unrendered:
285 if (!parent->layoutObject()) 283 if (!parent->layoutObject())
286 continue; 284 continue;
287 // or b) ancestors that we never encountered during a pre-order trav ersal starting at startNode: 285 // or b) ancestors that we never encountered during a pre-order trav ersal starting at startNode:
288 ASSERT(startNode); 286 ASSERT(startNode);
289 ASSERT(Strategy::isDescendantOf(*startNode, *parent)); 287 ASSERT(Strategy::isDescendantOf(*startNode, *parent));
290 if (markupAccumulator) { 288 if (markupAccumulator) {
291 RefPtrWillBeRawPtr<EditingStyle> style = nullptr; 289 RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyleIfNeed ed(*markupAccumulator, *parent);
292 if (parent->isElementNode())
293 style = markupAccumulator->createInlineStyle(toElement(*pare nt), convertBlocksToInlines() && isBlock(parent));
294 wrapWithNode(*markupAccumulator, *parent, style); 290 wrapWithNode(*markupAccumulator, *parent, style);
295 } 291 }
296 lastClosed = parent; 292 lastClosed = parent;
297 } 293 }
298 } 294 }
299 295
300 return lastClosed; 296 return lastClosed;
301 } 297 }
302 298
303 template<typename Strategy> 299 template<typename Strategy>
304 void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& acc umulator, ContainerNode& node, PassRefPtrWillBeRawPtr<EditingStyle> style) 300 void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& acc umulator, ContainerNode& node, PassRefPtrWillBeRawPtr<EditingStyle> style)
305 { 301 {
306 StringBuilder markup; 302 StringBuilder markup;
307 if (node.isElementNode()) 303 if (node.isElementNode())
308 accumulator.appendElement(markup, toElement(node), convertBlocksToInline s() && isBlock(&node), style); 304 accumulator.appendElement(markup, toElement(node), convertBlocksToInline s() && isBlock(&node), style);
309 else 305 else
310 accumulator.appendStartMarkup(markup, node); 306 accumulator.appendStartMarkup(markup, node);
311 accumulator.pushMarkup(markup.toString()); 307 accumulator.pushMarkup(markup.toString());
312 if (!node.isElementNode()) 308 if (!node.isElementNode())
313 return; 309 return;
314 accumulator.appendEndTag(toElement(node)); 310 accumulator.appendEndTag(toElement(node));
315 } 311 }
316 312
313 template<typename Strategy>
314 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupSerializer<Strategy>::createInlineS tyleIfNeeded(StyledMarkupAccumulator& accumulator, Node& node)
315 {
316 if (!node.isElementNode())
317 return nullptr;
318 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = accumulator.createInlineStyle (toElement(node));
319 if (convertBlocksToInlines() && isBlock(&node))
320 inlineStyle->forceInline();
321 return inlineStyle;
322 }
323
317 template class StyledMarkupSerializer<EditingStrategy>; 324 template class StyledMarkupSerializer<EditingStrategy>;
318 325
319 } // namespace blink 326 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/StyledMarkupSerializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698