| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING); | 875 var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING); |
| 876 for (var j = 0; i < n; i++, j++) { | 876 for (var j = 0; i < n; i++, j++) { |
| 877 var code = %_Arguments(i); | 877 var code = %_Arguments(i); |
| 878 if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff; | 878 if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff; |
| 879 %_TwoByteSeqStringSetChar(two_byte, j, code); | 879 %_TwoByteSeqStringSetChar(two_byte, j, code); |
| 880 } | 880 } |
| 881 return one_byte + two_byte; | 881 return one_byte + two_byte; |
| 882 } | 882 } |
| 883 | 883 |
| 884 | 884 |
| 885 // ES6 draft 07-15-13, section 15.5.3.22 |
| 886 function StringStartsWith(searchString /* position */) { // length == 1 |
| 887 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 888 throw MakeTypeError("called_on_null_or_undefined", |
| 889 ["String.prototype.startsWith"]); |
| 890 } |
| 891 |
| 892 var s = TO_STRING_INLINE(this); |
| 893 var s_len = s.length; |
| 894 var ss = TO_STRING_INLINE(searchString); |
| 895 var ss_len = ss.length; |
| 896 |
| 897 if (ss_len > 0) { |
| 898 var pos = 0; |
| 899 if (%_ArgumentsLength() > 1) { |
| 900 pos = %_Arguments(1); // position |
| 901 pos = TO_INTEGER(pos); |
| 902 } |
| 903 |
| 904 var start = $Math.min($Math.max(pos, 0), s_len); |
| 905 if (ss_len + start > s_len) { |
| 906 return false; |
| 907 } |
| 908 |
| 909 return %StringIndexOf(s, ss, start) === start; |
| 910 } |
| 911 |
| 912 return true; |
| 913 } |
| 914 |
| 915 |
| 885 // Helper function for very basic XSS protection. | 916 // Helper function for very basic XSS protection. |
| 886 function HtmlEscape(str) { | 917 function HtmlEscape(str) { |
| 887 return TO_STRING_INLINE(str).replace(/</g, "<") | 918 return TO_STRING_INLINE(str).replace(/</g, "<") |
| 888 .replace(/>/g, ">") | 919 .replace(/>/g, ">") |
| 889 .replace(/"/g, """) | 920 .replace(/"/g, """) |
| 890 .replace(/'/g, "'"); | 921 .replace(/'/g, "'"); |
| 891 } | 922 } |
| 892 | 923 |
| 893 | 924 |
| 894 // Compatibility support for KJS. | 925 // Compatibility support for KJS. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 "fontcolor", StringFontcolor, | 1034 "fontcolor", StringFontcolor, |
| 1004 "fontsize", StringFontsize, | 1035 "fontsize", StringFontsize, |
| 1005 "big", StringBig, | 1036 "big", StringBig, |
| 1006 "blink", StringBlink, | 1037 "blink", StringBlink, |
| 1007 "bold", StringBold, | 1038 "bold", StringBold, |
| 1008 "fixed", StringFixed, | 1039 "fixed", StringFixed, |
| 1009 "italics", StringItalics, | 1040 "italics", StringItalics, |
| 1010 "small", StringSmall, | 1041 "small", StringSmall, |
| 1011 "strike", StringStrike, | 1042 "strike", StringStrike, |
| 1012 "sub", StringSub, | 1043 "sub", StringSub, |
| 1013 "sup", StringSup | 1044 "sup", StringSup, |
| 1045 "startsWith", StringStartsWith |
| 1014 )); | 1046 )); |
| 1015 } | 1047 } |
| 1016 | 1048 |
| 1017 SetUpString(); | 1049 SetUpString(); |
| OLD | NEW |