| | 1 | 2007-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 | |