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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 Node* newNode = newDigest->m_node; | 174 Node* newNode = newDigest->m_node; |
175 | 175 |
176 if (newNode->nodeType() != oldNode->nodeType() || newNode->nodeName() != old
Node->nodeName()) | 176 if (newNode->nodeType() != oldNode->nodeType() || newNode->nodeName() != old
Node->nodeName()) |
177 return m_domEditor->replaceChild(oldNode->parentNode(), newNode, oldNode
, exceptionState); | 177 return m_domEditor->replaceChild(oldNode->parentNode(), newNode, oldNode
, exceptionState); |
178 | 178 |
179 if (oldNode->nodeValue() != newNode->nodeValue()) { | 179 if (oldNode->nodeValue() != newNode->nodeValue()) { |
180 if (!m_domEditor->setNodeValue(oldNode, newNode->nodeValue(), exceptionS
tate)) | 180 if (!m_domEditor->setNodeValue(oldNode, newNode->nodeValue(), exceptionS
tate)) |
181 return false; | 181 return false; |
182 } | 182 } |
183 | 183 |
184 if (oldNode->nodeType() != Node::ELEMENT_NODE) | 184 if (!oldNode->isElementNode()) |
185 return true; | 185 return true; |
186 | 186 |
187 // Patch attributes | 187 // Patch attributes |
188 Element* oldElement = toElement(oldNode); | 188 Element* oldElement = toElement(oldNode); |
189 Element* newElement = toElement(newNode); | 189 Element* newElement = toElement(newNode); |
190 if (oldDigest->m_attrsSHA1 != newDigest->m_attrsSHA1) { | 190 if (oldDigest->m_attrsSHA1 != newDigest->m_attrsSHA1) { |
191 // FIXME: Create a function in Element for removing all properties. Take
in account whether did/willModifyAttribute are important. | 191 // FIXME: Create a function in Element for removing all properties. Take
in account whether did/willModifyAttribute are important. |
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); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 Digest* digest = new Digest(node); | 413 Digest* digest = new Digest(node); |
414 | 414 |
415 OwnPtr<blink::WebCryptoDigestor> digestor = createDigestor(HashAlgorithmSha1
); | 415 OwnPtr<blink::WebCryptoDigestor> digestor = createDigestor(HashAlgorithmSha1
); |
416 DigestValue digestResult; | 416 DigestValue digestResult; |
417 | 417 |
418 Node::NodeType nodeType = node->nodeType(); | 418 Node::NodeType nodeType = node->nodeType(); |
419 digestor->consume(reinterpret_cast<const unsigned char*>(&nodeType), sizeof(
nodeType)); | 419 digestor->consume(reinterpret_cast<const unsigned char*>(&nodeType), sizeof(
nodeType)); |
420 addStringToDigestor(digestor.get(), node->nodeName()); | 420 addStringToDigestor(digestor.get(), node->nodeName()); |
421 addStringToDigestor(digestor.get(), node->nodeValue()); | 421 addStringToDigestor(digestor.get(), node->nodeValue()); |
422 | 422 |
423 if (node->nodeType() == Node::ELEMENT_NODE) { | 423 if (node->isElementNode()) { |
424 Node* child = node->firstChild(); | 424 Element& element = toElement(*node); |
| 425 Node* child = element.firstChild(); |
425 while (child) { | 426 while (child) { |
426 OwnPtr<Digest> childInfo = createDigest(child, unusedNodesMap); | 427 OwnPtr<Digest> childInfo = createDigest(child, unusedNodesMap); |
427 addStringToDigestor(digestor.get(), childInfo->m_sha1); | 428 addStringToDigestor(digestor.get(), childInfo->m_sha1); |
428 child = child->nextSibling(); | 429 child = child->nextSibling(); |
429 digest->m_children.append(childInfo.release()); | 430 digest->m_children.append(childInfo.release()); |
430 } | 431 } |
431 Element* element = toElement(node); | |
432 | 432 |
433 if (element->hasAttributesWithoutUpdate()) { | 433 if (element.hasAttributesWithoutUpdate()) { |
434 size_t numAttrs = element->attributeCount(); | 434 size_t numAttrs = element.attributeCount(); |
435 OwnPtr<blink::WebCryptoDigestor> attrsDigestor = createDigestor(Hash
AlgorithmSha1); | 435 OwnPtr<blink::WebCryptoDigestor> attrsDigestor = createDigestor(Hash
AlgorithmSha1); |
436 for (size_t i = 0; i < numAttrs; ++i) { | 436 for (size_t i = 0; i < numAttrs; ++i) { |
437 const Attribute& attribute = element->attributeItem(i); | 437 const Attribute& attribute = element.attributeItem(i); |
438 addStringToDigestor(attrsDigestor.get(), attribute.name().toStri
ng()); | 438 addStringToDigestor(attrsDigestor.get(), attribute.name().toStri
ng()); |
439 addStringToDigestor(attrsDigestor.get(), attribute.value().strin
g()); | 439 addStringToDigestor(attrsDigestor.get(), attribute.value().strin
g()); |
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); |
(...skipping 63 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 |