Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: Source/core/xml/XMLViewer.js

Issue 23604028: [XML Viewer crash] Store the reference of pretty-print div as tree to be used during the processing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/http/tests/xmlviewer/dumpAsText/xmlviewer-root-element-id-tree-appearing-blank-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 10 *
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 tree.classList.add('pretty-print'); 65 tree.classList.add('pretty-print');
66 tree.id = 'tree'; 66 tree.id = 'tree';
67 window.onload = sourceXMLLoaded; 67 window.onload = sourceXMLLoaded;
68 } 68 }
69 69
70 function sourceXMLLoaded() 70 function sourceXMLLoaded()
71 { 71 {
72 var sourceXML = document.getElementById('webkit-xml-viewer-source-xml'); 72 var sourceXML = document.getElementById('webkit-xml-viewer-source-xml');
73 if (!sourceXML) 73 if (!sourceXML)
74 return; // Stop if some XML tree extension is already processing this do cument 74 return; // Stop if some XML tree extension is already processing this do cument
75
76 // Momentarily detach the sourceXML from the DOM in order to not clash with
77 // any elements in the source XML having id="tree" attribute.
78 sourceXML.parentNode.removeChild(sourceXML);
79
75 var root = document.getElementById('tree'); 80 var root = document.getElementById('tree');
abarth-chromium 2013/09/04 02:02:40 Why not save off the |tree| reference instead of c
76 81
77 for (var child = sourceXML.firstChild; child; child = child.nextSibling) 82 for (var child = sourceXML.firstChild; child; child = child.nextSibling)
78 nodeParentPairs.push({parentElement: root, node: child}); 83 nodeParentPairs.push({parentElement: root, node: child});
79 84
80 for (var i = 0; i < nodeParentPairs.length; i++) 85 for (var i = 0; i < nodeParentPairs.length; i++)
81 processNode(nodeParentPairs[i].parentElement, nodeParentPairs[i].node); 86 processNode(nodeParentPairs[i].parentElement, nodeParentPairs[i].node);
82 87
83 drawArrows(); 88 drawArrows();
84 initButtons(); 89 initButtons();
85 90
91 // Processing of the XML document is complete. Now attach the sourceXML back into the body
92 document.body.appendChild(sourceXML);
93
86 if (typeof(onAfterWebkitXMLViewerLoaded) == 'function') 94 if (typeof(onAfterWebkitXMLViewerLoaded) == 'function')
87 onAfterWebkitXMLViewerLoaded(); 95 onAfterWebkitXMLViewerLoaded();
88 } 96 }
89 97
90 // Tree processing. 98 // Tree processing.
91 99
92 function processNode(parentElement, node) 100 function processNode(parentElement, node)
93 { 101 {
94 if (!processNode.processorsMap) { 102 if (!processNode.processorsMap) {
95 processNode.processorsMap = {}; 103 processNode.processorsMap = {};
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 expandButton.onmousedown = handleButtonMouseDown; 431 expandButton.onmousedown = handleButtonMouseDown;
424 } 432 }
425 433
426 } 434 }
427 435
428 function handleButtonMouseDown(e) 436 function handleButtonMouseDown(e)
429 { 437 {
430 // To prevent selection on double click 438 // To prevent selection on double click
431 e.preventDefault(); 439 e.preventDefault();
432 } 440 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/xmlviewer/dumpAsText/xmlviewer-root-element-id-tree-appearing-blank-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698