Changeset 26027 in webkit


Ignore:
Timestamp:
Oct 3, 2007 2:04:03 PM (17 years ago)
Author:
hyatt
Message:

Land support for the CSS @font-face rule. This patch allows custom fonts
to be downloaded from the Web and rendered in Web pages. Right now only
TrueType fonts are supported. Proprietary formats like .eot are not
supported.

Reviewed by Eric Seidel

Many tests will be coming in a future landing.

  • WebCore.base.exp: Expose some more stuff for WebKit, caused by font restructuring.
  • WebCore.xcodeproj/project.pbxproj: Add all the new font face files.
  • css/CSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Make sure to ignore the 'src' property of @font-face rules.
  • css/CSSFontFace.cpp: Added. (WebCore::CSSFontFace::CSSFontFace): (WebCore::CSSFontFace::~CSSFontFace): (WebCore::CSSFontFace::isLoaded): (WebCore::CSSFontFace::isValid): (WebCore::CSSFontFace::addSource): (WebCore::CSSFontFace::fontLoaded): (WebCore::CSSFontFace::getFontData):
  • css/CSSFontFace.h: Added. A CSSFontFace is a composite object. It consists of multiple font-face sources, where each source represents either a remote or local file in a @font-face rule's src list.
  • css/CSSFontFaceRule.cpp: (WebCore::CSSFontFaceRule::setDeclaration): (WebCore::CSSFontFaceRule::cssText):
  • css/CSSFontFaceRule.h: The implementation of the @font-face rule itself in the CSS sheet back end.


  • css/CSSFontFaceSource.cpp: Added. (WebCore::CSSFontFaceSource::CSSFontFaceSource): (WebCore::CSSFontFaceSource::~CSSFontFaceSource): (WebCore::CSSFontFaceSource::pruneTable): (WebCore::CSSFontFaceSource::isLoaded): (WebCore::CSSFontFaceSource::isValid): (WebCore::CSSFontFaceSource::fontLoaded): (WebCore::CSSFontFaceSource::getFontData):
  • css/CSSFontFaceSource.h: Added. (WebCore::CSSFontFaceSource::string): (WebCore::CSSFontFaceSource::setFontFace): A font face source represents a single remote or local font. If it represents a remote font than it wraps a CachedFont.


  • css/CSSFontFaceSrcValue.cpp: Added. (WebCore::CSSFontFaceSrcValue::isSupportedFormat): (WebCore::CSSFontFaceSrcValue::cssText):
  • css/CSSFontFaceSrcValue.h: Added. (WebCore::CSSFontFaceSrcValue::m_isLocal): (WebCore::CSSFontFaceSrcValue::~CSSFontFaceSrcValue): (WebCore::CSSFontFaceSrcValue::resource): (WebCore::CSSFontFaceSrcValue::format): (WebCore::CSSFontFaceSrcValue::isLocal): (WebCore::CSSFontFaceSrcValue::setFormat): Used in parsing. Represents the parsed form of the src value that can then be used to build up a CSSFontFace.
  • css/CSSFontSelector.cpp: Added. (WebCore::CSSFontSelector::CSSFontSelector): (WebCore::CSSFontSelector::~CSSFontSelector): (WebCore::CSSFontSelector::isEmpty): (WebCore::CSSFontSelector::docLoader): (WebCore::hashForFont): (WebCore::CSSFontSelector::addFontFaceRule): (WebCore::CSSFontSelector::fontLoaded): (WebCore::CSSFontSelector::getFontData):
  • css/CSSFontSelector.h: Added. The CSS font selector is the object that selects the correct font given a specified font family. It builds up a database of CSSFontFaces that can then be handed back.
  • css/CSSGrammar.y:
  • css/CSSParser.cpp: (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseFontFaceSrc): (WebCore::CSSParser::createFontFaceRule):
  • css/CSSParser.h: Modify the CSS grammar to now understand @font-face rules.
  • css/CSSPropertyNames.in: Add the src property.
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::CSSStyleSelector): (WebCore::CSSStyleSelector::styleForElement): (WebCore::CSSStyleSelector::updateFont): (WebCore::CSSRuleSet::addRulesFromSheet): (WebCore::CSSStyleSelector::applyProperty): (WebCore::CSSStyleSelector::ensureFontSelector):
  • css/CSSStyleSelector.h: (WebCore::CSSStyleSelector::fontSelector): The style selector now creates a font selector object and feeds it the appropriate information when @font-face rules are encountered.


  • dom/Document.cpp: (WebCore::Document::recalcStyle): Patch the update method now that it takes a font selector argument.


  • loader/Cache.cpp: (WebCore::createResource): (WebCore::Cache::getStatistics):
  • loader/Cache.h: Teach the Cache about CachedFonts.
  • loader/CachedFont.cpp: Added. (WebCore::CachedFont::CachedFont): (WebCore::CachedFont::~CachedFont): (WebCore::CachedFont::ref): (WebCore::CachedFont::data): (WebCore::CachedFont::beginLoadIfNeeded): (WebCore::CachedFont::ensureCustomFontData): (WebCore::CachedFont::platformDataFromCustomData): (WebCore::CachedFont::allReferencesRemoved): (WebCore::CachedFont::checkNotify): (WebCore::CachedFont::error):
  • loader/CachedFont.h: Added. (WebCore::CachedFont::schedule): The implementation of CachedFont. This represents the downloaded resource and has all the raw font data.
  • loader/CachedResource.h: (WebCore::CachedResource::):
  • loader/CachedResourceClient.h: (WebCore::CachedResourceClient::fontLoaded): Add a new fontLoaded method for clients of cached resources to track when fonts finish downloading.


  • loader/DocLoader.cpp: (WebCore::DocLoader::requestFont):
  • loader/DocLoader.h: Add the ability to request a font.
  • platform/Font.cpp: (WebCore::Font::operator==): (WebCore::Font::update): (WebCore::Font::drawText):
  • platform/Font.h:
  • platform/FontCache.cpp: (WebCore::FontCache::getFontData):
  • platform/FontCache.h:
  • platform/FontData.cpp: (WebCore::FontData::FontData):
  • platform/FontData.h: (WebCore::FontData::isCustomFont): (WebCore::FontData::isLoading):
  • platform/FontFallbackList.cpp: (WebCore::FontFallbackList::FontFallbackList): (WebCore::FontFallbackList::invalidate): (WebCore::FontFallbackList::fontDataAt):
  • platform/FontFallbackList.h: (WebCore::FontFallbackList::loadingCustomFonts): (WebCore::FontFallbackList::fontSelector):
  • platform/FontSelector.h: Added. (WebCore::FontSelector::~FontSelector):
  • platform/GlyphPageTreeNode.cpp: (WebCore::GlyphPageTreeNode::getRoot): (WebCore::GlyphPageTreeNode::pruneTreeCustomFontData): (WebCore::GlyphPageTreeNode::~GlyphPageTreeNode): (WebCore::GlyphPageTreeNode::initializePage): (WebCore::GlyphPageTreeNode::getChild): (WebCore::GlyphPageTreeNode::pruneCustomFontData):
  • platform/GlyphPageTreeNode.h: (WebCore::GlyphPageTreeNode::GlyphPageTreeNode): (WebCore::GlyphPageTreeNode::page):
  • platform/PopupMenuClient.h:
  • platform/mac/FontCacheMac.mm: (WebCore::FontCache::getFontDataForCharacters): (WebCore::FontCache::getLastResortFallbackFont): (WebCore::FontCache::fontExists): (WebCore::FontCache::createFontPlatformData):
  • platform/mac/FontCustomPlatformData.cpp: Added. (WebCore::FontCustomPlatformData::~FontCustomPlatformData): (WebCore::FontCustomPlatformData::fontPlatformData): (WebCore::createFontCustomPlatformData):
  • platform/mac/FontCustomPlatformData.h: Added. (WebCore::FontCustomPlatformData::FontCustomPlatformData):
  • platform/mac/FontDataMac.mm: (WebCore::initFontData): (WebCore::FontData::platformInit): (WebCore::FontData::smallCapsFontData): (WebCore::FontData::platformWidthForGlyph): (WebCore::FontData::checkShapesArabic):
  • platform/mac/FontMac.mm: (WebCore::initializeATSUStyle): (WebCore::Font::drawGlyphs):
  • platform/mac/FontPlatformData.h: (WebCore::FontPlatformData::FontPlatformData): (WebCore::FontPlatformData::hash): (WebCore::FontPlatformData::operator==):
  • platform/mac/FontPlatformDataMac.mm: Added. (WebCore::FontPlatformData::FontPlatformData): (WebCore::~FontPlatformData): (WebCore::FontPlatformData::setFont):
  • platform/mac/WebCoreSystemInterface.h:
  • platform/mac/WebCoreSystemInterface.mm:
  • platform/win/FontCacheWin.cpp: (WebCore::FontCache::getLastResortFallbackFont): (WebCore::FontCache::fontExists):
  • platform/win/FontCustomPlatformData.cpp: Added. (WebCore::FontCustomPlatformData::~FontCustomPlatformData): (WebCore::FontCustomPlatformData::fontPlatformData): (WebCore::getData): (WebCore::releaseData): (WebCore::getBytesWithOffset): (WebCore::createFontCustomPlatformData):
  • platform/win/FontCustomPlatformData.h: Added. (WebCore::FontCustomPlatformData::FontCustomPlatformData):
  • platform/win/FontDataWin.cpp: (WebCore::FontData::platformInit): (WebCore::FontData::platformDestroy): (WebCore::FontData::smallCapsFontData): (WebCore::FontData::containsCharacters): (WebCore::FontData::determinePitch):
  • platform/win/FontPlatformData.h: (WebCore::FontPlatformData::FontPlatformData): (WebCore::FontPlatformData::hash): (WebCore::FontPlatformData::operator==):
  • platform/win/FontPlatformDataWin.cpp: (WebCore::FontPlatformData::FontPlatformData):
  • platform/win/PopupMenuWin.cpp: (WebCore::PopupMenu::paint): Changes to platform to support rendering of custom fonts. Too large to go into, but for ports, the relevant object to implement is FontCustomPlatformData (to get the data loaded into your native font format), and then you have to patch your other font objects to know how to use the font.
  • rendering/RenderListBox.cpp: (WebCore::RenderListBox::updateFromElement): (WebCore::RenderListBox::paintItemForeground):
  • rendering/RenderMenuList.cpp: (WebCore::RenderMenuList::fontSelector):
  • rendering/RenderMenuList.h:
  • rendering/RenderTextControl.cpp: (WebCore::RenderTextControl::fontSelector):
  • rendering/RenderTextControl.h:
  • rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::setFontFromControlSize):
  • rendering/RenderThemeSafari.cpp: (WebCore::RenderThemeSafari::setFontFromControlSize): Patches for update now taking a font selector argument.
Location:
branches/feature-branch/WebCore
Files:
16 added
48 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-branch/WebCore/ChangeLog

    r26025 r26027  
     12007-10-03  David Hyatt  <hyatt@apple.com>
     2
     3        Land support for the CSS @font-face rule.  This patch allows custom fonts
     4        to be downloaded from the Web and rendered in Web pages.  Right now only
     5        TrueType fonts are supported.  Proprietary formats like .eot are not
     6        supported.
     7
     8        Reviewed by Eric Seidel
     9
     10        Many tests will be coming in a future landing.
     11
     12        * WebCore.base.exp:
     13        Expose some more stuff for WebKit, caused by font restructuring.
     14
     15        * WebCore.xcodeproj/project.pbxproj:
     16        Add all the new font face files.
     17
     18        * css/CSSComputedStyleDeclaration.cpp:
     19        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     20        Make sure to ignore the 'src' property of @font-face rules.
     21
     22        * css/CSSFontFace.cpp: Added.
     23        (WebCore::CSSFontFace::CSSFontFace):
     24        (WebCore::CSSFontFace::~CSSFontFace):
     25        (WebCore::CSSFontFace::isLoaded):
     26        (WebCore::CSSFontFace::isValid):
     27        (WebCore::CSSFontFace::addSource):
     28        (WebCore::CSSFontFace::fontLoaded):
     29        (WebCore::CSSFontFace::getFontData):
     30        * css/CSSFontFace.h: Added.
     31        A CSSFontFace is a composite object.  It consists of multiple font-face sources, where each source represents either a remote or local
     32        file in a @font-face rule's src list.
     33
     34        * css/CSSFontFaceRule.cpp:
     35        (WebCore::CSSFontFaceRule::setDeclaration):
     36        (WebCore::CSSFontFaceRule::cssText):
     37        * css/CSSFontFaceRule.h:
     38        The implementation of the @font-face rule itself in the CSS sheet back end.
     39       
     40        * css/CSSFontFaceSource.cpp: Added.
     41        (WebCore::CSSFontFaceSource::CSSFontFaceSource):
     42        (WebCore::CSSFontFaceSource::~CSSFontFaceSource):
     43        (WebCore::CSSFontFaceSource::pruneTable):
     44        (WebCore::CSSFontFaceSource::isLoaded):
     45        (WebCore::CSSFontFaceSource::isValid):
     46        (WebCore::CSSFontFaceSource::fontLoaded):
     47        (WebCore::CSSFontFaceSource::getFontData):
     48        * css/CSSFontFaceSource.h: Added.
     49        (WebCore::CSSFontFaceSource::string):
     50        (WebCore::CSSFontFaceSource::setFontFace):
     51        A font face source represents a single remote or local font.  If it represents a remote font than it wraps a CachedFont.
     52       
     53        * css/CSSFontFaceSrcValue.cpp: Added.
     54        (WebCore::CSSFontFaceSrcValue::isSupportedFormat):
     55        (WebCore::CSSFontFaceSrcValue::cssText):
     56        * css/CSSFontFaceSrcValue.h: Added.
     57        (WebCore::CSSFontFaceSrcValue::m_isLocal):
     58        (WebCore::CSSFontFaceSrcValue::~CSSFontFaceSrcValue):
     59        (WebCore::CSSFontFaceSrcValue::resource):
     60        (WebCore::CSSFontFaceSrcValue::format):
     61        (WebCore::CSSFontFaceSrcValue::isLocal):
     62        (WebCore::CSSFontFaceSrcValue::setFormat):
     63        Used in parsing.  Represents the parsed form of the src value that can then be used to build up a CSSFontFace.
     64
     65        * css/CSSFontSelector.cpp: Added.
     66        (WebCore::CSSFontSelector::CSSFontSelector):
     67        (WebCore::CSSFontSelector::~CSSFontSelector):
     68        (WebCore::CSSFontSelector::isEmpty):
     69        (WebCore::CSSFontSelector::docLoader):
     70        (WebCore::hashForFont):
     71        (WebCore::CSSFontSelector::addFontFaceRule):
     72        (WebCore::CSSFontSelector::fontLoaded):
     73        (WebCore::CSSFontSelector::getFontData):
     74        * css/CSSFontSelector.h: Added.
     75        The CSS font selector is the object that selects the correct font given a specified font family.  It builds up a database of CSSFontFaces that can then be handed
     76        back.
     77
     78        * css/CSSGrammar.y:
     79        * css/CSSParser.cpp:
     80        (WebCore::CSSParser::parseValue):
     81        (WebCore::CSSParser::parseFontFaceSrc):
     82        (WebCore::CSSParser::createFontFaceRule):
     83        * css/CSSParser.h:
     84        Modify the CSS grammar to now understand @font-face rules.
     85
     86        * css/CSSPropertyNames.in:
     87        Add the src property.
     88
     89        * css/CSSStyleSelector.cpp:
     90        (WebCore::CSSStyleSelector::CSSStyleSelector):
     91        (WebCore::CSSStyleSelector::styleForElement):
     92        (WebCore::CSSStyleSelector::updateFont):
     93        (WebCore::CSSRuleSet::addRulesFromSheet):
     94        (WebCore::CSSStyleSelector::applyProperty):
     95        (WebCore::CSSStyleSelector::ensureFontSelector):
     96        * css/CSSStyleSelector.h:
     97        (WebCore::CSSStyleSelector::fontSelector):
     98        The style selector now creates a font selector object and feeds it the appropriate information when @font-face rules are encountered.
     99   
     100        * dom/Document.cpp:
     101        (WebCore::Document::recalcStyle):
     102        Patch the update method now that it takes a font selector argument.
     103   
     104        * loader/Cache.cpp:
     105        (WebCore::createResource):
     106        (WebCore::Cache::getStatistics):
     107        * loader/Cache.h:
     108        Teach the Cache about CachedFonts.
     109
     110        * loader/CachedFont.cpp: Added.
     111        (WebCore::CachedFont::CachedFont):
     112        (WebCore::CachedFont::~CachedFont):
     113        (WebCore::CachedFont::ref):
     114        (WebCore::CachedFont::data):
     115        (WebCore::CachedFont::beginLoadIfNeeded):
     116        (WebCore::CachedFont::ensureCustomFontData):
     117        (WebCore::CachedFont::platformDataFromCustomData):
     118        (WebCore::CachedFont::allReferencesRemoved):
     119        (WebCore::CachedFont::checkNotify):
     120        (WebCore::CachedFont::error):
     121        * loader/CachedFont.h: Added.
     122        (WebCore::CachedFont::schedule):
     123        The implementation of CachedFont.  This represents the downloaded resource and has all the raw font data.
     124
     125        * loader/CachedResource.h:
     126        (WebCore::CachedResource::):
     127        * loader/CachedResourceClient.h:
     128        (WebCore::CachedResourceClient::fontLoaded):
     129        Add a new fontLoaded method for clients of cached resources to track when fonts finish downloading.
     130   
     131        * loader/DocLoader.cpp:
     132        (WebCore::DocLoader::requestFont):
     133        * loader/DocLoader.h:
     134         Add the ability to request a font.
     135
     136        * platform/Font.cpp:
     137        (WebCore::Font::operator==):
     138        (WebCore::Font::update):
     139        (WebCore::Font::drawText):
     140        * platform/Font.h:
     141        * platform/FontCache.cpp:
     142        (WebCore::FontCache::getFontData):
     143        * platform/FontCache.h:
     144        * platform/FontData.cpp:
     145        (WebCore::FontData::FontData):
     146        * platform/FontData.h:
     147        (WebCore::FontData::isCustomFont):
     148        (WebCore::FontData::isLoading):
     149        * platform/FontFallbackList.cpp:
     150        (WebCore::FontFallbackList::FontFallbackList):
     151        (WebCore::FontFallbackList::invalidate):
     152        (WebCore::FontFallbackList::fontDataAt):
     153        * platform/FontFallbackList.h:
     154        (WebCore::FontFallbackList::loadingCustomFonts):
     155        (WebCore::FontFallbackList::fontSelector):
     156        * platform/FontSelector.h: Added.
     157        (WebCore::FontSelector::~FontSelector):
     158        * platform/GlyphPageTreeNode.cpp:
     159        (WebCore::GlyphPageTreeNode::getRoot):
     160        (WebCore::GlyphPageTreeNode::pruneTreeCustomFontData):
     161        (WebCore::GlyphPageTreeNode::~GlyphPageTreeNode):
     162        (WebCore::GlyphPageTreeNode::initializePage):
     163        (WebCore::GlyphPageTreeNode::getChild):
     164        (WebCore::GlyphPageTreeNode::pruneCustomFontData):
     165        * platform/GlyphPageTreeNode.h:
     166        (WebCore::GlyphPageTreeNode::GlyphPageTreeNode):
     167        (WebCore::GlyphPageTreeNode::page):
     168        * platform/PopupMenuClient.h:
     169        * platform/mac/FontCacheMac.mm:
     170        (WebCore::FontCache::getFontDataForCharacters):
     171        (WebCore::FontCache::getLastResortFallbackFont):
     172        (WebCore::FontCache::fontExists):
     173        (WebCore::FontCache::createFontPlatformData):
     174        * platform/mac/FontCustomPlatformData.cpp: Added.
     175        (WebCore::FontCustomPlatformData::~FontCustomPlatformData):
     176        (WebCore::FontCustomPlatformData::fontPlatformData):
     177        (WebCore::createFontCustomPlatformData):
     178        * platform/mac/FontCustomPlatformData.h: Added.
     179        (WebCore::FontCustomPlatformData::FontCustomPlatformData):
     180        * platform/mac/FontDataMac.mm:
     181        (WebCore::initFontData):
     182        (WebCore::FontData::platformInit):
     183        (WebCore::FontData::smallCapsFontData):
     184        (WebCore::FontData::platformWidthForGlyph):
     185        (WebCore::FontData::checkShapesArabic):
     186        * platform/mac/FontMac.mm:
     187        (WebCore::initializeATSUStyle):
     188        (WebCore::Font::drawGlyphs):
     189        * platform/mac/FontPlatformData.h:
     190        (WebCore::FontPlatformData::FontPlatformData):
     191        (WebCore::FontPlatformData::hash):
     192        (WebCore::FontPlatformData::operator==):
     193        * platform/mac/FontPlatformDataMac.mm: Added.
     194        (WebCore::FontPlatformData::FontPlatformData):
     195        (WebCore::~FontPlatformData):
     196        (WebCore::FontPlatformData::setFont):
     197        * platform/mac/WebCoreSystemInterface.h:
     198        * platform/mac/WebCoreSystemInterface.mm:
     199        * platform/win/FontCacheWin.cpp:
     200        (WebCore::FontCache::getLastResortFallbackFont):
     201        (WebCore::FontCache::fontExists):
     202        * platform/win/FontCustomPlatformData.cpp: Added.
     203        (WebCore::FontCustomPlatformData::~FontCustomPlatformData):
     204        (WebCore::FontCustomPlatformData::fontPlatformData):
     205        (WebCore::getData):
     206        (WebCore::releaseData):
     207        (WebCore::getBytesWithOffset):
     208        (WebCore::createFontCustomPlatformData):
     209        * platform/win/FontCustomPlatformData.h: Added.
     210        (WebCore::FontCustomPlatformData::FontCustomPlatformData):
     211        * platform/win/FontDataWin.cpp:
     212        (WebCore::FontData::platformInit):
     213        (WebCore::FontData::platformDestroy):
     214        (WebCore::FontData::smallCapsFontData):
     215        (WebCore::FontData::containsCharacters):
     216        (WebCore::FontData::determinePitch):
     217        * platform/win/FontPlatformData.h:
     218        (WebCore::FontPlatformData::FontPlatformData):
     219        (WebCore::FontPlatformData::hash):
     220        (WebCore::FontPlatformData::operator==):
     221        * platform/win/FontPlatformDataWin.cpp:
     222        (WebCore::FontPlatformData::FontPlatformData):
     223        * platform/win/PopupMenuWin.cpp:
     224        (WebCore::PopupMenu::paint):
     225        Changes to platform to support rendering of custom fonts.  Too large to go into, but for ports, the relevant object to implement is
     226        FontCustomPlatformData (to get the data loaded into your native font format), and then you have to patch your other font objects to know
     227        how to use the font.
     228
     229        * rendering/RenderListBox.cpp:
     230        (WebCore::RenderListBox::updateFromElement):
     231        (WebCore::RenderListBox::paintItemForeground):
     232        * rendering/RenderMenuList.cpp:
     233        (WebCore::RenderMenuList::fontSelector):
     234        * rendering/RenderMenuList.h:
     235        * rendering/RenderTextControl.cpp:
     236        (WebCore::RenderTextControl::fontSelector):
     237        * rendering/RenderTextControl.h:
     238        * rendering/RenderThemeMac.mm:
     239        (WebCore::RenderThemeMac::setFontFromControlSize):
     240        * rendering/RenderThemeSafari.cpp:
     241        (WebCore::RenderThemeSafari::setFontFromControlSize):
     242        Patches for update now taking a font selector argument.
     243   
    12442007-10-03  Rob Buis  <buis@kde.org>
    2245
  • branches/feature-branch/WebCore/WebCore.base.exp

    r25906 r26027  
    347347__ZN7WebCore4FontD1Ev
    348348__ZN7WebCore4FontaSERKS0_
     349__ZN7WebCore16FontPlatformDataC1EP6NSFontbb
     350__ZN7WebCore16FontPlatformDataD1Ev
    349351__ZN7WebCore4KURL13decode_stringERKNS_16DeprecatedStringE
    350352__ZN7WebCore4KURLC1EP5NSURL
     
    705707_wkGetATSStyleGroup
    706708_wkGetCGFontFromNSFont
    707 _wkGetDefaultGlyphForChar
    708709_wkGetExtensionsForMIMEType
    709710_wkGetFontInLanguageForCharacter
  • branches/feature-branch/WebCore/WebCore.xcodeproj/project.pbxproj

    r25957 r26027  
    32923292                BC5A86B50C3367E800EEA649 /* JSDOMSelection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5A86B30C3367E800EEA649 /* JSDOMSelection.cpp */; };
    32933293                BC5A86B60C3367E800EEA649 /* JSDOMSelection.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5A86B40C3367E800EEA649 /* JSDOMSelection.h */; };
     3294                BC64B4B90CB428C7005F2B62 /* FontSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = BC64B4B80CB428C7005F2B62 /* FontSelector.h */; };
     3295                BC64B4BD0CB42929005F2B62 /* FontCustomPlatformData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC64B4BA0CB42929005F2B62 /* FontCustomPlatformData.cpp */; };
     3296                BC64B4BE0CB42929005F2B62 /* FontCustomPlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = BC64B4BB0CB42929005F2B62 /* FontCustomPlatformData.h */; };
     3297                BC64B4BF0CB42929005F2B62 /* FontPlatformDataMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC64B4BC0CB42929005F2B62 /* FontPlatformDataMac.mm */; };
     3298                BC64B4CB0CB4295D005F2B62 /* CachedFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC64B4C90CB4295D005F2B62 /* CachedFont.cpp */; };
     3299                BC64B4CC0CB4295D005F2B62 /* CachedFont.h in Headers */ = {isa = PBXBuildFile; fileRef = BC64B4CA0CB4295D005F2B62 /* CachedFont.h */; };
     3300                BC64B4D50CB4298A005F2B62 /* CSSFontFace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC64B4CD0CB4298A005F2B62 /* CSSFontFace.cpp */; };
     3301                BC64B4D60CB4298A005F2B62 /* CSSFontFace.h in Headers */ = {isa = PBXBuildFile; fileRef = BC64B4CE0CB4298A005F2B62 /* CSSFontFace.h */; };
     3302                BC64B4D70CB4298A005F2B62 /* CSSFontFaceSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC64B4CF0CB4298A005F2B62 /* CSSFontFaceSource.cpp */; };
     3303                BC64B4D80CB4298A005F2B62 /* CSSFontFaceSource.h in Headers */ = {isa = PBXBuildFile; fileRef = BC64B4D00CB4298A005F2B62 /* CSSFontFaceSource.h */; };
     3304                BC64B4D90CB4298A005F2B62 /* CSSFontFaceSrcValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC64B4D10CB4298A005F2B62 /* CSSFontFaceSrcValue.cpp */; };
     3305                BC64B4DA0CB4298A005F2B62 /* CSSFontFaceSrcValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC64B4D20CB4298A005F2B62 /* CSSFontFaceSrcValue.h */; };
     3306                BC64B4DB0CB4298A005F2B62 /* CSSFontSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC64B4D30CB4298A005F2B62 /* CSSFontSelector.cpp */; };
     3307                BC64B4DC0CB4298A005F2B62 /* CSSFontSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = BC64B4D40CB4298A005F2B62 /* CSSFontSelector.h */; };
    32943308                BC6D44BE0C07EFB60072D2C9 /* JSHTMLEmbedElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6D44BD0C07EFB60072D2C9 /* JSHTMLEmbedElementCustom.cpp */; };
    32953309                BC6D44EC0C07F2ED0072D2C9 /* JSHTMLEmbedElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6D44EA0C07F2ED0072D2C9 /* JSHTMLEmbedElement.cpp */; };
     
    71117125                BC5A86B40C3367E800EEA649 /* JSDOMSelection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSDOMSelection.h; sourceTree = "<group>"; };
    71127126                BC5EC1760A507E3E006007F5 /* view-source.css */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "view-source.css"; sourceTree = "<group>"; };
     7127                BC64B4B80CB428C7005F2B62 /* FontSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSelector.h; sourceTree = "<group>"; };
     7128                BC64B4BA0CB42929005F2B62 /* FontCustomPlatformData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCustomPlatformData.cpp; sourceTree = "<group>"; };
     7129                BC64B4BB0CB42929005F2B62 /* FontCustomPlatformData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontCustomPlatformData.h; sourceTree = "<group>"; };
     7130                BC64B4BC0CB42929005F2B62 /* FontPlatformDataMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FontPlatformDataMac.mm; sourceTree = "<group>"; };
     7131                BC64B4C90CB4295D005F2B62 /* CachedFont.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedFont.cpp; sourceTree = "<group>"; };
     7132                BC64B4CA0CB4295D005F2B62 /* CachedFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFont.h; sourceTree = "<group>"; };
     7133                BC64B4CD0CB4298A005F2B62 /* CSSFontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontFace.cpp; sourceTree = "<group>"; };
     7134                BC64B4CE0CB4298A005F2B62 /* CSSFontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFace.h; sourceTree = "<group>"; };
     7135                BC64B4CF0CB4298A005F2B62 /* CSSFontFaceSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontFaceSource.cpp; sourceTree = "<group>"; };
     7136                BC64B4D00CB4298A005F2B62 /* CSSFontFaceSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFaceSource.h; sourceTree = "<group>"; };
     7137                BC64B4D10CB4298A005F2B62 /* CSSFontFaceSrcValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontFaceSrcValue.cpp; sourceTree = "<group>"; };
     7138                BC64B4D20CB4298A005F2B62 /* CSSFontFaceSrcValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFaceSrcValue.h; sourceTree = "<group>"; };
     7139                BC64B4D30CB4298A005F2B62 /* CSSFontSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontSelector.cpp; sourceTree = "<group>"; };
     7140                BC64B4D40CB4298A005F2B62 /* CSSFontSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontSelector.h; sourceTree = "<group>"; };
    71137141                BC6D44BD0C07EFB60072D2C9 /* JSHTMLEmbedElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLEmbedElementCustom.cpp; sourceTree = "<group>"; };
    71147142                BC6D44EA0C07F2ED0072D2C9 /* JSHTMLEmbedElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLEmbedElement.cpp; sourceTree = "<group>"; };
     
    81778205                        isa = PBXGroup;
    81788206                        children = (
     8207                                BC64B4BA0CB42929005F2B62 /* FontCustomPlatformData.cpp */,
     8208                                BC64B4BB0CB42929005F2B62 /* FontCustomPlatformData.h */,
     8209                                BC64B4BC0CB42929005F2B62 /* FontPlatformDataMac.mm */,
    81798210                                51E1ECAD0C91C54600DC255B /* AutodrainedPool.mm */,
    81808211                                65A640F00533BB1F0085E777 /* BlockExceptions.h */,
     
    1068810719                                BCB16C000979C3BD00467741 /* CachedCSSStyleSheet.cpp */,
    1068910720                                BCB16C010979C3BD00467741 /* CachedCSSStyleSheet.h */,
     10721                                BC64B4C90CB4295D005F2B62 /* CachedFont.cpp */,
     10722                                BC64B4CA0CB4295D005F2B62 /* CachedFont.h */,
    1069010723                                BCB16C020979C3BD00467741 /* CachedImage.cpp */,
    1069110724                                BCB16C030979C3BD00467741 /* CachedImage.h */,
     
    1081010843                                BCC47E2409A3D6F100ADB771 /* FontFamily.cpp */,
    1081110844                                BCC47E2509A3D6F100ADB771 /* FontFamily.h */,
     10845                                BC64B4B80CB428C7005F2B62 /* FontSelector.h */,
    1081210846                                BCC71A120A0FF94D0014EE6E /* GlyphBuffer.h */,
    1081310847                                BC6DB4730A1A90FB00E5CD14 /* GlyphPageTreeNode.cpp */,
     
    1096611000                        isa = PBXGroup;
    1096711001                        children = (
     11002                                BC64B4CD0CB4298A005F2B62 /* CSSFontFace.cpp */,
     11003                                BC64B4CE0CB4298A005F2B62 /* CSSFontFace.h */,
     11004                                BC64B4CF0CB4298A005F2B62 /* CSSFontFaceSource.cpp */,
     11005                                BC64B4D00CB4298A005F2B62 /* CSSFontFaceSource.h */,
     11006                                BC64B4D10CB4298A005F2B62 /* CSSFontFaceSrcValue.cpp */,
     11007                                BC64B4D20CB4298A005F2B62 /* CSSFontFaceSrcValue.h */,
     11008                                BC64B4D30CB4298A005F2B62 /* CSSFontSelector.cpp */,
     11009                                BC64B4D40CB4298A005F2B62 /* CSSFontSelector.h */,
    1096811010                                A80E6CDA0A1989CA007FB8C5 /* Counter.h */,
    1096911011                                930705C709E0C95F00B17FE4 /* Counter.idl */,
     
    1316513207                                A8E545C00CA9D1C20097D09B /* DOMSVGDocument.h in Headers */,
    1316613208                                A8E545C10CA9D1C20097D09B /* DOMSVGDescElementInternal.h in Headers */,
     13209                                BC64B4B90CB428C7005F2B62 /* FontSelector.h in Headers */,
     13210                                BC64B4BE0CB42929005F2B62 /* FontCustomPlatformData.h in Headers */,
     13211                                BC64B4CC0CB4295D005F2B62 /* CachedFont.h in Headers */,
     13212                                BC64B4D60CB4298A005F2B62 /* CSSFontFace.h in Headers */,
     13213                                BC64B4D80CB4298A005F2B62 /* CSSFontFaceSource.h in Headers */,
     13214                                BC64B4DA0CB4298A005F2B62 /* CSSFontFaceSrcValue.h in Headers */,
     13215                                BC64B4DC0CB4298A005F2B62 /* CSSFontSelector.h in Headers */,
    1316713216                        );
    1316813217                        runOnlyForDeploymentPostprocessing = 0;
     
    1463914688                                AA4038900C4C0D8B00DB56DC /* SVGViewSpec.cpp in Sources */,
    1464014689                                B2CCEC470C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp in Sources */,
     14690                                BC64B4BD0CB42929005F2B62 /* FontCustomPlatformData.cpp in Sources */,
     14691                                BC64B4BF0CB42929005F2B62 /* FontPlatformDataMac.mm in Sources */,
     14692                                BC64B4CB0CB4295D005F2B62 /* CachedFont.cpp in Sources */,
     14693                                BC64B4D50CB4298A005F2B62 /* CSSFontFace.cpp in Sources */,
     14694                                BC64B4D70CB4298A005F2B62 /* CSSFontFaceSource.cpp in Sources */,
     14695                                BC64B4D90CB4298A005F2B62 /* CSSFontFaceSrcValue.cpp in Sources */,
     14696                                BC64B4DB0CB4298A005F2B62 /* CSSFontSelector.cpp in Sources */,
    1464114697                        );
    1464214698                        runOnlyForDeploymentPostprocessing = 0;
  • branches/feature-branch/WebCore/css/CSSComputedStyleDeclaration.cpp

    r25754 r26027  
    16251625        case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
    16261626        case CSS_PROP_SCROLLBAR_TRACK_COLOR:
     1627        case CSS_PROP_SRC: // Only used in @font-face rules.
    16271628        case CSS_PROP_SIZE:
    16281629        case CSS_PROP_TEXT_LINE_THROUGH:
  • branches/feature-branch/WebCore/css/CSSFontFaceRule.cpp

    r25754 r26027  
    3838}
    3939
     40void CSSFontFaceRule::setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style)
     41{
     42    m_style = style;
     43}
     44
    4045String CSSFontFaceRule::cssText() const
    4146{
    42     // FIXME: Implement!
    43     return String();
     47    String result("@font-face");
     48    result += " { ";
     49    result += m_style->cssText();
     50    result += "}";
     51    return result;
    4452}
    4553
  • branches/feature-branch/WebCore/css/CSSFontFaceRule.h

    r25754 r26027  
    2626
    2727#include "CSSRule.h"
     28#include <wtf/PassRefPtr.h>
    2829#include <wtf/RefPtr.h>
    2930
     
    4647    virtual String cssText() const;
    4748
     49    void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration>);
     50
    4851protected:
    4952    RefPtr<CSSMutableStyleDeclaration> m_style;
  • branches/feature-branch/WebCore/css/CSSGrammar.y

    r26015 r26027  
    552552  : ':' IDENT
    553553  ;
    554 
    555 font_face
    556   : FONT_FACE_SYM maybe_space
    557     '{' maybe_space declaration [ ';' maybe_space declaration ]* '}' maybe_space
    558   ;
    559554*/
    560555
     
    569564
    570565font_face:
    571     FONT_FACE_SYM error invalid_block {
     566    FONT_FACE_SYM maybe_space
     567    '{' maybe_space declaration_list '}'  maybe_space {
     568        $$ = static_cast<CSSParser*>(parser)->createFontFaceRule();
     569    }
     570    | FONT_FACE_SYM error invalid_block {
    572571      $$ = 0;
    573572    }
    574   | FONT_FACE_SYM error ';' {
     573    | FONT_FACE_SYM error ';' {
    575574      $$ = 0;
    576575    }
  • branches/feature-branch/WebCore/css/CSSParser.cpp

    r25996 r26027  
    3030#include "CSSHelper.h"
    3131#include "CSSImageValue.h"
     32#include "CSSFontFaceRule.h"
     33#include "CSSFontFaceSrcValue.h"
    3234#include "CSSImportRule.h"
    3335#include "CSSInheritedValue.h"
     
    10631065            valid_primitive = true;
    10641066        break;
     1067
     1068    case CSS_PROP_SRC:  // Only used within @font-face, so cannot use inherit | initial or be !important.  This is a list of urls or local references.
     1069        return parseFontFaceSrc();
    10651070
    10661071    /* CSS3 properties */
     
    24622467}
    24632468
     2469bool CSSParser::parseFontFaceSrc()
     2470{
     2471    CSSValueList* values = new CSSValueList();
     2472    Value* val;
     2473    bool expectComma = false;
     2474    bool allowFormat = false;
     2475    bool failed = false;
     2476    CSSFontFaceSrcValue* parsedValue = 0;
     2477    CSSFontFaceSrcValue* uriValue = 0;
     2478    while ((val = valueList->current())) {
     2479        parsedValue = 0;
     2480        if (val->unit == CSSPrimitiveValue::CSS_URI && !expectComma) {
     2481            String value = parseURL(domString(val->string));
     2482            parsedValue = new CSSFontFaceSrcValue(String(KURL(styleElement->baseURL().deprecatedString(), value.deprecatedString()).url()), false);
     2483            uriValue = parsedValue;
     2484            allowFormat = true;
     2485        } else if (val->unit == Value::Function) {
     2486            // There are two allowed functions: local() and format().             
     2487            String fname = domString(val->function->name).lower();
     2488            ValueList* args = val->function->args;
     2489            if (args && args->size() == 1) {
     2490                if (fname == "local(" && !expectComma) {
     2491                    // Parse it.
     2492                    expectComma = true;
     2493                    allowFormat = false;
     2494                    Value* a = args->current();
     2495                    uriValue = 0;
     2496                    parsedValue = new CSSFontFaceSrcValue(domString(a->string), true);
     2497                } else if (fname == "format(" && allowFormat && uriValue) {
     2498                    allowFormat = false;
     2499                    uriValue->setFormat(domString(args->current()->string));
     2500                    uriValue = 0;
     2501                    valueList->next();
     2502                    continue;
     2503                }
     2504            }
     2505        } else if (val->unit == Value::Operator && val->iValue == ',' && expectComma) {
     2506            expectComma = false;
     2507            allowFormat = false;
     2508            uriValue = 0;
     2509            valueList->next();
     2510            continue;
     2511        }
     2512   
     2513        if (parsedValue)
     2514            values->append(parsedValue);
     2515        else {
     2516            failed = true;
     2517            break;
     2518        }
     2519        valueList->next();
     2520    }
     2521   
     2522    if (values->length() && !failed) {
     2523        addProperty(CSS_PROP_SRC, values, important);
     2524        valueList->next();
     2525        return true;
     2526    }
     2527   
     2528    delete values;
     2529    return false;
     2530}
     2531
    24642532bool CSSParser::parseColor(const String &name, RGBA32& rgb, bool strict)
    24652533{
     
    33253393}
    33263394
     3395CSSRule* CSSParser::createFontFaceRule()
     3396{
     3397    CSSFontFaceRule* rule = new CSSFontFaceRule(styleElement);
     3398    m_parsedStyleObjects.append(rule);
     3399    rule->setDeclaration(new CSSMutableStyleDeclaration(rule, parsedProperties, numParsedProperties));
     3400    clearProperties();
     3401    return rule;
     3402}
     3403
    33273404DeprecatedString deprecatedString(const ParseString& ps)
    33283405{
  • branches/feature-branch/WebCore/css/CSSParser.h

    r25885 r26027  
    164164        static bool parseColor(const String&, RGBA32& rgb, bool strict);
    165165
     166        bool parseFontFaceSrc();
     167
    166168#if ENABLE(SVG)
    167169        bool parseSVGValue(int propId, bool important);
     
    194196        CSSRuleList* createRuleList();
    195197        CSSRule* createStyleRule(CSSSelector*);
     198        CSSRule* createFontFaceRule();
    196199
    197200        MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, ValueList*);
  • branches/feature-branch/WebCore/css/CSSPropertyNames.in

    r21026 r26027  
    107107scrollbar-track-color
    108108size
     109src
    109110table-layout
    110111text-align
  • branches/feature-branch/WebCore/css/CSSStyleSelector.cpp

    r25939 r26027  
    2828#include "CSSBorderImageValue.h"
    2929#include "CSSCursorImageValue.h"
     30#include "CSSFontFace.h"
     31#include "CSSFontFaceSource.h"
     32#include "CSSFontFaceRule.h"
    3033#include "CSSImageValue.h"
    3134#include "CSSImportRule.h"
     
    183186    typedef HashMap<AtomicStringImpl*, CSSRuleDataList*> AtomRuleMap;
    184187   
    185     void addRulesFromSheet(CSSStyleSheet* sheet, MediaQueryEvaluator* medium);
     188    void addRulesFromSheet(CSSStyleSheet*, MediaQueryEvaluator*, CSSStyleSelector* = 0);
    186189   
    187190    void addRule(CSSStyleRule* rule, CSSSelector* sel);
     
    199202    AtomRuleMap m_tagRules;
    200203    CSSRuleDataList* m_universalRules;
    201    
    202204    unsigned m_ruleCount;
    203205};
     
    260262
    261263        m_userStyle = new CSSRuleSet();
    262         m_userStyle->addRulesFromSheet(m_userSheet.get(), m_medium);
     264        m_userStyle->addRulesFromSheet(m_userSheet.get(), m_medium, this);
    263265    }
    264266
     
    269271    for (; it.current(); ++it)
    270272        if (it.current()->isCSSStyleSheet() && !it.current()->disabled())
    271             m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(it.current()), m_medium);
    272 
    273 }
    274 
    275 CSSStyleSelector::CSSStyleSelector(CSSStyleSheet *sheet)
    276 {
    277     init();
    278 
    279     if (!defaultStyle)
    280         loadDefaultStyle();
    281     FrameView *view = sheet->doc()->view();
    282 
    283     if (view)
    284         m_medium = new MediaQueryEvaluator(view->mediaType());
    285     else
    286         m_medium = new MediaQueryEvaluator("all");
    287 
    288     Element* root = sheet->doc()->documentElement();
    289     if (root)
    290         m_rootDefaultStyle = styleForElement(root, 0, false, true);
    291 
    292     if (m_rootDefaultStyle && view) {
    293         delete m_medium;
    294         m_medium = new MediaQueryEvaluator(view->mediaType(), view->frame()->page(), m_rootDefaultStyle);
    295     }
    296 
    297     m_authorStyle = new CSSRuleSet();
    298     m_authorStyle->addRulesFromSheet(sheet, m_medium);
     273            m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(it.current()), m_medium, this);
     274
     275    // Just delete our font selector if we end up with nothing but invalid @font-face rules.
     276    if (m_fontSelector && m_fontSelector->isEmpty())
     277        m_fontSelector = 0;
    299278}
    300279
     
    791770            styleNotYetAvailable->ref();
    792771            styleNotYetAvailable->setDisplay(NONE);
    793             styleNotYetAvailable->font().update();
     772            styleNotYetAvailable->font().update(m_fontSelector);
    794773        }
    795774        styleNotYetAvailable->ref();
     
    11721151    checkForTextSizeAdjust();
    11731152    checkForGenericFamilyChange(style, parentStyle);
    1174     style->font().update();
     1153    style->font().update(m_fontSelector);
    11751154    fontDirty = false;
    11761155}
     
    16861665}
    16871666
    1688 void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet,  MediaQueryEvaluator* medium)
     1667void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet,  MediaQueryEvaluator* medium, CSSStyleSelector* styleSelector)
    16891668{
    16901669    if (!sheet || !sheet->isCSSStyleSheet())
     
    17081687            CSSImportRule* import = static_cast<CSSImportRule*>(item);
    17091688            if (!import->media() || medium->eval(import->media()))
    1710                 addRulesFromSheet(import->styleSheet(), medium);
     1689                addRulesFromSheet(import->styleSheet(), medium, styleSelector);
    17111690        }
    17121691        else if(item->isMediaRule()) {
     
    17231702                        for (CSSSelector* s = rule->selector(); s; s = s->next())
    17241703                            addRule(rule, s);
    1725                        
     1704                    } else if (item->isFontFaceRule() && styleSelector) {
     1705                        // Add this font face to our set.
     1706                        const CSSFontFaceRule* fontFaceRule = static_cast<CSSFontFaceRule*>(item);
     1707                        styleSelector->ensureFontSelector()->addFontFaceRule(fontFaceRule);
    17261708                    }
    17271709                }   // for rules
    17281710            }   // if rules
     1711        } else if (item->isFontFaceRule() && styleSelector) {
     1712            // Add this font face to our set.
     1713            const CSSFontFaceRule* fontFaceRule = static_cast<CSSFontFaceRule*>(item);
     1714            styleSelector->ensureFontSelector()->addFontFaceRule(fontFaceRule);
    17291715        }
    17301716    }
     
    33433329                        break;
    33443330                    case CSS_VAL_SERIF:
    3345                         face = settings->serifFontFamily();
     3331                        face = m_fontSelector ? "-webkit-serif" : settings->serifFontFamily();
    33463332                        fontDescription.setGenericFamily(FontDescription::SerifFamily);
    33473333                        break;
    33483334                    case CSS_VAL_SANS_SERIF:
    3349                         face = settings->sansSerifFontFamily();
     3335                        face = m_fontSelector ? "-webkit-sans-serif" : settings->sansSerifFontFamily();
    33503336                        fontDescription.setGenericFamily(FontDescription::SansSerifFamily);
    33513337                        break;
    33523338                    case CSS_VAL_CURSIVE:
    3353                         face = settings->cursiveFontFamily();
     3339                        face = m_fontSelector ? "-webkit-cursive" : settings->cursiveFontFamily();
    33543340                        fontDescription.setGenericFamily(FontDescription::CursiveFamily);
    33553341                        break;
    33563342                    case CSS_VAL_FANTASY:
    3357                         face = settings->fantasyFontFamily();
     3343                        face = m_fontSelector ? "-webkit-fantasy" : settings->fantasyFontFamily();
    33583344                        fontDescription.setGenericFamily(FontDescription::FantasyFamily);
    33593345                        break;
    33603346                    case CSS_VAL_MONOSPACE:
    3361                         face = settings->fixedFontFamily();
     3347                        face = m_fontSelector ? "-webkit-monospace" : settings->fixedFontFamily();
    33623348                        fontDescription.setGenericFamily(FontDescription::MonospaceFamily);
    33633349                        break;
     
    35793565
    35803566            m_lineHeightValue = font->lineHeight.get();
     3567
    35813568            applyProperty(CSS_PROP_FONT_FAMILY, font->family.get());
    35823569        }
     
    38493836                return;
    38503837        }
    3851         return;       
     3838        return;
     3839    case CSS_PROP_SRC: // Only used in @font-face rules.
     3840        return;
    38523841    case CSS_PROP__WEBKIT_BOX_DIRECTION:
    38533842        HANDLE_INHERIT_AND_INITIAL(boxDirection, BoxDirection)
     
    49204909}
    49214910
     4911CSSFontSelector* CSSStyleSelector::ensureFontSelector()
     4912{
     4913    if (!m_fontSelector.get())
     4914        m_fontSelector = new CSSFontSelector(m_document);
     4915    return m_fontSelector.get();
     4916}
     4917
    49224918} // namespace WebCore
  • branches/feature-branch/WebCore/css/CSSStyleSelector.h

    r25754 r26027  
    2525#define CSSStyleSelector_h
    2626
     27#include "CSSFontSelector.h"
    2728#include "DeprecatedString.h"
    2829#include "RenderStyle.h"
    2930#include <wtf/HashSet.h>
    3031#include <wtf/Vector.h>
     32#include <wtf/RefPtr.h>
    3133
    3234namespace WebCore {
     
    3537class CSSPrimitiveValue;
    3638class CSSProperty;
     39class CSSFontFace;
     40class CSSFontFaceRule;
    3741class CSSRuleData;
    3842class CSSRuleDataList;
     
    7983    {
    8084    public:
    81         /**
    82          * creates a new StyleSelector for a Document.
    83          * goes through all StyleSheets defined in the document and
    84          * creates a list of rules it needs to apply to objects
    85          */
    8685        CSSStyleSelector(Document*, const String& userStyleSheet, StyleSheetList *styleSheets, bool strictParsing);
    87         /**
    88          * same as above but for a single stylesheet.
    89          */
    90         CSSStyleSelector(CSSStyleSheet *sheet);
    9186        ~CSSStyleSelector();
    9287
     
    133128        bool hasSelectorForAttribute(const AtomicString &attrname);
    134129 
     130        CSSFontSelector* fontSelector() { return m_fontSelector.get(); }
     131        CSSFontSelector* ensureFontSelector();
     132
    135133    protected:
    136134
     
    227225        bool fontDirty;
    228226        bool isXMLDoc;
    229 
    230         HashSet<AtomicStringImpl *> m_selectorAttrs;
     227       
     228        RefPtr<CSSFontSelector> m_fontSelector;
     229
     230        HashSet<AtomicStringImpl*> m_selectorAttrs;
    231231       
    232232        void applyProperty(int id, CSSValue *value);
     
    234234        void applySVGProperty(int id, CSSValue *value);
    235235#endif
     236
     237        friend class CSSRuleSet;
    236238    };
    237239
  • branches/feature-branch/WebCore/dom/Document.cpp

    r25813 r26027  
    10241024
    10251025        _style->setFontDescription(fontDescription);
    1026         _style->font().update();
     1026        _style->font().update(0);
    10271027        if (inCompatMode())
    10281028            _style->setHtmlHacks(true); // enable html specific rendering tricks
  • branches/feature-branch/WebCore/loader/Cache.cpp

    r25769 r26027  
    2525
    2626#include "CachedCSSStyleSheet.h"
     27#include "CachedFont.h"
    2728#include "CachedImage.h"
    2829#include "CachedScript.h"
     
    7172    case CachedResource::Script:
    7273        return new CachedScript(docLoader, url.url(), *charset);
     74    case CachedResource::FontResource:
     75        return new CachedFont(docLoader, url.url());
    7376#if ENABLE(XSLT)
    7477    case CachedResource::XSLStyleSheet:
     
    557560                break;
    558561#endif
     562            case CachedResource::FontResource:
     563                stats.fonts.count++;
     564                stats.fonts.size += o->size();
     565                stats.fonts.liveSize += o->referenced() ? o->size() : 0;
     566                stats.fonts.decodedSize += o->decodedSize();
     567                break;
    559568#if ENABLE(XBL)
    560569            case CachedResource::XBL:
  • branches/feature-branch/WebCore/loader/Cache.h

    r25754 r26027  
    8787        TypeStatistic xblDocs;
    8888#endif
     89        TypeStatistic fonts;
    8990    };
    9091
  • branches/feature-branch/WebCore/loader/CachedResource.h

    r25754 r26027  
    4848        ImageResource,
    4949        CSSStyleSheet,
    50         Script
     50        Script,
     51        FontResource
    5152#if ENABLE(XSLT)
    5253        , XSLStyleSheet
  • branches/feature-branch/WebCore/loader/CachedResourceClient.h

    r25754 r26027  
    3636namespace WebCore {
    3737
     38    class CachedFont;
    3839    class CachedResource;
    3940    class CachedImage;
     
    6768        virtual void setXSLStyleSheet(const String& /*URL*/, const String& /*sheet*/) { }
    6869
     70        virtual void fontLoaded(CachedFont*) {};
     71
    6972#if ENABLE(XBL)
    7073        virtual void setXBLDocument(const String& /*URL*/, XBL::XBLDocument*) { }
  • branches/feature-branch/WebCore/loader/DocLoader.cpp

    r25754 r26027  
    3131#include "Cache.h"
    3232#include "CachedCSSStyleSheet.h"
     33#include "CachedFont.h"
    3334#include "CachedImage.h"
    3435#include "CachedScript.h"
     
    9495}
    9596
     97CachedFont* DocLoader::requestFont(const String& url)
     98{
     99    return static_cast<CachedFont*>(requestResource(CachedResource::FontResource, url));
     100}
     101
    96102CachedCSSStyleSheet* DocLoader::requestCSSStyleSheet(const String& url, const String& charset, bool isUserStyleSheet)
    97103{
  • branches/feature-branch/WebCore/loader/DocLoader.h

    r25754 r26027  
    3535
    3636class CachedCSSStyleSheet;
     37class CachedFont;
    3738class CachedImage;
    3839class CachedScript;
     
    5758    CachedCSSStyleSheet* requestUserCSSStyleSheet(const String& url, const String& charset);
    5859    CachedScript* requestScript(const String& url, const String& charset);
     60    CachedFont* requestFont(const String& url);
    5961
    6062#if ENABLE(XSLT)
  • branches/feature-branch/WebCore/platform/Font.cpp

    r25887 r26027  
    334334}
    335335
     336bool Font::operator==(const Font& other) const
     337{
     338    // Our FontData don't have to be checked, since checking the font description will be fine.
     339    // FIXME: This does not work if the font was made with the FontPlatformData constructor.
     340    if ((m_fontList && m_fontList->loadingCustomFonts()) ||
     341        (other.m_fontList && other.m_fontList->loadingCustomFonts()))
     342        return false;
     343   
     344    FontSelector* first = m_fontList ? m_fontList->fontSelector() : 0;
     345    FontSelector* second = other.m_fontList ? other.m_fontList->fontSelector() : 0;
     346   
     347    return first == second
     348           && m_fontDescription == other.m_fontDescription
     349           && m_letterSpacing == other.m_letterSpacing
     350           && m_wordSpacing == other.m_wordSpacing;
     351}
     352   
    336353// FIXME: It is unfortunate that this function needs to be passed the original cluster.
    337354// It is only required for the platform's FontCache::getFontDataForCharacters(), and it means
     
    464481}
    465482
    466 void Font::update() const
     483void Font::update(PassRefPtr<FontSelector> fontSelector) const
    467484{
    468485    // FIXME: It is pretty crazy that we are willing to just poke into a RefPtr, but it ends up
     
    472489    // and could eventually be rectified by using RefPtrs for Fonts themselves.
    473490    if (!m_fontList)
    474         m_fontList = new FontFallbackList;
    475     m_fontList->invalidate();
     491        m_fontList = new FontFallbackList();
     492    m_fontList->invalidate(fontSelector);
    476493    m_pageZero = 0;
    477494    m_pages.clear();
     
    651668void Font::drawText(GraphicsContext* context, const TextRun& run, const TextStyle& style, const FloatPoint& point, int from, int to) const
    652669{
     670    // Don't draw anything while we are using custom fonts that are in the process of loading.
     671    if (m_fontList && m_fontList->loadingCustomFonts())
     672        return;
     673   
    653674    to = (to == -1 ? run.length() : to);
    654675    if (canUseGlyphCache(run))
  • branches/feature-branch/WebCore/platform/Font.h

    r25887 r26027  
    55 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    66 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    7  * Copyright (C) 2003, 2006 Apple Computer, Inc.
     7 * Copyright (C) 2003, 2006, 2007 Apple Computer, Inc.
    88 *
    99 * This library is free software; you can redistribute it and/or
     
    4242class FontFallbackList;
    4343class FontPlatformData;
     44class FontSelector;
    4445class GlyphBuffer;
    4546class GlyphPageTreeNode;
     
    8384    Font& operator=(const Font&);
    8485
    85     bool operator==(const Font& other) const
    86     {
    87         // Our FontData doesn't have to be checked, since checking the font description will be fine.
    88         // FIXME: This does not work if the font was made with the FontPlatformData constructor.
    89         return m_fontDescription == other.m_fontDescription
    90             && m_letterSpacing == other.m_letterSpacing
    91             && m_wordSpacing == other.m_wordSpacing;
    92     }
    93 
     86    bool operator==(const Font& other) const;
    9487    bool operator!=(const Font& other) const {
    9588        return !(*this == other);
     
    10194    float size() const { return fontDescription().computedSize(); }
    10295   
    103     void update() const;
     96    void update(PassRefPtr<FontSelector>) const;
    10497
    10598    void drawText(GraphicsContext*, const TextRun&, const TextStyle&, const FloatPoint&, int from = 0, int to = -1) const;
  • branches/feature-branch/WebCore/platform/FontCache.cpp

    r20126 r26027  
    3333#include "FontFallbackList.h"
    3434#include "FontPlatformData.h"
     35#include "FontSelector.h"
    3536#include "StringHash.h"
    3637#include <wtf/HashMap.h>
     
    213214}
    214215
    215 const FontData* FontCache::getFontData(const Font& font, int& familyIndex)
     216const FontData* FontCache::getFontData(const Font& font, int& familyIndex, FontSelector* fontSelector)
    216217{
    217218    FontPlatformData* result = 0;
     
    224225    while (currFamily && !result) {
    225226        familyIndex++;
    226         if (currFamily->family().length())
     227        if (currFamily->family().length()) {
     228            if (fontSelector) {
     229                FontData* data = fontSelector->getFontData(font.fontDescription(), currFamily->family());
     230                if (data)
     231                    return data;
     232            }
    227233            result = getCachedFontPlatformData(font.fontDescription(), currFamily->family());
     234        }
    228235        currFamily = currFamily->next();
    229236    }
     
    241248        // We still don't have a result.  Hand back our last resort fallback font.  We only do the last resort fallback
    242249        // when trying to find the primary font.  Otherwise our fallback will rely on the actual characters used.
    243         result = getLastResortFallbackFont(font);
     250        result = getLastResortFallbackFont(font.fontDescription());
    244251
    245252    // Now that we have a result, we need to go from FontPlatformData -> FontData.
  • branches/feature-branch/WebCore/platform/FontCache.h

    r18874 r26027  
    4444class Font;
    4545class FontDescription;
     46class FontSelector;
    4647
    4748class FontCache {
    4849public:
    49     static const FontData* getFontData(const Font&, int& familyIndex);
     50    static const FontData* getFontData(const Font&, int& familyIndex, FontSelector*);
    5051   
    5152    // This method is implemented by the platform.
     
    5960#endif
    6061
    61 private:
     62    static bool fontExists(const FontDescription&, const AtomicString& family);
     63
    6264    static FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName = false);
    6365    static FontData* getCachedFontData(const FontPlatformData*);
     66    static FontPlatformData* getLastResortFallbackFont(const FontDescription&);
    6467   
    65     // These three methods are implemented by each platform.
     68private:
     69    // These methods are implemented by each platform.
    6670    static FontPlatformData* getSimilarFontPlatformData(const Font&);
    67     static FontPlatformData* getLastResortFallbackFont(const Font&);
    6871    static FontPlatformData* createFontPlatformData(const FontDescription&, const AtomicString& family);
    6972
  • branches/feature-branch/WebCore/platform/FontData.cpp

    r25215 r26027  
    3535namespace WebCore {
    3636
    37 FontData::FontData(const FontPlatformData& f)
     37FontData::FontData(const FontPlatformData& f, bool customFont, bool loading)
    3838    : m_font(f)
    3939    , m_treatAsFixedPitch(false)
     40    , m_isCustomFont(customFont)
     41    , m_isLoading(loading)
    4042    , m_smallCapsFontData(0)
    4143{   
     
    5355        return;
    5456    }
     57
    5558    // Nasty hack to determine if we should round or ceil space widths.
    5659    // If the font is monospace or fake monospace we ceil to ensure that
  • branches/feature-branch/WebCore/platform/FontData.h

    r25887 r26027  
    4343class FontDescription;
    4444class FontPlatformData;
     45class SharedBuffer;
    4546class WidthMap;
    4647
     
    4950class FontData : Noncopyable {
    5051public:
    51     FontData(const FontPlatformData&);
     52    FontData(const FontPlatformData&, bool customFont = false, bool loading = false);
    5253    ~FontData();
    5354
     
    7172    void determinePitch();
    7273    Pitch pitch() const { return m_treatAsFixedPitch ? FixedPitch : VariablePitch; }
     74
     75    bool isCustomFont() const { return m_isCustomFont; }
     76    bool isLoading() const { return m_isLoading; }
    7377
    7478    const GlyphData& missingGlyphData() const { return m_missingGlyphData; }
     
    98102    void platformInit();
    99103    void platformDestroy();
     104   
     105    void commonInit();
    100106
    101107public:
     
    108114
    109115    FontPlatformData m_font;
     116
    110117    mutable GlyphWidthMap m_glyphToWidthMap;
    111118
    112119    bool m_treatAsFixedPitch;
     120
     121    bool m_isCustomFont;  // Whether or not we are custom font loaded via @font-face
     122    bool m_isLoading; // Whether or not this custom font is still in the act of loading.
     123
    113124    Glyph m_spaceGlyph;
    114125    float m_spaceWidth;
  • branches/feature-branch/WebCore/platform/FontFallbackList.cpp

    r20495 r26027  
    3636
    3737FontFallbackList::FontFallbackList()
    38     : m_familyIndex(0), m_pitch(UnknownPitch)
     38: m_familyIndex(0)
     39, m_pitch(UnknownPitch)
     40, m_loadingCustomFonts(false)
     41, m_fontSelector(0)
    3942{
    4043}
    4144
    42 void FontFallbackList::invalidate()
     45void FontFallbackList::invalidate(PassRefPtr<FontSelector> fontSelector)
    4346{
    4447    m_fontList.clear();
    4548    m_familyIndex = 0;   
    4649    m_pitch = UnknownPitch;
     50    m_loadingCustomFonts = false;
     51    m_fontSelector = fontSelector;
    4752}
    4853
     
    6772    // in |m_familyIndex|, so that we never scan the same spot in the list twice.  getFontData will adjust our
    6873    // |m_familyIndex| as it scans for the right font to make.
    69     const FontData* result = FontCache::getFontData(*font, m_familyIndex);
    70     if (result)
     74    const FontData* result = FontCache::getFontData(*font, m_familyIndex, m_fontSelector.get());
     75    if (result) {
    7176        m_fontList.append(result);
     77        if (result->isLoading())
     78            m_loadingCustomFonts = true;
     79    }
    7280    return result;
    7381}
  • branches/feature-branch/WebCore/platform/FontFallbackList.h

    r25754 r26027  
    2727#include "FontData.h"
    2828#include "Shared.h"
     29#include "FontSelector.h"
    2930#include <wtf/Vector.h>
    3031
     
    3637class FontDescription;
    3738class FontPlatformData;
     39class FontSelector;
    3840
    3941const int cAllFamiliesScanned = -1;
     
    4345    FontFallbackList();
    4446
    45     void invalidate();
     47    void invalidate(PassRefPtr<FontSelector>);
    4648   
    4749    bool isFixedPitch(const Font* f) const { if (m_pitch == UnknownPitch) determinePitch(f); return m_pitch == FixedPitch; };
    4850    void determinePitch(const Font*) const;
     51
     52    bool loadingCustomFonts() const { return m_loadingCustomFonts; }
     53
     54    FontSelector* fontSelector() const { return m_fontSelector.get(); }
    4955
    5056private:
     
    5864    mutable int m_familyIndex;
    5965    mutable Pitch m_pitch;
    60    
     66    mutable bool m_loadingCustomFonts;
     67    RefPtr<FontSelector> m_fontSelector;
     68
    6169    friend class Font;
    6270};
  • branches/feature-branch/WebCore/platform/GlyphPageTreeNode.cpp

    r24740 r26027  
    3636namespace WebCore {
    3737
     38HashMap<int, GlyphPageTreeNode*>* GlyphPageTreeNode::roots = 0;
     39GlyphPageTreeNode* GlyphPageTreeNode::pageZeroRoot = 0;
     40
    3841GlyphPageTreeNode* GlyphPageTreeNode::getRoot(unsigned pageNumber)
    3942{
    40     static HashMap<int, GlyphPageTreeNode*> roots;
    41     static GlyphPageTreeNode* pageZeroRoot;
    42     GlyphPageTreeNode* node = pageNumber ? roots.get(pageNumber) : pageZeroRoot;
     43    static bool initialized;
     44    if (!initialized) {
     45        initialized = true;
     46        roots = new HashMap<int, GlyphPageTreeNode*>;
     47        pageZeroRoot = new GlyphPageTreeNode;
     48    }
     49
     50    GlyphPageTreeNode* node = pageNumber ? roots->get(pageNumber) : pageZeroRoot;
    4351    if (!node) {
    4452        node = new GlyphPageTreeNode;
     
    4755#endif
    4856        if (pageNumber)
    49             roots.set(pageNumber, node);
     57            roots->set(pageNumber, node);
    5058        else
    5159            pageZeroRoot = node;
    5260    }
    5361    return node;
     62}
     63
     64void GlyphPageTreeNode::pruneTreeCustomFontData(const FontData* fontData)
     65{
     66    // Enumerate all the roots and prune any tree that contains our custom font data.
     67    if (roots) {
     68        HashMap<int, GlyphPageTreeNode*>::iterator end = roots->end();
     69        for (HashMap<int, GlyphPageTreeNode*>::iterator it = roots->begin(); it != end; ++it)
     70            it->second->pruneCustomFontData(fontData);
     71    }
     72   
     73    if (pageZeroRoot)
     74        pageZeroRoot->pruneCustomFontData(fontData);
     75}
     76
     77GlyphPageTreeNode::~GlyphPageTreeNode()
     78{
     79    deleteAllValues(m_children);
     80    delete m_systemFallbackChild;
    5481}
    5582
     
    6491    // The parent's page will be 0 if we are level one or the parent's font data
    6592    // did not contain any glyphs for that page.
    66     GlyphPage* parentPage = m_parent->m_page;
     93    GlyphPage* parentPage = m_parent->page();
    6794
    6895    // NULL FontData means we're being asked for the system fallback font.
     
    120147            bool haveGlyphs = m_page->fill(buffer, bufferLength, fontData);
    121148
    122             if (!haveGlyphs) {
    123                 delete m_page;
     149            if (!haveGlyphs)
    124150                m_page = 0;
    125             }
    126151        } else if (parentPage && parentPage->owner() != m_parent) {
    127152            // The page we're overriding may not be owned by our parent node.
     
    169194                }
    170195
    171                 if (!newGlyphs) {
     196                if (!newGlyphs)
    172197                    // We didn't override anything, so our override is just the parent page.
    173                     delete m_page;
    174198                    m_page = parentPage;
    175                 }
    176199            }
    177200        }
     
    202225        child->m_parent = this;
    203226        child->m_level = m_level + 1;
     227        if (fontData && fontData->isCustomFont()) {
     228            for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent)
     229                curr->m_customFontCount++;
     230        }
     231
    204232#ifndef NDEBUG
    205233        child->m_pageNumber = m_pageNumber;
     
    216244}
    217245
    218 }
     246void GlyphPageTreeNode::pruneCustomFontData(const FontData* fontData)
     247{
     248    if (!fontData || !m_customFontCount)
     249        return;
     250       
     251    // Prune any branch that contains this FontData.
     252    GlyphPageTreeNode* node = m_children.get(fontData);
     253    if (node) {
     254        m_children.remove(fontData);
     255        unsigned fontCount = node->m_customFontCount + 1;
     256        delete node;
     257        for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent)
     258            curr->m_customFontCount -= fontCount;
     259    }
     260   
     261    // Check any branches that remain that still have custom fonts underneath them.
     262    if (!m_customFontCount)
     263        return;
     264    HashMap<const FontData*, GlyphPageTreeNode*>::iterator end = m_children.end();
     265    for (HashMap<const FontData*, GlyphPageTreeNode*>::iterator it = m_children.begin(); it != end; ++it)
     266        it->second->pruneCustomFontData(fontData);
     267}
     268
     269}
  • branches/feature-branch/WebCore/platform/GlyphPageTreeNode.h

    r21293 r26027  
    11/*
    2  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2007 Apple Computer, Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030#define GlyphPageTreeNode_h
    3131
     32#include "Shared.h"
    3233#include <wtf/unicode/Unicode.h>
    3334#include <wtf/Noncopyable.h>
     
    5657// although multiple nodes may reference it as their "page" if they are supposed
    5758// to be overriding the parent's node, but provide no additional information.
    58 struct GlyphPage {
     59struct GlyphPage : public Shared<GlyphPage> {
    5960    GlyphPage()
    6061        : m_owner(0)
     
    110111    GlyphPageTreeNode()
    111112        : m_parent(0)
    112         , m_page(0)
    113113        , m_level(0)
    114114        , m_isSystemFallback(false)
    115115        , m_systemFallbackChild(0)
     116        , m_customFontCount(0)
    116117#ifndef NDEBUG
    117118        , m_pageNumber(0)
     
    120121    }
    121122
     123    ~GlyphPageTreeNode();
     124
     125    static HashMap<int, GlyphPageTreeNode*>* roots;
     126    static GlyphPageTreeNode* pageZeroRoot;
     127
    122128    static GlyphPageTreeNode* getRootChild(const FontData* fontData, unsigned pageNumber)
    123129    {
     
    125131    }
    126132
     133    static void pruneTreeCustomFontData(const FontData*);
     134
     135    void pruneCustomFontData(const FontData*);
     136
    127137    GlyphPageTreeNode* parent() const { return m_parent; }
    128138    GlyphPageTreeNode* getChild(const FontData*, unsigned pageNumber);
    129139
    130140    // Returns a page of glyphs (or NULL if there are no glyphs in this page's character range).
    131     GlyphPage* page() const { return m_page; }
     141    GlyphPage* page() const { return m_page.get(); }
    132142
    133143    // Returns the level of this node. See class-level comment.
     
    142152
    143153    GlyphPageTreeNode* m_parent;
    144     GlyphPage* m_page;
     154    RefPtr<GlyphPage> m_page;
    145155    unsigned m_level;
    146156    bool m_isSystemFallback;
    147157    HashMap<const FontData*, GlyphPageTreeNode*> m_children;
    148158    GlyphPageTreeNode* m_systemFallbackChild;
     159    unsigned m_customFontCount;
     160
    149161#ifndef NDEBUG
    150162    unsigned m_pageNumber;
  • branches/feature-branch/WebCore/platform/PopupMenuClient.h

    r25754 r26027  
    2626class Color;
    2727class Document;
     28class FontSelector;
    2829class String;
    2930class RenderStyle;
     
    5152    virtual bool valueShouldChangeOnHotTrack() const = 0;
    5253    virtual void setTextFromItem(unsigned listIndex) = 0;
     54    virtual FontSelector* fontSelector() const = 0;
    5355};
    5456
  • branches/feature-branch/WebCore/platform/mac/FontCacheMac.mm

    r24835 r26027  
    142142
    143143    NSFontTraitMask traits = [manager traitsOfFont:nsFont];
    144     if (platformData.syntheticBold)
     144    if (platformData.m_syntheticBold)
    145145        traits |= NSBoldFontMask;
    146     if (platformData.syntheticOblique)
     146    if (platformData.m_syntheticOblique)
    147147        traits |= NSItalicFontMask;
    148148
     
    186186}
    187187
    188 FontPlatformData* FontCache::getLastResortFallbackFont(const Font& font)
     188FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
    189189{
    190190    static AtomicString timesStr("Times");
     
    193193    // FIXME: Would be even better to somehow get the user's default font here.  For now we'll pick
    194194    // the default that the user would get without changing any prefs.
    195     FontPlatformData* platformFont = getCachedFontPlatformData(font.fontDescription(), timesStr);
     195    FontPlatformData* platformFont = getCachedFontPlatformData(fontDescription, timesStr);
    196196    if (!platformFont)
    197197        // The Times fallback will almost always work, but in the highly unusual case where
     
    199199        // guaranteed to be there, according to Nathan Taylor. This is good enough
    200200        // to avoid a crash at least.
    201         platformFont = getCachedFontPlatformData(font.fontDescription(), lucidaGrandeStr);
     201        platformFont = getCachedFontPlatformData(fontDescription, lucidaGrandeStr);
    202202
    203203    return platformFont;
    204204}
    205205
    206 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
     206bool FontCache::fontExists(const FontDescription& fontDescription, const AtomicString& family)
    207207{
    208208    NSFontTraitMask traits = 0;
     
    214214   
    215215    NSFont* nsFont = [WebFontCache fontWithFamily:family traits:traits size:size];
     216    return nsFont != 0;
     217}
     218
     219FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
     220{
     221    NSFontTraitMask traits = 0;
     222    if (fontDescription.italic())
     223        traits |= NSItalicFontMask;
     224    if (fontDescription.bold())
     225        traits |= NSBoldFontMask;
     226    float size = fontDescription.computedPixelSize();
     227   
     228    NSFont* nsFont = [WebFontCache fontWithFamily:family traits:traits size:size];
    216229    if (!nsFont)
    217230        return 0;
     
    225238    // Use the correct font for print vs. screen.
    226239    result->setFont(fontDescription.usePrinterFont() ? [nsFont printerFont] : [nsFont screenFont]);
    227     result->syntheticBold = (traits & NSBoldFontMask) && !(actualTraits & NSBoldFontMask);
    228     result->syntheticOblique = (traits & NSItalicFontMask) && !(actualTraits & NSItalicFontMask);
     240    result->m_syntheticBold = (traits & NSBoldFontMask) && !(actualTraits & NSBoldFontMask);
     241    result->m_syntheticOblique = (traits & NSItalicFontMask) && !(actualTraits & NSItalicFontMask);
    229242    return result;
    230243}
  • branches/feature-branch/WebCore/platform/mac/FontDataMac.mm

    r25887 r26027  
    3636#import "FontCache.h"
    3737#import "FontDescription.h"
     38#import "SharedBuffer.h"
    3839#import "WebCoreSystemInterface.h"
    3940#import <ApplicationServices/ApplicationServices.h>
     
    5556bool initFontData(FontData* fontData)
    5657{
     58    if (!fontData->m_font.m_cgFont)
     59        return false;
     60
    5761    ATSUStyle fontStyle;
    5862    if (ATSUCreateStyle(&fontStyle) != noErr)
    5963        return false;
    6064   
    61     ATSUFontID fontId = wkGetNSFontATSUFontId(fontData->m_font.font());
     65    ATSUFontID fontId = fontData->m_font.m_atsuFontID;
    6266    if (!fontId) {
    6367        ATSUDisposeStyle(fontStyle);
     
    99103    m_checkedShapesArabic = false;
    100104    m_shapesArabic = false;
    101    
    102     m_syntheticBoldOffset = m_font.syntheticBold ? 1.0f : 0.f;
     105
     106    m_syntheticBoldOffset = m_font.m_syntheticBold ? 1.0f : 0.f;
    103107   
    104108    bool failedSetup = false;
     
    161165    int iDescent;
    162166    int iLineGap;
    163     wkGetFontMetrics(wkGetCGFontFromNSFont(m_font.font()), &iAscent, &iDescent, &iLineGap, &m_unitsPerEm);
    164     float pointSize = [m_font.font() pointSize];
     167    wkGetFontMetrics(m_font.m_cgFont, &iAscent, &iDescent, &iLineGap, &m_unitsPerEm);
     168    float pointSize = m_font.m_size;
    165169    float fAscent = scaleEmToUnits(iAscent, m_unitsPerEm) * pointSize;
    166170    float fDescent = -scaleEmToUnits(iDescent, m_unitsPerEm) * pointSize;
     
    215219{
    216220    if (!m_smallCapsFontData) {
    217         NS_DURING
     221        if (isCustomFont()) {
     222            FontPlatformData smallCapsFontData(m_font);
     223            smallCapsFontData.m_size = smallCapsFontData.m_size * smallCapsFontSizeMultiplier;
     224            m_smallCapsFontData = new FontData(smallCapsFontData, true, false);
     225        } else {
     226            NS_DURING
    218227            float size = [m_font.font() pointSize] * smallCapsFontSizeMultiplier;
    219228            FontPlatformData smallCapsFont([[NSFontManager sharedFontManager] convertFont:m_font.font() toSize:size]);
     
    227236                NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_font.font()];
    228237
    229                 if (m_font.syntheticBold)
     238                if (m_font.m_syntheticBold)
    230239                    fontTraits |= NSBoldFontMask;
    231                 if (m_font.syntheticOblique)
     240                if (m_font.m_syntheticOblique)
    232241                    fontTraits |= NSItalicFontMask;
    233242
    234243                NSFontTraitMask smallCapsFontTraits = [fontManager traitsOfFont:smallCapsFont.font()];
    235                 smallCapsFont.syntheticBold = (fontTraits & NSBoldFontMask) && !(smallCapsFontTraits & NSBoldFontMask);
    236                 smallCapsFont.syntheticOblique = (fontTraits & NSItalicFontMask) && !(smallCapsFontTraits & NSItalicFontMask);
     244                smallCapsFont.m_syntheticBold = (fontTraits & NSBoldFontMask) && !(smallCapsFontTraits & NSBoldFontMask);
     245                smallCapsFont.m_syntheticOblique = (fontTraits & NSItalicFontMask) && !(smallCapsFontTraits & NSItalicFontMask);
    237246
    238247                m_smallCapsFontData = FontCache::getCachedFontData(&smallCapsFont);
    239248            }
    240         NS_HANDLER
     249
     250            NS_HANDLER
    241251            NSLog(@"uncaught exception selecting font for small caps: %@", localException);
    242         NS_ENDHANDLER
     252            NS_ENDHANDLER
     253        }
    243254    }
    244255    return m_smallCapsFontData;
     
    278289float FontData::platformWidthForGlyph(Glyph glyph) const
    279290{
    280     NSFont *font = m_font.font();
    281     float pointSize = [font pointSize];
     291    NSFont* font = m_font.font();
     292    float pointSize = m_font.m_size;
    282293    CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
    283294    CGSize advance;
    284     if (!wkGetGlyphTransformedAdvances(wkGetCGFontFromNSFont(font), font, &m, &glyph, &advance)) {
     295    if (!wkGetGlyphTransformedAdvances(m_font.m_cgFont, font, &m, &glyph, &advance)) {
    285296        LOG_ERROR("Unable to cache glyph widths for %@ %f", [font displayName], pointSize);
    286297        advance.width = 0;
     
    295306    m_checkedShapesArabic = true;
    296307   
    297     ATSUFontID fontID = wkGetNSFontATSUFontId(m_font.font());
     308    ATSUFontID fontID = m_font.m_atsuFontID;
    298309    if (!fontID) {
    299310        LOG_ERROR("unable to get ATSUFontID for %@", m_font.font());
  • branches/feature-branch/WebCore/platform/mac/FontMac.mm

    r25754 r26027  
    116116       
    117117        CGAffineTransform transform = CGAffineTransformMakeScale(1, -1);
    118         if (fontData->m_font.syntheticOblique)
     118        if (fontData->m_font.m_syntheticOblique)
    119119            transform = CGAffineTransformConcat(transform, CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, 0, 0));
    120120        Fixed fontSize = FloatToFixed([fontData->m_font.font() pointSize]);
     
    625625    }
    626626   
    627     CGContextSetFont(cgContext, wkGetCGFontFromNSFont(drawFont));
    628 
    629     CGAffineTransform matrix;
    630     memcpy(&matrix, [drawFont matrix], sizeof(matrix));
     627    CGContextSetFont(cgContext, platformData.m_cgFont);
     628
     629    CGAffineTransform matrix = CGAffineTransformIdentity;
     630    if (drawFont)
     631        memcpy(&matrix, [drawFont matrix], sizeof(matrix));
    631632    matrix.b = -matrix.b;
    632633    matrix.d = -matrix.d;
    633     if (platformData.syntheticOblique)
     634    if (platformData.m_syntheticOblique)
    634635        matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, 0, 0));
    635636    CGContextSetTextMatrix(cgContext, matrix);
    636637
    637     wkSetCGFontRenderingMode(cgContext, drawFont);
    638     CGContextSetFontSize(cgContext, 1.0f);
    639 
     638    if (drawFont) {
     639        wkSetCGFontRenderingMode(cgContext, drawFont);
     640        CGContextSetFontSize(cgContext, 1.0f);
     641    } else
     642        CGContextSetFontSize(cgContext, platformData.m_size);
     643   
    640644    CGContextSetTextPosition(cgContext, point.x(), point.y());
    641645    CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
  • branches/feature-branch/WebCore/platform/mac/FontPlatformData.h

    r25754 r26027  
    3333#endif
    3434
     35typedef struct CGFont* CGFontRef;
     36typedef UInt32 ATSUFontID;
     37
    3538#include <CoreFoundation/CFBase.h>
    3639#include <objc/objc-auto.h>
     
    4245
    4346    FontPlatformData(Deleted)
    44     : syntheticBold(false), syntheticOblique(false), m_font((NSFont*)-1)
     47    : m_syntheticBold(false), m_syntheticOblique(false), m_cgFont(0), m_atsuFontID(0), m_size(0), m_font((NSFont*)-1)
    4548    {}
    4649
    47     FontPlatformData(NSFont* f = 0, bool b = false, bool o = false)
    48     : syntheticBold(b), syntheticOblique(o), m_font(f)
     50    FontPlatformData(NSFont* f = 0, bool b = false, bool o = false);
     51   
     52    FontPlatformData(CGFontRef f, ATSUFontID fontID, float s, bool b , bool o)
     53    : m_syntheticBold(b), m_syntheticOblique(o), m_cgFont(f), m_atsuFontID(fontID), m_size(s), m_font(0)
    4954    {
    50         if (f)
    51             CFRetain(f);
    5255    }
    5356
    54     FontPlatformData(const FontPlatformData& f)
    55     {
    56         m_font = (f.m_font && f.m_font != (NSFont*)-1) ? (NSFont*)CFRetain(f.m_font) : f.m_font;
    57         syntheticBold = f.syntheticBold;
    58         syntheticOblique = f.syntheticOblique;
    59     }
     57    FontPlatformData(const FontPlatformData& f);
     58   
     59    ~FontPlatformData();
    6060
    61     ~FontPlatformData()
    62     {
    63         if (m_font && m_font != (NSFont*)-1)
    64             CFRelease(m_font);
    65     }
    66 
    67     bool syntheticBold;
    68     bool syntheticOblique;
     61    bool m_syntheticBold;
     62    bool m_syntheticOblique;
     63   
     64    CGFontRef m_cgFont; // It is not necessary to refcount this, since either an NSFont owns it or some CachedFont has it referenced.
     65    ATSUFontID m_atsuFontID;
     66    float m_size;
    6967
    7068    unsigned hash() const
    71     {
    72         uintptr_t hashCodes[2] = { (uintptr_t)m_font, syntheticBold << 1 | syntheticOblique };
     69    {
     70        ASSERT(m_font != 0 || m_cgFont == 0);
     71        uintptr_t hashCodes[2] = { (uintptr_t)m_font, m_syntheticBold << 1 | m_syntheticOblique };
    7372        return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
    7473    }
     
    7675    bool operator==(const FontPlatformData& other) const
    7776    {
    78         return m_font == other.m_font && syntheticBold == other.syntheticBold && syntheticOblique == other.syntheticOblique;
     77        return m_font == other.m_font && m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique &&
     78               m_cgFont == other.m_cgFont && m_size == other.m_size && m_atsuFontID == other.m_atsuFontID;
    7979    }
     80
    8081    NSFont *font() const { return m_font; }
    81     void setFont(NSFont* font) {
    82         if (m_font == font)
    83             return;
    84         if (font && font != (NSFont*)-1)
    85             CFRetain(font);
    86         if (m_font && m_font != (NSFont*)-1)
    87             CFRelease(m_font);
    88         m_font = font;
    89     }
     82    void setFont(NSFont* font);
     83
    9084private:
    9185    NSFont *m_font;
  • branches/feature-branch/WebCore/platform/mac/WebCoreSystemInterface.h

    r25774 r26027  
    9090extern OSStatus (*wkGetATSStyleGroup)(ATSUStyle, void** styleGroup);
    9191extern CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
    92 extern ATSGlyphRef (*wkGetDefaultGlyphForChar)(NSFont*, UniChar);
    9392extern NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange);
    9493extern NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
  • branches/feature-branch/WebCore/platform/mac/WebCoreSystemInterface.mm

    r25774 r26027  
    3939OSStatus (*wkGetATSStyleGroup)(ATSUStyle, void** styleGroup);
    4040CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
    41 ATSGlyphRef (*wkGetDefaultGlyphForChar)(NSFont*, UniChar);
    4241NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange);
    4342NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
  • branches/feature-branch/WebCore/platform/win/FontCacheWin.cpp

    r25994 r26027  
    118118}
    119119
    120 FontPlatformData* FontCache::getLastResortFallbackFont(const Font& font)
     120FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
    121121{
    122122    // FIXME: Would be even better to somehow get the user's default font here.  For now we'll pick
    123123    // the default that the user would get without changing any prefs.
    124124    static AtomicString timesStr("Times New Roman");
    125     return getCachedFontPlatformData(font.fontDescription(), timesStr);
    126 }
    127 
    128 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
     125    return getCachedFontPlatformData(fontDescription, timesStr);
     126}
     127
     128bool FontCache::fontExists(const FontDescription& fontDescription, const AtomicString& family)
    129129{
    130130    LOGFONT winfont;
     
    172172    ReleaseDC(0, dc);
    173173
     174    DeleteObject(hfont);
     175
     176    return !wcsicmp(winfont.lfFaceName, name);
     177}
     178
     179FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
     180{
     181    LOGFONT winfont;
     182
     183    // The size here looks unusual.  The negative number is intentional.  The logical size constant is 32.
     184    winfont.lfHeight = -fontDescription.computedPixelSize() * 32;
     185    winfont.lfWidth = 0;
     186    winfont.lfEscapement = 0;
     187    winfont.lfOrientation = 0;
     188    winfont.lfUnderline = false;
     189    winfont.lfStrikeOut = false;
     190    winfont.lfCharSet = DEFAULT_CHARSET;
     191#if PLATFORM(CG)
     192    winfont.lfOutPrecision = OUT_TT_ONLY_PRECIS;
     193#else
     194    winfont.lfOutPrecision = OUT_TT_PRECIS;
     195#endif
     196    winfont.lfQuality = 5; // Force cleartype.
     197    winfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
     198    winfont.lfItalic = fontDescription.italic();
     199
     200    // FIXME: Support weights for real.  Do our own enumeration of the available weights.
     201    // We can't rely on Windows here, since we need to follow the CSS2 algorithm for how to fill in
     202    // gaps in the weight list.
     203    // FIXME: Hardcoding Lucida Grande for now.  It uses different weights than typical Win32 fonts
     204    // (500/600 instead of 400/700).
     205    static AtomicString lucidaStr("Lucida Grande");
     206    if (equalIgnoringCase(family, lucidaStr))
     207        winfont.lfWeight = fontDescription.bold() ? 600 : 500;
     208    else
     209        winfont.lfWeight = fontDescription.bold() ? 700 : 400;
     210    int len = min(family.length(), (unsigned int)LF_FACESIZE - 1);
     211    memcpy(winfont.lfFaceName, family.characters(), len * sizeof(WORD));
     212    winfont.lfFaceName[len] = '\0';
     213
     214    HFONT hfont = CreateFontIndirect(&winfont);
     215    // Windows will always give us a valid pointer here, even if the face name is non-existent.  We have to double-check
     216    // and see if the family name was really used.
     217    HDC dc = GetDC((HWND)0);
     218    SaveDC(dc);
     219    SelectObject(dc, hfont);
     220    WCHAR name[LF_FACESIZE];
     221    GetTextFace(dc, LF_FACESIZE, name);
     222    RestoreDC(dc, -1);
     223    ReleaseDC(0, dc);
     224
    174225    if (_wcsicmp(winfont.lfFaceName, name)) {
    175226        DeleteObject(hfont);
  • branches/feature-branch/WebCore/platform/win/FontDataWin.cpp

    r25887 r26027  
    4646using std::max;
    4747
     48const float cSmallCapsFontSizeMultiplier = 0.7f;
     49
    4850static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return unitsPerEm ? x / (float)unitsPerEm : x; }
    4951
    5052void FontData::platformInit()
    5153{   
    52     HDC dc = GetDC(0);
    53     SaveDC(dc);
    54 
    55     SelectObject(dc, m_font.hfont());
    56 
    57     int faceLength = GetTextFace(dc, 0, 0);
    58     Vector<TCHAR> faceName(faceLength);
    59     GetTextFace(dc, faceLength, faceName.data());
    60 
    6154    m_syntheticBoldOffset = m_font.syntheticBold() ? 1.0f : 0.f;
    6255
     
    6558    int iDescent = CGFontGetDescent(font);
    6659    int iLineGap = CGFontGetLeading(font);
    67     unsigned unitsPerEm = CGFontGetUnitsPerEm(font);
     60    m_unitsPerEm = CGFontGetUnitsPerEm(font);
    6861    float pointSize = m_font.size();
    69     float fAscent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
    70     float fDescent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize;
    71     float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
    72 
    73     m_isSystemFont = !_tcscmp(faceName.data(), _T("Lucida Grande"));
    74    
    75     // We need to adjust Times, Helvetica, and Courier to closely match the
    76     // vertical metrics of their Microsoft counterparts that are the de facto
    77     // web standard. The AppKit adjustment of 20% is too big and is
    78     // incorrectly added to line spacing, so we use a 15% adjustment instead
    79     // and add it to the ascent.
    80     if (!_tcscmp(faceName.data(), _T("Times")) || !_tcscmp(faceName.data(), _T("Helvetica")) || !_tcscmp(faceName.data(), _T("Courier")))
    81         fAscent += floorf(((fAscent + fDescent) * 0.15f) + 0.5f);
    82 
    83     m_unitsPerEm = 1; // FIXME!
     62    float fAscent = scaleEmToUnits(iAscent, m_unitsPerEm) * pointSize;
     63    float fDescent = -scaleEmToUnits(iDescent, m_unitsPerEm) * pointSize;
     64    float fLineGap = scaleEmToUnits(iLineGap, m_unitsPerEm) * pointSize;
     65
     66    m_isSystemFont = false;
     67    if (!isCustomFont()) {
     68        HDC dc = GetDC(0);
     69        HGDIOBJ oldFont = SelectObject(dc, m_font.hfont());
     70        int faceLength = GetTextFace(dc, 0, 0);
     71        Vector<TCHAR> faceName(faceLength);
     72        GetTextFace(dc, faceLength, faceName.data());
     73        m_isSystemFont = !_tcscmp(faceName.data(), _T("Lucida Grande"));
     74        SelectObject(dc, oldFont);
     75        ReleaseDC(0, dc);
     76
     77        // We need to adjust Times, Helvetica, and Courier to closely match the
     78        // vertical metrics of their Microsoft counterparts that are the de facto
     79        // web standard. The AppKit adjustment of 20% is too big and is
     80        // incorrectly added to line spacing, so we use a 15% adjustment instead
     81        // and add it to the ascent.
     82        if (!_tcscmp(faceName.data(), _T("Times")) || !_tcscmp(faceName.data(), _T("Helvetica")) || !_tcscmp(faceName.data(), _T("Courier")))
     83            fAscent += floorf(((fAscent + fDescent) * 0.15f) + 0.5f);
     84    }
    8485
    8586    m_ascent = lroundf(fAscent);
     
    9899        // poorly if we return an accurate height. Classic case is Times 13 point,
    99100        // which has an "x" that is 7x6 pixels.
    100         m_xHeight = scaleEmToUnits(max(CGRectGetMaxX(xBox), CGRectGetMaxY(xBox)), unitsPerEm) * pointSize;
     101        m_xHeight = scaleEmToUnits(max(CGRectGetMaxX(xBox), CGRectGetMaxY(xBox)), m_unitsPerEm) * pointSize;
    101102    } else {
    102103        int iXHeight = CGFontGetXHeight(font);
    103         m_xHeight = scaleEmToUnits(iXHeight, unitsPerEm) * pointSize;
    104     }
    105 
    106     RestoreDC(dc, -1);
    107     ReleaseDC(0, dc);
     104        m_xHeight = scaleEmToUnits(iXHeight, m_unitsPerEm) * pointSize;
     105    }
    108106
    109107    m_scriptCache = 0;
     
    113111void FontData::platformDestroy()
    114112{
    115     CGFontRelease(m_font.cgFont());
    116     DeleteObject(m_font.hfont());
     113    if (!isCustomFont()) {
     114        DeleteObject(m_font.hfont());
     115        CGFontRelease(m_font.cgFont());
     116    }
    117117
    118118    // We don't hash this on Win32, so it's effectively owned by us.
     
    126126{
    127127    if (!m_smallCapsFontData) {
    128         LOGFONT winfont;
    129         GetObject(m_font.hfont(), sizeof(LOGFONT), &winfont);
    130         int smallCapsHeight = lroundf(0.70f * fontDescription.computedSize());
    131         winfont.lfHeight = -smallCapsHeight * 32;
    132         HFONT hfont = CreateFontIndirect(&winfont);
    133         m_smallCapsFontData = new FontData(FontPlatformData(hfont, smallCapsHeight, fontDescription.bold(), fontDescription.italic()));
     128        int smallCapsHeight = lroundf(cSmallCapsFontSizeMultiplier * m_font.m_size);
     129        if (isCustomFont()) {
     130            FontPlatformData smallCapsFontData(m_font);
     131            smallCapsFontData.m_size = smallCapsHeight;
     132            m_smallCapsFontData = new FontData(smallCapsFontData, true, false);
     133        } else {
     134            LOGFONT winfont;
     135            GetObject(m_font.hfont(), sizeof(LOGFONT), &winfont);
     136            winfont.lfHeight = -smallCapsHeight * 32;
     137            HFONT hfont = CreateFontIndirect(&winfont);
     138            m_smallCapsFontData = new FontData(FontPlatformData(hfont, smallCapsHeight, fontDescription.bold(), fontDescription.italic()));
     139        }
    134140    }
    135141    return m_smallCapsFontData;
     
    138144bool FontData::containsCharacters(const UChar* characters, int length) const
    139145{
     146    // FIXME: Support custom fonts.
     147    if (isCustomFont())
     148        return false;
     149
    140150    // FIXME: Microsoft documentation seems to imply that characters can be output using a given font and DC
    141151    // merely by testing code page intersection.  This seems suspect though.  Can't a font only partially
     
    170180void FontData::determinePitch()
    171181{
     182    if (isCustomFont()) {
     183        m_treatAsFixedPitch = false;
     184        return;
     185    }
     186
    172187    // TEXTMETRICS have this.  Set m_treatAsFixedPitch based off that.
    173188    HDC dc = GetDC((HWND)0);
  • branches/feature-branch/WebCore/platform/win/FontPlatformData.h

    r25754 r26027  
    4444    , m_cgFont(NULL)
    4545    , m_size(0)
     46    , m_syntheticBold(false)
     47    , m_syntheticOblique(false)
    4648    {}
    4749
     
    5052    , m_cgFont(NULL)
    5153    , m_size(0)
     54    , m_syntheticBold(false)
     55    , m_syntheticOblique(false)
    5256    {}
    5357
    5458    FontPlatformData(HFONT, int size, bool bold, bool oblique);
     59    FontPlatformData(CGFontRef, int size, bool bold, bool oblique);
    5560    ~FontPlatformData();
    5661
     
    6368
    6469    unsigned hash() const
    65     { 
     70    {
    6671        return StringImpl::computeHash((UChar*)(&m_font), sizeof(HFONT) / sizeof(UChar));
    6772    }
     
    6974    bool operator==(const FontPlatformData& other) const
    7075    {
    71         return m_font == other.m_font
    72               && m_cgFont ==other.m_cgFont
    73               && m_size == other.m_size;
     76        return m_font == other.m_font && m_cgFont ==other.m_cgFont && m_size == other.m_size &&
     77               m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique;
    7478    }
    7579
  • branches/feature-branch/WebCore/platform/win/FontPlatformDataWin.cpp

    r25754 r26027  
    197197}
    198198
     199FontPlatformData::FontPlatformData(CGFontRef font, int size, bool bold, bool oblique)
     200    : m_font(0)
     201    , m_size(size)
     202    , m_cgFont(font)
     203    , m_syntheticBold(bold)
     204    , m_syntheticOblique(oblique)
     205{
     206}
     207
    199208FontPlatformData::~FontPlatformData()
    200209{
  • branches/feature-branch/WebCore/platform/win/PopupMenuWin.cpp

    r25754 r26027  
    2525#include "FloatRect.h"
    2626#include "FontData.h"
     27#include "FontSelector.h"
    2728#include "Frame.h"
    2829#include "FrameView.h"
     
    512513            d.setBold(true);
    513514            itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
    514             itemFont.update();
     515            itemFont.update(m_popupClient->fontSelector());
    515516        }
    516517        context.setFont(itemFont);
  • branches/feature-branch/WebCore/rendering/RenderListBox.cpp

    r24582 r26027  
    3232#include "RenderListBox.h"
    3333
     34#include "CSSStyleSelector.h"
    3435#include "Document.h"
    3536#include "EventHandler.h"
     
    109110                d.setBold(true);
    110111                itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
    111                 itemFont.update();
     112                itemFont.update(document()->styleSelector()->fontSelector());
    112113            }
    113114               
     
    325326        d.setBold(true);
    326327        itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
    327         itemFont.update();
     328        itemFont.update(document()->styleSelector()->fontSelector());
    328329    }
    329330    paintInfo.context->setFont(itemFont);
  • branches/feature-branch/WebCore/rendering/RenderMenuList.cpp

    r25754 r26027  
    2424#include "RenderMenuList.h"
    2525
     26#include "CSSStyleSelector.h"
    2627#include "Document.h"
     28#include "FontSelector.h"
    2729#include "FrameView.h"
    2830#include "GraphicsContext.h"
     
    394396}
    395397
    396 }
     398FontSelector* RenderMenuList::fontSelector() const
     399{
     400    return document()->styleSelector()->fontSelector();
     401}
     402
     403}
  • branches/feature-branch/WebCore/rendering/RenderMenuList.h

    r25754 r26027  
    8787    virtual bool shouldPopOver() const { return !POPUP_MENU_PULLS_DOWN; }
    8888    virtual void valueChanged(unsigned listIndex, bool fireOnChange = true);
     89    virtual FontSelector* fontSelector() const;
    8990
    9091    virtual bool hasLineIfEmpty() const { return true; }
  • branches/feature-branch/WebCore/rendering/RenderTextControl.cpp

    r25754 r26027  
    2323
    2424#include "CharacterNames.h"
     25#include "CSSStyleSelector.h"
    2526#include "Document.h"
    2627#include "Editor.h"
     
    2829#include "Event.h"
    2930#include "EventNames.h"
     31#include "FontSelector.h"
    3032#include "Frame.h"
    3133#include "HTMLBRElement.h"
     
    11871189}
    11881190
     1191FontSelector* RenderTextControl::fontSelector() const
     1192{
     1193    return document()->styleSelector()->fontSelector();
     1194}
     1195
    11891196} // namespace WebCore
  • branches/feature-branch/WebCore/rendering/RenderTextControl.h

    r25754 r26027  
    2828namespace WebCore {
    2929
     30class FontSelector;
    3031class HTMLTextFieldInnerElement;
    3132class HTMLTextFieldInnerTextElement;
     
    122123    virtual bool shouldPopOver() const { return false; }
    123124    virtual bool valueShouldChangeOnHotTrack() const { return false; }
    124    
     125    virtual FontSelector* fontSelector() const;
     126
    125127    RenderStyle* createInnerBlockStyle(RenderStyle* startStyle);
    126128    RenderStyle* createInnerTextStyle(RenderStyle* startStyle);
  • branches/feature-branch/WebCore/rendering/RenderThemeMac.mm

    r25754 r26027  
    393393
    394394    if (style->setFontDescription(fontDescription))
    395         style->font().update();
     395        style->font().update(0);
    396396}
    397397
  • branches/feature-branch/WebCore/rendering/RenderThemeSafari.cpp

    r25754 r26027  
    335335
    336336    if (style->setFontDescription(fontDescription))
    337         style->font().update();
     337        style->font().update(selector->fontSelector());
    338338}
    339339
Note: See TracChangeset for help on using the changeset viewer.