2006-07-19 Anders Carlsson <acarlsson@apple.com>
Reviewed by Darin.
<rdar://problem/
4620655> REGRESSION(10.4.7-10.5): preview button for a blogger.com post doesn't work
* kjs/nodes2string.cpp:
(StringNode::streamTo):
Return the escaped string.
(RegExpNode::streamTo):
Use the correct syntax.
* kjs/function.cpp:
(KJS::escapeStringForPrettyPrinting):
* kjs/function.h:
Add escape function which escapes a string for pretty-printing so it can be parsed again.
* wtf/unicode/icu/UnicodeIcu.h:
(WTF::Unicode::isPrintableChar):
New function.
LayoutTests:
2006-07-19 Anders Carlsson <acarlsson@apple.com>
Reviewed by Darin.
<rdar://problem/
4620655> REGRESSION(10.4.7-10.5): preview button for a blogger.com post doesn't work
* fast/js/pretty-print-expected.txt: Added.
* fast/js/pretty-print.html: Added.
* fast/js/resources/pretty-print.js: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15526
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-07-19 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Darin.
+
+ <rdar://problem/4620655> REGRESSION(10.4.7-10.5): preview button for a blogger.com post doesn't work
+
+ * kjs/nodes2string.cpp:
+ (StringNode::streamTo):
+ Return the escaped string.
+
+ (RegExpNode::streamTo):
+ Use the correct syntax.
+
+ * kjs/function.cpp:
+ (KJS::escapeStringForPrettyPrinting):
+ * kjs/function.h:
+ Add escape function which escapes a string for pretty-printing so it can be parsed again.
+
+ * wtf/unicode/icu/UnicodeIcu.h:
+ (WTF::Unicode::isPrintableChar):
+ New function.
+
=== Safari-521.19 ===
2006-07-18 Maciej Stachowiak <mjs@apple.com>
return res;
}
+UString escapeStringForPrettyPrinting(const UString& s)
+{
+ UString escapedString;
+
+ for (int i = 0; i < s.size(); i++) {
+ unsigned short c = s.data()[i].unicode();
+
+ switch (c) {
+ case '\"':
+ escapedString += "\\\"";
+ break;
+ case '\n':
+ escapedString += "\\n";
+ break;
+ case '\r':
+ escapedString += "\\r";
+ break;
+ case '\t':
+ escapedString += "\\t";
+ break;
+ case '\\':
+ escapedString += "\\\\";
+ break;
+ default:
+ if (c < 128 && WTF::Unicode::isPrintableChar(c))
+ escapedString.append(c);
+ else {
+ char hexValue[7];
+
+ snprintf(hexValue, 7, "\\u%04x", c);
+ escapedString += hexValue;
+ }
+ }
+ }
+
+ return escapedString;
+}
+
+
} // namespace
int id;
};
-
+UString escapeStringForPrettyPrinting(const UString& s);
} // namespace
#include "config.h"
#include "nodes.h"
+#include "function.h"
namespace KJS {
/**
void StringNode::streamTo(SourceStream &s) const
{
- s << '"' << value << '"';
+ s << '"' << escapeStringForPrettyPrinting(value) << '"';
}
-void RegExpNode::streamTo(SourceStream &s) const { s << pattern; }
+void RegExpNode::streamTo(SourceStream &s) const
+{
+ s << "/" << pattern << "/" << flags;
+}
void ThisNode::streamTo(SourceStream &s) const { s << "this"; }
return u_charType(c) == U_SPACE_SEPARATOR;
}
+ inline bool isPrintableChar(int32_t c)
+ {
+ return u_isprint(c);
+ }
+
inline CharCategory category(int32_t c)
{
switch (u_charType(c)) {
+2006-07-19 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Darin.
+
+ <rdar://problem/4620655> REGRESSION(10.4.7-10.5): preview button for a blogger.com post doesn't work
+
+ * fast/js/pretty-print-expected.txt: Added.
+ * fast/js/pretty-print.html: Added.
+ * fast/js/resources/pretty-print.js: Added.
+
2006-07-19 David Harrison <harrison@apple.com>
<rdar://problem/4629307> -[DOMRange markupString] does not include the initial table element if it is at the beginning of the range
--- /dev/null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/pretty-print.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
--- /dev/null
+//description(
+"This test checks that regexps and strings with are pretty-printed correctly"
+//);
+
+function f() {
+ var re = /test/g;
+ var s = '\n\r\\';
+}
+
+eval(f.toString());
+
+var successfullyParsed = true;