Changeset 30421 in webkit


Ignore:
Timestamp:
Feb 19, 2008 6:17:25 PM (16 years ago)
Author:
Darin Adler
Message:

Reviewed by Sam.

  • removed use of DeprecatedString for font family names
  • css/CSSFontSelector.cpp: (WebCore::CSSFontSelector::addFontFaceRule): Update for name change.
  • css/CSSParser.cpp: (WebCore::CSSParser::parseFontFamily): Update to use new appendSpaceSeparated function and String rather than DeprecatedString.
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::applyProperty): Updated for name change.
  • css/FontFamilyValue.cpp: (WebCore::FontFamilyValue::FontFamilyValue): Replaced code using a regular expression with code that does the same thing more efficiently. (WebCore::FontFamilyValue::appendSpaceSeparated): Added. (WebCore::FontFamilyValue::cssText): Updated for name change.
  • css/FontFamilyValue.h: Changed DeprecatedString to String. Renamed fontName to familyName and parsedFontName to m_familyName. Removed unused genericFamilyType and m_genericFamilyType. Added appendSpaceSeparated so that m_familyName can be private instead of public.
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r30420 r30421  
     12008-02-19  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Sam.
     4
     5        - removed use of DeprecatedString for font family names
     6
     7        * css/CSSFontSelector.cpp:
     8        (WebCore::CSSFontSelector::addFontFaceRule): Update for name change.
     9        * css/CSSParser.cpp:
     10        (WebCore::CSSParser::parseFontFamily): Update to use new appendSpaceSeparated
     11        function and String rather than DeprecatedString.
     12        * css/CSSStyleSelector.cpp:
     13        (WebCore::CSSStyleSelector::applyProperty): Updated for name change.
     14        * css/FontFamilyValue.cpp:
     15        (WebCore::FontFamilyValue::FontFamilyValue): Replaced code using a regular
     16        expression with code that does the same thing more efficiently.
     17        (WebCore::FontFamilyValue::appendSpaceSeparated): Added.
     18        (WebCore::FontFamilyValue::cssText): Updated for name change.
     19        * css/FontFamilyValue.h: Changed DeprecatedString to String. Renamed fontName
     20        to familyName and parsedFontName to m_familyName. Removed unused genericFamilyType
     21        and m_genericFamilyType. Added appendSpaceSeparated so that m_familyName can
     22        be private instead of public.
     23
    1242008-02-19  Darin Adler  <darin@apple.com>
    225
  • trunk/WebCore/css/CSSFontSelector.cpp

    r29864 r30421  
    207207        String familyName;
    208208        if (item->primitiveType() == CSSPrimitiveValue::CSS_STRING)
    209             familyName = static_cast<FontFamilyValue*>(item)->fontName();
     209            familyName = static_cast<FontFamilyValue*>(item)->familyName();
    210210        else if (item->primitiveType() == CSSPrimitiveValue::CSS_IDENT) {
    211211            // We need to use the raw text for all the generic family types, since @font-face is a way of actually
  • trunk/WebCore/css/CSSParser.cpp

    r30393 r30421  
    26752675}
    26762676
    2677 static DeprecatedString deprecatedString(const ParseString& ps)
    2678 {
    2679     return DeprecatedString(reinterpret_cast<const DeprecatedChar*>(ps.characters), ps.length);
    2680 }
    2681 
    26822677PassRefPtr<CSSValueList> CSSParser::parseFontFamily()
    26832678{
     
    26942689
    26952690        if (value->id >= CSS_VAL_SERIF && value->id <= CSS_VAL__WEBKIT_BODY) {
    2696             if (currFamily) {
    2697                 currFamily->parsedFontName += ' ';
    2698                 currFamily->parsedFontName += deprecatedString(value->string);
    2699             }
     2691            if (currFamily)
     2692                currFamily->appendSpaceSeparated(value->string.characters, value->string.length);
    27002693            else if (nextValBreaksFont || !nextValIsFontName)
    27012694                list->append(new CSSPrimitiveValue(value->id));
    27022695            else
    2703                 list->append(currFamily = new FontFamilyValue(deprecatedString(value->string)));
     2696                list->append(currFamily = new FontFamilyValue(domString(value->string)));
    27042697        }
    27052698        else if (value->unit == CSSPrimitiveValue::CSS_STRING) {
    27062699            // Strings never share in a family name.
    27072700            currFamily = 0;
    2708             list->append(new FontFamilyValue(deprecatedString(value->string)));
     2701            list->append(new FontFamilyValue(domString(value->string)));
    27092702        }
    27102703        else if (value->unit == CSSPrimitiveValue::CSS_IDENT) {
    2711             if (currFamily) {
    2712                 currFamily->parsedFontName += ' ';
    2713                 currFamily->parsedFontName += deprecatedString(value->string);
    2714             }
     2704            if (currFamily)
     2705                currFamily->appendSpaceSeparated(value->string.characters, value->string.length);
    27152706            else if (nextValBreaksFont || !nextValIsFontName)
    2716                 list->append(new FontFamilyValue(deprecatedString(value->string)));
     2707                list->append(new FontFamilyValue(domString(value->string)));
    27172708            else
    2718                 list->append(currFamily = new FontFamilyValue(deprecatedString(value->string)));
     2709                list->append(currFamily = new FontFamilyValue(domString(value->string)));
    27192710        }
    27202711        else {
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r30243 r30421  
    4646#include "Counter.h"
    4747#include "DashboardRegion.h"
     48#include "DeprecatedString.h"
    4849#include "FontFamilyValue.h"
    4950#include "FontValue.h"
     
    35833584            Settings* settings = m_document->settings();
    35843585            if (val->primitiveType() == CSSPrimitiveValue::CSS_STRING)
    3585                 face = static_cast<FontFamilyValue*>(val)->fontName();
     3586                face = static_cast<FontFamilyValue*>(val)->familyName();
    35863587            else if (val->primitiveType() == CSSPrimitiveValue::CSS_IDENT && settings) {
    35873588                switch (val->getIdent()) {
  • trunk/WebCore/css/FontFamilyValue.cpp

    r25754 r30421  
    1 /**
     1/*
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    1818 * Boston, MA 02110-1301, USA.
    1919 */
     20
    2021#include "config.h"
    2122#include "FontFamilyValue.h"
    22 
    23 #include "PlatformString.h"
    24 #include "RegularExpression.h"
    2523
    2624namespace WebCore {
     
    6260}
    6361
    64 FontFamilyValue::FontFamilyValue(const DeprecatedString& string)
     62FontFamilyValue::FontFamilyValue(const String& familyName)
    6563    : CSSPrimitiveValue(String(), CSS_STRING)
     64    , m_familyName(familyName)
    6665{
    67     static const RegularExpression parenReg(" \\(.*\\)$");
    68     static const RegularExpression braceReg(" \\[.*\\]$");
     66    // If there is anything in parentheses or square brackets at the end, delete it.
     67    // FIXME: Do we really need this? The original code mentioned "a language tag in
     68    // braces at the end" and "[Xft] qualifiers", but it's not clear either of those
     69    // is in active use on the web.
     70    unsigned length = m_familyName.length();
     71    while (length >= 3) {
     72        UChar startCharacter = 0;
     73        switch (m_familyName[length - 1]) {
     74            case ']':
     75                startCharacter = '[';
     76                break;
     77            case ')':
     78                startCharacter = '(';
     79                break;
     80        }
     81        if (!startCharacter)
     82            break;
     83        unsigned first = 0;
     84        for (unsigned i = length - 2; i > 0; --i) {
     85            if (m_familyName[i - 1] == ' ' && m_familyName[i] == startCharacter)
     86                first = i - 1;
     87        }
     88        if (!first)
     89            break;
     90        length = first;
     91    }
     92    m_familyName.truncate(length);
     93}
    6994
    70     parsedFontName = string;
    71     // a language tag is often added in braces at the end. Remove it.
    72     parsedFontName.replace(parenReg, "");
    73     // remove [Xft] qualifiers
    74     parsedFontName.replace(braceReg, "");
     95void FontFamilyValue::appendSpaceSeparated(const UChar* characters, unsigned length)
     96{
     97    m_familyName.append(' ');
     98    m_familyName.append(characters, length);
    7599}
    76100
    77101String FontFamilyValue::cssText() const
    78102{
    79     return quoteStringIfNeeded(parsedFontName);
     103    return quoteStringIfNeeded(m_familyName);
    80104}
    81105
  • trunk/WebCore/css/FontFamilyValue.h

    r25754 r30421  
    11/*
    2  * This file is part of the DOM implementation for KDE.
    3  *
    42 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    5  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
     3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
    64 *
    75 * This library is free software; you can redistribute it and/or
     
    2523
    2624#include "CSSPrimitiveValue.h"
    27 #include "DeprecatedString.h"
     25#include "PlatformString.h"
    2826
    2927namespace WebCore {
    3028
    31 class FontFamilyValue : public CSSPrimitiveValue
    32 {
     29class FontFamilyValue : public CSSPrimitiveValue {
    3330public:
    34     FontFamilyValue(const DeprecatedString& string);
    35     const DeprecatedString& fontName() const { return parsedFontName; }
    36     int genericFamilyType() const { return m_genericFamilyType; }
     31    FontFamilyValue(const String& familyName);
     32    void appendSpaceSeparated(const UChar* characters, unsigned length);
     33
     34    const String& familyName() const { return m_familyName; }
    3735
    3836    virtual String cssText() const;
    3937
    40     DeprecatedString parsedFontName;
    4138private:
    42     int m_genericFamilyType;
     39    String m_familyName;
    4340};
    4441
Note: See TracChangeset for help on using the changeset viewer.