Title: [216301] trunk
Revision
216301
Author
[email protected]
Date
2017-05-05 17:33:20 -0700 (Fri, 05 May 2017)

Log Message

Move trivial String prototype functions to JS builtins
https://bugs.webkit.org/show_bug.cgi?id=171737

Reviewed by Saam Barati.

Source/_javascript_Core:

Super simple change to migrate all of the old school
html-ifying string operations to builtin JS.

Core implementation is basically a 1-for-1 match to the spec.

* builtins/StringPrototype.js:
(globalPrivate.createHTML):
(anchor):
(big):
(blink):
(bold):
(fixed):
(fontcolor):
(fontsize):
(italics):
(link):
(small):
(strike):
(sub):
(sup):
* runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):
(JSC::stringProtoFuncBig): Deleted.
(JSC::stringProtoFuncSmall): Deleted.
(JSC::stringProtoFuncBlink): Deleted.
(JSC::stringProtoFuncBold): Deleted.
(JSC::stringProtoFuncFixed): Deleted.
(JSC::stringProtoFuncItalics): Deleted.
(JSC::stringProtoFuncStrike): Deleted.
(JSC::stringProtoFuncSub): Deleted.
(JSC::stringProtoFuncSup): Deleted.
(JSC::stringProtoFuncFontcolor): Deleted.
(JSC::stringProtoFuncFontsize): Deleted.
(JSC::stringProtoFuncAnchor): Deleted.
(JSC::stringProtoFuncLink): Deleted.

LayoutTests:

Updated output

* js/dom/string-anchor-expected.txt:
* js/dom/string-anchor.html:
* js/dom/string-fontcolor-expected.txt:
* js/dom/string-fontcolor.html:
* js/dom/string-fontsize-expected.txt:
* js/dom/string-fontsize.html:
* js/dom/string-link-expected.txt:
* js/dom/string-link.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (216300 => 216301)


--- trunk/LayoutTests/ChangeLog	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/LayoutTests/ChangeLog	2017-05-06 00:33:20 UTC (rev 216301)
@@ -1,3 +1,21 @@
+2017-05-05  Oliver Hunt  <[email protected]>
+
+        Move trivial String prototype functions to JS builtins
+        https://bugs.webkit.org/show_bug.cgi?id=171737
+
+        Reviewed by Saam Barati.
+
+        Updated output
+
+        * js/dom/string-anchor-expected.txt:
+        * js/dom/string-anchor.html:
+        * js/dom/string-fontcolor-expected.txt:
+        * js/dom/string-fontcolor.html:
+        * js/dom/string-fontsize-expected.txt:
+        * js/dom/string-fontsize.html:
+        * js/dom/string-link-expected.txt:
+        * js/dom/string-link.html:
+
 2017-05-05  Dean Jackson  <[email protected]>
 
         Restrict SVG filters to accessible security origins

Modified: trunk/LayoutTests/js/dom/string-anchor-expected.txt (216300 => 216301)


--- trunk/LayoutTests/js/dom/string-anchor-expected.txt	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/LayoutTests/js/dom/string-anchor-expected.txt	2017-05-06 00:33:20 UTC (rev 216301)
@@ -9,8 +9,8 @@
 PASS '_'.anchor('"') is "<a name=\"&quot;\">_</a>"
 PASS '_'.anchor('" href="" is "<a name=\"&quot; href=""
 PASS String.prototype.anchor.call(0x2A, 0x2A) is "<a name=\"42\">42</a>"
-PASS String.prototype.anchor.call(undefined) threw exception TypeError: Type error.
-PASS String.prototype.anchor.call(null) threw exception TypeError: Type error.
+PASS String.prototype.anchor.call(undefined) threw exception TypeError: String.prototype.link requires that |this| not be null or undefined.
+PASS String.prototype.anchor.call(null) threw exception TypeError: String.prototype.link requires that |this| not be null or undefined.
 PASS String.prototype.anchor.length is 1
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/js/dom/string-anchor.html (216300 => 216301)


--- trunk/LayoutTests/js/dom/string-anchor.html	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/LayoutTests/js/dom/string-anchor.html	2017-05-06 00:33:20 UTC (rev 216301)
@@ -28,10 +28,10 @@
 shouldBe("String.prototype.anchor.call(0x2A, 0x2A)", '"<a name=\\"42\\">42</a>"');
 
 // Generic use on non-coercible object `undefined`.
-shouldThrow("String.prototype.anchor.call(undefined)", '"TypeError: Type error"');
+shouldThrowErrorName("String.prototype.anchor.call(undefined)", 'TypeError');
 
 // Generic use on non-coercible object `null`.
-shouldThrow("String.prototype.anchor.call(null)", '"TypeError: Type error"');
+shouldThrowErrorName("String.prototype.anchor.call(null)", 'TypeError');
 
 // Check anchor.length.
 shouldBe("String.prototype.anchor.length", "1");

Modified: trunk/LayoutTests/js/dom/string-fontcolor-expected.txt (216300 => 216301)


--- trunk/LayoutTests/js/dom/string-fontcolor-expected.txt	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/LayoutTests/js/dom/string-fontcolor-expected.txt	2017-05-06 00:33:20 UTC (rev 216301)
@@ -9,8 +9,8 @@
 PASS '_'.fontcolor('"') is "<font color=\"&quot;\">_</font>"
 PASS '_'.fontcolor('" size="2px') is "<font color=\"&quot; size=&quot;2px\">_</font>"
 PASS String.prototype.fontcolor.call(0x2A, 0x2A) is "<font color=\"42\">42</font>"
-PASS String.prototype.fontcolor.call(undefined) threw exception TypeError: Type error.
-PASS String.prototype.fontcolor.call(null) threw exception TypeError: Type error.
+PASS String.prototype.fontcolor.call(undefined) threw exception TypeError: String.prototype.fontcolor requires that |this| not be null or undefined.
+PASS String.prototype.fontcolor.call(null) threw exception TypeError: String.prototype.fontcolor requires that |this| not be null or undefined.
 PASS String.prototype.fontcolor.length is 1
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/js/dom/string-fontcolor.html (216300 => 216301)


--- trunk/LayoutTests/js/dom/string-fontcolor.html	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/LayoutTests/js/dom/string-fontcolor.html	2017-05-06 00:33:20 UTC (rev 216301)
@@ -28,10 +28,10 @@
 shouldBe("String.prototype.fontcolor.call(0x2A, 0x2A)", '"<font color=\\"42\\">42</font>"');
 
 // Generic use on non-coercible object `undefined`.
-shouldThrow("String.prototype.fontcolor.call(undefined)", '"TypeError: Type error"');
+shouldThrowErrorName("String.prototype.fontcolor.call(undefined)", 'TypeError');
 
 // Generic use on non-coercible object `null`.
-shouldThrow("String.prototype.fontcolor.call(null)", '"TypeError: Type error"');
+shouldThrowErrorName("String.prototype.fontcolor.call(null)", 'TypeError');
 
 // Check fontcolor.length.
 shouldBe("String.prototype.fontcolor.length", "1");

Modified: trunk/LayoutTests/js/dom/string-fontsize-expected.txt (216300 => 216301)


--- trunk/LayoutTests/js/dom/string-fontsize-expected.txt	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/LayoutTests/js/dom/string-fontsize-expected.txt	2017-05-06 00:33:20 UTC (rev 216301)
@@ -10,8 +10,8 @@
 PASS '_'.fontsize('"') is "<font size=\"&quot;\">_</font>"
 PASS '_'.fontsize('" color="b') is "<font size=\"&quot; color=&quot;b\">_</font>"
 PASS String.prototype.fontsize.call(0x2A, 0x2A) is "<font size=\"42\">42</font>"
-PASS String.prototype.fontsize.call(undefined) threw exception TypeError: Type error.
-PASS String.prototype.fontsize.call(null) threw exception TypeError: Type error.
+PASS String.prototype.fontsize.call(undefined) threw exception TypeError: String.prototype.fontsize requires that |this| not be null or undefined.
+PASS String.prototype.fontsize.call(null) threw exception TypeError: String.prototype.fontsize requires that |this| not be null or undefined.
 PASS String.prototype.fontsize.length is 1
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/js/dom/string-fontsize.html (216300 => 216301)


--- trunk/LayoutTests/js/dom/string-fontsize.html	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/LayoutTests/js/dom/string-fontsize.html	2017-05-06 00:33:20 UTC (rev 216301)
@@ -31,10 +31,10 @@
 shouldBe("String.prototype.fontsize.call(0x2A, 0x2A)", '"<font size=\\"42\\">42</font>"');
 
 // Generic use on non-coercible object `undefined`.
-shouldThrow("String.prototype.fontsize.call(undefined)", '"TypeError: Type error"');
+shouldThrowErrorName("String.prototype.fontsize.call(undefined)", 'TypeError');
 
 // Generic use on non-coercible object `null`.
-shouldThrow("String.prototype.fontsize.call(null)", '"TypeError: Type error"');
+shouldThrowErrorName("String.prototype.fontsize.call(null)", 'TypeError');
 
 // Check fontsize.length.
 shouldBe("String.prototype.fontsize.length", "1");

Modified: trunk/LayoutTests/js/dom/string-link-expected.txt (216300 => 216301)


--- trunk/LayoutTests/js/dom/string-link-expected.txt	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/LayoutTests/js/dom/string-link-expected.txt	2017-05-06 00:33:20 UTC (rev 216301)
@@ -10,8 +10,8 @@
 PASS '_'.link('"') is "<a href=""
 PASS '_'.link('" target="_blank') is "<a href="" target=&quot;_blank\">_</a>"
 PASS String.prototype.link.call(0x2A, 0x2A) is "<a href=""
-PASS String.prototype.link.call(undefined) threw exception TypeError: Type error.
-PASS String.prototype.link.call(null) threw exception TypeError: Type error.
+PASS String.prototype.link.call(undefined) threw exception TypeError: String.prototype.link requires that |this| not be null or undefined.
+PASS String.prototype.link.call(null) threw exception TypeError: String.prototype.link requires that |this| not be null or undefined.
 PASS String.prototype.link.length is 1
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/js/dom/string-link.html (216300 => 216301)


--- trunk/LayoutTests/js/dom/string-link.html	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/LayoutTests/js/dom/string-link.html	2017-05-06 00:33:20 UTC (rev 216301)
@@ -31,10 +31,10 @@
 shouldBe("String.prototype.link.call(0x2A, 0x2A)", '"<a href=""
 
 // Generic use on non-coercible object `undefined`.
-shouldThrow("String.prototype.link.call(undefined)", '"TypeError: Type error"');
+shouldThrowErrorName("String.prototype.link.call(undefined)", 'TypeError');
 
 // Generic use on non-coercible object `null`.
-shouldThrow("String.prototype.link.call(null)", '"TypeError: Type error"');
+shouldThrowErrorName("String.prototype.link.call(null)", 'TypeError');
 
 // Check link.length.
 shouldBe("String.prototype.link.length", "1");

Modified: trunk/Source/_javascript_Core/ChangeLog (216300 => 216301)


--- trunk/Source/_javascript_Core/ChangeLog	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-05-06 00:33:20 UTC (rev 216301)
@@ -1,3 +1,46 @@
+2017-05-05  Oliver Hunt  <[email protected]>
+
+        Move trivial String prototype functions to JS builtins
+        https://bugs.webkit.org/show_bug.cgi?id=171737
+
+        Reviewed by Saam Barati.
+
+        Super simple change to migrate all of the old school
+        html-ifying string operations to builtin JS.
+
+        Core implementation is basically a 1-for-1 match to the spec.
+
+        * builtins/StringPrototype.js:
+        (globalPrivate.createHTML):
+        (anchor):
+        (big):
+        (blink):
+        (bold):
+        (fixed):
+        (fontcolor):
+        (fontsize):
+        (italics):
+        (link):
+        (small):
+        (strike):
+        (sub):
+        (sup):
+        * runtime/StringPrototype.cpp:
+        (JSC::StringPrototype::finishCreation):
+        (JSC::stringProtoFuncBig): Deleted.
+        (JSC::stringProtoFuncSmall): Deleted.
+        (JSC::stringProtoFuncBlink): Deleted.
+        (JSC::stringProtoFuncBold): Deleted.
+        (JSC::stringProtoFuncFixed): Deleted.
+        (JSC::stringProtoFuncItalics): Deleted.
+        (JSC::stringProtoFuncStrike): Deleted.
+        (JSC::stringProtoFuncSub): Deleted.
+        (JSC::stringProtoFuncSup): Deleted.
+        (JSC::stringProtoFuncFontcolor): Deleted.
+        (JSC::stringProtoFuncFontsize): Deleted.
+        (JSC::stringProtoFuncAnchor): Deleted.
+        (JSC::stringProtoFuncLink): Deleted.
+
 2017-05-05  Don Olmstead  <[email protected]>
 
         [JSC] Remove export from Intrinsic

Modified: trunk/Source/_javascript_Core/builtins/StringPrototype.js (216300 => 216301)


--- trunk/Source/_javascript_Core/builtins/StringPrototype.js	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/Source/_javascript_Core/builtins/StringPrototype.js	2017-05-06 00:33:20 UTC (rev 216301)
@@ -304,3 +304,100 @@
     
     return @stringSplitFast.@call(this, separator, limit);
 }
+
+@globalPrivate
+function createHTML(func, string, tag, attribute, value)
+{
+    "use strict";
+    if (string == null)
+        @throwTypeError(`${func} requires that |this| not be null or undefined`);
+    let S = @toString(string);
+    let p1 = "<" + tag;
+    if (attribute) {
+        let V = @toString(value);
+        let escapedV = V.@replaceUsingRegExp(/"/g, '&quot;');
+        p1 = p1 + " " + @toString(attribute) + '="' + escapedV + '"'
+    }
+    let p2 = p1 + ">"
+    let p3 = p2 + S;
+    let p4 = p3 + "</" + tag + ">";
+    return p4;
+}
+
+function anchor(url)
+{
+    "use strict";
+    return @createHTML("String.prototype.link", this, "a", "name", url)
+}
+
+function big()
+{
+    "use strict";
+    return @createHTML("String.prototype.big", this, "big", "", "");
+}
+
+function blink()
+{
+    "use strict";
+    return @createHTML("String.prototype.blink", this, "blink", "", "");
+}
+
+function bold()
+{
+    "use strict";
+    return @createHTML("String.prototype.bold", this, "b", "", "");
+}
+
+function fixed()
+{
+    "use strict";
+    return @createHTML("String.prototype.fixed", this, "tt", "", "");
+}
+
+function fontcolor(color)
+{
+    "use strict";
+    return @createHTML("String.prototype.fontcolor", this, "font", "color", color);
+}
+
+function fontsize(size)
+{
+    "use strict";
+    return @createHTML("String.prototype.fontsize", this, "font", "size", size);
+}
+
+function italics()
+{
+    "use strict";
+    return @createHTML("String.prototype.italics", this, "i", "", "");
+}
+
+function link(url)
+{
+    "use strict";
+    return @createHTML("String.prototype.link", this, "a", "href", url)
+}
+
+function small()
+{
+    "use strict";
+    return @createHTML("String.prototype.small", this, "small", "", "");
+}
+
+function strike()
+{
+    "use strict";
+    return @createHTML("String.prototype.strike", this, "strike", "", "");
+}
+
+function sub()
+{
+    "use strict";
+    return @createHTML("String.prototype.sub", this, "sub", "", "");
+}
+
+function sup()
+{
+    "use strict";
+    return @createHTML("String.prototype.sup", this, "sup", "", "");
+}

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (216300 => 216301)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2017-05-06 00:24:11 UTC (rev 216300)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2017-05-06 00:33:20 UTC (rev 216301)
@@ -76,19 +76,6 @@
 EncodedJSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState*);
 EncodedJSValue JSC_HOST_CALL stringProtoFuncToLocaleLowerCase(ExecState*);
 EncodedJSValue JSC_HOST_CALL stringProtoFuncToLocaleUpperCase(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncBig(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncBold(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncSub(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncSup(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState*);
-EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState*);
 EncodedJSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState*);
 EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState*);
 EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState*);
@@ -115,6 +102,19 @@
     replace   JSBuiltin    DontEnum|Function 2
     search    JSBuiltin    DontEnum|Function 1
     split     JSBuiltin    DontEnum|Function 1
+    anchor    JSBuiltin    DontEnum|Function 1
+    big       JSBuiltin    DontEnum|Function 0
+    bold      JSBuiltin    DontEnum|Function 0
+    blink     JSBuiltin    DontEnum|Function 0
+    fixed     JSBuiltin    DontEnum|Function 0
+    fontcolor JSBuiltin    DontEnum|Function 1
+    fontsize  JSBuiltin    DontEnum|Function 1
+    italics   JSBuiltin    DontEnum|Function 0
+    link      JSBuiltin    DontEnum|Function 1
+    small     JSBuiltin    DontEnum|Function 0
+    strike    JSBuiltin    DontEnum|Function 0
+    sub       JSBuiltin    DontEnum|Function 0
+    sup       JSBuiltin    DontEnum|Function 0
 @end
 */
 
@@ -153,19 +153,6 @@
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("toLocaleLowerCase", stringProtoFuncToLowerCase, DontEnum, 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("toLocaleUpperCase", stringProtoFuncToUpperCase, DontEnum, 0);
 #endif
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("big", stringProtoFuncBig, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("small", stringProtoFuncSmall, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("blink", stringProtoFuncBlink, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("bold", stringProtoFuncBold, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("fixed", stringProtoFuncFixed, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("italics", stringProtoFuncItalics, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("strike", stringProtoFuncStrike, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("sub", stringProtoFuncSub, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("sup", stringProtoFuncSup, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("fontcolor", stringProtoFuncFontcolor, DontEnum, 1);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("fontsize", stringProtoFuncFontsize, DontEnum, 1);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("anchor", stringProtoFuncAnchor, DontEnum, 1);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("link", stringProtoFuncLink, DontEnum, 1);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("trim", stringProtoFuncTrim, DontEnum, 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("trimLeft", stringProtoFuncTrimLeft, DontEnum, 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("trimRight", stringProtoFuncTrimRight, DontEnum, 0);
@@ -1569,268 +1556,6 @@
 }
 #endif // ENABLE(INTL)
 
-EncodedJSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<big>", s, "</big>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<small>", s, "</small>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<blink>", s, "</blink>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncBold(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<b>", s, "</b>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<tt>", s, "</tt>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<i>", s, "</i>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<strike>", s, "</strike>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncSub(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<sub>", s, "</sub>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncSup(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<sup>", s, "</sup>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-
-    JSValue a0 = exec->argument(0);
-    String color = a0.toWTFString(exec);
-    color.replaceWithLiteral('"', "&quot;");
-
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<font color=\"", color, "\">", s, "</font>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-
-    JSValue a0 = exec->argument(0);
-
-    uint32_t smallInteger;
-    if (a0.getUInt32(smallInteger) && smallInteger <= 9) {
-        unsigned stringSize = s.length();
-        unsigned bufferSize = 22 + stringSize;
-        // FIXME: Should we have an 8-bit version of this code path too? Or maybe only an 8-bit version?
-        UChar* buffer;
-        auto impl = StringImpl::tryCreateUninitialized(bufferSize, buffer);
-        if (!impl)
-            return JSValue::encode(jsUndefined());
-        buffer[0] = '<';
-        buffer[1] = 'f';
-        buffer[2] = 'o';
-        buffer[3] = 'n';
-        buffer[4] = 't';
-        buffer[5] = ' ';
-        buffer[6] = 's';
-        buffer[7] = 'i';
-        buffer[8] = 'z';
-        buffer[9] = 'e';
-        buffer[10] = '=';
-        buffer[11] = '"';
-        buffer[12] = '0' + smallInteger;
-        buffer[13] = '"';
-        buffer[14] = '>';
-        StringView(s).getCharactersWithUpconvert(&buffer[15]);
-        buffer[15 + stringSize] = '<';
-        buffer[16 + stringSize] = '/';
-        buffer[17 + stringSize] = 'f';
-        buffer[18 + stringSize] = 'o';
-        buffer[19 + stringSize] = 'n';
-        buffer[20 + stringSize] = 't';
-        buffer[21 + stringSize] = '>';
-        return JSValue::encode(jsNontrivialString(exec, WTFMove(impl)));
-    }
-
-    String fontSize = a0.toWTFString(exec);
-    fontSize.replaceWithLiteral('"', "&quot;");
-
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<font size=\"", fontSize, "\">", s, "</font>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-
-    JSValue a0 = exec->argument(0);
-    String anchor = a0.toWTFString(exec);
-    anchor.replaceWithLiteral('"', "&quot;");
-
-    scope.release();
-    return JSValue::encode(jsMakeNontrivialString(exec, "<a name=\"", anchor, "\">", s, "</a>"));
-}
-
-EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSValue thisValue = exec->thisValue();
-    if (!checkObjectCoercible(thisValue))
-        return throwVMTypeError(exec, scope);
-    String s = thisValue.toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-
-    JSValue a0 = exec->argument(0);
-    String linkText = a0.toWTFString(exec);
-    linkText.replaceWithLiteral('"', "&quot;");
-
-    unsigned linkTextSize = linkText.length();
-    unsigned stringSize = s.length();
-    unsigned bufferSize = 15 + linkTextSize + stringSize;
-    // FIXME: Should we have an 8-bit version of this code path too? Or maybe only an 8-bit version?
-    UChar* buffer;
-    auto impl = StringImpl::tryCreateUninitialized(bufferSize, buffer);
-    if (!impl)
-        return JSValue::encode(jsUndefined());
-    buffer[0] = '<';
-    buffer[1] = 'a';
-    buffer[2] = ' ';
-    buffer[3] = 'h';
-    buffer[4] = 'r';
-    buffer[5] = 'e';
-    buffer[6] = 'f';
-    buffer[7] = '=';
-    buffer[8] = '"';
-    StringView(linkText).getCharactersWithUpconvert(&buffer[9]);
-    buffer[9 + linkTextSize] = '"';
-    buffer[10 + linkTextSize] = '>';
-    StringView(s).getCharactersWithUpconvert(&buffer[11 + linkTextSize]);
-    buffer[11 + linkTextSize + stringSize] = '<';
-    buffer[12 + linkTextSize + stringSize] = '/';
-    buffer[13 + linkTextSize + stringSize] = 'a';
-    buffer[14 + linkTextSize + stringSize] = '>';
-    return JSValue::encode(jsNontrivialString(exec, WTFMove(impl)));
-}
-
 enum {
     TrimLeft = 1,
     TrimRight = 2
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to