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 20 matching lines...) Expand all Loading... |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/inspector/DOMPatchSupport.h" | 32 #include "core/inspector/DOMPatchSupport.h" |
33 | 33 |
34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
35 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 35 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
36 #include "core/dom/Attribute.h" | 36 #include "core/dom/Attribute.h" |
37 #include "core/dom/ContextFeatures.h" | 37 #include "core/dom/ContextFeatures.h" |
38 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
39 #include "core/dom/DocumentFragment.h" | 39 #include "core/dom/DocumentFragment.h" |
40 #include "core/dom/Node.h" | 40 #include "core/dom/Node.h" |
| 41 #include "core/dom/NodeTraversal.h" |
41 #include "core/dom/XMLDocument.h" | 42 #include "core/dom/XMLDocument.h" |
42 #include "core/html/HTMLBodyElement.h" | 43 #include "core/html/HTMLBodyElement.h" |
43 #include "core/html/HTMLDocument.h" | 44 #include "core/html/HTMLDocument.h" |
44 #include "core/html/HTMLHeadElement.h" | 45 #include "core/html/HTMLHeadElement.h" |
45 #include "core/html/parser/HTMLDocumentParser.h" | 46 #include "core/html/parser/HTMLDocumentParser.h" |
46 #include "core/inspector/DOMEditor.h" | 47 #include "core/inspector/DOMEditor.h" |
47 #include "core/inspector/InspectorHistory.h" | 48 #include "core/inspector/InspectorHistory.h" |
48 #include "core/xml/parser/XMLDocumentParser.h" | 49 #include "core/xml/parser/XMLDocumentParser.h" |
49 #include "platform/Crypto.h" | 50 #include "platform/Crypto.h" |
50 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // 2. Patch nodes marked for merge. | 374 // 2. Patch nodes marked for merge. |
374 for (HashMap<Digest*, Digest*>::iterator it = merges.begin(); it != merges.e
nd(); ++it) { | 375 for (HashMap<Digest*, Digest*>::iterator it = merges.begin(); it != merges.e
nd(); ++it) { |
375 if (!innerPatchNode(it->value, it->key, exceptionState)) | 376 if (!innerPatchNode(it->value, it->key, exceptionState)) |
376 return false; | 377 return false; |
377 } | 378 } |
378 | 379 |
379 // 3. Insert missing nodes. | 380 // 3. Insert missing nodes. |
380 for (size_t i = 0; i < newMap.size(); ++i) { | 381 for (size_t i = 0; i < newMap.size(); ++i) { |
381 if (newMap[i].first || merges.contains(newList[i].get())) | 382 if (newMap[i].first || merges.contains(newList[i].get())) |
382 continue; | 383 continue; |
383 if (!insertBeforeAndMarkAsUsed(parentNode, newList[i].get(), parentNode-
>traverseToChildAt(i), exceptionState)) | 384 if (!insertBeforeAndMarkAsUsed(parentNode, newList[i].get(), NodeTravers
al::childAt(*parentNode, i), exceptionState)) |
384 return false; | 385 return false; |
385 } | 386 } |
386 | 387 |
387 // 4. Then put all nodes that retained into their slots (sort by new index). | 388 // 4. Then put all nodes that retained into their slots (sort by new index). |
388 for (size_t i = 0; i < oldMap.size(); ++i) { | 389 for (size_t i = 0; i < oldMap.size(); ++i) { |
389 if (!oldMap[i].first) | 390 if (!oldMap[i].first) |
390 continue; | 391 continue; |
391 RefPtrWillBeRawPtr<Node> node = oldMap[i].first->m_node; | 392 RefPtrWillBeRawPtr<Node> node = oldMap[i].first->m_node; |
392 Node* anchorNode = parentNode->traverseToChildAt(oldMap[i].second); | 393 Node* anchorNode = NodeTraversal::childAt(*parentNode, oldMap[i].second)
; |
393 if (node == anchorNode) | 394 if (node == anchorNode) |
394 continue; | 395 continue; |
395 if (isHTMLBodyElement(*node) || isHTMLHeadElement(*node)) | 396 if (isHTMLBodyElement(*node) || isHTMLHeadElement(*node)) |
396 continue; // Never move head or body, move the rest of the nodes aro
und them. | 397 continue; // Never move head or body, move the rest of the nodes aro
und them. |
397 | 398 |
398 if (!m_domEditor->insertBefore(parentNode, node.release(), anchorNode, e
xceptionState)) | 399 if (!m_domEditor->insertBefore(parentNode, node.release(), anchorNode, e
xceptionState)) |
399 return false; | 400 return false; |
400 } | 401 } |
401 return true; | 402 return true; |
402 } | 403 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) | 510 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) |
510 { | 511 { |
511 fprintf(stderr, "\n\n"); | 512 fprintf(stderr, "\n\n"); |
512 for (size_t i = 0; i < map.size(); ++i) | 513 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); | 514 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 } | 515 } |
515 #endif | 516 #endif |
516 | 517 |
517 } // namespace blink | 518 } // namespace blink |
518 | 519 |
OLD | NEW |