Chromium Code Reviews| 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 Import("DocumentXMLTreeViewer.css"); | |
|
haraken
2014/11/25 09:41:41
Sorry for another idea: Would it be possible to al
haraken
2014/11/25 09:41:41
Import => import ?
vivekg
2014/11/25 11:30:32
I tried 'import' but this is a reserved keyword fo
vivekg
2014/11/25 11:31:08
Ya sure, let me try to get it this way which looks
| |
| 8 | |
| 7 installClass("Document", function(DocumentPrototype) { | 9 installClass("Document", function(DocumentPrototype) { |
| 8 // FIXME: The stylesheet should be defined in a separate css file | |
| 9 var styleSheet = [ | |
| 10 "div.header {", | |
| 11 " border-bottom: 2px solid black;", | |
| 12 " padding-bottom: 5px;", | |
| 13 " margin: 10px;", | |
| 14 "}", | |
| 15 "", | |
| 16 "div.collapsible > div.hidden {", | |
| 17 " display:none;", | |
| 18 "}", | |
| 19 "", | |
| 20 ".pretty-print {", | |
| 21 " margin-top: 1em;", | |
| 22 " margin-left: 20px;", | |
| 23 " font-family: monospace;", | |
| 24 " font-size: 13px;", | |
| 25 "}", | |
| 26 "", | |
| 27 "#webkit-xml-viewer-source-xml {", | |
| 28 " display: none;", | |
| 29 "}", | |
| 30 "", | |
| 31 ".collapsible-content {", | |
| 32 " margin-left: 1em;", | |
| 33 "}", | |
| 34 ".comment {", | |
| 35 " white-space: pre;", | |
| 36 "}", | |
| 37 "", | |
| 38 ".button {", | |
| 39 " -webkit-user-select: none;", | |
| 40 " cursor: pointer;", | |
| 41 " display: inline-block;", | |
| 42 " margin-left: -10px;", | |
| 43 " width: 10px;", | |
| 44 " background-repeat: no-repeat;", | |
| 45 " background-position: left top;", | |
| 46 " vertical-align: bottom;", | |
| 47 "}", | |
| 48 "", | |
| 49 ".collapse-button {", | |
| 50 " background-image: -webkit-canvas(arrowDown);", | |
| 51 " height: 10px;", | |
| 52 "}", | |
| 53 "", | |
| 54 ".expand-button {", | |
| 55 " background-image: -webkit-canvas(arrowRight);", | |
| 56 " height: 11px;", | |
| 57 "}"].join(''); | |
| 58 var nodeParentPairs = []; | 10 var nodeParentPairs = []; |
| 59 var tree; | 11 var tree; |
| 60 | 12 |
| 61 function prepareWebKitXMLViewer(noStyleMessage) | 13 function prepareWebKitXMLViewer(noStyleMessage) |
| 62 { | 14 { |
| 63 var html = createHTMLElement('html'); | 15 var html = createHTMLElement('html'); |
| 64 var head = createHTMLElement('head'); | 16 var head = createHTMLElement('head'); |
| 65 html.appendChild(head); | 17 html.appendChild(head); |
| 66 var style = createHTMLElement('style'); | 18 var style = createHTMLElement('style'); |
| 67 style.id = 'xml-viewer-style'; | 19 style.id = 'xml-viewer-style'; |
| 68 style.appendChild(document.createTextNode(styleSheet)); | 20 style.appendChild(document.createTextNode(cssDocumentXMLTreeViewer)); |
| 69 head.appendChild(style); | 21 head.appendChild(style); |
| 70 var body = createHTMLElement('body'); | 22 var body = createHTMLElement('body'); |
| 71 html.appendChild(body); | 23 html.appendChild(body); |
| 72 var sourceXML = createHTMLElement('div'); | 24 var sourceXML = createHTMLElement('div'); |
| 73 sourceXML.id = 'webkit-xml-viewer-source-xml'; | 25 sourceXML.id = 'webkit-xml-viewer-source-xml'; |
| 74 body.appendChild(sourceXML); | 26 body.appendChild(sourceXML); |
| 75 | 27 |
| 76 var child; | 28 var child; |
| 77 while (child = document.firstChild) { | 29 while (child = document.firstChild) { |
| 78 document.removeChild(child); | 30 document.removeChild(child); |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 { | 409 { |
| 458 // To prevent selection on double click | 410 // To prevent selection on double click |
| 459 e.preventDefault(); | 411 e.preventDefault(); |
| 460 } | 412 } |
| 461 | 413 |
| 462 DocumentPrototype.transformDocumentToTreeView = function(noStyleMessage) { | 414 DocumentPrototype.transformDocumentToTreeView = function(noStyleMessage) { |
| 463 prepareWebKitXMLViewer(noStyleMessage); | 415 prepareWebKitXMLViewer(noStyleMessage); |
| 464 } | 416 } |
| 465 }); | 417 }); |
| 466 | 418 |
| OLD | NEW |