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

Side by Side Diff: third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 template<typename Strategy> 86 template<typename Strategy>
87 class StyledMarkupTraverser { 87 class StyledMarkupTraverser {
88 WTF_MAKE_NONCOPYABLE(StyledMarkupTraverser); 88 WTF_MAKE_NONCOPYABLE(StyledMarkupTraverser);
89 STACK_ALLOCATED(); 89 STACK_ALLOCATED();
90 public: 90 public:
91 StyledMarkupTraverser(); 91 StyledMarkupTraverser();
92 StyledMarkupTraverser(StyledMarkupAccumulator*, Node*); 92 StyledMarkupTraverser(StyledMarkupAccumulator*, Node*);
93 93
94 Node* traverse(Node*, Node*); 94 Node* traverse(Node*, Node*);
95 void wrapWithNode(ContainerNode&, PassRefPtrWillBeRawPtr<EditingStyle>); 95 void wrapWithNode(ContainerNode&, RawPtr<EditingStyle>);
96 RefPtrWillBeRawPtr<EditingStyle> createInlineStyleIfNeeded(Node&); 96 RawPtr<EditingStyle> createInlineStyleIfNeeded(Node&);
97 97
98 private: 98 private:
99 bool shouldAnnotate() const; 99 bool shouldAnnotate() const;
100 bool convertBlocksToInlines() const; 100 bool convertBlocksToInlines() const;
101 void appendStartMarkup(Node&); 101 void appendStartMarkup(Node&);
102 void appendEndMarkup(Node&); 102 void appendEndMarkup(Node&);
103 RefPtrWillBeRawPtr<EditingStyle> createInlineStyle(Element&); 103 RawPtr<EditingStyle> createInlineStyle(Element&);
104 bool needsInlineStyle(const Element&); 104 bool needsInlineStyle(const Element&);
105 bool shouldApplyWrappingStyle(const Node&) const; 105 bool shouldApplyWrappingStyle(const Node&) const;
106 106
107 StyledMarkupAccumulator* m_accumulator; 107 StyledMarkupAccumulator* m_accumulator;
108 RefPtrWillBeMember<Node> m_lastClosed; 108 Member<Node> m_lastClosed;
109 RefPtrWillBeMember<EditingStyle> m_wrappingStyle; 109 Member<EditingStyle> m_wrappingStyle;
110 }; 110 };
111 111
112 template<typename Strategy> 112 template<typename Strategy>
113 bool StyledMarkupTraverser<Strategy>::shouldAnnotate() const 113 bool StyledMarkupTraverser<Strategy>::shouldAnnotate() const
114 { 114 {
115 return m_accumulator->shouldAnnotate(); 115 return m_accumulator->shouldAnnotate();
116 } 116 }
117 117
118 template<typename Strategy> 118 template<typename Strategy>
119 bool StyledMarkupTraverser<Strategy>::convertBlocksToInlines() const 119 bool StyledMarkupTraverser<Strategy>::convertBlocksToInlines() const
(...skipping 30 matching lines...) Expand all
150 } 150 }
151 151
152 template<typename Strategy> 152 template<typename Strategy>
153 static bool areSameRanges(Node* node, const PositionTemplate<Strategy>& startPos ition, const PositionTemplate<Strategy>& endPosition) 153 static bool areSameRanges(Node* node, const PositionTemplate<Strategy>& startPos ition, const PositionTemplate<Strategy>& endPosition)
154 { 154 {
155 ASSERT(node); 155 ASSERT(node);
156 const EphemeralRange range = VisibleSelection::selectionFromContentsOfNode(n ode).toNormalizedEphemeralRange(); 156 const EphemeralRange range = VisibleSelection::selectionFromContentsOfNode(n ode).toNormalizedEphemeralRange();
157 return toPositionInDOMTree(startPosition) == range.startPosition() && toPosi tionInDOMTree(endPosition) == range.endPosition(); 157 return toPositionInDOMTree(startPosition) == range.startPosition() && toPosi tionInDOMTree(endPosition) == range.endPosition();
158 } 158 }
159 159
160 static PassRefPtrWillBeRawPtr<EditingStyle> styleFromMatchedRulesAndInlineDecl(c onst HTMLElement* element) 160 static RawPtr<EditingStyle> styleFromMatchedRulesAndInlineDecl(const HTMLElement * element)
161 { 161 {
162 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element->inlin eStyle()); 162 RawPtr<EditingStyle> style = EditingStyle::create(element->inlineStyle());
163 // FIXME: Having to const_cast here is ugly, but it is quite a bit of work t o untangle 163 // FIXME: Having to const_cast here is ugly, but it is quite a bit of work t o untangle
164 // the non-const-ness of styleFromMatchedRulesForElement. 164 // the non-const-ness of styleFromMatchedRulesForElement.
165 style->mergeStyleFromRules(const_cast<HTMLElement*>(element)); 165 style->mergeStyleFromRules(const_cast<HTMLElement*>(element));
166 return style.release(); 166 return style.release();
167 } 167 }
168 168
169 template<typename Strategy> 169 template<typename Strategy>
170 String StyledMarkupSerializer<Strategy>::createMarkup() 170 String StyledMarkupSerializer<Strategy>::createMarkup()
171 { 171 {
172 StyledMarkupAccumulator markupAccumulator(m_shouldResolveURLs, toTextOffset( m_start.parentAnchoredEquivalent()), toTextOffset(m_end.parentAnchoredEquivalent ()), m_start.document(), m_shouldAnnotate, m_convertBlocksToInlines); 172 StyledMarkupAccumulator markupAccumulator(m_shouldResolveURLs, toTextOffset( m_start.parentAnchoredEquivalent()), toTextOffset(m_end.parentAnchoredEquivalent ()), m_start.document(), m_shouldAnnotate, m_convertBlocksToInlines);
(...skipping 28 matching lines...) Expand all
201 HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(firstP ositionInNode(commonAncestor), bodyTag)); 201 HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(firstP ositionInNode(commonAncestor), bodyTag));
202 HTMLBodyElement* fullySelectedRoot = nullptr; 202 HTMLBodyElement* fullySelectedRoot = nullptr;
203 // FIXME: Do this for all fully selected blocks, not just the body. 203 // FIXME: Do this for all fully selected blocks, not just the body.
204 if (body && areSameRanges(body, m_start, m_end)) 204 if (body && areSameRanges(body, m_start, m_end))
205 fullySelectedRoot = body; 205 fullySelectedRoot = body;
206 206
207 // Also include all of the ancestors of lastClosed up to this special an cestor. 207 // Also include all of the ancestors of lastClosed up to this special an cestor.
208 // FIXME: What is ancestor? 208 // FIXME: What is ancestor?
209 for (ContainerNode* ancestor = Strategy::parent(*lastClosed); ancestor; ancestor = Strategy::parent(*ancestor)) { 209 for (ContainerNode* ancestor = Strategy::parent(*lastClosed); ancestor; ancestor = Strategy::parent(*ancestor)) {
210 if (ancestor == fullySelectedRoot && !markupAccumulator.convertBlock sToInlines()) { 210 if (ancestor == fullySelectedRoot && !markupAccumulator.convertBlock sToInlines()) {
211 RefPtrWillBeRawPtr<EditingStyle> fullySelectedRootStyle = styleF romMatchedRulesAndInlineDecl(fullySelectedRoot); 211 RawPtr<EditingStyle> fullySelectedRootStyle = styleFromMatchedRu lesAndInlineDecl(fullySelectedRoot);
212 212
213 // Bring the background attribute over, but not as an attribute because a background attribute on a div 213 // Bring the background attribute over, but not as an attribute because a background attribute on a div
214 // appears to have no effect. 214 // appears to have no effect.
215 if ((!fullySelectedRootStyle || !fullySelectedRootStyle->style() || !fullySelectedRootStyle->style()->getPropertyCSSValue(CSSPropertyBackgroundI mage)) 215 if ((!fullySelectedRootStyle || !fullySelectedRootStyle->style() || !fullySelectedRootStyle->style()->getPropertyCSSValue(CSSPropertyBackgroundI mage))
216 && fullySelectedRoot->hasAttribute(backgroundAttr)) 216 && fullySelectedRoot->hasAttribute(backgroundAttr))
217 fullySelectedRootStyle->style()->setProperty(CSSPropertyBack groundImage, "url('" + fullySelectedRoot->getAttribute(backgroundAttr) + "')"); 217 fullySelectedRootStyle->style()->setProperty(CSSPropertyBack groundImage, "url('" + fullySelectedRoot->getAttribute(backgroundAttr) + "')");
218 218
219 if (fullySelectedRootStyle->style()) { 219 if (fullySelectedRootStyle->style()) {
220 // Reset the CSS properties to avoid an assertion error in a ddStyleMarkup(). 220 // Reset the CSS properties to avoid an assertion error in a ddStyleMarkup().
221 // This assertion is caused at least when we select all text of a <body> element whose 221 // This assertion is caused at least when we select all text of a <body> element whose
222 // 'text-decoration' property is "inherit", and copy it. 222 // 'text-decoration' property is "inherit", and copy it.
223 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyTextDecoration)) 223 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyTextDecoration))
224 fullySelectedRootStyle->style()->setProperty(CSSProperty TextDecoration, CSSValueNone); 224 fullySelectedRootStyle->style()->setProperty(CSSProperty TextDecoration, CSSValueNone);
225 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyWebkitTextDecorationsInEffect)) 225 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyWebkitTextDecorationsInEffect))
226 fullySelectedRootStyle->style()->setProperty(CSSProperty WebkitTextDecorationsInEffect, CSSValueNone); 226 fullySelectedRootStyle->style()->setProperty(CSSProperty WebkitTextDecorationsInEffect, CSSValueNone);
227 markupAccumulator.wrapWithStyleNode(fullySelectedRootStyle-> style()); 227 markupAccumulator.wrapWithStyleNode(fullySelectedRootStyle-> style());
228 } 228 }
229 } else { 229 } else {
230 RefPtrWillBeRawPtr<EditingStyle> style = traverser.createInlineS tyleIfNeeded(*ancestor); 230 RawPtr<EditingStyle> style = traverser.createInlineStyleIfNeeded (*ancestor);
231 // Since this node and all the other ancestors are not in the se lection we want 231 // Since this node and all the other ancestors are not in the se lection we want
232 // styles that affect the exterior of the node not to be not inc luded. 232 // styles that affect the exterior of the node not to be not inc luded.
233 // 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 233 // 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
234 // only the ones that affect it and the nodes within it. 234 // only the ones that affect it and the nodes within it.
235 if (style && style->style()) 235 if (style && style->style())
236 style->style()->removeProperty(CSSPropertyFloat); 236 style->style()->removeProperty(CSSPropertyFloat);
237 traverser.wrapWithNode(*ancestor, style); 237 traverser.wrapWithNode(*ancestor, style);
238 } 238 }
239 239
240 if (ancestor == m_highestNodeToBeSerialized) 240 if (ancestor == m_highestNodeToBeSerialized)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if (shouldAnnotate()) { 273 if (shouldAnnotate()) {
274 m_wrappingStyle = EditingStyle::wrappingStyleForAnnotatedSerialization(p arent); 274 m_wrappingStyle = EditingStyle::wrappingStyleForAnnotatedSerialization(p arent);
275 return; 275 return;
276 } 276 }
277 m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(parent); 277 m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(parent);
278 } 278 }
279 279
280 template<typename Strategy> 280 template<typename Strategy>
281 Node* StyledMarkupTraverser<Strategy>::traverse(Node* startNode, Node* pastEnd) 281 Node* StyledMarkupTraverser<Strategy>::traverse(Node* startNode, Node* pastEnd)
282 { 282 {
283 WillBeHeapVector<RawPtrWillBeMember<ContainerNode>> ancestorsToClose; 283 HeapVector<Member<ContainerNode>> ancestorsToClose;
284 Node* next; 284 Node* next;
285 Node* lastClosed = nullptr; 285 Node* lastClosed = nullptr;
286 for (Node* n = startNode; n && n != pastEnd; n = next) { 286 for (Node* n = startNode; n && n != pastEnd; n = next) {
287 // If |n| is a selection boundary such as <input>, traverse the child 287 // If |n| is a selection boundary such as <input>, traverse the child
288 // nodes in the DOM tree instead of the flat tree. 288 // nodes in the DOM tree instead of the flat tree.
289 if (handleSelectionBoundary<Strategy>(*n)) { 289 if (handleSelectionBoundary<Strategy>(*n)) {
290 lastClosed = StyledMarkupTraverser<EditingStrategy>(m_accumulator, m _lastClosed.get()).traverse(n, EditingStrategy::nextSkippingChildren(*n)); 290 lastClosed = StyledMarkupTraverser<EditingStrategy>(m_accumulator, m _lastClosed.get()).traverse(n, EditingStrategy::nextSkippingChildren(*n));
291 next = EditingInFlatTreeStrategy::nextSkippingChildren(*n); 291 next = EditingInFlatTreeStrategy::nextSkippingChildren(*n);
292 } else { 292 } else {
293 next = Strategy::next(*n); 293 next = Strategy::next(*n);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 ASSERT(n); 340 ASSERT(n);
341 Node* lastAncestorClosedOrSelf = (lastClosed && Strategy::isDescendantOf (*n, *lastClosed)) ? lastClosed : n; 341 Node* lastAncestorClosedOrSelf = (lastClosed && Strategy::isDescendantOf (*n, *lastClosed)) ? lastClosed : n;
342 for (ContainerNode* parent = Strategy::parent(*lastAncestorClosedOrSelf) ; parent && parent != nextParent; parent = Strategy::parent(*parent)) { 342 for (ContainerNode* parent = Strategy::parent(*lastAncestorClosedOrSelf) ; parent && parent != nextParent; parent = Strategy::parent(*parent)) {
343 // All ancestors that aren't in the ancestorsToClose list should eit her be a) unrendered: 343 // All ancestors that aren't in the ancestorsToClose list should eit her be a) unrendered:
344 if (!parent->layoutObject()) 344 if (!parent->layoutObject())
345 continue; 345 continue;
346 // or b) ancestors that we never encountered during a pre-order trav ersal starting at startNode: 346 // or b) ancestors that we never encountered during a pre-order trav ersal starting at startNode:
347 ASSERT(startNode); 347 ASSERT(startNode);
348 ASSERT(Strategy::isDescendantOf(*startNode, *parent)); 348 ASSERT(Strategy::isDescendantOf(*startNode, *parent));
349 RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyleIfNeeded(* parent); 349 RawPtr<EditingStyle> style = createInlineStyleIfNeeded(*parent);
350 wrapWithNode(*parent, style); 350 wrapWithNode(*parent, style);
351 lastClosed = parent; 351 lastClosed = parent;
352 } 352 }
353 } 353 }
354 354
355 return lastClosed; 355 return lastClosed;
356 } 356 }
357 357
358 template<typename Strategy> 358 template<typename Strategy>
359 bool StyledMarkupTraverser<Strategy>::needsInlineStyle(const Element& element) 359 bool StyledMarkupTraverser<Strategy>::needsInlineStyle(const Element& element)
360 { 360 {
361 if (!element.isHTMLElement()) 361 if (!element.isHTMLElement())
362 return false; 362 return false;
363 if (shouldAnnotate()) 363 if (shouldAnnotate())
364 return true; 364 return true;
365 return convertBlocksToInlines() && isEnclosingBlock(&element); 365 return convertBlocksToInlines() && isEnclosingBlock(&element);
366 } 366 }
367 367
368 template<typename Strategy> 368 template<typename Strategy>
369 void StyledMarkupTraverser<Strategy>::wrapWithNode(ContainerNode& node, PassRefP trWillBeRawPtr<EditingStyle> style) 369 void StyledMarkupTraverser<Strategy>::wrapWithNode(ContainerNode& node, RawPtr<E ditingStyle> style)
370 { 370 {
371 if (!m_accumulator) 371 if (!m_accumulator)
372 return; 372 return;
373 StringBuilder markup; 373 StringBuilder markup;
374 if (node.isDocumentNode()) { 374 if (node.isDocumentNode()) {
375 MarkupFormatter::appendXMLDeclaration(markup, toDocument(node)); 375 MarkupFormatter::appendXMLDeclaration(markup, toDocument(node));
376 m_accumulator->pushMarkup(markup.toString()); 376 m_accumulator->pushMarkup(markup.toString());
377 return; 377 return;
378 } 378 }
379 if (!node.isElementNode()) 379 if (!node.isElementNode())
380 return; 380 return;
381 Element& element = toElement(node); 381 Element& element = toElement(node);
382 if (shouldApplyWrappingStyle(element) || needsInlineStyle(element)) 382 if (shouldApplyWrappingStyle(element) || needsInlineStyle(element))
383 m_accumulator->appendElementWithInlineStyle(markup, element, style); 383 m_accumulator->appendElementWithInlineStyle(markup, element, style);
384 else 384 else
385 m_accumulator->appendElement(markup, element); 385 m_accumulator->appendElement(markup, element);
386 m_accumulator->pushMarkup(markup.toString()); 386 m_accumulator->pushMarkup(markup.toString());
387 m_accumulator->appendEndTag(toElement(node)); 387 m_accumulator->appendEndTag(toElement(node));
388 } 388 }
389 389
390 template<typename Strategy> 390 template<typename Strategy>
391 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupTraverser<Strategy>::createInlineSt yleIfNeeded(Node& node) 391 RawPtr<EditingStyle> StyledMarkupTraverser<Strategy>::createInlineStyleIfNeeded( Node& node)
392 { 392 {
393 if (!m_accumulator) 393 if (!m_accumulator)
394 return nullptr; 394 return nullptr;
395 if (!node.isElementNode()) 395 if (!node.isElementNode())
396 return nullptr; 396 return nullptr;
397 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(toElement(n ode)); 397 RawPtr<EditingStyle> inlineStyle = createInlineStyle(toElement(node));
398 if (convertBlocksToInlines() && isEnclosingBlock(&node)) 398 if (convertBlocksToInlines() && isEnclosingBlock(&node))
399 inlineStyle->forceInline(); 399 inlineStyle->forceInline();
400 return inlineStyle; 400 return inlineStyle;
401 } 401 }
402 402
403 template<typename Strategy> 403 template<typename Strategy>
404 void StyledMarkupTraverser<Strategy>::appendStartMarkup(Node& node) 404 void StyledMarkupTraverser<Strategy>::appendStartMarkup(Node& node)
405 { 405 {
406 if (!m_accumulator) 406 if (!m_accumulator)
407 return; 407 return;
408 switch (node.nodeType()) { 408 switch (node.nodeType()) {
409 case Node::TEXT_NODE: { 409 case Node::TEXT_NODE: {
410 Text& text = toText(node); 410 Text& text = toText(node);
411 if (text.parentElement() && isHTMLTextAreaElement(text.parentElement())) { 411 if (text.parentElement() && isHTMLTextAreaElement(text.parentElement())) {
412 m_accumulator->appendText(text); 412 m_accumulator->appendText(text);
413 break; 413 break;
414 } 414 }
415 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = nullptr; 415 RawPtr<EditingStyle> inlineStyle = nullptr;
416 if (shouldApplyWrappingStyle(text)) { 416 if (shouldApplyWrappingStyle(text)) {
417 inlineStyle = m_wrappingStyle->copy(); 417 inlineStyle = m_wrappingStyle->copy();
418 // FIXME: <rdar://problem/5371536> Style rules that match pasted con tent can change it's appearance 418 // FIXME: <rdar://problem/5371536> Style rules that match pasted con tent can change it's appearance
419 // Make sure spans are inline style in paste side e.g. span { displa y: block }. 419 // Make sure spans are inline style in paste side e.g. span { displa y: block }.
420 inlineStyle->forceInline(); 420 inlineStyle->forceInline();
421 // FIXME: Should this be included in forceInline? 421 // FIXME: Should this be included in forceInline?
422 inlineStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone); 422 inlineStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone);
423 } 423 }
424 m_accumulator->appendTextWithInlineStyle(text, inlineStyle); 424 m_accumulator->appendTextWithInlineStyle(text, inlineStyle);
425 break; 425 break;
426 } 426 }
427 case Node::ELEMENT_NODE: { 427 case Node::ELEMENT_NODE: {
428 Element& element = toElement(node); 428 Element& element = toElement(node);
429 if ((element.isHTMLElement() && shouldAnnotate()) || shouldApplyWrapping Style(element)) { 429 if ((element.isHTMLElement() && shouldAnnotate()) || shouldApplyWrapping Style(element)) {
430 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(ele ment); 430 RawPtr<EditingStyle> inlineStyle = createInlineStyle(element);
431 m_accumulator->appendElementWithInlineStyle(element, inlineStyle); 431 m_accumulator->appendElementWithInlineStyle(element, inlineStyle);
432 break; 432 break;
433 } 433 }
434 m_accumulator->appendElement(element); 434 m_accumulator->appendElement(element);
435 break; 435 break;
436 } 436 }
437 default: 437 default:
438 m_accumulator->appendStartMarkup(node); 438 m_accumulator->appendStartMarkup(node);
439 break; 439 break;
440 } 440 }
441 } 441 }
442 442
443 template<typename Strategy> 443 template<typename Strategy>
444 void StyledMarkupTraverser<Strategy>::appendEndMarkup(Node& node) 444 void StyledMarkupTraverser<Strategy>::appendEndMarkup(Node& node)
445 { 445 {
446 if (!m_accumulator || !node.isElementNode()) 446 if (!m_accumulator || !node.isElementNode())
447 return; 447 return;
448 m_accumulator->appendEndTag(toElement(node)); 448 m_accumulator->appendEndTag(toElement(node));
449 } 449 }
450 450
451 template<typename Strategy> 451 template<typename Strategy>
452 bool StyledMarkupTraverser<Strategy>::shouldApplyWrappingStyle(const Node& node) const 452 bool StyledMarkupTraverser<Strategy>::shouldApplyWrappingStyle(const Node& node) const
453 { 453 {
454 return m_lastClosed && Strategy::parent(*m_lastClosed) == Strategy::parent(n ode) 454 return m_lastClosed && Strategy::parent(*m_lastClosed) == Strategy::parent(n ode)
455 && m_wrappingStyle && m_wrappingStyle->style(); 455 && m_wrappingStyle && m_wrappingStyle->style();
456 } 456 }
457 457
458 template<typename Strategy> 458 template<typename Strategy>
459 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupTraverser<Strategy>::createInlineSt yle(Element& element) 459 RawPtr<EditingStyle> StyledMarkupTraverser<Strategy>::createInlineStyle(Element& element)
460 { 460 {
461 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = nullptr; 461 RawPtr<EditingStyle> inlineStyle = nullptr;
462 462
463 if (shouldApplyWrappingStyle(element)) { 463 if (shouldApplyWrappingStyle(element)) {
464 inlineStyle = m_wrappingStyle->copy(); 464 inlineStyle = m_wrappingStyle->copy();
465 inlineStyle->removePropertiesInElementDefaultStyle(&element); 465 inlineStyle->removePropertiesInElementDefaultStyle(&element);
466 inlineStyle->removeStyleConflictingWithStyleOfElement(&element); 466 inlineStyle->removeStyleConflictingWithStyleOfElement(&element);
467 } else { 467 } else {
468 inlineStyle = EditingStyle::create(); 468 inlineStyle = EditingStyle::create();
469 } 469 }
470 470
471 if (element.isStyledElement() && element.inlineStyle()) 471 if (element.isStyledElement() && element.inlineStyle())
472 inlineStyle->overrideWithStyle(element.inlineStyle()); 472 inlineStyle->overrideWithStyle(element.inlineStyle());
473 473
474 if (element.isHTMLElement() && shouldAnnotate()) 474 if (element.isHTMLElement() && shouldAnnotate())
475 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element) ); 475 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element) );
476 476
477 return inlineStyle; 477 return inlineStyle;
478 } 478 }
479 479
480 template class StyledMarkupSerializer<EditingStrategy>; 480 template class StyledMarkupSerializer<EditingStrategy>;
481 template class StyledMarkupSerializer<EditingInFlatTreeStrategy>; 481 template class StyledMarkupSerializer<EditingInFlatTreeStrategy>;
482 482
483 } // namespace blink 483 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698