OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |