| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // cloneDataFromElement() is close but not enough for this case. | 208 // cloneDataFromElement() is close but not enough for this case. |
| 209 for (auto& attribute : newElement->attributesWithoutUpdate()) { | 209 for (auto& attribute : newElement->attributesWithoutUpdate()) { |
| 210 if (!m_domEditor->setAttribute(oldElement, attribute.name().toString(), | 210 if (!m_domEditor->setAttribute(oldElement, attribute.name().toString(), |
| 211 attribute.value(), exceptionState)) | 211 attribute.value(), exceptionState)) |
| 212 return false; | 212 return false; |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 bool result = innerPatchChildren(oldElement, oldDigest->m_children, | 216 bool result = innerPatchChildren(oldElement, oldDigest->m_children, |
| 217 newDigest->m_children, exceptionState); | 217 newDigest->m_children, exceptionState); |
| 218 m_unusedNodesMap.remove(newDigest->m_sha1); | 218 m_unusedNodesMap.erase(newDigest->m_sha1); |
| 219 return result; | 219 return result; |
| 220 } | 220 } |
| 221 | 221 |
| 222 std::pair<DOMPatchSupport::ResultMap, DOMPatchSupport::ResultMap> | 222 std::pair<DOMPatchSupport::ResultMap, DOMPatchSupport::ResultMap> |
| 223 DOMPatchSupport::diff(const HeapVector<Member<Digest>>& oldList, | 223 DOMPatchSupport::diff(const HeapVector<Member<Digest>>& oldList, |
| 224 const HeapVector<Member<Digest>>& newList) { | 224 const HeapVector<Member<Digest>>& newList) { |
| 225 ResultMap newMap(newList.size()); | 225 ResultMap newMap(newList.size()); |
| 226 ResultMap oldMap(oldList.size()); | 226 ResultMap oldMap(oldList.size()); |
| 227 | 227 |
| 228 for (size_t i = 0; i < oldMap.size(); ++i) { | 228 for (size_t i = 0; i < oldMap.size(); ++i) { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 return false; | 534 return false; |
| 535 } | 535 } |
| 536 return true; | 536 return true; |
| 537 } | 537 } |
| 538 | 538 |
| 539 void DOMPatchSupport::markNodeAsUsed(Digest* digest) { | 539 void DOMPatchSupport::markNodeAsUsed(Digest* digest) { |
| 540 HeapDeque<Member<Digest>> queue; | 540 HeapDeque<Member<Digest>> queue; |
| 541 queue.append(digest); | 541 queue.append(digest); |
| 542 while (!queue.isEmpty()) { | 542 while (!queue.isEmpty()) { |
| 543 Digest* first = queue.takeFirst(); | 543 Digest* first = queue.takeFirst(); |
| 544 m_unusedNodesMap.remove(first->m_sha1); | 544 m_unusedNodesMap.erase(first->m_sha1); |
| 545 for (size_t i = 0; i < first->m_children.size(); ++i) | 545 for (size_t i = 0; i < first->m_children.size(); ++i) |
| 546 queue.append(first->m_children[i].get()); | 546 queue.append(first->m_children[i].get()); |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 | 549 |
| 550 #ifdef DEBUG_DOM_PATCH_SUPPORT | 550 #ifdef DEBUG_DOM_PATCH_SUPPORT |
| 551 static String nodeName(Node* node) { | 551 static String nodeName(Node* node) { |
| 552 if (node->document().isXHTMLDocument()) | 552 if (node->document().isXHTMLDocument()) |
| 553 return node->nodeName(); | 553 return node->nodeName(); |
| 554 return node->nodeName().lower(); | 554 return node->nodeName().lower(); |
| 555 } | 555 } |
| 556 | 556 |
| 557 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) { | 557 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) { |
| 558 fprintf(stderr, "\n\n"); | 558 fprintf(stderr, "\n\n"); |
| 559 for (size_t i = 0; i < map.size(); ++i) | 559 for (size_t i = 0; i < map.size(); ++i) |
| 560 fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, | 560 fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, |
| 561 map[i].first ? nodeName(map[i].first->m_node).utf8().data() : "", | 561 map[i].first ? nodeName(map[i].first->m_node).utf8().data() : "", |
| 562 map[i].first, map[i].second); | 562 map[i].first, map[i].second); |
| 563 } | 563 } |
| 564 #endif | 564 #endif |
| 565 | 565 |
| 566 DEFINE_TRACE(DOMPatchSupport::Digest) { | 566 DEFINE_TRACE(DOMPatchSupport::Digest) { |
| 567 visitor->trace(m_node); | 567 visitor->trace(m_node); |
| 568 visitor->trace(m_children); | 568 visitor->trace(m_children); |
| 569 } | 569 } |
| 570 | 570 |
| 571 } // namespace blink | 571 } // namespace blink |
| OLD | NEW |