OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 entry.node.parentElement.removeChild(entry.node); | 969 entry.node.parentElement.removeChild(entry.node); |
970 break; | 970 break; |
971 case "changed": | 971 case "changed": |
972 entry.node.textContent = entry.oldText; | 972 entry.node.textContent = entry.oldText; |
973 break; | 973 break; |
974 } | 974 } |
975 } | 975 } |
976 } | 976 } |
977 | 977 |
978 /** | 978 /** |
979 * @param {string=} extraFlags | 979 * @param {string=} flags |
980 * @return {RegExp} | 980 * @return {RegExp} |
981 */ | 981 */ |
982 function createSearchRegex(query, extraFlags) | 982 function createSearchRegex(query, flags) |
983 { | 983 { |
984 // This should be kept the same as the one in ContentSearchUtils.cpp. | 984 // This should be kept the same as the one in ContentSearchUtils.cpp. |
985 var regexSpecialCharacters = "[](){}+-*.,?\\^$|"; | 985 var regexSpecialCharacters = "[](){}+-*.,?\\^$|"; |
986 var regex = ""; | 986 var regex = ""; |
987 for (var i = 0; i < query.length; ++i) { | 987 for (var i = 0; i < query.length; ++i) { |
988 var c = query.charAt(i); | 988 var c = query.charAt(i); |
989 if (regexSpecialCharacters.indexOf(c) != -1) | 989 if (regexSpecialCharacters.indexOf(c) != -1) |
990 regex += "\\"; | 990 regex += "\\"; |
991 regex += c; | 991 regex += c; |
992 } | 992 } |
993 return new RegExp(regex, "i" + (extraFlags || "")); | 993 return new RegExp(regex, flags || ""); |
994 } | 994 } |
995 | 995 |
996 /** | 996 /** |
997 * @param {RegExp} regex | 997 * @param {RegExp} regex |
998 * @param {string} content | 998 * @param {string} content |
999 * @return {number} | 999 * @return {number} |
1000 */ | 1000 */ |
1001 function countRegexMatches(regex, content) | 1001 function countRegexMatches(regex, content) |
1002 { | 1002 { |
1003 var text = content; | 1003 var text = content; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 diffData.changed.push(i); | 1056 diffData.changed.push(i); |
1057 else { | 1057 else { |
1058 diffData.added.push(i); | 1058 diffData.added.push(i); |
1059 offset++; | 1059 offset++; |
1060 } | 1060 } |
1061 } else | 1061 } else |
1062 offset = i - right[i].row; | 1062 offset = i - right[i].row; |
1063 } | 1063 } |
1064 return diffData; | 1064 return diffData; |
1065 } | 1065 } |
OLD | NEW |