Changeset 15526 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jul 19, 2006, 10:32:15 AM (19 years ago)
Author:
andersca
Message:

JavaScriptCore:

2006-07-19 Anders Carlsson <[email protected]>

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 <[email protected]>

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.
Location:
trunk/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r15524 r15526  
     12006-07-19  Anders Carlsson  <[email protected]>
     2
     3        Reviewed by Darin.
     4
     5        <rdar://problem/4620655> REGRESSION(10.4.7-10.5): preview button for a blogger.com post doesn't work
     6       
     7        * kjs/nodes2string.cpp:
     8        (StringNode::streamTo):
     9        Return the escaped string.
     10       
     11        (RegExpNode::streamTo):
     12        Use the correct syntax.
     13       
     14        * kjs/function.cpp:
     15        (KJS::escapeStringForPrettyPrinting):
     16        * kjs/function.h:
     17        Add escape function which escapes a string for pretty-printing so it can be parsed again.
     18       
     19        * wtf/unicode/icu/UnicodeIcu.h:
     20        (WTF::Unicode::isPrintableChar):
     21        New function.
     22
    123=== Safari-521.19 ===
    224
  • trunk/JavaScriptCore/kjs/function.cpp

    r15026 r15526  
    919919}
    920920
     921UString escapeStringForPrettyPrinting(const UString& s)
     922{
     923    UString escapedString;
     924   
     925    for (int i = 0; i < s.size(); i++) {
     926        unsigned short c = s.data()[i].unicode();
     927       
     928        switch (c) {
     929        case '\"':
     930            escapedString += "\\\"";
     931            break;
     932        case '\n':
     933            escapedString += "\\n";
     934            break;
     935        case '\r':
     936            escapedString += "\\r";
     937            break;
     938        case '\t':
     939            escapedString += "\\t";
     940            break;
     941        case '\\':
     942            escapedString += "\\\\";
     943            break;
     944        default:
     945            if (c < 128 && WTF::Unicode::isPrintableChar(c))
     946                escapedString.append(c);
     947            else {
     948                char hexValue[7];
     949           
     950                snprintf(hexValue, 7, "\\u%04x", c);
     951                escapedString += hexValue;
     952            }
     953        }
     954    }
     955   
     956    return escapedString;   
     957}
     958
     959
    921960} // namespace
  • trunk/JavaScriptCore/kjs/function.h

    r14256 r15526  
    162162  };
    163163
    164 
     164UString escapeStringForPrettyPrinting(const UString& s);
    165165
    166166} // namespace
  • trunk/JavaScriptCore/kjs/nodes2string.cpp

    r14502 r15526  
    2323#include "config.h"
    2424#include "nodes.h"
     25#include "function.h"
    2526
    2627namespace KJS {
     
    117118void StringNode::streamTo(SourceStream &s) const
    118119{
    119   s << '"' << value << '"';
    120 }
    121 
    122 void RegExpNode::streamTo(SourceStream &s) const { s <<  pattern; }
     120  s << '"' << escapeStringForPrettyPrinting(value) << '"';
     121}
     122
     123void RegExpNode::streamTo(SourceStream &s) const
     124{
     125    s << "/" <<  pattern << "/" << flags;
     126}
    123127
    124128void ThisNode::streamTo(SourceStream &s) const { s << "this"; }
  • trunk/JavaScriptCore/wtf/unicode/icu/UnicodeIcu.h

    r14256 r15526  
    8383    }
    8484
     85    inline bool isPrintableChar(int32_t c)
     86    {
     87      return u_isprint(c);
     88    }
     89   
    8590    inline CharCategory category(int32_t c)
    8691    {
Note: See TracChangeset for help on using the changeset viewer.