OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 cr.define('extensions', function() { | 5 cr.define('extensions', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 var CodeSection = Polymer({ | 8 var CodeSection = Polymer({ |
9 is: 'extensions-code-section', | 9 is: 'extensions-code-section', |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... | |
28 couldNotDisplayCode: String, | 28 couldNotDisplayCode: String, |
29 }, | 29 }, |
30 | 30 |
31 /** | 31 /** |
32 * Returns true if no code could be displayed (e.g. because the file could | 32 * Returns true if no code could be displayed (e.g. because the file could |
33 * not be loaded). | 33 * not be loaded). |
34 * @return {boolean} | 34 * @return {boolean} |
35 */ | 35 */ |
36 isEmpty: function() { | 36 isEmpty: function() { |
37 return !this.code || | 37 return !this.code || |
38 (!this.code.beforeHighlight && !this.code.highlight && | 38 (!this.code.beforeHighlight && !this.code.highlight && |
Devlin
2017/06/17 02:25:39
this now violates the rectangle rule, which I *tho
Dan Beam
2017/06/19 23:01:24
there's an internal reference to this rectangle ru
Devlin
2017/06/20 16:02:06
The rule says you should be able to "draw" a recta
| |
39 !this.code.afterHighlight); | 39 !this.code.afterHighlight); |
40 }, | 40 }, |
41 | 41 |
42 /** | 42 /** |
43 * Computes the content of the line numbers span, which basically just | 43 * Computes the content of the line numbers span, which basically just |
44 * contains 1\n2\n3\n... for the number of lines. | 44 * contains 1\n2\n3\n... for the number of lines. |
45 * @return {string} | 45 * @return {string} |
46 * @private | 46 * @private |
47 */ | 47 */ |
48 computeLineNumbersContent_: function() { | 48 computeLineNumbersContent_: function() { |
49 if (!this.code) | 49 if (!this.code) |
50 return ''; | 50 return ''; |
51 | 51 |
52 var lines = [this.code.beforeHighlight, | 52 var lines = [ |
53 this.code.highlight, | 53 this.code.beforeHighlight, this.code.highlight, this.code.afterHighlight |
54 this.code.afterHighlight].join('').match(/\n/g); | 54 ].join('').match(/\n/g); |
55 var lineCount = lines ? lines.length : 0; | 55 var lineCount = lines ? lines.length : 0; |
56 var textContent = ''; | 56 var textContent = ''; |
57 for (var i = 1; i <= lineCount; ++i) | 57 for (var i = 1; i <= lineCount; ++i) |
58 textContent += i + '\n'; | 58 textContent += i + '\n'; |
59 return textContent; | 59 return textContent; |
60 }, | 60 }, |
61 }); | 61 }); |
62 | 62 |
63 return {CodeSection: CodeSection}; | 63 return {CodeSection: CodeSection}; |
64 }); | 64 }); |
OLD | NEW |