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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 // 2. Patch nodes marked for merge. | 369 // 2. Patch nodes marked for merge. |
370 for (HashMap<Digest*, Digest*>::iterator it = merges.begin(); it != merges.e
nd(); ++it) { | 370 for (HashMap<Digest*, Digest*>::iterator it = merges.begin(); it != merges.e
nd(); ++it) { |
371 if (!innerPatchNode(it->value, it->key, exceptionState)) | 371 if (!innerPatchNode(it->value, it->key, exceptionState)) |
372 return false; | 372 return false; |
373 } | 373 } |
374 | 374 |
375 // 3. Insert missing nodes. | 375 // 3. Insert missing nodes. |
376 for (size_t i = 0; i < newMap.size(); ++i) { | 376 for (size_t i = 0; i < newMap.size(); ++i) { |
377 if (newMap[i].first || merges.contains(newList[i].get())) | 377 if (newMap[i].first || merges.contains(newList[i].get())) |
378 continue; | 378 continue; |
379 if (!insertBeforeAndMarkAsUsed(parentNode, newList[i].get(), parentNode-
>childNode(i), exceptionState)) | 379 if (!insertBeforeAndMarkAsUsed(parentNode, newList[i].get(), parentNode-
>traverseToChildAt(i), exceptionState)) |
380 return false; | 380 return false; |
381 } | 381 } |
382 | 382 |
383 // 4. Then put all nodes that retained into their slots (sort by new index). | 383 // 4. Then put all nodes that retained into their slots (sort by new index). |
384 for (size_t i = 0; i < oldMap.size(); ++i) { | 384 for (size_t i = 0; i < oldMap.size(); ++i) { |
385 if (!oldMap[i].first) | 385 if (!oldMap[i].first) |
386 continue; | 386 continue; |
387 RefPtr<Node> node = oldMap[i].first->m_node; | 387 RefPtr<Node> node = oldMap[i].first->m_node; |
388 Node* anchorNode = parentNode->childNode(oldMap[i].second); | 388 Node* anchorNode = parentNode->traverseToChildAt(oldMap[i].second); |
389 if (node.get() == anchorNode) | 389 if (node.get() == anchorNode) |
390 continue; | 390 continue; |
391 if (node->hasTagName(bodyTag) || node->hasTagName(headTag)) | 391 if (node->hasTagName(bodyTag) || node->hasTagName(headTag)) |
392 continue; // Never move head or body, move the rest of the nodes aro
und them. | 392 continue; // Never move head or body, move the rest of the nodes aro
und them. |
393 | 393 |
394 if (!m_domEditor->insertBefore(parentNode, node.release(), anchorNode, e
xceptionState)) | 394 if (!m_domEditor->insertBefore(parentNode, node.release(), anchorNode, e
xceptionState)) |
395 return false; | 395 return false; |
396 } | 396 } |
397 return true; | 397 return true; |
398 } | 398 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) | 506 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) |
507 { | 507 { |
508 fprintf(stderr, "\n\n"); | 508 fprintf(stderr, "\n\n"); |
509 for (size_t i = 0; i < map.size(); ++i) | 509 for (size_t i = 0; i < map.size(); ++i) |
510 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); | 510 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); |
511 } | 511 } |
512 #endif | 512 #endif |
513 | 513 |
514 } // namespace WebCore | 514 } // namespace WebCore |
515 | 515 |
OLD | NEW |