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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 if (oldElement->hasAttributesWithoutUpdate()) { | 192 if (oldElement->hasAttributesWithoutUpdate()) { |
193 while (oldElement->attributeCount()) { | 193 while (oldElement->attributeCount()) { |
194 const Attribute& attribute = oldElement->attributeItem(0); | 194 const Attribute& attribute = oldElement->attributeItem(0); |
195 if (!m_domEditor->removeAttribute(oldElement, attribute.localNam
e(), exceptionState)) | 195 if (!m_domEditor->removeAttribute(oldElement, attribute.localNam
e(), exceptionState)) |
196 return false; | 196 return false; |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 // FIXME: Create a function in Element for copying properties. cloneData
FromElement() is close but not enough for this case. | 200 // FIXME: Create a function in Element for copying properties. cloneData
FromElement() is close but not enough for this case. |
201 if (newElement->hasAttributesWithoutUpdate()) { | 201 if (newElement->hasAttributesWithoutUpdate()) { |
202 size_t numAttrs = newElement->attributeCount(); | 202 AttributeIteratorAccessor attributes = newElement->attributesIterato
r(); |
203 for (size_t i = 0; i < numAttrs; ++i) { | 203 AttributeConstIterator end = attributes.end(); |
204 const Attribute& attribute = newElement->attributeItem(i); | 204 for (AttributeConstIterator it = attributes.begin(); it != end; ++it
) { |
205 if (!m_domEditor->setAttribute(oldElement, attribute.name().loca
lName(), attribute.value(), exceptionState)) | 205 if (!m_domEditor->setAttribute(oldElement, it->name().localName(
), it->value(), exceptionState)) |
206 return false; | 206 return false; |
207 } | 207 } |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 bool result = innerPatchChildren(oldElement, oldDigest->m_children, newDiges
t->m_children, exceptionState); | 211 bool result = innerPatchChildren(oldElement, oldDigest->m_children, newDiges
t->m_children, exceptionState); |
212 m_unusedNodesMap.remove(newDigest->m_sha1); | 212 m_unusedNodesMap.remove(newDigest->m_sha1); |
213 return result; | 213 return result; |
214 } | 214 } |
215 | 215 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 Element& element = toElement(*node); | 424 Element& element = toElement(*node); |
425 Node* child = element.firstChild(); | 425 Node* child = element.firstChild(); |
426 while (child) { | 426 while (child) { |
427 OwnPtr<Digest> childInfo = createDigest(child, unusedNodesMap); | 427 OwnPtr<Digest> childInfo = createDigest(child, unusedNodesMap); |
428 addStringToDigestor(digestor.get(), childInfo->m_sha1); | 428 addStringToDigestor(digestor.get(), childInfo->m_sha1); |
429 child = child->nextSibling(); | 429 child = child->nextSibling(); |
430 digest->m_children.append(childInfo.release()); | 430 digest->m_children.append(childInfo.release()); |
431 } | 431 } |
432 | 432 |
433 if (element.hasAttributesWithoutUpdate()) { | 433 if (element.hasAttributesWithoutUpdate()) { |
434 size_t numAttrs = element.attributeCount(); | |
435 OwnPtr<blink::WebCryptoDigestor> attrsDigestor = createDigestor(Hash
AlgorithmSha1); | 434 OwnPtr<blink::WebCryptoDigestor> attrsDigestor = createDigestor(Hash
AlgorithmSha1); |
436 for (size_t i = 0; i < numAttrs; ++i) { | 435 AttributeIteratorAccessor attributes = element.attributesIterator(); |
437 const Attribute& attribute = element.attributeItem(i); | 436 AttributeConstIterator end = attributes.end(); |
438 addStringToDigestor(attrsDigestor.get(), attribute.name().toStri
ng()); | 437 for (AttributeConstIterator it = attributes.begin(); it != end; ++it
) { |
439 addStringToDigestor(attrsDigestor.get(), attribute.value().strin
g()); | 438 addStringToDigestor(attrsDigestor.get(), it->name().toString()); |
| 439 addStringToDigestor(attrsDigestor.get(), it->value().string()); |
440 } | 440 } |
441 finishDigestor(attrsDigestor.get(), digestResult); | 441 finishDigestor(attrsDigestor.get(), digestResult); |
442 digest->m_attrsSHA1 = base64Encode(reinterpret_cast<const char*>(dig
estResult.data()), 10); | 442 digest->m_attrsSHA1 = base64Encode(reinterpret_cast<const char*>(dig
estResult.data()), 10); |
443 addStringToDigestor(digestor.get(), digest->m_attrsSHA1); | 443 addStringToDigestor(digestor.get(), digest->m_attrsSHA1); |
444 digestResult.clear(); | 444 digestResult.clear(); |
445 } | 445 } |
446 } | 446 } |
447 finishDigestor(digestor.get(), digestResult); | 447 finishDigestor(digestor.get(), digestResult); |
448 digest->m_sha1 = base64Encode(reinterpret_cast<const char*>(digestResult.dat
a()), 10); | 448 digest->m_sha1 = base64Encode(reinterpret_cast<const char*>(digestResult.dat
a()), 10); |
449 | 449 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) | 511 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) |
512 { | 512 { |
513 fprintf(stderr, "\n\n"); | 513 fprintf(stderr, "\n\n"); |
514 for (size_t i = 0; i < map.size(); ++i) | 514 for (size_t i = 0; i < map.size(); ++i) |
515 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); | 515 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); |
516 } | 516 } |
517 #endif | 517 #endif |
518 | 518 |
519 } // namespace WebCore | 519 } // namespace WebCore |
520 | 520 |
OLD | NEW |