Changeset 30421 in webkit
- Timestamp:
- Feb 19, 2008 6:17:25 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r30420 r30421 1 2008-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 1 24 2008-02-19 Darin Adler <darin@apple.com> 2 25 -
trunk/WebCore/css/CSSFontSelector.cpp
r29864 r30421 207 207 String familyName; 208 208 if (item->primitiveType() == CSSPrimitiveValue::CSS_STRING) 209 familyName = static_cast<FontFamilyValue*>(item)->f ontName();209 familyName = static_cast<FontFamilyValue*>(item)->familyName(); 210 210 else if (item->primitiveType() == CSSPrimitiveValue::CSS_IDENT) { 211 211 // 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 2675 2675 } 2676 2676 2677 static DeprecatedString deprecatedString(const ParseString& ps)2678 {2679 return DeprecatedString(reinterpret_cast<const DeprecatedChar*>(ps.characters), ps.length);2680 }2681 2682 2677 PassRefPtr<CSSValueList> CSSParser::parseFontFamily() 2683 2678 { … … 2694 2689 2695 2690 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); 2700 2693 else if (nextValBreaksFont || !nextValIsFontName) 2701 2694 list->append(new CSSPrimitiveValue(value->id)); 2702 2695 else 2703 list->append(currFamily = new FontFamilyValue(d eprecatedString(value->string)));2696 list->append(currFamily = new FontFamilyValue(domString(value->string))); 2704 2697 } 2705 2698 else if (value->unit == CSSPrimitiveValue::CSS_STRING) { 2706 2699 // Strings never share in a family name. 2707 2700 currFamily = 0; 2708 list->append(new FontFamilyValue(d eprecatedString(value->string)));2701 list->append(new FontFamilyValue(domString(value->string))); 2709 2702 } 2710 2703 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); 2715 2706 else if (nextValBreaksFont || !nextValIsFontName) 2716 list->append(new FontFamilyValue(d eprecatedString(value->string)));2707 list->append(new FontFamilyValue(domString(value->string))); 2717 2708 else 2718 list->append(currFamily = new FontFamilyValue(d eprecatedString(value->string)));2709 list->append(currFamily = new FontFamilyValue(domString(value->string))); 2719 2710 } 2720 2711 else { -
trunk/WebCore/css/CSSStyleSelector.cpp
r30243 r30421 46 46 #include "Counter.h" 47 47 #include "DashboardRegion.h" 48 #include "DeprecatedString.h" 48 49 #include "FontFamilyValue.h" 49 50 #include "FontValue.h" … … 3583 3584 Settings* settings = m_document->settings(); 3584 3585 if (val->primitiveType() == CSSPrimitiveValue::CSS_STRING) 3585 face = static_cast<FontFamilyValue*>(val)->f ontName();3586 face = static_cast<FontFamilyValue*>(val)->familyName(); 3586 3587 else if (val->primitiveType() == CSSPrimitiveValue::CSS_IDENT && settings) { 3587 3588 switch (val->getIdent()) { -
trunk/WebCore/css/FontFamilyValue.cpp
r25754 r30421 1 /* *1 /* 2 2 * (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. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 18 18 * Boston, MA 02110-1301, USA. 19 19 */ 20 20 21 #include "config.h" 21 22 #include "FontFamilyValue.h" 22 23 #include "PlatformString.h"24 #include "RegularExpression.h"25 23 26 24 namespace WebCore { … … 62 60 } 63 61 64 FontFamilyValue::FontFamilyValue(const DeprecatedString& string)62 FontFamilyValue::FontFamilyValue(const String& familyName) 65 63 : CSSPrimitiveValue(String(), CSS_STRING) 64 , m_familyName(familyName) 66 65 { 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 } 69 94 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, ""); 95 void FontFamilyValue::appendSpaceSeparated(const UChar* characters, unsigned length) 96 { 97 m_familyName.append(' '); 98 m_familyName.append(characters, length); 75 99 } 76 100 77 101 String FontFamilyValue::cssText() const 78 102 { 79 return quoteStringIfNeeded( parsedFontName);103 return quoteStringIfNeeded(m_familyName); 80 104 } 81 105 -
trunk/WebCore/css/FontFamilyValue.h
r25754 r30421 1 1 /* 2 * This file is part of the DOM implementation for KDE.3 *4 2 * (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. 6 4 * 7 5 * This library is free software; you can redistribute it and/or … … 25 23 26 24 #include "CSSPrimitiveValue.h" 27 #include " DeprecatedString.h"25 #include "PlatformString.h" 28 26 29 27 namespace WebCore { 30 28 31 class FontFamilyValue : public CSSPrimitiveValue 32 { 29 class FontFamilyValue : public CSSPrimitiveValue { 33 30 public: 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; } 37 35 38 36 virtual String cssText() const; 39 37 40 DeprecatedString parsedFontName;41 38 private: 42 int m_genericFamilyType;39 String m_familyName; 43 40 }; 44 41
Note: See TracChangeset
for help on using the changeset viewer.