| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 (function() { | 5 (function() { |
| 6 var a = 7; | 6 var a = 7; |
| 7 var a2 = a / 2; | 7 var a2 = a / 2; |
| 8 var ctx = document.getCSSCanvasContext('2d', 'triangle-filled', a2 + 2, a + 1)
; | 8 var ctx = document.getCSSCanvasContext('2d', 'triangle-filled', a2 + 2, a + 1)
; |
| 9 | 9 |
| 10 ctx.fillStyle = '#000'; | 10 ctx.fillStyle = '#000'; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 ctx.translate(.5 + 2, .5 + 2); | 44 ctx.translate(.5 + 2, .5 + 2); |
| 45 ctx.fillStyle = '#000'; | 45 ctx.fillStyle = '#000'; |
| 46 ctx.beginPath(); | 46 ctx.beginPath(); |
| 47 | 47 |
| 48 ctx.moveTo(0, 0); | 48 ctx.moveTo(0, 0); |
| 49 ctx.lineTo(0, a); | 49 ctx.lineTo(0, a); |
| 50 ctx.lineTo(a2, a2); | 50 ctx.lineTo(a2, a2); |
| 51 ctx.closePath(); | 51 ctx.closePath(); |
| 52 ctx.stroke(); | 52 ctx.stroke(); |
| 53 })(); | 53 })(); |
| 54 | |
| 55 // We need to generate CSS for the indentation. | |
| 56 (function() { | |
| 57 // We need to generat the following | |
| 58 //.tree-item > * > .tree-item > .tree-row { | |
| 59 // -webkit-padding-start: 20px; | |
| 60 //} | |
| 61 | |
| 62 //.tree-item > * .tree-item > * .tree-item > * > .tree-item > .tree-row { | |
| 63 // -webkit-padding-start: 60px; | |
| 64 //} | |
| 65 var style = document.createElement('style'); | |
| 66 | |
| 67 function repeat(s, n) { | |
| 68 return Array(n + 1).join(s); | |
| 69 } | |
| 70 | |
| 71 var s = ''; | |
| 72 for (var i = 1; i < 10; i++) { | |
| 73 s += repeat('.tree-item > * ', i) + '.tree-item > .tree-row {\n' + | |
| 74 '-webkit-padding-start:' + i * 20 + 'px\n' + | |
| 75 '}\n'; | |
| 76 } | |
| 77 style.textContent = s; | |
| 78 document.documentElement.firstElementChild.appendChild(style); | |
| 79 })(); | |
| OLD | NEW |