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

Side by Side Diff: Source/core/inspector/DOMPatchSupport.cpp

Issue 428533006: Use ContainerNode::hasChildren() instead of firstChild() in conditionals (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: build fix Created 6 years, 4 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/html/shadow/DateTimeEditElement.cpp ('k') | Source/core/svg/SVGTitleElement.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 Vector<OwnPtr<Digest> > oldList; 139 Vector<OwnPtr<Digest> > oldList;
140 for (Node* child = parentNode->firstChild(); child; child = child->nextSibli ng()) 140 for (Node* child = parentNode->firstChild(); child; child = child->nextSibli ng())
141 oldList.append(createDigest(child, 0)); 141 oldList.append(createDigest(child, 0));
142 142
143 // Compose the new list. 143 // Compose the new list.
144 String markupCopy = markup.lower(); 144 String markupCopy = markup.lower();
145 Vector<OwnPtr<Digest> > newList; 145 Vector<OwnPtr<Digest> > newList;
146 for (Node* child = parentNode->firstChild(); child != node; child = child->n extSibling()) 146 for (Node* child = parentNode->firstChild(); child != node; child = child->n extSibling())
147 newList.append(createDigest(child, 0)); 147 newList.append(createDigest(child, 0));
148 for (Node* child = fragment->firstChild(); child; child = child->nextSibling ()) { 148 for (Node* child = fragment->firstChild(); child; child = child->nextSibling ()) {
149 if (isHTMLHeadElement(*child) && !child->firstChild() && markupCopy.find ("</head>") == kNotFound) 149 if (isHTMLHeadElement(*child) && !child->hasChildren() && markupCopy.fin d("</head>") == kNotFound)
150 continue; // HTML5 parser inserts empty <head> tag whenever it parse s <body> 150 continue; // HTML5 parser inserts empty <head> tag whenever it parse s <body>
151 if (isHTMLBodyElement(*child) && !child->firstChild() && markupCopy.find ("</body>") == kNotFound) 151 if (isHTMLBodyElement(*child) && !child->hasChildren() && markupCopy.fin d("</body>") == kNotFound)
152 continue; // HTML5 parser inserts empty <body> tag whenever it parse s </head> 152 continue; // HTML5 parser inserts empty <body> tag whenever it parse s </head>
153 newList.append(createDigest(child, &m_unusedNodesMap)); 153 newList.append(createDigest(child, &m_unusedNodesMap));
154 } 154 }
155 for (Node* child = node->nextSibling(); child; child = child->nextSibling()) 155 for (Node* child = node->nextSibling(); child; child = child->nextSibling())
156 newList.append(createDigest(child, 0)); 156 newList.append(createDigest(child, 0));
157 157
158 if (!innerPatchChildren(parentNode, oldList, newList, exceptionState)) { 158 if (!innerPatchChildren(parentNode, oldList, newList, exceptionState)) {
159 // Fall back to total replace. 159 // Fall back to total replace.
160 if (!m_domEditor->replaceChild(parentNode, fragment.release(), node, exc eptionState)) 160 if (!m_domEditor->replaceChild(parentNode, fragment.release(), node, exc eptionState))
161 return 0; 161 return 0;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) 509 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name)
510 { 510 {
511 fprintf(stderr, "\n\n"); 511 fprintf(stderr, "\n\n");
512 for (size_t i = 0; i < map.size(); ++i) 512 for (size_t i = 0; i < map.size(); ++i)
513 fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, map [i].first ? nodeName(map[i].first->m_node).utf8().data() : "", map[i].first, map [i].second); 513 fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, map [i].first ? nodeName(map[i].first->m_node).utf8().data() : "", map[i].first, map [i].second);
514 } 514 }
515 #endif 515 #endif
516 516
517 } // namespace blink 517 } // namespace blink
518 518
OLDNEW
« no previous file with comments | « Source/core/html/shadow/DateTimeEditElement.cpp ('k') | Source/core/svg/SVGTitleElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698