| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 "use strict"; | 5 "use strict"; |
| 6 | 6 |
| 7 var xmlTreeViewerCSS = privateScriptController.import("DocumentXMLTreeViewer.css
"); | 7 var xmlTreeViewerCSS = privateScriptController.import("DocumentXMLTreeViewer.css
"); |
| 8 | 8 |
| 9 privateScriptController.installClass("Document", function(DocumentPrototype) { | 9 privateScriptController.installClass("Document", function(DocumentPrototype) { |
| 10 var nodeParentPairs = []; | 10 var nodeParentPairs = []; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 var sourceXML = document.getElementById('webkit-xml-viewer-source-xml'); | 52 var sourceXML = document.getElementById('webkit-xml-viewer-source-xml'); |
| 53 if (!sourceXML) | 53 if (!sourceXML) |
| 54 return; // Stop if some XML tree extension is already processing thi
s document | 54 return; // Stop if some XML tree extension is already processing thi
s document |
| 55 | 55 |
| 56 for (var child = sourceXML.firstChild; child; child = child.nextSibling) | 56 for (var child = sourceXML.firstChild; child; child = child.nextSibling) |
| 57 nodeParentPairs.push({parentElement: tree, node: child}); | 57 nodeParentPairs.push({parentElement: tree, node: child}); |
| 58 | 58 |
| 59 for (var i = 0; i < nodeParentPairs.length; i++) | 59 for (var i = 0; i < nodeParentPairs.length; i++) |
| 60 processNode(nodeParentPairs[i].parentElement, nodeParentPairs[i].nod
e); | 60 processNode(nodeParentPairs[i].parentElement, nodeParentPairs[i].nod
e); |
| 61 | 61 |
| 62 drawArrows(); | |
| 63 initButtons(); | 62 initButtons(); |
| 64 | 63 |
| 65 return false; | 64 return false; |
| 66 } | 65 } |
| 67 | 66 |
| 68 // Tree processing. | 67 // Tree processing. |
| 69 | 68 |
| 70 function processNode(parentElement, node) | 69 function processNode(parentElement, node) |
| 71 { | 70 { |
| 72 var map = processNode.processorsMap; | 71 var map = processNode.processorsMap; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 var textAfter = document.createTextNode('"'); | 332 var textAfter = document.createTextNode('"'); |
| 334 | 333 |
| 335 attribute.appendChild(textBefore); | 334 attribute.appendChild(textBefore); |
| 336 attribute.appendChild(attributeName); | 335 attribute.appendChild(attributeName); |
| 337 attribute.appendChild(textBetween); | 336 attribute.appendChild(textBetween); |
| 338 attribute.appendChild(attributeValue); | 337 attribute.appendChild(attributeValue); |
| 339 attribute.appendChild(textAfter); | 338 attribute.appendChild(textAfter); |
| 340 return attribute; | 339 return attribute; |
| 341 } | 340 } |
| 342 | 341 |
| 343 // Tree behaviour. | |
| 344 | |
| 345 function drawArrows() | |
| 346 { | |
| 347 var ctx = document.getCSSCanvasContext("2d", "arrowRight", 10, 11); | |
| 348 | |
| 349 ctx.fillStyle = "rgb(90,90,90)"; | |
| 350 ctx.beginPath(); | |
| 351 ctx.moveTo(0, 0); | |
| 352 ctx.lineTo(0, 8); | |
| 353 ctx.lineTo(7, 4); | |
| 354 ctx.lineTo(0, 0); | |
| 355 ctx.fill(); | |
| 356 ctx.closePath(); | |
| 357 | |
| 358 var ctx = document.getCSSCanvasContext("2d", "arrowDown", 10, 10); | |
| 359 | |
| 360 ctx.fillStyle = "rgb(90,90,90)"; | |
| 361 ctx.beginPath(); | |
| 362 ctx.moveTo(0, 0); | |
| 363 ctx.lineTo(8, 0); | |
| 364 ctx.lineTo(4, 7); | |
| 365 ctx.lineTo(0, 0); | |
| 366 ctx.fill(); | |
| 367 ctx.closePath(); | |
| 368 } | |
| 369 | |
| 370 function expandFunction(sectionId) | 342 function expandFunction(sectionId) |
| 371 { | 343 { |
| 372 return function() | 344 return function() |
| 373 { | 345 { |
| 374 document.querySelector('#' + sectionId + ' > .expanded').className =
'expanded'; | 346 document.querySelector('#' + sectionId + ' > .expanded').className =
'expanded'; |
| 375 document.querySelector('#' + sectionId + ' > .collapsed').className
= 'collapsed hidden'; | 347 document.querySelector('#' + sectionId + ' > .collapsed').className
= 'collapsed hidden'; |
| 376 }; | 348 }; |
| 377 } | 349 } |
| 378 | 350 |
| 379 function collapseFunction(sectionId) | 351 function collapseFunction(sectionId) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 409 { | 381 { |
| 410 // To prevent selection on double click | 382 // To prevent selection on double click |
| 411 e.preventDefault(); | 383 e.preventDefault(); |
| 412 } | 384 } |
| 413 | 385 |
| 414 DocumentPrototype.transformDocumentToTreeView = function(noStyleMessage) { | 386 DocumentPrototype.transformDocumentToTreeView = function(noStyleMessage) { |
| 415 prepareWebKitXMLViewer(noStyleMessage); | 387 prepareWebKitXMLViewer(noStyleMessage); |
| 416 } | 388 } |
| 417 }); | 389 }); |
| 418 | 390 |
| OLD | NEW |