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

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

Issue 1163673005: Refactoring: Remove StyledMarkupAccumulator::RangeFullySelectsNodes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: yosin'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 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 // Since this node and all the other ancestors are not in the se lection we want to set RangeFullySelectsNode to DoesNotFullySelectNode 175 RefPtrWillBeRawPtr<EditingStyle> style = nullptr;
176 // so that styles that affect the exterior of the node are not i ncluded. 176 if (ancestor->isElementNode())
177 wrapWithNode(markupAccumulator, *ancestor, StyledMarkupAccumulat or::DoesNotFullySelectNode); 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
179 // 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
181 // only the ones that affect it and the nodes within it.
182 if (style && style->style())
183 style->style()->removeProperty(CSSPropertyFloat);
184 wrapWithNode(markupAccumulator, *ancestor, style);
178 } 185 }
179 186
180 if (ancestor == m_highestNodeToBeSerialized) 187 if (ancestor == m_highestNodeToBeSerialized)
181 break; 188 break;
182 } 189 }
183 } 190 }
184 191
185 // FIXME: The interchange newline should be placed in the block that it's in , not after all of the content, unconditionally. 192 // FIXME: The interchange newline should be placed in the block that it's in , not after all of the content, unconditionally.
186 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAt(v isibleEnd)) 193 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAt(v isibleEnd))
187 markupAccumulator.appendInterchangeNewline(); 194 markupAccumulator.appendInterchangeNewline();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 280
274 ASSERT(n); 281 ASSERT(n);
275 Node* lastAncestorClosedOrSelf = Strategy::isDescendantOf(*n, *lastClose d) ? lastClosed : n; 282 Node* lastAncestorClosedOrSelf = Strategy::isDescendantOf(*n, *lastClose d) ? lastClosed : n;
276 for (ContainerNode* parent = Strategy::parent(*lastAncestorClosedOrSelf) ; parent && parent != nextParent; parent = Strategy::parent(*parent)) { 283 for (ContainerNode* parent = Strategy::parent(*lastAncestorClosedOrSelf) ; parent && parent != nextParent; parent = Strategy::parent(*parent)) {
277 // All ancestors that aren't in the ancestorsToClose list should eit her be a) unrendered: 284 // All ancestors that aren't in the ancestorsToClose list should eit her be a) unrendered:
278 if (!parent->layoutObject()) 285 if (!parent->layoutObject())
279 continue; 286 continue;
280 // or b) ancestors that we never encountered during a pre-order trav ersal starting at startNode: 287 // or b) ancestors that we never encountered during a pre-order trav ersal starting at startNode:
281 ASSERT(startNode); 288 ASSERT(startNode);
282 ASSERT(Strategy::isDescendantOf(*startNode, *parent)); 289 ASSERT(Strategy::isDescendantOf(*startNode, *parent));
283 if (markupAccumulator) 290 if (markupAccumulator) {
284 wrapWithNode(*markupAccumulator, *parent, StyledMarkupAccumulato r::DoesFullySelectNode); 291 RefPtrWillBeRawPtr<EditingStyle> style = nullptr;
292 if (parent->isElementNode())
293 style = markupAccumulator->createInlineStyle(toElement(*pare nt), convertBlocksToInlines() && isBlock(parent));
294 wrapWithNode(*markupAccumulator, *parent, style);
295 }
285 lastClosed = parent; 296 lastClosed = parent;
286 } 297 }
287 } 298 }
288 299
289 return lastClosed; 300 return lastClosed;
290 } 301 }
291 302
292 template<typename Strategy> 303 template<typename Strategy>
293 void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& acc umulator, ContainerNode& node, StyledMarkupAccumulator::RangeFullySelectsNode ra ngeFullySelectsNode) 304 void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& acc umulator, ContainerNode& node, PassRefPtrWillBeRawPtr<EditingStyle> style)
294 { 305 {
295 StringBuilder markup; 306 StringBuilder markup;
296 if (node.isElementNode()) 307 if (node.isElementNode())
297 accumulator.appendElement(markup, toElement(node), convertBlocksToInline s() && isBlock(&node), rangeFullySelectsNode); 308 accumulator.appendElement(markup, toElement(node), convertBlocksToInline s() && isBlock(&node), style);
298 else 309 else
299 accumulator.appendStartMarkup(markup, node); 310 accumulator.appendStartMarkup(markup, node);
300 accumulator.pushMarkup(markup.toString()); 311 accumulator.pushMarkup(markup.toString());
301 if (!node.isElementNode()) 312 if (!node.isElementNode())
302 return; 313 return;
303 accumulator.appendEndTag(toElement(node)); 314 accumulator.appendEndTag(toElement(node));
304 } 315 }
305 316
306 template class StyledMarkupSerializer<EditingStrategy>; 317 template class StyledMarkupSerializer<EditingStrategy>;
307 318
308 } // namespace blink 319 } // namespace blink
OLDNEW
« Source/core/editing/StyledMarkupSerializer.h ('K') | « Source/core/editing/StyledMarkupSerializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698