Changeset 1024 in webkit for trunk/JavaScriptCore/kjs/lexer.cpp


Ignore:
Timestamp:
Apr 15, 2002, 4:43:21 PM (23 years ago)
Author:
darin
Message:

Merged KDE 3.0 final code in and:

JavaScriptCore:

  • kjs/internal.cpp:
  • kjs/property_map.cpp:
  • kjs/ustring.h: Removed some unneeded <config.h> includes so we are more similar to the real KDE sources.

Merged changes from KDE 3.0 final and did some build fixes.

  • kjs/grammar.*: Regenerated.
  • kjs/*.lut.h: Regenerated.

WebCore:

  • src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration): Remove some minor gratuitous diffs vs. KDE.
  • src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration): Richard updated to reflect changes in KDE.
  • src/kdelibs/khtml/css/css_valueimpl.cpp: (FontFamilyValueImpl::FontFamilyValueImpl): Fix comment.
  • src/kdelibs/khtml/css/cssstyleselector.cpp: Remove some gratuitous diffs vs. KDE.
  • src/kdelibs/khtml/html/html_objectimpl.cpp: (HTMLEmbedElementImpl::parseAttribute): Remove unneeded copy from KWQ's early days.
  • src/kdelibs/khtml/html/html_tableimpl.cpp: (HTMLTableElementImpl::parseAttribute), (HTMLTablePartElementImpl::parseAttribute): Remove unneeded copy from KWQ's early days.
  • src/kdelibs/khtml/html/htmltokenizer.cpp: (HTMLTokenizer::processToken): Redo the APPLE_CHANGES ifdef here.
  • src/kdelibs/khtml/khtmlpart_p.h: Update to latest kde.
  • src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::KHTMLView): Add ifdef APPLE_CHANGES. (KHTMLView::~KHTMLView): Add ifdef APPLE_CHANGES. (KHTMLView::print): Remove code left in here during merge process.
  • src/kwq/KWQKHTMLPart.mm: Remove unused setFontSizes(), fontSizes(), and resetFontSizes(). After the merge is landed, remove more.
  • src/libwebcore.exp: Export updateStyleSelector() for WebKit.

Fix text to it displays at the right font size.

  • src/kdelibs/khtml/css/cssstyleselector.cpp: (CSSStyleSelector::computeFontSizes): Apply the same SCREEN_RESOLUTION hack here that we do elsewhere.
  • src/kdelibs/khtml/rendering/font.cpp: (Font::width): Use kMin instead of max (oops). (Font::update): Turn off font database chicanery.
  • src/kwq/KWQKHTMLPart.mm: (KHTMLPart::zoomFactor): Use zoom factor 100, not 1.

More fixes so text displays (still at wrong font size).

  • src/kdelibs/khtml/rendering/font.cpp: (max): New helper. (Font::drawText): Simplified implementation for now. (Font::width): Simplified implementation for now.
  • src/kwq/KWQColorGroup.mm: Reinstated QCOLOR_GROUP_SIZE.
  • src/kwq/qt/qfontmetrics.h: Removed charWidth and changed _width to take QChar *.
  • src/kwq/KWQFontMetrics.mm: Removed charWidth and changed _width to take QChar *.

Merged changes from KDE 3.0 final. Other fixes to get things compiling.

  • src/kdelibs/khtml/css/css_valueimpl.cpp: (CSSStyleDeclarationImpl::setProperty): Fix unused variable.
  • src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::contentsContextMenuEvent): Fix unused variable.
  • src/kdelibs/khtml/rendering/font.cpp: (Font::drawText), (Font::width), (Font::update): Disable special "nsbp" logic for now. We can reenable it if necessary.
  • src/kdelibs/khtml/rendering/render_replaced.cpp: Fix mismerge.
  • src/kdelibs/khtml/rendering/render_text.cpp: (RenderText::nodeAtPoint): Fix unused variable.
  • src/kwq/KWQApplication.mm: (QDesktopWidget::width), (QApplication::desktop): Fix mismerge.
  • src/kwq/KWQColorGroup.mm: Fix QCOLOR_GROUP_SIZE.
  • src/kwq/KWQFontMetrics.mm: (QFontMetrics::lineSpacing): New. (QFontMetrics::width): Remove unused optimization.
  • src/kwq/qt/qfontmetrics.h: Add lineSpacing().

Merged changes from previous merge pass.

2002-03-25 Darin Adler <Darin Adler>

Last bit of making stuff compile and link. Probably will drop the merge now
and take it up again when it's time to merge in KDE 3.0 final.

  • src/kwq/KWQEvent.mm: (QFocusEvent::reason): New.
  • src/kwq/KWQPainter.mm: (QPainter::drawText): New overload.

2002-03-25 Darin Adler <Darin Adler>

  • src/kdelibs/khtml/rendering/font.cpp: (Font::width): Make it call _width so we don't lose the optimization.
  • src/kwq/KWQApplication.mm: (QDesktopWidget::screenNumber): New. (QDesktopWidget::screenGeometry): New. (QApplication::style): New.
  • src/kwq/KWQColorGroup.mm: (QColorGroup::highlight): New. (QColorGroup::highlightedText): New.
  • src/kwq/KWQFont.mm: (QFont::setPixelSize): New.
  • src/kwq/KWQFontMetrics.mm: (QFontMetrics::charWidth): New.
  • src/kwq/KWQKGlobal.mm: (KGlobal::locale): Implement. (KLocale::KLocale): New. (KLocale::languageList): New.
  • src/kwq/KWQKHTMLPart.mm: (KHTMLPart::sheetUsed): New. (KHTMLPart::setSheetUsed): New. (KHTMLPart::zoomFactor): New.
  • src/kwq/KWQKHTMLSettings.mm: (KHTMLSettings::mediumFontSize): New.
  • src/kwq/KWQScrollView.mm: (QScrollView::childX): New. (QScrollView::childY): New.
  • src/kwq/qt/qapplication.h: style() returns a QStyle &.
  • src/kwq/qt/qpalette.h: Add Highlight and HighlightedText.

2002-03-24 Darin Adler <Darin Adler>

More compiling. Still won't link.

  • src/kdelibs/khtml/khtmlview.cpp: Disable printing and drag and drop code.
  • src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration): Temporarily turn off our smarter underlining since it relies on access to the string, and TextSlave doesn't have that any more. (RenderText::nodeAtPoint): Get rid of a workaround we don't need any more for a bug that was fixed by KDE folks.
  • src/kwq/KWQApplication.mm: (QApplication::desktop): Make the desktop be a QDesktopWidget.
  • src/kwq/qt/qnamespace.h: Add MetaButton.
  • src/kwq/qt/qtooltip.h: Add a maybeTip virtual function member and a virtual destructor.

2002-03-24 Darin Adler <Darin Adler>

Some fixes to get more stuff to compile.

  • src/kdelibs/khtml/ecma/kjs_dom.cpp: (DOMDocument::getValueProperty): Don't try to look at the private m_bComplete to display "complete". Just do "loading" and "loaded".
  • src/kdelibs/khtml/khtmlpart_p.h: #ifdef this all out for APPLE_CHANGES.
  • src/kdelibs/khtml/rendering/font.cpp: (Font::update): Add an explicit cast to int to avoid float -> int warning.
  • src/kdelibs/khtml/rendering/render_table.cpp: (RenderTable::calcColMinMax): Add an explicit cast to int to avoid uint compared with int warning.
  • src/kdelibs/khtml/xml/dom_docimpl.cpp: (DocumentImpl::recalcStyleSelector): Use sheetUsed() and setSheetUsed() functions on KHTMLPart intead of getting at private fields the way the real KDE code does.
  • src/kwq/KWQKHTMLPart.h: Declare zoomFactor(), sheetUsed(), and setSheetUsed().
  • src/kwq/KWQStyle.h: Add PM_DefaultFramWidth as another metric.
  • src/kwq/kdecore/klocale.h: Add languageList().
  • src/kwq/khtml/khtml_settings.h: Add mediumFontSize().
  • src/kwq/qt/qapplication.h: Add style() and QDesktopWidget.
  • src/kwq/qt/qevent.h: Add reason().
  • src/kwq/qt/qfont.h: Add setPixelSize(int).
  • src/kwq/qt/qfontmetrics.h: Add charWidth() and _charWidth() functions.
  • src/kwq/qt/qpainter.h: Add drawText() overload with position parameter.
  • src/kwq/qt/qpalette.h: Add highlight() and highlightedText().
  • src/kwq/qt/qscrollview.h: Add childX() and childY().
  • src/kwq/KWQApplication.mm: Change KWQDesktopWidget to QDesktopWidget.

WebKit:

  • WebView.subproj/IFPreferences.h:
  • WebView.subproj/IFPreferences.mm: (+[IFPreferences load]): Remove the old WebKitFontSizes preference. (-[IFPreferences mediumFontSize]), (-[IFPreferences setMediumFontSize:]): New.
  • WebView.subproj/IFWebView.mm: (-[IFWebView reapplyStyles]): Call updateStyleSelector() instead of recalcStyle().

Merged changes from previous merge branch.

2002-03-25 Darin Adler <Darin Adler>

  • WebView.subproj/IFPreferences.mm: (+[IFPreferences load]): Add WebKitMediumFontSizePreferenceKey.

WebBrowser:

  • Preferences.subproj/TextPreferences.m: (-[TextPreferences defaultFontSize]), (-[TextPreferences setDefaultFontSize:]): Just get and set the new mediumFontSize preference rather than doing the whole fontSizes preference dance.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/lexer.cpp

    r798 r1024  
    1919 *  Boston, MA 02111-1307, USA.
    2020 *
    21  *  $Id$
    2221 */
    2322
     
    5352#include "lexer.lut.h"
    5453
    55 extern YYLTYPE yylloc;  // global bison variable holding token info
     54extern YYLTYPE yylloc; // global bison variable holding token info
    5655
    5756// a bridge for yacc from the C world to C++
     
    6261
    6362Lexer::Lexer()
    64   : yylineno(0),
     63  : yylineno(1),
    6564    size8(128), size16(128), restrKeyword(false),
    6665    eatNextIdentifier(false), stackToken(-1), lastToken(-1), pos(0),
     
    9594void Lexer::setCode(const UChar *c, unsigned int len)
    9695{
    97   yylineno = 0;
     96  yylineno = 1;
    9897  restrKeyword = false;
    9998  delimited = false;
     
    126125    next3 = (pos + 3 < length) ? code[pos+3].unicode() : 0;
    127126  }
     127}
     128
     129// called on each new line
     130void Lexer::nextLine()
     131{
     132  yylineno++;
     133#ifndef KJS_PURE_ECMA
     134  bol = true;
     135#endif
    128136}
    129137
     
    167175    case Start:
    168176      if (isWhiteSpace()) {
    169         // do nothing
     177        // do nothing
    170178      } else if (current == '/' && next1 == '/') {
    171         shift(1);
    172         state = InSingleLineComment;
     179        shift(1);
     180        state = InSingleLineComment;
    173181      } else if (current == '/' && next1 == '*') {
    174         shift(1);
    175         state = InMultiLineComment;
     182        shift(1);
     183        state = InMultiLineComment;
    176184      } else if (current == 0) {
    177         if (!terminator && !delimited) {
    178           // automatic semicolon insertion if program incomplete
    179           token = ';';
    180           stackToken = 0;
    181           setDone(Other);
    182         } else
    183           setDone(Eof);
     185        if (!terminator && !delimited) {
     186          // automatic semicolon insertion if program incomplete
     187          token = ';';
     188          stackToken = 0;
     189          setDone(Other);
     190        } else
     191          setDone(Eof);
    184192      } else if (isLineTerminator()) {
    185         yylineno++;
     193        nextLine();
     194        terminator = true;
     195        if (restrKeyword) {
     196          token = ';';
     197          setDone(Other);
     198        }
     199      } else if (current == '"' || current == '\'') {
     200        state = InString;
     201        stringType = current;
     202      } else if (isIdentLetter(current)) {
     203        record16(current);
     204        state = InIdentifier;
     205      } else if (current == '0') {
     206        record8(current);
     207        state = InNum0;
     208      } else if (isDecimalDigit(current)) {
     209        record8(current);
     210        state = InNum;
     211      } else if (current == '.' && isDecimalDigit(next1)) {
     212        record8(current);
     213        state = InDecimal;
    186214#ifndef KJS_PURE_ECMA
    187         bol = true;
    188 #endif
    189         terminator = true;
    190         if (restrKeyword) {
    191           token = ';';
    192           setDone(Other);
    193         }
    194       } else if (current == '"' || current == '\'') {
    195         state = InString;
    196         stringType = current;
    197       } else if (isIdentLetter(current)) {
    198         record16(current);
    199         state = InIdentifier;
    200       } else if (current == '0') {
    201         record8(current);
    202         state = InNum0;
    203       } else if (isDecimalDigit(current)) {
    204         record8(current);
    205         state = InNum;
    206       } else if (current == '.' && isDecimalDigit(next1)) {
    207         record8(current);
    208         state = InDecimal;
    209 #ifndef KJS_PURE_ECMA
    210         // <!-- marks the beginning of a line comment (for www usage)
    211       } else if (bol && current == '<' && next1 == '!' &&
    212                  next2 == '-' && next3 == '-') {
    213         shift(3);
    214         state = InSingleLineComment;
    215         // same of -->
     215        // <!-- marks the beginning of a line comment (for www usage)
     216      } else if (current == '<' && next1 == '!' &&
     217                 next2 == '-' && next3 == '-') {
     218        shift(3);
     219        state = InSingleLineComment;
     220        // same for -->
    216221      } else if (bol && current == '-' && next1 == '-' &&  next2 == '>') {
    217         shift(2);
    218         state = InSingleLineComment;
     222        shift(2);
     223        state = InSingleLineComment;
    219224#endif
    220225      } else {
    221         token = matchPunctuator(current, next1, next2, next3);
    222         if (token != -1) {
    223           setDone(Other);
    224         } else {
    225           //      cerr << "encountered unknown character" << endl;
    226           setDone(Bad);
    227         }
     226        token = matchPunctuator(current, next1, next2, next3);
     227        if (token != -1) {
     228          setDone(Other);
     229        } else {
     230          //      cerr << "encountered unknown character" << endl;
     231          setDone(Bad);
     232        }
    228233      }
    229234      break;
    230235    case InString:
    231236      if (current == stringType) {
    232         shift(1);
    233         setDone(String);
     237        shift(1);
     238        setDone(String);
    234239      } else if (current == 0 || isLineTerminator()) {
    235         setDone(Bad);
     240        setDone(Bad);
    236241      } else if (current == '\\') {
    237         state = InEscapeSequence;
     242        state = InEscapeSequence;
    238243      } else {
    239         record16(current);
     244        record16(current);
    240245      }
    241246      break;
     
    243248    case InEscapeSequence:
    244249      if (isOctalDigit(current)) {
    245         if (current >= '0' && current <= '3' &&
    246             isOctalDigit(next1) && isOctalDigit(next2)) {
    247           record16(convertOctal(current, next1, next2));
    248           shift(2);
    249           state = InString;
    250         } else if (isOctalDigit(current) && isOctalDigit(next1)) {
    251           record16(convertOctal('0', current, next1));
    252           shift(1);
    253           state = InString;
    254         } else if (isOctalDigit(current)) {
    255           record16(convertOctal('0', '0', current));
    256           state = InString;
    257         } else {
    258           setDone(Bad);
    259         }
     250        if (current >= '0' && current <= '3' &&
     251            isOctalDigit(next1) && isOctalDigit(next2)) {
     252          record16(convertOctal(current, next1, next2));
     253          shift(2);
     254          state = InString;
     255        } else if (isOctalDigit(current) && isOctalDigit(next1)) {
     256          record16(convertOctal('0', current, next1));
     257          shift(1);
     258          state = InString;
     259        } else if (isOctalDigit(current)) {
     260          record16(convertOctal('0', '0', current));
     261          state = InString;
     262        } else {
     263          setDone(Bad);
     264        }
    260265      } else if (current == 'x')
    261         state = InHexEscape;
     266        state = InHexEscape;
    262267      else if (current == 'u')
    263         state = InUnicodeEscape;
     268        state = InUnicodeEscape;
    264269      else {
    265         record16(singleEscape(current));
    266         state = InString;
     270        record16(singleEscape(current));
     271        state = InString;
    267272      }
    268273      break;
    269274    case InHexEscape:
    270275      if (isHexDigit(current) && isHexDigit(next1)) {
    271         state = InString;
    272         record16(convertHex(current, next1));
    273         shift(1);
     276        state = InString;
     277        record16(convertHex(current, next1));
     278        shift(1);
    274279      } else if (current == stringType) {
    275         record16('x');
    276         shift(1);
    277         setDone(String);
     280        record16('x');
     281        shift(1);
     282        setDone(String);
    278283      } else {
    279         record16('x');
    280         record16(current);
    281         state = InString;
     284        record16('x');
     285        record16(current);
     286        state = InString;
    282287      }
    283288      break;
    284289    case InUnicodeEscape:
    285290      if (isHexDigit(current) && isHexDigit(next1) &&
    286           isHexDigit(next2) && isHexDigit(next3)) {
    287         record16(convertUnicode(current, next1, next2, next3));
    288         shift(3);
    289         state = InString;
     291          isHexDigit(next2) && isHexDigit(next3)) {
     292        record16(convertUnicode(current, next1, next2, next3));
     293        shift(3);
     294        state = InString;
    290295      } else if (current == stringType) {
    291         record16('u');
    292         shift(1);
    293         setDone(String);
     296        record16('u');
     297        shift(1);
     298        setDone(String);
    294299      } else {
    295         setDone(Bad);
     300        setDone(Bad);
    296301      }
    297302      break;
    298303    case InSingleLineComment:
    299304      if (isLineTerminator()) {
    300         yylineno++;
    301         terminator = true;
    302 #ifndef KJS_PURE_ECMA
    303         bol = true;
    304 #endif
    305         if (restrKeyword) {
    306           token = ';';
    307           setDone(Other);
    308         } else
    309           state = Start;
     305        nextLine();
     306        terminator = true;
     307        if (restrKeyword) {
     308          token = ';';
     309          setDone(Other);
     310        } else
     311          state = Start;
    310312      } else if (current == 0) {
    311         setDone(Eof);
     313        setDone(Eof);
    312314      }
    313315      break;
    314316    case InMultiLineComment:
    315317      if (current == 0) {
    316         setDone(Bad);
     318        setDone(Bad);
    317319      } else if (isLineTerminator()) {
    318         yylineno++;
     320        nextLine();
    319321      } else if (current == '*' && next1 == '/') {
    320         state = Start;
    321         shift(1);
     322        state = Start;
     323        shift(1);
    322324      }
    323325      break;
    324326    case InIdentifier:
    325327      if (isIdentLetter(current) || isDecimalDigit(current)) {
    326         record16(current);
    327         break;
     328        record16(current);
     329        break;
    328330      }
    329331      setDone(Identifier);
     
    331333    case InNum0:
    332334      if (current == 'x' || current == 'X') {
    333         record8(current);
    334         state = InHex;
     335        record8(current);
     336        state = InHex;
    335337      } else if (current == '.') {
    336         record8(current);
    337         state = InDecimal;
     338        record8(current);
     339        state = InDecimal;
    338340      } else if (current == 'e' || current == 'E') {
    339         record8(current);
    340         state = InExponentIndicator;
     341        record8(current);
     342        state = InExponentIndicator;
    341343      } else if (isOctalDigit(current)) {
    342         record8(current);
    343         state = InOctal;
     344        record8(current);
     345        state = InOctal;
    344346      } else if (isDecimalDigit(current)) {
    345347        record8(current);
    346348        state = InDecimal;
    347349      } else {
    348         setDone(Number);
     350        setDone(Number);
    349351      }
    350352      break;
    351353    case InHex:
    352354      if (isHexDigit(current)) {
    353         record8(current);
     355        record8(current);
    354356      } else {
    355         setDone(Hex);
     357        setDone(Hex);
    356358      }
    357359      break;
    358360    case InOctal:
    359361      if (isOctalDigit(current)) {
    360         record8(current);
     362        record8(current);
    361363      }
    362364      else if (isDecimalDigit(current)) {
     
    364366        state = InDecimal;
    365367      } else
    366         setDone(Octal);
     368        setDone(Octal);
    367369      break;
    368370    case InNum:
    369371      if (isDecimalDigit(current)) {
    370         record8(current);
     372        record8(current);
    371373      } else if (current == '.') {
    372         record8(current);
    373         state = InDecimal;
     374        record8(current);
     375        state = InDecimal;
    374376      } else if (current == 'e' || current == 'E') {
    375         record8(current);
    376         state = InExponentIndicator;
     377        record8(current);
     378        state = InExponentIndicator;
    377379      } else
    378         setDone(Number);
     380        setDone(Number);
    379381      break;
    380382    case InDecimal:
    381383      if (isDecimalDigit(current)) {
    382         record8(current);
     384        record8(current);
    383385      } else if (current == 'e' || current == 'E') {
    384         record8(current);
    385         state = InExponentIndicator;
     386        record8(current);
     387        state = InExponentIndicator;
    386388      } else
    387         setDone(Number);
     389        setDone(Number);
    388390      break;
    389391    case InExponentIndicator:
    390392      if (current == '+' || current == '-') {
    391         record8(current);
     393        record8(current);
    392394      } else if (isDecimalDigit(current)) {
    393         record8(current);
    394         state = InExponent;
     395        record8(current);
     396        state = InExponent;
    395397      } else
    396         setDone(Bad);
     398        setDone(Bad);
    397399      break;
    398400    case InExponent:
    399401      if (isDecimalDigit(current)) {
    400         record8(current);
     402        record8(current);
    401403      } else
    402         setDone(Number);
     404        setDone(Number);
    403405      break;
    404406    default:
     
    506508
    507509    if (token == CONTINUE || token == BREAK ||
    508         token == RETURN || token == THROW)
     510        token == RETURN || token == THROW)
    509511      restrKeyword = true;
    510512    break;
     
    531533{
    532534  return (current == ' ' || current == '\t' ||
    533           current == 0x0b || current == 0x0c);
     535          current == 0x0b || current == 0x0c);
    534536}
    535537
     
    549551  /* TODO: allow other legitimate unicode chars */
    550552  return (c >= 'a' && c <= 'z' ||
    551           c >= 'A' && c <= 'Z' ||
    552           c == '$' || c == '_');
     553          c >= 'A' && c <= 'Z' ||
     554          c == '$' || c == '_');
    553555}
    554556
     
    561563{
    562564  return (c >= '0' && c <= '9' ||
    563           c >= 'a' && c <= 'f' ||
    564           c >= 'A' && c <= 'F');
     565          c >= 'a' && c <= 'f' ||
     566          c >= 'A' && c <= 'F');
    565567}
    566568
     
    571573
    572574int Lexer::matchPunctuator(unsigned short c1, unsigned short c2,
    573                               unsigned short c3, unsigned short c4)
     575                              unsigned short c3, unsigned short c4)
    574576{
    575577  if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') {
     
    736738{
    737739  return UChar((convertHex(c1) << 4) + convertHex(c2),
    738                (convertHex(c3) << 4) + convertHex(c4));
     740               (convertHex(c3) << 4) + convertHex(c4));
    739741}
    740742
Note: See TracChangeset for help on using the changeset viewer.