Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 // This file relies on the fact that the following declaration has been made | 5 // This file relies on the fact that the following declaration has been made |
| 6 // in runtime.js: | 6 // in runtime.js: |
| 7 // var $String = global.String; | 7 // var $String = global.String; |
| 8 | 8 |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 | 10 |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 return TO_STRING_INLINE(str).replace(/</g, "<") | 832 return TO_STRING_INLINE(str).replace(/</g, "<") |
| 833 .replace(/>/g, ">") | 833 .replace(/>/g, ">") |
| 834 .replace(/"/g, """) | 834 .replace(/"/g, """) |
| 835 .replace(/'/g, "'"); | 835 .replace(/'/g, "'"); |
| 836 } | 836 } |
| 837 | 837 |
| 838 | 838 |
| 839 // Compatibility support for KJS. | 839 // Compatibility support for KJS. |
| 840 // Tested by mozilla/js/tests/js1_5/Regress/regress-276103.js. | 840 // Tested by mozilla/js/tests/js1_5/Regress/regress-276103.js. |
| 841 function StringLink(s) { | 841 function StringLink(s) { |
| 842 CHECK_OBJECT_COERCIBLE(this, "String.prototype.link"); | |
|
Yang
2014/08/05 10:34:19
Now that all of this is specified in ES6, do you m
| |
| 842 return "<a href=\"" + HtmlEscape(s) + "\">" + this + "</a>"; | 843 return "<a href=\"" + HtmlEscape(s) + "\">" + this + "</a>"; |
| 843 } | 844 } |
| 844 | 845 |
| 845 | 846 |
| 846 function StringAnchor(name) { | 847 function StringAnchor(name) { |
| 848 CHECK_OBJECT_COERCIBLE(this, "String.prototype.anchor"); | |
| 847 return "<a name=\"" + HtmlEscape(name) + "\">" + this + "</a>"; | 849 return "<a name=\"" + HtmlEscape(name) + "\">" + this + "</a>"; |
| 848 } | 850 } |
| 849 | 851 |
| 850 | 852 |
| 851 function StringFontcolor(color) { | 853 function StringFontcolor(color) { |
| 854 CHECK_OBJECT_COERCIBLE(this, "String.prototype.fontcolor"); | |
| 852 return "<font color=\"" + HtmlEscape(color) + "\">" + this + "</font>"; | 855 return "<font color=\"" + HtmlEscape(color) + "\">" + this + "</font>"; |
| 853 } | 856 } |
| 854 | 857 |
| 855 | 858 |
| 856 function StringFontsize(size) { | 859 function StringFontsize(size) { |
| 860 CHECK_OBJECT_COERCIBLE(this, "String.prototype.fontsize"); | |
| 857 return "<font size=\"" + HtmlEscape(size) + "\">" + this + "</font>"; | 861 return "<font size=\"" + HtmlEscape(size) + "\">" + this + "</font>"; |
| 858 } | 862 } |
| 859 | 863 |
| 860 | 864 |
| 861 function StringBig() { | 865 function StringBig() { |
| 866 CHECK_OBJECT_COERCIBLE(this, "String.prototype.big"); | |
| 862 return "<big>" + this + "</big>"; | 867 return "<big>" + this + "</big>"; |
| 863 } | 868 } |
| 864 | 869 |
| 865 | 870 |
| 866 function StringBlink() { | 871 function StringBlink() { |
| 872 CHECK_OBJECT_COERCIBLE(this, "String.prototype.blink"); | |
| 867 return "<blink>" + this + "</blink>"; | 873 return "<blink>" + this + "</blink>"; |
| 868 } | 874 } |
| 869 | 875 |
| 870 | 876 |
| 871 function StringBold() { | 877 function StringBold() { |
| 878 CHECK_OBJECT_COERCIBLE(this, "String.prototype.bold"); | |
| 872 return "<b>" + this + "</b>"; | 879 return "<b>" + this + "</b>"; |
| 873 } | 880 } |
| 874 | 881 |
| 875 | 882 |
| 876 function StringFixed() { | 883 function StringFixed() { |
| 884 CHECK_OBJECT_COERCIBLE(this, "String.prototype.fixed"); | |
| 877 return "<tt>" + this + "</tt>"; | 885 return "<tt>" + this + "</tt>"; |
| 878 } | 886 } |
| 879 | 887 |
| 880 | 888 |
| 881 function StringItalics() { | 889 function StringItalics() { |
| 890 CHECK_OBJECT_COERCIBLE(this, "String.prototype.italics"); | |
| 882 return "<i>" + this + "</i>"; | 891 return "<i>" + this + "</i>"; |
| 883 } | 892 } |
| 884 | 893 |
| 885 | 894 |
| 886 function StringSmall() { | 895 function StringSmall() { |
| 896 CHECK_OBJECT_COERCIBLE(this, "String.prototype.small"); | |
| 887 return "<small>" + this + "</small>"; | 897 return "<small>" + this + "</small>"; |
| 888 } | 898 } |
| 889 | 899 |
| 890 | 900 |
| 891 function StringStrike() { | 901 function StringStrike() { |
| 902 CHECK_OBJECT_COERCIBLE(this, "String.prototype.strike"); | |
| 892 return "<strike>" + this + "</strike>"; | 903 return "<strike>" + this + "</strike>"; |
| 893 } | 904 } |
| 894 | 905 |
| 895 | 906 |
| 896 function StringSub() { | 907 function StringSub() { |
| 908 CHECK_OBJECT_COERCIBLE(this, "String.prototype.sub"); | |
| 897 return "<sub>" + this + "</sub>"; | 909 return "<sub>" + this + "</sub>"; |
| 898 } | 910 } |
| 899 | 911 |
| 900 | 912 |
| 901 function StringSup() { | 913 function StringSup() { |
| 914 CHECK_OBJECT_COERCIBLE(this, "String.prototype.sup"); | |
| 902 return "<sup>" + this + "</sup>"; | 915 return "<sup>" + this + "</sup>"; |
| 903 } | 916 } |
| 904 | 917 |
| 905 // ------------------------------------------------------------------- | 918 // ------------------------------------------------------------------- |
| 906 | 919 |
| 907 function SetUpString() { | 920 function SetUpString() { |
| 908 %CheckIsBootstrapping(); | 921 %CheckIsBootstrapping(); |
| 909 | 922 |
| 910 // Set the String function and constructor. | 923 // Set the String function and constructor. |
| 911 %SetCode($String, StringConstructor); | 924 %SetCode($String, StringConstructor); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 "fixed", StringFixed, | 967 "fixed", StringFixed, |
| 955 "italics", StringItalics, | 968 "italics", StringItalics, |
| 956 "small", StringSmall, | 969 "small", StringSmall, |
| 957 "strike", StringStrike, | 970 "strike", StringStrike, |
| 958 "sub", StringSub, | 971 "sub", StringSub, |
| 959 "sup", StringSup | 972 "sup", StringSup |
| 960 )); | 973 )); |
| 961 } | 974 } |
| 962 | 975 |
| 963 SetUpString(); | 976 SetUpString(); |
| OLD | NEW |