OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 /** | 74 /** |
75 * @param {string} content | 75 * @param {string} content |
76 * @param {string} query | 76 * @param {string} query |
77 * @param {boolean} caseSensitive | 77 * @param {boolean} caseSensitive |
78 * @param {boolean} isRegex | 78 * @param {boolean} isRegex |
79 * @return {!Array.<!Common.ContentProvider.SearchMatch>} | 79 * @return {!Array.<!Common.ContentProvider.SearchMatch>} |
80 */ | 80 */ |
81 Common.ContentProvider.performSearchInContent = function(content, query, caseSen
sitive, isRegex) { | 81 Common.ContentProvider.performSearchInContent = function(content, query, caseSen
sitive, isRegex) { |
82 var regex = createSearchRegex(query, caseSensitive, isRegex); | 82 var regex = createSearchRegex(query, caseSensitive, isRegex); |
83 | 83 |
84 var text = new Common.Text(content); | 84 var text = new TextUtils.Text(content); |
85 var result = []; | 85 var result = []; |
86 for (var i = 0; i < text.lineCount(); ++i) { | 86 for (var i = 0; i < text.lineCount(); ++i) { |
87 var lineContent = text.lineAt(i); | 87 var lineContent = text.lineAt(i); |
88 regex.lastIndex = 0; | 88 regex.lastIndex = 0; |
89 if (regex.exec(lineContent)) | 89 if (regex.exec(lineContent)) |
90 result.push(new Common.ContentProvider.SearchMatch(i, lineContent)); | 90 result.push(new Common.ContentProvider.SearchMatch(i, lineContent)); |
91 } | 91 } |
92 return result; | 92 return result; |
93 }; | 93 }; |
94 | 94 |
95 /** | 95 /** |
96 * @param {?string} content | 96 * @param {?string} content |
97 * @param {string} mimeType | 97 * @param {string} mimeType |
98 * @param {boolean} contentEncoded | 98 * @param {boolean} contentEncoded |
99 * @param {?string=} charset | 99 * @param {?string=} charset |
100 * @return {?string} | 100 * @return {?string} |
101 */ | 101 */ |
102 Common.ContentProvider.contentAsDataURL = function(content, mimeType, contentEnc
oded, charset) { | 102 Common.ContentProvider.contentAsDataURL = function(content, mimeType, contentEnc
oded, charset) { |
103 const maxDataUrlSize = 1024 * 1024; | 103 const maxDataUrlSize = 1024 * 1024; |
104 if (content === null || content.length > maxDataUrlSize) | 104 if (content === null || content.length > maxDataUrlSize) |
105 return null; | 105 return null; |
106 | 106 |
107 return 'data:' + mimeType + (charset ? ';charset=' + charset : '') + (contentE
ncoded ? ';base64' : '') + ',' + | 107 return 'data:' + mimeType + (charset ? ';charset=' + charset : '') + (contentE
ncoded ? ';base64' : '') + ',' + |
108 content; | 108 content; |
109 }; | 109 }; |
OLD | NEW |