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

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

Issue 69543007: Have NodeTraversal::nextSkippingChildren() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years, 1 month 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/htmlediting.cpp ('k') | Source/core/html/HTMLCollection.cpp » ('j') | 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 break; 356 break;
357 357
358 next = NodeTraversal::next(*n); 358 next = NodeTraversal::next(*n);
359 bool openedTag = false; 359 bool openedTag = false;
360 360
361 if (isBlock(n) && canHaveChildrenForEditing(n) && next == pastEnd) 361 if (isBlock(n) && canHaveChildrenForEditing(n) && next == pastEnd)
362 // Don't write out empty block containers that aren't fully selected . 362 // Don't write out empty block containers that aren't fully selected .
363 continue; 363 continue;
364 364
365 if (!n->renderer() && !enclosingNodeWithTag(firstPositionInOrBeforeNode( n), selectTag)) { 365 if (!n->renderer() && !enclosingNodeWithTag(firstPositionInOrBeforeNode( n), selectTag)) {
366 next = NodeTraversal::nextSkippingChildren(n); 366 next = NodeTraversal::nextSkippingChildren(*n);
367 // Don't skip over pastEnd. 367 // Don't skip over pastEnd.
368 if (pastEnd && pastEnd->isDescendantOf(n)) 368 if (pastEnd && pastEnd->isDescendantOf(n))
369 next = pastEnd; 369 next = pastEnd;
370 } else { 370 } else {
371 // Add the node to the markup if we're not skipping the descendants 371 // Add the node to the markup if we're not skipping the descendants
372 if (shouldEmit) 372 if (shouldEmit)
373 appendStartTag(n); 373 appendStartTag(n);
374 374
375 // If node has no children, close the tag now. 375 // If node has no children, close the tag now.
376 if (!n->childNodeCount()) { 376 if (!n->childNodeCount()) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 } 671 }
672 672
673 static void trimFragment(DocumentFragment* fragment, Node* nodeBeforeContext, No de* nodeAfterContext) 673 static void trimFragment(DocumentFragment* fragment, Node* nodeBeforeContext, No de* nodeAfterContext)
674 { 674 {
675 RefPtr<Node> next; 675 RefPtr<Node> next;
676 for (RefPtr<Node> node = fragment->firstChild(); node; node = next) { 676 for (RefPtr<Node> node = fragment->firstChild(); node; node = next) {
677 if (nodeBeforeContext->isDescendantOf(node.get())) { 677 if (nodeBeforeContext->isDescendantOf(node.get())) {
678 next = NodeTraversal::next(*node); 678 next = NodeTraversal::next(*node);
679 continue; 679 continue;
680 } 680 }
681 next = NodeTraversal::nextSkippingChildren(node.get()); 681 next = NodeTraversal::nextSkippingChildren(*node);
682 ASSERT(!node->contains(nodeAfterContext)); 682 ASSERT(!node->contains(nodeAfterContext));
683 node->parentNode()->removeChild(node.get(), ASSERT_NO_EXCEPTION); 683 node->parentNode()->removeChild(node.get(), ASSERT_NO_EXCEPTION);
684 if (nodeBeforeContext == node) 684 if (nodeBeforeContext == node)
685 break; 685 break;
686 } 686 }
687 687
688 ASSERT(nodeAfterContext->parentNode()); 688 ASSERT(nodeAfterContext->parentNode());
689 for (RefPtr<Node> node = nodeAfterContext; node; node = next) { 689 for (RefPtr<Node> node = nodeAfterContext; node; node = next) {
690 next = NodeTraversal::nextSkippingChildren(node.get()); 690 next = NodeTraversal::nextSkippingChildren(*node);
691 node->parentNode()->removeChild(node.get(), ASSERT_NO_EXCEPTION); 691 node->parentNode()->removeChild(node.get(), ASSERT_NO_EXCEPTION);
692 } 692 }
693 } 693 }
694 694
695 PassRefPtr<DocumentFragment> createFragmentFromMarkupWithContext(Document& docum ent, const String& markup, unsigned fragmentStart, unsigned fragmentEnd, 695 PassRefPtr<DocumentFragment> createFragmentFromMarkupWithContext(Document& docum ent, const String& markup, unsigned fragmentStart, unsigned fragmentEnd,
696 const String& baseURL, ParserContentPolicy parserContentPolicy) 696 const String& baseURL, ParserContentPolicy parserContentPolicy)
697 { 697 {
698 // FIXME: Need to handle the case where the markup already contains these ma rkers. 698 // FIXME: Need to handle the case where the markup already contains these ma rkers.
699 699
700 StringBuilder taggedMarkup; 700 StringBuilder taggedMarkup;
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 return; 1083 return;
1084 1084
1085 RefPtr<Text> textNode = toText(node.get()); 1085 RefPtr<Text> textNode = toText(node.get());
1086 RefPtr<Text> textNext = toText(next); 1086 RefPtr<Text> textNext = toText(next);
1087 textNode->appendData(textNext->data()); 1087 textNode->appendData(textNext->data());
1088 if (textNext->parentNode()) // Might have been removed by mutation event. 1088 if (textNext->parentNode()) // Might have been removed by mutation event.
1089 textNext->remove(es); 1089 textNext->remove(es);
1090 } 1090 }
1091 1091
1092 } 1092 }
OLDNEW
« no previous file with comments | « Source/core/editing/htmlediting.cpp ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698