Show
Ignore:
Timestamp:
10/03/07 14:04:03 (14 months 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.
Files:
1 modified

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