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

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

Issue 1320573003: Rename isBlock() to isEnclosingBlock() in EditingUtilities (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-26T21:48:03 Rebase Created 5 years, 3 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
« no previous file with comments | « Source/core/editing/commands/ReplaceSelectionCommand.cpp ('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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 Node* next; 285 Node* next;
286 Node* lastClosed = nullptr; 286 Node* lastClosed = nullptr;
287 for (Node* n = startNode; n && n != pastEnd; n = next) { 287 for (Node* n = startNode; n && n != pastEnd; n = next) {
288 // If |n| is a selection boundary such as <input>, traverse the child 288 // If |n| is a selection boundary such as <input>, traverse the child
289 // nodes in the DOM tree instead of the composed tree. 289 // nodes in the DOM tree instead of the composed tree.
290 if (handleSelectionBoundary<Strategy>(*n)) { 290 if (handleSelectionBoundary<Strategy>(*n)) {
291 lastClosed = StyledMarkupTraverser<EditingStrategy>(m_accumulator, m _lastClosed.get()).traverse(n, EditingStrategy::nextSkippingChildren(*n)); 291 lastClosed = StyledMarkupTraverser<EditingStrategy>(m_accumulator, m _lastClosed.get()).traverse(n, EditingStrategy::nextSkippingChildren(*n));
292 next = EditingInComposedTreeStrategy::nextSkippingChildren(*n); 292 next = EditingInComposedTreeStrategy::nextSkippingChildren(*n);
293 } else { 293 } else {
294 next = Strategy::next(*n); 294 next = Strategy::next(*n);
295 if (isBlock(n) && canHaveChildrenForEditing(n) && next == pastEnd) { 295 if (isEnclosingBlock(n) && canHaveChildrenForEditing(n) && next == p astEnd) {
296 // Don't write out empty block containers that aren't fully sele cted. 296 // Don't write out empty block containers that aren't fully sele cted.
297 continue; 297 continue;
298 } 298 }
299 299
300 if (!n->layoutObject() && !enclosingElementWithTag(firstPositionInOr BeforeNode(n), selectTag)) { 300 if (!n->layoutObject() && !enclosingElementWithTag(firstPositionInOr BeforeNode(n), selectTag)) {
301 next = Strategy::nextSkippingChildren(*n); 301 next = Strategy::nextSkippingChildren(*n);
302 // Don't skip over pastEnd. 302 // Don't skip over pastEnd.
303 if (pastEnd && Strategy::isDescendantOf(*pastEnd, *n)) 303 if (pastEnd && Strategy::isDescendantOf(*pastEnd, *n))
304 next = pastEnd; 304 next = pastEnd;
305 } else { 305 } else {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return lastClosed; 356 return lastClosed;
357 } 357 }
358 358
359 template<typename Strategy> 359 template<typename Strategy>
360 bool StyledMarkupTraverser<Strategy>::needsInlineStyle(const Element& element) 360 bool StyledMarkupTraverser<Strategy>::needsInlineStyle(const Element& element)
361 { 361 {
362 if (!element.isHTMLElement()) 362 if (!element.isHTMLElement())
363 return false; 363 return false;
364 if (shouldAnnotate()) 364 if (shouldAnnotate())
365 return true; 365 return true;
366 return convertBlocksToInlines() && isBlock(&element); 366 return convertBlocksToInlines() && isEnclosingBlock(&element);
367 } 367 }
368 368
369 template<typename Strategy> 369 template<typename Strategy>
370 void StyledMarkupTraverser<Strategy>::wrapWithNode(ContainerNode& node, PassRefP trWillBeRawPtr<EditingStyle> style) 370 void StyledMarkupTraverser<Strategy>::wrapWithNode(ContainerNode& node, PassRefP trWillBeRawPtr<EditingStyle> style)
371 { 371 {
372 if (!m_accumulator) 372 if (!m_accumulator)
373 return; 373 return;
374 StringBuilder markup; 374 StringBuilder markup;
375 if (node.isDocumentNode()) { 375 if (node.isDocumentNode()) {
376 MarkupFormatter::appendXMLDeclaration(markup, toDocument(node)); 376 MarkupFormatter::appendXMLDeclaration(markup, toDocument(node));
(...skipping 12 matching lines...) Expand all
389 } 389 }
390 390
391 template<typename Strategy> 391 template<typename Strategy>
392 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupTraverser<Strategy>::createInlineSt yleIfNeeded(Node& node) 392 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupTraverser<Strategy>::createInlineSt yleIfNeeded(Node& node)
393 { 393 {
394 if (!m_accumulator) 394 if (!m_accumulator)
395 return nullptr; 395 return nullptr;
396 if (!node.isElementNode()) 396 if (!node.isElementNode())
397 return nullptr; 397 return nullptr;
398 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(toElement(n ode)); 398 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(toElement(n ode));
399 if (convertBlocksToInlines() && isBlock(&node)) 399 if (convertBlocksToInlines() && isEnclosingBlock(&node))
400 inlineStyle->forceInline(); 400 inlineStyle->forceInline();
401 return inlineStyle; 401 return inlineStyle;
402 } 402 }
403 403
404 template<typename Strategy> 404 template<typename Strategy>
405 void StyledMarkupTraverser<Strategy>::appendStartMarkup(Node& node) 405 void StyledMarkupTraverser<Strategy>::appendStartMarkup(Node& node)
406 { 406 {
407 if (!m_accumulator) 407 if (!m_accumulator)
408 return; 408 return;
409 switch (node.nodeType()) { 409 switch (node.nodeType()) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 if (element.isHTMLElement() && shouldAnnotate()) 475 if (element.isHTMLElement() && shouldAnnotate())
476 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element) ); 476 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element) );
477 477
478 return inlineStyle; 478 return inlineStyle;
479 } 479 }
480 480
481 template class StyledMarkupSerializer<EditingStrategy>; 481 template class StyledMarkupSerializer<EditingStrategy>;
482 template class StyledMarkupSerializer<EditingInComposedTreeStrategy>; 482 template class StyledMarkupSerializer<EditingInComposedTreeStrategy>;
483 483
484 } // namespace blink 484 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/commands/ReplaceSelectionCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698