Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/text/qcssparser.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4949#include <qbrush.h>
    5050#include <qimagereader.h>
     51
    5152
    5253#ifndef QT_NO_CSSPARSER
     
    5758
    5859using namespace QCss;
    59 
    60 const char *Scanner::tokenName(QCss::TokenType t)
    61 {
    62     switch (t) {
    63         case NONE: return "NONE";
    64         case S: return "S";
    65         case CDO: return "CDO";
    66         case CDC: return "CDC";
    67         case INCLUDES: return "INCLUDES";
    68         case DASHMATCH: return "DASHMATCH";
    69         case LBRACE: return "LBRACE";
    70         case PLUS: return "PLUS";
    71         case GREATER: return "GREATER";
    72         case COMMA: return "COMMA";
    73         case STRING: return "STRING";
    74         case INVALID: return "INVALID";
    75         case IDENT: return "IDENT";
    76         case HASH: return "HASH";
    77         case ATKEYWORD_SYM: return "ATKEYWORD_SYM";
    78         case EXCLAMATION_SYM: return "EXCLAMATION_SYM";
    79         case LENGTH: return "LENGTH";
    80         case PERCENTAGE: return "PERCENTAGE";
    81         case NUMBER: return "NUMBER";
    82         case FUNCTION: return "FUNCTION";
    83         case COLON: return "COLON";
    84         case SEMICOLON: return "SEMICOLON";
    85         case RBRACE: return "RBRACE";
    86         case SLASH: return "SLASH";
    87         case MINUS: return "MINUS";
    88         case DOT: return "DOT";
    89         case STAR: return "STAR";
    90         case LBRACKET: return "LBRACKET";
    91         case RBRACKET: return "RBRACKET";
    92         case EQUAL: return "EQUAL";
    93         case LPAREN: return "LPAREN";
    94         case RPAREN: return "RPAREN";
    95         case OR: return "OR";
    96     }
    97     return "";
    98 }
    9960
    10061struct QCssKnownValue
     
    240201    { "link-visited", Value_LinkVisited },
    241202    { "lower-alpha", Value_LowerAlpha },
     203
    242204    { "lowercase", Value_Lowercase },
    243205    { "medium", Value_Medium },
     
    271233    { "underline", Value_Underline },
    272234    { "upper-alpha", Value_UpperAlpha },
     235
    273236    { "uppercase", Value_Uppercase },
    274237    { "wave", Value_Wave },
     
    279242};
    280243
     244
     245
     246
     247
     248
     249
    281250QString Value::toString() const
    282251{
    283     static int indexOfId[NumKnownValues - 1];
    284     static bool hasCachedIndexes = false;
    285 
    286252    if (type == KnownIdentifier) {
    287         if (!hasCachedIndexes) {
    288             for (int i = 0; i < NumKnownValues - 1; ++i)
    289                 indexOfId[values[i].id] = i;
    290 
    291             hasCachedIndexes = true;
    292         }
    293 
    294253        return QLatin1String(values[indexOfId[variant.toInt()]].name);
    295254    } else {
     
    383342};
    384343
    385 static bool operator<(const QString &name, const QCssKnownValue &prop)
     344 bool operator<(const QString &name, const QCssKnownValue &prop)
    386345{
    387346    return QString::compare(name, QLatin1String(prop.name), Qt::CaseInsensitive) < 0;
    388347}
    389348
    390 static bool operator<(const QCssKnownValue &prop, const QString &name)
     349 bool operator<(const QCssKnownValue &prop, const QString &name)
    391350{
    392351    return QString::compare(QLatin1String(prop.name), name, Qt::CaseInsensitive) < 0;
     
    425384        s.chop(2);
    426385
    427     bool ok;
    428     data.number = s.toDouble(&ok);
    429     if (!ok)
    430         data.number = 0;
     386    data.number = s.toDouble();
    431387    return data;
    432388}
     
    754710    for (int i = 0; i < qMin(colorDigits.count(), 7); i += 2) {
    755711        if (colorDigits.at(i).type == Value::Percentage) {
    756             colorDigits[i].variant = colorDigits.at(i).variant.toDouble() * 255. / 100.;
     712            colorDigits[i].variant = colorDigits.at(i).variant.to;
    757713            colorDigits[i].type = Value::Number;
    758714        } else if (colorDigits.at(i).type != Value::Number) {
     
    831787            if(cd.type == ColorData::Role)
    832788                dependsOnThePalette = true;
    833             stops.append(QGradientStop(stop.variant.toDouble(), colorFromData(cd, pal)));
     789            stops.append(QGradientStop(stop.variant.to(), colorFromData(cd, pal)));
    834790        } else {
    835791            parser.next();
    836792            Value value;
    837             parser.parseTerm(&value);
     793            parser.parseTerm(&value);
    838794            if (attr.compare(QLatin1String("spread"), Qt::CaseInsensitive) == 0) {
    839795                spread = spreads.indexOf(value.variant.toString());
    840796            } else {
    841                 vars[attr] = value.variant.toString().toDouble();
     797                vars[attr] = value.variant.to();
    842798            }
    843799        }
    844800        parser.skipSpace();
    845         parser.test(COMMA);
     801        parser.test(COMMA);
    846802    }
    847803
     
    11221078        s.chop(2);
    11231079        value.variant = s;
    1124         if (value.variant.convert(QVariant::Double)) {
    1125             font->setPointSizeF(value.variant.toDouble());
     1080        if (value.variant.convert()) {
     1081            font->setPointSizeF(value.variant.to());
    11261082            valid = true;
    11271083        }
     
    11661122}
    11671123
    1168 static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font)
     1124/** \internal
     1125 * parse the font family from the values (starting from index \a start)
     1126 * and set it the \a font
     1127 * \returns true if a family was extracted.
     1128 */
     1129static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font, int start = 0)
    11691130{
    11701131    QString family;
    1171     for (int i = 0; i < values.count(); ++i) {
     1132    bool shouldAddSpace = false;
     1133    for (int i = start; i < values.count(); ++i) {
    11721134        const Value &v = values.at(i);
    1173         if (v.type == Value::TermOperatorComma)
    1174             break;
     1135        if (v.type == Value::TermOperatorComma) {
     1136            family += QLatin1Char(',');
     1137            shouldAddSpace = false;
     1138            continue;
     1139        }
    11751140        const QString str = v.variant.toString();
    11761141        if (str.isEmpty())
    11771142            break;
     1143
     1144
    11781145        family += str;
    1179         family += QLatin1Char(' ');
    1180     }
    1181     family = family.simplified();
     1146        shouldAddSpace = true;
     1147    }
    11821148    if (family.isEmpty())
    11831149        return false;
     
    12091175    font->setStyle(QFont::StyleNormal);
    12101176    font->setWeight(QFont::Normal);
    1211     *fontSizeAdjustment = 0;
     1177    *fontSizeAdjustment = ;
    12121178
    12131179    int i = 0;
     
    12261192
    12271193    if (i < values.count()) {
    1228         QString fam = values.at(i).variant.toString();
    1229         if (!fam.isEmpty())
    1230             font->setFamily(fam);
     1194        setFontFamilyFromValues(values, font, i);
    12311195    }
    12321196}
     
    15081472    if (func.count() != 2 || func.at(0).compare(QLatin1String("rect")) != 0)
    15091473        return QRect();
    1510     QStringList args = func[1].split(QLatin1String(" "), QString::SkipEmptyParts);
     1474    QStringList args = func[1].split(QLatin1), QString::SkipEmptyParts);
    15111475    if (args.count() != 4)
    15121476        return QRect();
     
    21532117        QFile file(css);
    21542118        if (file.open(QFile::ReadOnly)) {
    2155             sourcePath = QFileInfo(styleSheet).absolutePath() + QLatin1String("/");
     2119            sourcePath = QFileInfo(styleSheet).absolutePath() + QLatin1);
    21562120            QTextStream stream(&file);
    21572121            styleSheet = stream.readAll();
     
    21662130    hasEscapeSequences = false;
    21672131    symbols.resize(0);
     2132
    21682133    Scanner::scan(Scanner::preprocess(styleSheet, &hasEscapeSequences), &symbols);
    21692134    index = 0;
     
    24992464bool Parser::parsePseudo(Pseudo *pseudo)
    25002465{
    2501     test(COLON);
     2466    test(COLON);
    25022467    pseudo->negated = test(EXCLAMATION_SYM);
    25032468    if (test(IDENT)) {
Note: See TracChangeset for help on using the changeset viewer.