Changeset 14216 in webkit
- Timestamp:
- May 6, 2006 1:40:28 AM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 deleted
- 16 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r14215 r14216 1 2006-05-06 David Hyatt <hyatt@apple.com> 2 3 Rename WebCoreFont to FontPlatformData and WebTextRenderer to FontData. Merge them into the 4 headers (uncleanly with ifdefs at the moment, so I can see what I'm working towards). 5 6 Reviewed by mjs 7 8 * ChangeLog: 9 * WebCore.vcproj/WebCore/WebCore.vcproj: 10 * WebCore.xcodeproj/project.pbxproj: 11 * bridge/mac/WebCoreStringTruncator.mm: 12 (stringWidth): 13 (truncateString): 14 (+[WebCoreStringTruncator widthOfString:font:]): 15 * kwq/KWQComboBox.mm: 16 (QComboBox::sizeHint): 17 * kwq/KWQLineEdit.mm: 18 (QLineEdit::sizeForCharacterWidth): 19 * kwq/KWQListBox.mm: 20 (itemTextRenderer): 21 (groupLabelTextRenderer): 22 (QListBox::sizeForNumberOfLines): 23 (-[KWQTableView drawRow:clipRect:]): 24 * platform/Font.cpp: 25 (WebCore::m_wordSpacing): 26 (WebCore::Font::Font): 27 (WebCore::Font::operator=): 28 (WebCore::Font::update): 29 (WebCore::Font::ascent): 30 (WebCore::Font::descent): 31 (WebCore::Font::lineSpacing): 32 (WebCore::Font::xHeight): 33 (WebCore::Font::isFixedPitch): 34 * platform/Font.h: 35 (WebCore::Font::getNSFont): 36 * platform/FontData.h: 37 (WebCore::FontData::ascent): 38 (WebCore::FontData::descent): 39 (WebCore::FontData::lineSpacing): 40 (WebCore::FontData::lineGap): 41 (WebCore::FontData::misspellingLineThickness): 42 (WebCore::FontData::misspellingLinePatternWidth): 43 (WebCore::FontData::misspellingLinePatternGapWidth): 44 * platform/FontDataSet.h: Removed. 45 * platform/FontFallbackList.h: Added. 46 * platform/FontPlatformData.h: 47 * platform/mac/FontData.mm: Added. 48 (WebCore::WebCoreInitializeFont): 49 (WebCore::WebCoreInitializeEmptyTextGeometry): 50 (WebCore::widthForGlyph): 51 (WebCore::overrideLayoutOperation): 52 (WebCore::FontData::~FontData): 53 (WebCore::FontData::xHeight): 54 (WebCore::FontData::drawRun): 55 (WebCore::FontData::floatWidthForRun): 56 (WebCore::FontData::drawLineForCharacters): 57 (WebCore::FontData::selectionRectForRun): 58 (WebCore::FontData::drawHighlightForRun): 59 (WebCore::FontData::drawLineForMisspelling): 60 (WebCore::FontData::pointToOffset): 61 (WebCore::FontData::setAlwaysUseATSU): 62 (WebCore::getSmallCapsRenderer): 63 (WebCore::findSubstituteFont): 64 (WebCore::rendererForAlternateFont): 65 (WebCore::findSubstituteRenderer): 66 (WebCore::computeWidthForSpace): 67 (WebCore::setUpFont): 68 (WebCore::CG_drawHighlight): 69 (WebCore::CG_selectionRect): 70 (WebCore::CG_draw): 71 (WebCore::CG_floatWidthForRun): 72 (WebCore::updateGlyphMapEntry): 73 (WebCore::extendGlyphMap): 74 (WebCore::extendWidthMap): 75 (WebCore::initializeATSUStyle): 76 (WebCore::createATSULayoutParameters): 77 (WebCore::getTextBounds): 78 (WebCore::ATSU_floatWidthForRun): 79 (WebCore::ATSU_drawHighlight): 80 (WebCore::ATSU_selectionRect): 81 (WebCore::ATSU_draw): 82 (WebCore::ATSU_pointToOffset): 83 (WebCore::advanceWidthIteratorOneCharacter): 84 (WebCore::CG_pointToOffset): 85 (WebCore::glyphForCharacter): 86 (WebCore::initializeWidthIterator): 87 (WebCore::advanceWidthIterator): 88 * platform/mac/FontMac.mm: 89 (WebCore::m_font): 90 (WebCore::FontFallbackList::~FontFallbackList): 91 (WebCore::FontFallbackList::platformFont): 92 (WebCore::FontFallbackList::primaryFont): 93 (WebCore::FontFallbackList::determinePitch): 94 (WebCore::FontFallbackList::invalidate): 95 (WebCore::Font::platformFont): 96 (WebCore::Font::selectionRectForText): 97 (WebCore::Font::drawText): 98 (WebCore::Font::drawHighlightForText): 99 (WebCore::Font::drawLineForText): 100 (WebCore::Font::drawLineForMisspelling): 101 (WebCore::Font::misspellingLineThickness): 102 (WebCore::Font::floatWidth): 103 (WebCore::Font::checkSelectionPoint): 104 * platform/mac/WebCoreTextRenderer.mm: 105 (WebCoreDrawTextAtPoint): 106 (WebCoreTextFloatWidth): 107 (WebCoreSetAlwaysUseATSU): 108 * platform/mac/WebTextRenderer.h: Removed. 109 * platform/mac/WebTextRenderer.mm: Removed. 110 * platform/mac/WebTextRendererFactory.h: 111 * platform/mac/WebTextRendererFactory.mm: 112 (-[WebTextRendererFactory isFontFixedPitch:]): 113 (-[WebTextRendererFactory init]): 114 (-[WebTextRendererFactory rendererWithFont:]): 115 (-[WebTextRendererFactory fontWithFamilies:traits:size:]): 116 * platform/win/FontWin.cpp: 117 (WebCore::FontFallbackList::~FontFallbackList): 118 (WebCore::FontFallbackList::determinePitch): 119 (WebCore::FontFallbackList::invalidate): 120 (WebCore::FontFallbackList::primaryFont): 121 (WebCore::Font::floatWidth): 122 (WebCore::Font::drawText): 123 (WebCore::Font::drawHighlightForText): 124 (WebCore::Font::selectionRectForText): 125 (WebCore::Font::checkSelectionPoint): 126 1 127 2006-05-05 Darin Adler <darin@apple.com> 2 128 -
trunk/WebCore/WebCore.vcproj/WebCore/WebCore.vcproj
r14163 r14216 700 700 </File> 701 701 <File 702 RelativePath="..\..\platform\Font DataSet.h"702 RelativePath="..\..\platform\FontFallbackList.h" 703 703 > 704 704 </File> -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r14174 r14216 990 990 AB67D1A8097F3AE300F9392E /* RenderTextField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB67D1A6097F3AE300F9392E /* RenderTextField.cpp */; }; 991 991 AB67D1A9097F3AE300F9392E /* RenderTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = AB67D1A7097F3AE300F9392E /* RenderTextField.h */; }; 992 BC066F3709FEAF5300C589A7 /* WebTextRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = BC066F3309FEAF5300C589A7 /* WebTextRenderer.h */; };993 BC066F3809FEAF5300C589A7 /* WebTextRenderer.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC066F3409FEAF5300C589A7 /* WebTextRenderer.mm */; };994 992 BC066F3909FEAF5300C589A7 /* WebTextRendererFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = BC066F3509FEAF5300C589A7 /* WebTextRendererFactory.h */; }; 995 993 BC066F3A09FEAF5300C589A7 /* WebTextRendererFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC066F3609FEAF5300C589A7 /* WebTextRendererFactory.mm */; }; … … 1067 1065 BCC8D1730988301200140BF2 /* Pen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC8D1710988301200140BF2 /* Pen.cpp */; }; 1068 1066 BCC8D1740988301200140BF2 /* Pen.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC8D1720988301200140BF2 /* Pen.h */; }; 1067 BCCD13200A0C0030001AFA8B /* FontData.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCCD131E0A0C0030001AFA8B /* FontData.mm */; }; 1069 1068 BCD75ABC0989A446003E28DF /* Image.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD75ABB0989A446003E28DF /* Image.h */; }; 1070 1069 BCEA478D097CAAC80094C9E4 /* css_base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA477A097CAAC80094C9E4 /* css_base.cpp */; }; … … 1146 1145 BCEA4948097F0F770094C9E4 /* BrowserExtensionMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4946097F0F770094C9E4 /* BrowserExtensionMac.mm */; }; 1147 1146 BCEB377309B7BA3900CB38B1 /* FontMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCEB377209B7BA3900CB38B1 /* FontMac.mm */; }; 1148 BCEB377609B7BB0D00CB38B1 /* Font DataSet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEB377509B7BB0D00CB38B1 /* FontDataSet.h */; };1147 BCEB377609B7BB0D00CB38B1 /* FontFallbackList.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEB377509B7BB0D00CB38B1 /* FontFallbackList.h */; }; 1149 1148 BCEF3434087B563E00BBF833 /* HTMLElementFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEF3432087B563E00BBF833 /* HTMLElementFactory.cpp */; }; 1150 1149 BCEF3435087B563E00BBF833 /* HTMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEF3433087B563E00BBF833 /* HTMLElementFactory.h */; }; … … 2271 2270 AB67D1A6097F3AE300F9392E /* RenderTextField.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextField.cpp; sourceTree = "<group>"; }; 2272 2271 AB67D1A7097F3AE300F9392E /* RenderTextField.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTextField.h; sourceTree = "<group>"; }; 2273 BC066F3309FEAF5300C589A7 /* WebTextRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebTextRenderer.h; sourceTree = "<group>"; };2274 BC066F3409FEAF5300C589A7 /* WebTextRenderer.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebTextRenderer.mm; sourceTree = "<group>"; };2275 2272 BC066F3509FEAF5300C589A7 /* WebTextRendererFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebTextRendererFactory.h; sourceTree = "<group>"; }; 2276 2273 BC066F3609FEAF5300C589A7 /* WebTextRendererFactory.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebTextRendererFactory.mm; sourceTree = "<group>"; }; … … 2358 2355 BCC8D1710988301200140BF2 /* Pen.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Pen.cpp; sourceTree = "<group>"; }; 2359 2356 BCC8D1720988301200140BF2 /* Pen.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Pen.h; sourceTree = "<group>"; }; 2357 BCCD131E0A0C0030001AFA8B /* FontData.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FontData.mm; sourceTree = "<group>"; }; 2360 2358 BCD75ABB0989A446003E28DF /* Image.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Image.h; sourceTree = "<group>"; }; 2361 2359 BCEA477A097CAAC80094C9E4 /* css_base.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = css_base.cpp; sourceTree = "<group>"; }; … … 2441 2439 BCEA4946097F0F770094C9E4 /* BrowserExtensionMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = BrowserExtensionMac.mm; sourceTree = "<group>"; }; 2442 2440 BCEB377209B7BA3900CB38B1 /* FontMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FontMac.mm; sourceTree = "<group>"; }; 2443 BCEB377509B7BB0D00CB38B1 /* Font DataSet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontDataSet.h; sourceTree = "<group>"; };2441 BCEB377509B7BB0D00CB38B1 /* FontFallbackList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontFallbackList.h; sourceTree = "<group>"; }; 2444 2442 BCEF3432087B563E00BBF833 /* HTMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLElementFactory.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 2445 2443 BCEF3433087B563E00BBF833 /* HTMLElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HTMLElementFactory.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; … … 2841 2839 9352071C09BD3BBB00F2038D /* WebCoreWidgetHolder.h */, 2842 2840 BCFE8E310A02A1D30009E61D /* WebCoreTextRenderer.mm */, 2841 BCCD131E0A0C0030001AFA8B /* FontData.mm */, 2843 2842 BC066F6C09FEB2FA00C589A7 /* WebCoreTextRenderer.h */, 2844 BC066F3309FEAF5300C589A7 /* WebTextRenderer.h */,2845 BC066F3409FEAF5300C589A7 /* WebTextRenderer.mm */,2846 2843 BC066F3509FEAF5300C589A7 /* WebTextRendererFactory.h */, 2847 2844 BC066F3609FEAF5300C589A7 /* WebTextRendererFactory.mm */, … … 3887 3884 BC6D6DD009AF906600F59759 /* Font.cpp */, 3888 3885 BC6D6DD109AF906600F59759 /* Font.h */, 3889 BCEB377509B7BB0D00CB38B1 /* Font DataSet.h */,3886 BCEB377509B7BB0D00CB38B1 /* FontFallbackList.h */, 3890 3887 BCC47E6A09A3FE4700ADB771 /* FontDescription.h */, 3891 3888 BCC47E2409A3D6F100ADB771 /* FontFamily.cpp */, … … 4738 4735 A82398A609B3ACDB00B60641 /* PlugInInfoStore.h in Headers */, 4739 4736 A8239E0109B3CF8A00B60641 /* Logging.h in Headers */, 4740 BCEB377609B7BB0D00CB38B1 /* Font DataSet.h in Headers */,4737 BCEB377609B7BB0D00CB38B1 /* FontFallbackList.h in Headers */, 4741 4738 C6D74AD509AA282E000B0A52 /* ModifySelectionListLevelCommand.h in Headers */, 4742 4739 6545F67109B82FED0013006F /* TransferJob.h in Headers */, … … 4843 4840 93EB169709F880C00091F8FF /* WebCoreSystemInterface.h in Headers */, 4844 4841 65901A4409FC6039005BD752 /* WebCoreStringTruncator.h in Headers */, 4845 BC066F3709FEAF5300C589A7 /* WebTextRenderer.h in Headers */,4846 4842 BC066F3909FEAF5300C589A7 /* WebTextRendererFactory.h in Headers */, 4847 4843 BC066F6F09FEB2FA00C589A7 /* WebCoreTextRenderer.h in Headers */, … … 5561 5557 93EB169509F880B00091F8FF /* WebCoreSystemInterface.mm in Sources */, 5562 5558 65901A4509FC6039005BD752 /* WebCoreStringTruncator.mm in Sources */, 5563 BC066F3809FEAF5300C589A7 /* WebTextRenderer.mm in Sources */,5564 5559 BC066F3A09FEAF5300C589A7 /* WebTextRendererFactory.mm in Sources */, 5565 5560 BCFE8E320A02A1D30009E61D /* WebCoreTextRenderer.mm in Sources */, … … 5567 5562 142011B60A003133008303F9 /* JSCSSStyleDeclaration.cpp in Sources */, 5568 5563 936BDD1D0A031AEB004DF4AB /* GraphicsContextCG.cpp in Sources */, 5564 BCCD13200A0C0030001AFA8B /* FontData.mm in Sources */, 5569 5565 ); 5570 5566 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bridge/mac/WebCoreStringTruncator.mm
r14179 r14216 34 34 #import <kxmlcore/Assertions.h> 35 35 #import "WebTextRendererFactory.h" 36 #import " WebTextRenderer.h"36 #import "FontData.h" 37 37 38 38 #define STRING_BUFFER_SIZE 2048 … … 42 42 43 43 static NSFont *currentFont; 44 static WebTextRenderer* currentRenderer;44 static FontData* currentRenderer; 45 45 static float currentEllipsisWidth; 46 46 … … 82 82 } 83 83 84 static float stringWidth( WebTextRenderer* renderer, const unichar *characters, unsigned length)84 static float stringWidth(FontData* renderer, const unichar *characters, unsigned length) 85 85 { 86 86 WebCoreTextRun run; … … 115 115 [currentFont release]; 116 116 currentFont = [font retain]; 117 WebCoreFontf;117 FontPlatformData f; 118 118 WebCoreInitializeFont(&f); 119 119 f.font = font; … … 224 224 unichar *s = static_cast<unichar*>(malloc(sizeof(unichar) * length)); 225 225 [string getCharacters:s]; 226 WebCoreFontf;226 FontPlatformData f; 227 227 WebCoreInitializeFont(&f); 228 228 f.font = font; -
trunk/WebCore/kwq/KWQComboBox.mm
r14174 r14216 32 32 #import "KWQLineEdit.h" 33 33 #import "WebCoreFrameBridge.h" 34 #import " WebTextRenderer.h"34 #import "FontData.h" 35 35 #import "WebTextRendererFactory.h" 36 36 #import "WebCoreWidgetHolder.h" … … 166 166 DeprecatedValueListConstIterator<KWQListBoxItem> e = const_cast<const DeprecatedValueList<KWQListBoxItem> &>(_items).end(); 167 167 if (i != e) { 168 WebCoreFontitemFont;168 FontPlatformData itemFont; 169 169 WebCoreInitializeFont(&itemFont); 170 170 itemFont.font = [button font]; 171 171 itemFont.forPrinter = ![NSGraphicsContext currentContextDrawingToScreen]; 172 WebTextRenderer* itemRenderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:itemFont];173 WebTextRenderer* labelRenderer = nil;172 FontData* itemRenderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:itemFont]; 173 FontData* labelRenderer = nil; 174 174 WebCoreTextStyle style; 175 175 WebCoreInitializeEmptyTextStyle(&style); … … 185 185 WebCoreInitializeTextRun(&run, reinterpret_cast<const UniChar *>(s.unicode()), length, 0, length); 186 186 187 WebTextRenderer* renderer;187 FontData* renderer; 188 188 if (isGroupLabel) { 189 189 if (labelRenderer == nil) { 190 WebCoreFontlabelFont;190 FontPlatformData labelFont; 191 191 WebCoreInitializeFont(&labelFont); 192 192 labelFont.font = this->labelFont(); -
trunk/WebCore/kwq/KWQLineEdit.mm
r14149 r14216 34 34 #import "WebCoreTextField.h" 35 35 #import "WebCoreFrameBridge.h" 36 #import " WebTextRenderer.h"36 #import "FontData.h" 37 37 #import "WebTextRendererFactory.h" 38 38 #import "WebCoreViewFactory.h" … … 262 262 BEGIN_BLOCK_OBJC_EXCEPTIONS; 263 263 264 WebCoreFontfont;264 FontPlatformData font; 265 265 WebCoreInitializeFont(&font); 266 266 font.font = [textField font]; 267 267 font.forPrinter = ![NSGraphicsContext currentContextDrawingToScreen]; 268 WebTextRenderer* renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:font];268 FontData* renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:font]; 269 269 270 270 NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; -
trunk/WebCore/kwq/KWQListBox.mm
r14149 r14216 30 30 #import "FrameMac.h" 31 31 #import "WebCoreFrameBridge.h" 32 #import " WebTextRenderer.h"32 #import "FontData.h" 33 33 #import "WebTextRendererFactory.h" 34 34 #import "WebCoreWidgetHolder.h" … … 67 67 @end 68 68 69 static WebTextRenderer* itemScreenRenderer;70 static WebTextRenderer* itemPrinterRenderer;71 static WebTextRenderer* groupLabelScreenRenderer;72 static WebTextRenderer* groupLabelPrinterRenderer;69 static FontData* itemScreenRenderer; 70 static FontData* itemPrinterRenderer; 71 static FontData* groupLabelScreenRenderer; 72 static FontData* groupLabelPrinterRenderer; 73 73 74 74 static NSFont *itemFont() … … 78 78 } 79 79 80 static WebTextRenderer* itemTextRenderer()80 static FontData* itemTextRenderer() 81 81 { 82 82 if ([NSGraphicsContext currentContextDrawingToScreen]) { 83 83 if (itemScreenRenderer == nil) { 84 WebCoreFontfont;84 FontPlatformData font; 85 85 WebCoreInitializeFont(&font); 86 86 font.font = itemFont(); … … 90 90 } else { 91 91 if (itemPrinterRenderer == nil) { 92 WebCoreFontfont;92 FontPlatformData font; 93 93 WebCoreInitializeFont(&font); 94 94 font.font = itemFont(); … … 100 100 } 101 101 102 static WebTextRenderer* groupLabelTextRenderer()102 static FontData* groupLabelTextRenderer() 103 103 { 104 104 if ([NSGraphicsContext currentContextDrawingToScreen]) { 105 105 if (groupLabelScreenRenderer == nil) { 106 WebCoreFontfont;106 FontPlatformData font; 107 107 WebCoreInitializeFont(&font); 108 108 font.font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]]; … … 112 112 } else { 113 113 if (groupLabelPrinterRenderer == nil) { 114 WebCoreFontfont;114 FontPlatformData font; 115 115 WebCoreInitializeFont(&font); 116 116 font.font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]]; … … 280 280 style.applyWordRounding = NO; 281 281 282 WebTextRenderer* renderer;283 WebTextRenderer* groupLabelRenderer;282 FontData* renderer; 283 FontData* groupLabelRenderer; 284 284 285 285 if (tableView->isSystemFont) { … … 287 287 groupLabelRenderer = groupLabelTextRenderer(); 288 288 } else { 289 renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:font(). getWebCoreFont()];289 renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:font().platformFont()]; 290 290 FontDescription boldDesc = font().fontDescription(); 291 291 boldDesc.setWeight(cBoldWeight); 292 292 Font b = Font(boldDesc, font().letterSpacing(), font().wordSpacing()); 293 293 b.update(); 294 groupLabelRenderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:b. getWebCoreFont()];294 groupLabelRenderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:b.platformFont()]; 295 295 } 296 296 … … 681 681 bool rtl = _direction == NSWritingDirectionRightToLeft; 682 682 683 WebTextRenderer* renderer;683 FontData* renderer; 684 684 if (isSystemFont) { 685 685 renderer = (item.type == KWQListBoxGroupLabel) ? groupLabelTextRenderer() : itemTextRenderer(); … … 690 690 Font b = Font(boldDesc, _box->font().letterSpacing(), _box->font().wordSpacing()); 691 691 b.update(); 692 renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:b. getWebCoreFont()];692 renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:b.platformFont()]; 693 693 } 694 694 else 695 renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:_box->font(). getWebCoreFont()];695 renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:_box->font().platformFont()]; 696 696 } 697 697 -
trunk/WebCore/platform/Font.cpp
r13858 r14216 26 26 #include "config.h" 27 27 #include "Font.h" 28 #include "FontData.h" 28 29 29 #include "Font DataSet.h"30 #include "FontFallbackList.h" 30 31 #include "GraphicsContext.h" 31 32 #include "KWQKHTMLSettings.h" … … 33 34 namespace WebCore { 34 35 35 Font::Font() :m_ dataSet(0), m_letterSpacing(0), m_wordSpacing(0) {}36 Font::Font() :m_fontList(0), m_letterSpacing(0), m_wordSpacing(0) {} 36 37 Font::Font(const FontDescription& fd, short letterSpacing, short wordSpacing) 37 38 : m_fontDescription(fd), 38 m_ dataSet(0),39 m_fontList(0), 39 40 m_letterSpacing(letterSpacing), 40 41 m_wordSpacing(wordSpacing) … … 44 45 { 45 46 m_fontDescription = other.m_fontDescription; 46 m_ dataSet = other.m_dataSet;47 m_fontList = other.m_fontList; 47 48 m_letterSpacing = other.m_letterSpacing; 48 49 m_wordSpacing = other.m_wordSpacing; … … 53 54 if (&other != this) { 54 55 m_fontDescription = other.m_fontDescription; 55 m_ dataSet = other.m_dataSet;56 m_fontList = other.m_fontList; 56 57 m_letterSpacing = other.m_letterSpacing; 57 58 m_wordSpacing = other.m_wordSpacing; … … 71 72 // won't stick around long enough to get you in trouble). Still, this is pretty disgusting, 72 73 // and could eventually be rectified by using RefPtrs for Fonts themselves. 73 if (!m_ dataSet)74 m_ dataSet = new FontDataSet();75 m_ dataSet->invalidate();74 if (!m_fontList) 75 m_fontList = new FontFallbackList(); 76 m_fontList->invalidate(); 76 77 } 77 78 … … 86 87 } 87 88 89 int Font::ascent() const 90 { 91 assert(m_fontList); 92 return m_fontList->primaryFont(fontDescription())->ascent(); 88 93 } 94 95 int Font::descent() const 96 { 97 assert(m_fontList); 98 return m_fontList->primaryFont(fontDescription())->descent(); 99 } 100 101 int Font::lineSpacing() const 102 { 103 assert(m_fontList); 104 return m_fontList->primaryFont(fontDescription())->lineSpacing(); 105 } 106 107 float Font::xHeight() const 108 { 109 assert(m_fontList); 110 return m_fontList->primaryFont(fontDescription())->xHeight(); 111 } 112 113 bool Font::isFixedPitch() const 114 { 115 assert(m_fontList); 116 return m_fontList->isFixedPitch(fontDescription()); 117 } 118 119 } -
trunk/WebCore/platform/Font.h
r14115 r14216 32 32 33 33 #if __APPLE__ 34 35 #ifdef __OBJC__ 36 @class NSFont; 37 #else 38 class NSFont; 39 #endif 40 41 struct WebCoreFont { 42 NSFont *font; 43 bool syntheticBold; 44 bool syntheticOblique; 45 bool forPrinter; 46 }; 47 34 // FIXME: Should not be necessary. 35 #include "FontPlatformData.h" 48 36 #endif 49 37 50 38 namespace WebCore { 51 39 52 class Font DataSet;40 class FontFallbackList; 53 41 class GraphicsContext; 54 42 class IntPoint; … … 124 112 125 113 #if __APPLE__ 114 // FIXME: Shouldn't need to access FontPlatformData... should just need NSFont. 126 115 NSString* getNSFamily() const { return m_fontDescription.family().getNSFamily(); } 127 NSFont* getNSFont() const { return getWebCoreFont().font; }128 const WebCoreFont& getWebCoreFont() const;116 NSFont* getNSFont() const { return platformFont().font; } 117 const FontPlatformData& platformFont() const; 129 118 #endif 130 119 131 // Metrics that we query the Font DataSet for.120 // Metrics that we query the FontFallbackList for. 132 121 int ascent() const; 133 122 int descent() const; … … 138 127 private: 139 128 FontDescription m_fontDescription; 140 mutable RefPtr<Font DataSet> m_dataSet;129 mutable RefPtr<FontFallbackList> m_fontList; 141 130 short m_letterSpacing; 142 131 short m_wordSpacing; -
trunk/WebCore/platform/FontData.h
r13329 r14216 21 21 * 22 22 */ 23 24 #if __APPLE__ 25 typedef UInt16 ATSGlyphRef; 26 typedef struct OpaqueATSUStyle* ATSUStyle; 27 28 #if __OBJC__ 29 @class NSColor; 30 #else 31 class NSColor; 32 #endif 33 34 #include "FloatPoint.h" 35 #include "FontPlatformData.h" 36 37 namespace WebCore 38 { 39 40 class FloatRect; 41 class Color; 42 43 struct WebCoreTextStyle 44 { 45 NSColor *textColor; 46 NSColor *backgroundColor; 47 int letterSpacing; 48 int wordSpacing; 49 int padding; 50 int tabWidth; 51 int xpos; 52 NSString **families; 53 bool smallCaps; 54 bool rtl; 55 bool directionalOverride; 56 bool applyRunRounding; 57 bool applyWordRounding; 58 bool attemptFontSubstitution; 59 }; 60 61 struct WebCoreTextRun 62 { 63 const UniChar *characters; 64 unsigned int length; 65 int from; 66 int to; 67 }; 68 69 struct WebCoreTextGeometry 70 { 71 FloatPoint point; 72 float selectionY; 73 float selectionHeight; 74 bool useFontMetricsForSelectionYAndHeight; 75 }; 76 77 void WebCoreInitializeTextRun(WebCoreTextRun *run, const UniChar *characters, unsigned int length, int from, int to); 78 void WebCoreInitializeEmptyTextStyle(WebCoreTextStyle *style); 79 void WebCoreInitializeEmptyTextGeometry(WebCoreTextGeometry *geometry); 80 void WebCoreInitializeFont(FontPlatformData *font); 81 82 typedef struct WidthMap WidthMap; 83 typedef struct GlyphMap GlyphMap; 84 85 class FontData 86 { 87 public: 88 FontData(const FontPlatformData& f); 89 ~FontData(); 90 91 public: 92 static void setAlwaysUseATSU(bool); 93 static bool gAlwaysUseATSU; 94 95 // vertical metrics 96 int ascent() const { return m_ascent; } 97 int descent() const { return m_descent; } 98 int lineSpacing() const { return m_lineSpacing; } 99 int lineGap() const { return m_lineGap; } 100 101 float xHeight() const; 102 103 // horizontal metrics 104 float floatWidthForRun(const WebCoreTextRun* run, const WebCoreTextStyle* style); 105 106 // drawing 107 void drawRun(const WebCoreTextRun* run, const WebCoreTextStyle* style, const WebCoreTextGeometry* geometry); 108 FloatRect selectionRectForRun(const WebCoreTextRun* run, const WebCoreTextStyle* style, const WebCoreTextGeometry* geometry); 109 void drawHighlightForRun(const WebCoreTextRun* run, const WebCoreTextStyle* style, const WebCoreTextGeometry* geometry); 110 void drawLineForCharacters(const FloatPoint& point, float yOffset, int width, const Color& color, float thickness); 111 void drawLineForMisspelling(const FloatPoint& point, int width); 112 int misspellingLineThickness() const { return 3; } 113 114 // selection point check 115 int pointToOffset(const WebCoreTextRun* run, const WebCoreTextStyle* style, int x, bool includePartialGlyphs); 116 117 private: 118 int misspellingLinePatternWidth() const { return 4; } 119 int misspellingLinePatternGapWidth() const { return 1; } // the number of transparent pixels after the dot 120 121 public: 122 int m_ascent; 123 int m_descent; 124 int m_lineSpacing; 125 int m_lineGap; 126 127 void* m_styleGroup; 128 129 FontPlatformData m_font; 130 GlyphMap* m_characterToGlyphMap; 131 WidthMap* m_glyphToWidthMap; 132 133 bool m_treatAsFixedPitch; 134 ATSGlyphRef m_spaceGlyph; 135 float m_spaceWidth; 136 float m_adjustedSpaceWidth; 137 float m_syntheticBoldOffset; 138 139 FontData* m_smallCapsRenderer; 140 ATSUStyle m_ATSUStyle; 141 bool m_ATSUStyleInitialized; 142 bool m_ATSUMirrors; 143 }; 144 145 } 146 147 #else 23 148 24 149 #include "FontPlatformData.h" … … 60 185 61 186 } 187 #endif -
trunk/WebCore/platform/FontFallbackList.h
r14184 r14216 29 29 namespace WebCore { 30 30 31 #ifdef __APPLE__32 class WebTextRenderer;33 #endif34 35 31 class Font; 36 32 class GraphicsContext; 37 33 class IntRect; 38 39 34 class FontData; 40 35 41 class Font DataSet : public Shared<FontDataSet>, Noncopyable {36 class FontFallbackList : public Shared<FontFallbackList>, Noncopyable { 42 37 public: 43 Font DataSet();44 ~Font DataSet();38 FontFallbackList(); 39 ~FontFallbackList(); 45 40 41 // FIXME: Eventually FontFallbackLists will be hashed themselves (by FontDescription), and so instead of invalidating we'll just 42 // drop our reference. 46 43 void invalidate(); 47 44 … … 51 48 private: 52 49 mutable Pitch m_pitch; 50 51 FontData* primaryFont(const FontDescription&) const; 52 53 53 #if __APPLE__ 54 WebTextRenderer* m_renderer; 55 WebTextRenderer* getRenderer(const FontDescription&); 56 mutable WebCoreFont m_webCoreFont; 57 const WebCoreFont& getWebCoreFont(const FontDescription&) const; 54 // FIXME: FontData is still doing too much and is basically handling functionality that will be lifted up into 55 // FontFallbackList and Font. That's why we still only have one FontData object and don't yet have the vector. 56 mutable FontData* m_font; 57 mutable FontPlatformData m_platformFont; 58 59 const FontPlatformData& platformFont(const FontDescription&) const; 58 60 #else 59 mutable Vector<FontData*> m_fontSet; 60 FontData* primaryFont(const FontDescription& desc) const; 61 mutable Vector<FontData*> m_fontList; 61 62 #endif 62 63 -
trunk/WebCore/platform/FontPlatformData.h
r13329 r14216 24 24 #ifndef FontPlatformData_H 25 25 #define FontPlatformData_H 26 27 #ifdef __APPLE__ 28 29 #ifdef __OBJC__ 30 @class NSFont; 31 #else 32 class NSFont; 33 #endif 34 35 namespace WebCore { 36 37 struct FontPlatformData { 38 NSFont *font; 39 bool syntheticBold; 40 bool syntheticOblique; 41 bool forPrinter; 42 }; 43 44 } 45 46 #else 26 47 27 48 #include <kxmlcore/Noncopyable.h> … … 61 82 62 83 #endif 84 85 #endif -
trunk/WebCore/platform/mac/FontData.mm
r14184 r14216 29 29 30 30 #import "config.h" 31 #import "WebTextRenderer.h" 31 #import "FontData.h" 32 #import "Color.h" 32 33 #import "WebCoreTextRenderer.h" 33 34 … … 99 100 typedef struct GlyphEntry { 100 101 ATSGlyphRef glyph; 101 WebTextRenderer*renderer;102 FontData *renderer; 102 103 } GlyphEntry; 103 104 … … 110 111 111 112 typedef struct WidthIterator { 112 WebTextRenderer*renderer;113 FontData *renderer; 113 114 const WebCoreTextRun *run; 114 115 const WebCoreTextStyle *style; … … 126 127 const WebCoreTextStyle *style; 127 128 ATSUTextLayout layout; 128 WebTextRenderer**renderers;129 FontData **renderers; 129 130 UniChar *charBuffer; 130 131 bool hasSyntheticBold; … … 133 134 } ATSULayoutParameters; 134 135 135 static WebTextRenderer *rendererForAlternateFont(WebTextRenderer *, WebCoreFont);136 137 static WidthMap *extendWidthMap( WebTextRenderer*, ATSGlyphRef);138 static ATSGlyphRef extendGlyphMap( WebTextRenderer*, UChar32);139 static void updateGlyphMapEntry( WebTextRenderer *, UChar32, ATSGlyphRef, WebTextRenderer*substituteRenderer);136 static FontData *rendererForAlternateFont(FontData *, FontPlatformData); 137 138 static WidthMap *extendWidthMap(FontData *, ATSGlyphRef); 139 static ATSGlyphRef extendGlyphMap(FontData *, UChar32); 140 static void updateGlyphMapEntry(FontData *, UChar32, ATSGlyphRef, FontData *substituteRenderer); 140 141 141 142 static void freeWidthMap(WidthMap *); 142 143 static void freeGlyphMap(GlyphMap *); 143 static inline ATSGlyphRef glyphForCharacter( WebTextRenderer**, UChar32);144 static inline ATSGlyphRef glyphForCharacter(FontData **, UChar32); 144 145 145 146 // Measuring runs. 146 static float CG_floatWidthForRun( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *,147 float *widthBuffer, WebTextRenderer**rendererBuffer, CGGlyph *glyphBuffer, float *startPosition, int *numGlyphsResult);148 static float ATSU_floatWidthForRun( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *);147 static float CG_floatWidthForRun(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *, 148 float *widthBuffer, FontData **rendererBuffer, CGGlyph *glyphBuffer, float *startPosition, int *numGlyphsResult); 149 static float ATSU_floatWidthForRun(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *); 149 150 150 151 // Drawing runs. 151 static void CG_draw( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *);152 static void ATSU_draw( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *);152 static void CG_draw(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *); 153 static void ATSU_draw(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *); 153 154 154 155 // Selection point detection in runs. 155 static int CG_pointToOffset( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *,156 static int CG_pointToOffset(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *, 156 157 int x, bool includePartialGlyphs); 157 static int ATSU_pointToOffset( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *,158 static int ATSU_pointToOffset(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *, 158 159 int x, bool includePartialGlyphs); 159 160 160 161 // Selection rect. 161 static NSRect CG_selectionRect( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *);162 static NSRect ATSU_selectionRect( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *);162 static NSRect CG_selectionRect(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *); 163 static NSRect ATSU_selectionRect(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *); 163 164 164 165 // Drawing highlight. 165 static void CG_drawHighlight( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *);166 static void ATSU_drawHighlight( WebTextRenderer*, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *);167 168 static bool setUpFont( WebTextRenderer*);166 static void CG_drawHighlight(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *); 167 static void ATSU_drawHighlight(FontData *, const WebCoreTextRun *, const WebCoreTextStyle *, const WebCoreTextGeometry *); 168 169 static bool setUpFont(FontData *); 169 170 170 171 // Iterator functions 171 static void initializeWidthIterator(WidthIterator *iterator, WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style);172 static unsigned advanceWidthIterator(WidthIterator *iterator, unsigned offset, float *widths, WebTextRenderer**renderersUsed, ATSGlyphRef *glyphsUsed);172 static void initializeWidthIterator(WidthIterator *iterator, FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style); 173 static unsigned advanceWidthIterator(WidthIterator *iterator, unsigned offset, float *widths, FontData **renderersUsed, ATSGlyphRef *glyphsUsed); 173 174 174 175 static bool fillStyleWithAttributes(ATSUStyle style, NSFont *theFont); … … 179 180 #endif 180 181 181 static void createATSULayoutParameters(ATSULayoutParameters *params, WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style);182 static void createATSULayoutParameters(ATSULayoutParameters *params, FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style); 182 183 static void disposeATSULayoutParameters(ATSULayoutParameters *params); 183 184 … … 208 209 } 209 210 210 void WebCoreInitializeFont( WebCoreFont*font)211 void WebCoreInitializeFont(FontPlatformData *font) 211 212 { 212 213 font->font = nil; … … 242 243 void WebCoreInitializeEmptyTextGeometry(WebCoreTextGeometry *geometry) 243 244 { 244 geometry->point.x = 0;245 geometry->point.y = 0;246 245 geometry->useFontMetricsForSelectionYAndHeight = YES; 247 246 } … … 249 248 // Map utility functions 250 249 251 static inline WebGlyphWidth widthForGlyph( WebTextRenderer*renderer, ATSGlyphRef glyph)250 static inline WebGlyphWidth widthForGlyph(FontData *renderer, ATSGlyphRef glyph) 252 251 { 253 252 WidthMap *map; … … 293 292 const WebCoreTextRun *run = params->run; 294 293 const UniChar *characters = run->characters + run->from; 295 WebTextRenderer**renderers = params->renderers + run->from;296 WebTextRenderer*renderer;297 WebTextRenderer*lastRenderer = 0;294 FontData **renderers = params->renderers + run->from; 295 FontData *renderer; 296 FontData *lastRenderer = 0; 298 297 UniChar ch, nextCh; 299 298 ByteCount offset = layoutRecords[0].originalOffset; … … 397 396 } 398 397 399 WebTextRenderer::WebTextRenderer(const WebCoreFont& f)398 FontData::FontData(const FontPlatformData& f) 400 399 :m_styleGroup(0), m_font(f), m_characterToGlyphMap(0), m_glyphToWidthMap(0), m_treatAsFixedPitch(false), 401 400 m_smallCapsRenderer(0), m_ATSUStyleInitialized(false), m_ATSUMirrors(false) … … 489 488 } 490 489 491 WebTextRenderer::~WebTextRenderer()490 FontData::~FontData() 492 491 { 493 492 if (m_styleGroup) … … 506 505 } 507 506 508 float WebTextRenderer::xHeight() const507 float FontData::xHeight() const 509 508 { 510 509 // Measure the actual character "x", because AppKit synthesizes X height rather than getting it from the font. 511 510 // Unfortunately, NSFont will round this for us so we don't quite get the right value. 512 WebTextRenderer*renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:m_font];511 FontData *renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:m_font]; 513 512 NSGlyph xGlyph = glyphForCharacter(&renderer, 'x'); 514 513 if (xGlyph) { … … 524 523 } 525 524 526 void WebTextRenderer::drawRun(const WebCoreTextRun* run, const WebCoreTextStyle* style, const WebCoreTextGeometry* geometry)525 void FontData::drawRun(const WebCoreTextRun* run, const WebCoreTextStyle* style, const WebCoreTextGeometry* geometry) 527 526 { 528 527 if (shouldUseATSU(run)) … … 532 531 } 533 532 534 float WebTextRenderer::floatWidthForRun(const WebCoreTextRun* run, const WebCoreTextStyle* style)533 float FontData::floatWidthForRun(const WebCoreTextRun* run, const WebCoreTextStyle* style) 535 534 { 536 535 if (shouldUseATSU(run)) … … 562 561 } 563 562 564 void WebTextRenderer::drawLineForCharacters(const FloatPoint& point, float yOffset, int width, const Color& color, float thickness)563 void FontData::drawLineForCharacters(const FloatPoint& point, float yOffset, int width, const Color& color, float thickness) 565 564 { 566 565 // Note: This function assumes that point.x and point.y are integers (and that's currently always the case). … … 609 608 } 610 609 611 FloatRect WebTextRenderer::selectionRectForRun(const WebCoreTextRun* run, const WebCoreTextStyle* style, const WebCoreTextGeometry* geometry)610 FloatRect FontData::selectionRectForRun(const WebCoreTextRun* run, const WebCoreTextStyle* style, const WebCoreTextGeometry* geometry) 612 611 { 613 612 if (shouldUseATSU(run)) … … 617 616 } 618 617 619 void WebTextRenderer::drawHighlightForRun(const WebCoreTextRun* run, const WebCoreTextStyle* style, const WebCoreTextGeometry* geometry)618 void FontData::drawHighlightForRun(const WebCoreTextRun* run, const WebCoreTextStyle* style, const WebCoreTextGeometry* geometry) 620 619 { 621 620 if (shouldUseATSU(run)) … … 625 624 } 626 625 627 void WebTextRenderer::drawLineForMisspelling(const FloatPoint& point, int width)626 void FontData::drawLineForMisspelling(const FloatPoint& point, int width) 628 627 { 629 628 // Constants for pattern color … … 672 671 } 673 672 674 int WebTextRenderer::pointToOffset(const WebCoreTextRun* run, const WebCoreTextStyle* style, int x, bool includePartialGlyphs)673 int FontData::pointToOffset(const WebCoreTextRun* run, const WebCoreTextStyle* style, int x, bool includePartialGlyphs) 675 674 { 676 675 if (shouldUseATSU(run)) … … 679 678 } 680 679 681 bool WebTextRenderer::gAlwaysUseATSU = false;682 683 void WebTextRenderer::setAlwaysUseATSU(bool alwaysUse)680 bool FontData::gAlwaysUseATSU = false; 681 682 void FontData::setAlwaysUseATSU(bool alwaysUse) 684 683 { 685 684 gAlwaysUseATSU = alwaysUse; 686 685 } 687 686 688 static WebTextRenderer *getSmallCapsRenderer(WebTextRenderer*renderer)687 static FontData *getSmallCapsRenderer(FontData *renderer) 689 688 { 690 689 if (!renderer->m_smallCapsRenderer) { 691 690 NS_DURING 692 691 float size = [renderer->m_font.font pointSize] * SMALLCAPS_FONTSIZE_MULTIPLIER; 693 WebCoreFontsmallCapsFont;692 FontPlatformData smallCapsFont; 694 693 WebCoreInitializeFont(&smallCapsFont); 695 694 smallCapsFont.font = [[NSFontManager sharedFontManager] convertFont:renderer->m_font.font toSize:size]; … … 708 707 } 709 708 710 static NSFont *findSubstituteFont( WebTextRenderer*renderer, NSString *string, NSString **families)709 static NSFont *findSubstituteFont(FontData *renderer, NSString *string, NSString **families) 711 710 { 712 711 NSFont *substituteFont = nil; … … 754 753 } 755 754 756 static WebTextRenderer *rendererForAlternateFont(WebTextRenderer *renderer, WebCoreFontalternateFont)755 static FontData *rendererForAlternateFont(FontData *renderer, FontPlatformData alternateFont) 757 756 { 758 757 if (!alternateFont.font) … … 774 773 } 775 774 776 static WebTextRenderer *findSubstituteRenderer(WebTextRenderer*renderer, const unichar *characters, int numCharacters, NSString **families)777 { 778 WebCoreFontsubstituteFont;775 static FontData *findSubstituteRenderer(FontData *renderer, const unichar *characters, int numCharacters, NSString **families) 776 { 777 FontPlatformData substituteFont; 779 778 WebCoreInitializeFont(&substituteFont); 780 779 NSString *string = [[NSString alloc] initWithCharactersNoCopy:(unichar *)characters length: numCharacters freeWhenDone: NO]; … … 787 786 // If the font is monospace or fake monospace we ceil to ensure that 788 787 // every character and the space are the same width. Otherwise we round. 789 static bool computeWidthForSpace( WebTextRenderer*renderer)788 static bool computeWidthForSpace(FontData *renderer) 790 789 { 791 790 renderer->m_spaceGlyph = extendGlyphMap(renderer, SPACE); … … 803 802 } 804 803 805 static bool setUpFont( WebTextRenderer*renderer)804 static bool setUpFont(FontData *renderer) 806 805 { 807 806 renderer->m_font.font = renderer->m_font.forPrinter ? [renderer->m_font.font printerFont] : [renderer->m_font.font screenFont]; … … 907 906 } 908 907 909 static void CG_drawHighlight( WebTextRenderer*renderer, const WebCoreTextRun * run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry)908 static void CG_drawHighlight(FontData *renderer, const WebCoreTextRun * run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry) 910 909 { 911 910 if (run->length == 0) … … 919 918 } 920 919 921 static NSRect CG_selectionRect( WebTextRenderer*renderer, const WebCoreTextRun * run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry)920 static NSRect CG_selectionRect(FontData *renderer, const WebCoreTextRun * run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry) 922 921 { 923 922 float yPos = geometry->useFontMetricsForSelectionYAndHeight 924 ? geometry->point.y - renderer->ascent() - (renderer->lineGap() / 2) : geometry->selectionY;923 ? geometry->point.y() - renderer->ascent() - (renderer->lineGap() / 2) : geometry->selectionY; 925 924 float height = geometry->useFontMetricsForSelectionYAndHeight 926 925 ? renderer->lineSpacing() : geometry->selectionHeight; … … 941 940 advanceWidthIterator(&it, run->length, 0, 0, 0); 942 941 float totalWidth = it.runWidthSoFar; 943 return NSMakeRect(geometry->point.x + floorf(totalWidth - afterWidth), yPos, roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), height);942 return NSMakeRect(geometry->point.x() + floorf(totalWidth - afterWidth), yPos, roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), height); 944 943 } else { 945 return NSMakeRect(geometry->point.x + floorf(beforeWidth), yPos, roundf(afterWidth) - floorf(beforeWidth), height);946 } 947 } 948 949 static void CG_draw( WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry)944 return NSMakeRect(geometry->point.x() + floorf(beforeWidth), yPos, roundf(afterWidth) - floorf(beforeWidth), height); 945 } 946 } 947 948 static void CG_draw(FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry) 950 949 { 951 950 float *widthBuffer, localWidthBuffer[LOCAL_BUFFER_SIZE]; 952 951 CGGlyph *glyphBuffer, localGlyphBuffer[LOCAL_BUFFER_SIZE]; 953 WebTextRenderer**rendererBuffer, *localRendererBuffer[LOCAL_BUFFER_SIZE];952 FontData **rendererBuffer, *localRendererBuffer[LOCAL_BUFFER_SIZE]; 954 953 CGSize *advances, localAdvanceBuffer[LOCAL_BUFFER_SIZE]; 955 954 int numGlyphs = 0, i; … … 964 963 widthBuffer = new float[length * MAX_GLYPH_EXPANSION]; 965 964 glyphBuffer = new CGGlyph[length * MAX_GLYPH_EXPANSION]; 966 rendererBuffer = new WebTextRenderer*[length * MAX_GLYPH_EXPANSION];965 rendererBuffer = new FontData*[length * MAX_GLYPH_EXPANSION]; 967 966 } else { 968 967 advances = localAdvanceBuffer; … … 986 985 // Calculate the starting point of the glyphs to be displayed by adding 987 986 // all the advances up to the first glyph. 988 startX += geometry->point.x ;987 startX += geometry->point.x(); 989 988 990 989 if (style->backgroundColor != nil) … … 1007 1006 advances[end] = aswap1; 1008 1007 1009 WebTextRenderer*rswap1 = rendererBuffer[i];1010 WebTextRenderer*rswap2 = rendererBuffer[end];1008 FontData *rswap1 = rendererBuffer[i]; 1009 FontData *rswap2 = rendererBuffer[end]; 1011 1010 rendererBuffer[i] = rswap2; 1012 1011 rendererBuffer[end] = rswap1; … … 1015 1014 1016 1015 // Draw each contiguous run of glyphs that use the same renderer. 1017 WebTextRenderer*currentRenderer = rendererBuffer[0];1016 FontData *currentRenderer = rendererBuffer[0]; 1018 1017 float nextX = startX; 1019 1018 int lastFrom = 0; 1020 1019 int nextGlyph = 0; 1021 1020 while (nextGlyph < numGlyphs) { 1022 WebTextRenderer*nextRenderer = rendererBuffer[nextGlyph];1021 FontData *nextRenderer = rendererBuffer[nextGlyph]; 1023 1022 if (nextRenderer != currentRenderer) { 1024 1023 drawGlyphs(currentRenderer->m_font.font, style->textColor, &glyphBuffer[lastFrom], &advances[lastFrom], 1025 startX, geometry->point.y , nextGlyph - lastFrom,1024 startX, geometry->point.y(), nextGlyph - lastFrom, 1026 1025 currentRenderer->m_syntheticBoldOffset, currentRenderer->m_font.syntheticOblique); 1027 1026 lastFrom = nextGlyph; … … 1033 1032 } 1034 1033 drawGlyphs(currentRenderer->m_font.font, style->textColor, &glyphBuffer[lastFrom], &advances[lastFrom], 1035 startX, geometry->point.y , nextGlyph - lastFrom,1034 startX, geometry->point.y(), nextGlyph - lastFrom, 1036 1035 currentRenderer->m_syntheticBoldOffset, currentRenderer->m_font.syntheticOblique); 1037 1036 … … 1044 1043 } 1045 1044 1046 static float CG_floatWidthForRun( WebTextRenderer *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, float *widthBuffer, WebTextRenderer**rendererBuffer, CGGlyph *glyphBuffer, float *startPosition, int *numGlyphsResult)1045 static float CG_floatWidthForRun(FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, float *widthBuffer, FontData **rendererBuffer, CGGlyph *glyphBuffer, float *startPosition, int *numGlyphsResult) 1047 1046 { 1048 1047 WidthIterator it; … … 1073 1072 } 1074 1073 1075 static void updateGlyphMapEntry( WebTextRenderer *renderer, UChar32 c, ATSGlyphRef glyph, WebTextRenderer*substituteRenderer)1074 static void updateGlyphMapEntry(FontData *renderer, UChar32 c, ATSGlyphRef glyph, FontData *substituteRenderer) 1076 1075 { 1077 1076 GlyphMap *map; … … 1090 1089 } 1091 1090 1092 static ATSGlyphRef extendGlyphMap( WebTextRenderer*renderer, UChar32 c)1091 static ATSGlyphRef extendGlyphMap(FontData *renderer, UChar32 c) 1093 1092 { 1094 1093 GlyphMap *map = new GlyphMap; … … 1186 1185 } 1187 1186 1188 static WidthMap *extendWidthMap( WebTextRenderer*renderer, ATSGlyphRef glyph)1187 static WidthMap *extendWidthMap(FontData *renderer, ATSGlyphRef glyph) 1189 1188 { 1190 1189 WidthMap *map = new WidthMap; … … 1230 1229 } 1231 1230 1232 static void initializeATSUStyle( WebTextRenderer*renderer)1231 static void initializeATSUStyle(FontData *renderer) 1233 1232 { 1234 1233 // The two NSFont calls in this method (pointSize and _atsFontID) do not raise exceptions. … … 1283 1282 } 1284 1283 1285 static void createATSULayoutParameters(ATSULayoutParameters *params, WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style)1284 static void createATSULayoutParameters(ATSULayoutParameters *params, FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style) 1286 1285 { 1287 1286 params->run = run; … … 1289 1288 // FIXME: It is probably best to always allocate a buffer for RTL, since even if for this 1290 1289 // renderer ATSUMirrors is true, for a substitute renderer it might be false. 1291 WebTextRenderer** renderers = new WebTextRenderer*[run->length];1290 FontData** renderers = new FontData*[run->length]; 1292 1291 params->renderers = renderers; 1293 1292 UniChar *charBuffer = (UniChar*)((style->smallCaps || (style->rtl && !renderer->m_ATSUMirrors)) ? new UniChar[run->length] : 0); … … 1352 1351 UniCharCount substituteLength; 1353 1352 UniCharArrayOffset lastOffset; 1354 WebTextRenderer*substituteRenderer = 0;1353 FontData *substituteRenderer = 0; 1355 1354 1356 1355 while (substituteOffset < runTo) { … … 1372 1371 bool isSmallCap = false; 1373 1372 UniCharArrayOffset firstSmallCap = 0; 1374 WebTextRenderer*r = renderer;1373 FontData *r = renderer; 1375 1374 UniCharArrayOffset i; 1376 1375 for (i = lastOffset; ; i++) { … … 1434 1433 } 1435 1434 1436 static ATSTrapezoid getTextBounds( WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, NSPoint p)1435 static ATSTrapezoid getTextBounds(FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, NSPoint p) 1437 1436 { 1438 1437 OSStatus status; … … 1459 1458 } 1460 1459 1461 static float ATSU_floatWidthForRun( WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style)1460 static float ATSU_floatWidthForRun(FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style) 1462 1461 { 1463 1462 ATSTrapezoid oGlyphBounds = getTextBounds(renderer, run, style, NSZeroPoint); … … 1492 1491 } 1493 1492 1494 static void ATSU_drawHighlight( WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry)1493 static void ATSU_drawHighlight(FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry) 1495 1494 { 1496 1495 // The only Cocoa calls made here are to NSColor and NSBezierPath, and they do not raise exceptions. … … 1505 1504 } 1506 1505 1507 static NSRect ATSU_selectionRect( WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry)1506 static NSRect ATSU_selectionRect(FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry) 1508 1507 { 1509 1508 int from = run->from; … … 1544 1543 float afterWidth = MAX(FixedToFloat(firstGlyphBounds.lowerRight.x), FixedToFloat(firstGlyphBounds.upperRight.x)); 1545 1544 float yPos = geometry->useFontMetricsForSelectionYAndHeight 1546 ? geometry->point.y - renderer->ascent() : geometry->selectionY;1545 ? geometry->point.y() - renderer->ascent() : geometry->selectionY; 1547 1546 float height = geometry->useFontMetricsForSelectionYAndHeight 1548 1547 ? renderer->lineSpacing() : geometry->selectionHeight; 1549 1548 1550 NSRect rect = NSMakeRect(geometry->point.x + floorf(beforeWidth), yPos, roundf(afterWidth) - floorf(beforeWidth), height);1549 NSRect rect = NSMakeRect(geometry->point.x() + floorf(beforeWidth), yPos, roundf(afterWidth) - floorf(beforeWidth), height); 1551 1550 1552 1551 if (style->directionalOverride) … … 1557 1556 1558 1557 1559 static void ATSU_draw( WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry)1558 static void ATSU_draw(FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, const WebCoreTextGeometry *geometry) 1560 1559 { 1561 1560 // The only Cocoa calls made here are to NSColor and NSGraphicsContext, and they do not raise exceptions. … … 1596 1595 NSGraphicsContext *gContext = [NSGraphicsContext currentContext]; 1597 1596 CGContextRef context = (CGContextRef)[gContext graphicsPort]; 1598 CGContextTranslateCTM(context, geometry->point.x , geometry->point.y);1597 CGContextTranslateCTM(context, geometry->point.x(), geometry->point.y()); 1599 1598 bool flipped = [gContext isFlipped]; 1600 1599 if (!flipped) … … 1609 1608 if (!flipped) 1610 1609 CGContextScaleCTM(context, 1.0, -1.0); 1611 CGContextTranslateCTM(context, -geometry->point.x , -geometry->point.y);1610 CGContextTranslateCTM(context, -geometry->point.x(), -geometry->point.y()); 1612 1611 1613 1612 if (status != noErr) { … … 1622 1621 } 1623 1622 1624 static int ATSU_pointToOffset( WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style,1623 static int ATSU_pointToOffset(FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, 1625 1624 int x, bool includePartialGlyphs) 1626 1625 { … … 1663 1662 { 1664 1663 float widths[MAX_GLYPH_EXPANSION]; 1665 WebTextRenderer*renderers[MAX_GLYPH_EXPANSION];1664 FontData *renderers[MAX_GLYPH_EXPANSION]; 1666 1665 ATSGlyphRef glyphs[MAX_GLYPH_EXPANSION]; 1667 1666 unsigned numGlyphs = advanceWidthIterator(iterator, iterator->currentCharacter + 1, widths, renderers, glyphs); … … 1674 1673 } 1675 1674 1676 static int CG_pointToOffset( WebTextRenderer*renderer, const WebCoreTextRun * run, const WebCoreTextStyle *style,1675 static int CG_pointToOffset(FontData *renderer, const WebCoreTextRun * run, const WebCoreTextStyle *style, 1677 1676 int x, bool includePartialGlyphs) 1678 1677 { … … 1740 1739 } 1741 1740 1742 static inline ATSGlyphRef glyphForCharacter( WebTextRenderer**renderer, UChar32 c)1741 static inline ATSGlyphRef glyphForCharacter(FontData **renderer, UChar32 c) 1743 1742 { 1744 1743 // this loop is hot, so it is written to avoid LSU stalls … … 1758 1757 } 1759 1758 1760 static void initializeWidthIterator(WidthIterator *iterator, WebTextRenderer*renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style)1759 static void initializeWidthIterator(WidthIterator *iterator, FontData *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style) 1761 1760 { 1762 1761 iterator->renderer = renderer; … … 1817 1816 } 1818 1817 1819 static unsigned advanceWidthIterator(WidthIterator *iterator, unsigned offset, float *widths, WebTextRenderer**renderersUsed, ATSGlyphRef *glyphsUsed)1818 static unsigned advanceWidthIterator(WidthIterator *iterator, unsigned offset, float *widths, FontData **renderersUsed, ATSGlyphRef *glyphsUsed) 1820 1819 { 1821 1820 const WebCoreTextRun *run = iterator->run; … … 1867 1866 } 1868 1867 1869 WebTextRenderer*renderer = iterator->renderer;1868 FontData *renderer = iterator->renderer; 1870 1869 1871 1870 if (needCharTransform) { … … 1902 1901 // string. If one isn't found we end up drawing and measuring the 0 glyph, usually a box. 1903 1902 if (glyph == 0 && style->attemptFontSubstitution) { 1904 WebTextRenderer*substituteRenderer = findSubstituteRenderer(renderer, cp, clusterLength, style->families);1903 FontData *substituteRenderer = findSubstituteRenderer(renderer, cp, clusterLength, style->families); 1905 1904 if (substituteRenderer) { 1906 1905 WebCoreTextRun clusterRun = { cp, clusterLength, 0, clusterLength }; … … 1912 1911 int cNumGlyphs; 1913 1912 float localWidthBuffer[MAX_GLYPH_EXPANSION]; 1914 WebTextRenderer*localRendererBuffer[MAX_GLYPH_EXPANSION];1913 FontData *localRendererBuffer[MAX_GLYPH_EXPANSION]; 1915 1914 ATSGlyphRef localGlyphBuffer[MAX_GLYPH_EXPANSION]; 1916 1915 CG_floatWidthForRun(substituteRenderer, &clusterRun, &clusterStyle, localWidthBuffer, localRendererBuffer, localGlyphBuffer, 0, &cNumGlyphs); -
trunk/WebCore/platform/mac/FontMac.mm
r14149 r14216 31 31 #import "FoundationExtras.h" 32 32 33 #import "Font DataSet.h"33 #import "FontFallbackList.h" 34 34 #import "GraphicsContext.h" 35 35 #import "KWQKHTMLSettings.h" 36 36 37 #import " WebTextRenderer.h"37 #import "FontData.h" 38 38 #import "WebTextRendererFactory.h" 39 39 … … 42 42 namespace WebCore { 43 43 44 Font DataSet::FontDataSet()45 :m_pitch(UnknownPitch), m_ renderer(nil)46 { 47 m_ webCoreFont.font = nil;48 } 49 50 Font DataSet::~FontDataSet()51 { 52 KWQRelease(m_ webCoreFont.font);53 } 54 55 const WebCoreFont& FontDataSet::getWebCoreFont(const FontDescription& fontDescription) const56 { 57 if (!m_ webCoreFont.font) {44 FontFallbackList::FontFallbackList() 45 :m_pitch(UnknownPitch), m_font(nil) 46 { 47 m_platformFont.font = nil; 48 } 49 50 FontFallbackList::~FontFallbackList() 51 { 52 KWQRelease(m_platformFont.font); 53 } 54 55 const FontPlatformData& FontFallbackList::platformFont(const FontDescription& fontDescription) const 56 { 57 if (!m_platformFont.font) { 58 58 CREATE_FAMILY_ARRAY(fontDescription, families); 59 59 BEGIN_BLOCK_OBJC_EXCEPTIONS; … … 63 63 if (fontDescription.weight() >= WebCore::cBoldWeight) 64 64 traits |= NSBoldFontMask; 65 m_ webCoreFont = [[WebTextRendererFactory sharedFactory]65 m_platformFont = [[WebTextRendererFactory sharedFactory] 66 66 fontWithFamilies:families traits:traits size:fontDescription.computedPixelSize()]; 67 KWQRetain(m_ webCoreFont.font);68 m_ webCoreFont.forPrinter = fontDescription.usePrinterFont();67 KWQRetain(m_platformFont.font); 68 m_platformFont.forPrinter = fontDescription.usePrinterFont(); 69 69 END_BLOCK_OBJC_EXCEPTIONS; 70 70 } 71 return m_webCoreFont; 72 } 73 74 WebTextRenderer* FontDataSet::getRenderer(const FontDescription& fontDescription) 75 { 76 if (!m_renderer) 77 m_renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:getWebCoreFont(fontDescription)]; 78 return m_renderer; 79 } 80 81 void FontDataSet::determinePitch(const FontDescription& fontDescription) const { 71 return m_platformFont; 72 } 73 74 FontData* FontFallbackList::primaryFont(const FontDescription& fontDescription) const 75 { 76 if (!m_font) 77 m_font = [[WebTextRendererFactory sharedFactory] rendererWithFont:platformFont(fontDescription)]; 78 return m_font; 79 } 80 81 void FontFallbackList::determinePitch(const FontDescription& fontDescription) const 82 { 82 83 BEGIN_BLOCK_OBJC_EXCEPTIONS; 83 if ([[WebTextRendererFactory sharedFactory] isFontFixedPitch: getWebCoreFont(fontDescription)])84 if ([[WebTextRendererFactory sharedFactory] isFontFixedPitch:platformFont(fontDescription)]) 84 85 m_pitch = FixedPitch; 85 86 else … … 88 89 } 89 90 90 void Font DataSet::invalidate()91 { 92 m_ renderer= 0;93 KWQRelease(m_ webCoreFont.font);94 m_ webCoreFont.font = nil;91 void FontFallbackList::invalidate() 92 { 93 m_font = 0; 94 KWQRelease(m_platformFont.font); 95 m_platformFont.font = nil; 95 96 m_pitch = UnknownPitch; 96 97 } 97 98 98 const WebCoreFont& Font::getWebCoreFont() const 99 { 100 return m_dataSet->getWebCoreFont(fontDescription()); 101 } 102 103 int Font::ascent() const 104 { 105 assert(m_dataSet); 106 return m_dataSet->getRenderer(fontDescription())->ascent(); 107 } 108 109 int Font::descent() const 110 { 111 assert(m_dataSet); 112 return m_dataSet->getRenderer(fontDescription())->descent(); 113 } 114 115 int Font::lineSpacing() const 116 { 117 assert(m_dataSet); 118 return m_dataSet->getRenderer(fontDescription())->lineSpacing(); 119 } 120 121 float Font::xHeight() const 122 { 123 assert(m_dataSet); 124 return m_dataSet->getRenderer(fontDescription())->xHeight(); 125 } 126 127 bool Font::isFixedPitch() const 128 { 129 assert(m_dataSet); 130 return m_dataSet->isFixedPitch(fontDescription()); 99 const FontPlatformData& Font::platformFont() const 100 { 101 return m_fontList->platformFont(fontDescription()); 131 102 } 132 103 … … 135 106 bool rtl, bool visuallyOrdered, int from, int to) const 136 107 { 137 assert(m_ dataSet);108 assert(m_fontList); 138 109 int len = std::min(slen - pos, l); 139 110 … … 164 135 geometry.selectionHeight = h; 165 136 geometry.useFontMetricsForSelectionYAndHeight = false; 166 return enclosingIntRect(m_ dataSet->getRenderer(fontDescription())->selectionRectForRun(&run, &style, &geometry));137 return enclosingIntRect(m_fontList->primaryFont(fontDescription())->selectionRectForRun(&run, &style, &geometry)); 167 138 } 168 139 … … 197 168 WebCoreInitializeEmptyTextGeometry(&geometry); 198 169 geometry.point = point; 199 m_ dataSet->getRenderer(fontDescription())->drawRun(&run, &style, &geometry);170 m_fontList->primaryFont(fontDescription())->drawRun(&run, &style, &geometry); 200 171 } 201 172 … … 234 205 geometry.selectionHeight = h; 235 206 geometry.useFontMetricsForSelectionYAndHeight = false; 236 m_ dataSet->getRenderer(fontDescription())->drawHighlightForRun(&run, &style, &geometry);207 m_fontList->primaryFont(fontDescription())->drawHighlightForRun(&run, &style, &geometry); 237 208 } 238 209 239 210 void Font::drawLineForText(GraphicsContext* context, const IntPoint& point, int yOffset, int width) const 240 211 { 241 m_ dataSet->getRenderer(fontDescription())->drawLineForCharacters(point, yOffset, width, context->pen().color(), context->pen().width());212 m_fontList->primaryFont(fontDescription())->drawLineForCharacters(point, yOffset, width, context->pen().color(), context->pen().width()); 242 213 } 243 214 244 215 void Font::drawLineForMisspelling(GraphicsContext* context, const IntPoint& point, int width) const 245 216 { 246 m_ dataSet->getRenderer(fontDescription())->drawLineForMisspelling(point, width);217 m_fontList->primaryFont(fontDescription())->drawLineForMisspelling(point, width); 247 218 } 248 219 249 220 int Font::misspellingLineThickness(GraphicsContext* context) const 250 221 { 251 return m_ dataSet->getRenderer(fontDescription())->misspellingLineThickness();222 return m_fontList->primaryFont(fontDescription())->misspellingLineThickness(); 252 223 } 253 224 254 225 float Font::floatWidth(const QChar* uchars, int slen, int pos, int len, int tabWidth, int xpos, bool runRounding) const 255 226 { 256 assert(m_ dataSet);227 assert(m_fontList); 257 228 CREATE_FAMILY_ARRAY(fontDescription(), families); 258 229 … … 270 241 style.applyRunRounding = runRounding; 271 242 272 return m_ dataSet->getRenderer(fontDescription())->floatWidthForRun(&run, &style);243 return m_fontList->primaryFont(fontDescription())->floatWidthForRun(&run, &style); 273 244 } 274 245 275 246 int Font::checkSelectionPoint(const QChar* s, int slen, int pos, int len, int toAdd, int tabWidth, int xpos, int x, TextDirection d, bool visuallyOrdered, bool includePartialGlyphs) const 276 247 { 277 assert(m_ dataSet);248 assert(m_fontList); 278 249 CREATE_FAMILY_ARRAY(fontDescription(), families); 279 250 … … 293 264 style.directionalOverride = visuallyOrdered; 294 265 295 return m_ dataSet->getRenderer(fontDescription())->pointToOffset(&run, &style, x, includePartialGlyphs);296 } 297 298 } 266 return m_fontList->primaryFont(fontDescription())->pointToOffset(&run, &style, x, includePartialGlyphs); 267 } 268 269 } -
trunk/WebCore/platform/mac/WebCoreTextRenderer.mm
r14149 r14216 27 27 #import "WebCoreTextRenderer.h" 28 28 29 #import " WebTextRenderer.h"29 #import "FontData.h" 30 30 #import "WebTextRendererFactory.h" 31 31 … … 34 34 void WebCoreDrawTextAtPoint(const UniChar* buffer, unsigned length, NSPoint point, NSFont* font, NSColor* textColor) 35 35 { 36 WebCoreFontf;36 FontPlatformData f; 37 37 WebCoreInitializeFont(&f); 38 38 f.font = font; 39 WebTextRenderer* renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:f];39 FontData* renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:f]; 40 40 41 41 WebCoreTextRun run; … … 54 54 float WebCoreTextFloatWidth(const UniChar* buffer, unsigned length , NSFont* font) 55 55 { 56 WebCoreFontf;56 FontPlatformData f; 57 57 WebCoreInitializeFont(&f); 58 58 f.font = font; 59 WebTextRenderer* renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:f];59 FontData* renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:f]; 60 60 61 61 WebCoreTextRun run; … … 82 82 void WebCoreSetAlwaysUseATSU(bool useATSU) 83 83 { 84 WebTextRenderer::setAlwaysUseATSU(useATSU);84 FontData::setAlwaysUseATSU(useATSU); 85 85 } 86 86 -
trunk/WebCore/platform/mac/WebTextRendererFactory.h
r14149 r14216 60 60 #include <kxmlcore/HashMap.h> 61 61 62 struct WebCoreFont;63 64 62 namespace WebCore { 65 class WebTextRenderer; 63 class FontData; 64 struct FontPlatformData; 66 65 } 67 66 … … 70 69 @interface WebTextRendererFactory : NSObject 71 70 { 72 HashMap<NSFont*, WebCore:: WebTextRenderer*>* caches[WEB_TEXT_RENDERER_FACTORY_NUM_CACHES];71 HashMap<NSFont*, WebCore::FontData*>* caches[WEB_TEXT_RENDERER_FACTORY_NUM_CACHES]; 73 72 } 74 73 … … 76 75 + (WebTextRendererFactory *)sharedFactory; 77 76 78 - (WebCore Font)fontWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size;79 - (BOOL)isFontFixedPitch:(WebCore Font)font;77 - (WebCore::FontPlatformData)fontWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size; 78 - (BOOL)isFontFixedPitch:(WebCore::FontPlatformData)font; 80 79 81 80 - (void)clearCaches; … … 83 82 - (NSFont *)cachedFontFromFamily:(NSString *)family traits:(NSFontTraitMask)traits size:(float)size; 84 83 85 - (WebCore:: WebTextRenderer *)rendererWithFont:(WebCoreFont)font;84 - (WebCore::FontData *)rendererWithFont:(WebCore::FontPlatformData)font; 86 85 87 86 @end -
trunk/WebCore/platform/mac/WebTextRendererFactory.mm
r14179 r14216 29 29 #import "config.h" 30 30 #import "WebTextRendererFactory.h" 31 #import " WebTextRenderer.h"31 #import "FontData.h" 32 32 #import "WebCoreSystemInterface.h" 33 33 … … 198 198 } 199 199 200 - (BOOL)isFontFixedPitch:( WebCoreFont)font200 - (BOOL)isFontFixedPitch:(FontPlatformData)font 201 201 { 202 202 NSFont *f = font.font; … … 234 234 int i; 235 235 for (i = 0; i < WEB_TEXT_RENDERER_FACTORY_NUM_CACHES; ++i) 236 caches[i] = new HashMap<NSFont*, WebTextRenderer*>;236 caches[i] = new HashMap<NSFont*, FontData*>; 237 237 238 238 ASSERT(!sharedFactory); … … 251 251 } 252 252 253 - ( WebTextRenderer *)rendererWithFont:(WebCoreFont)font254 { 255 HashMap<NSFont*, WebTextRenderer*>* cache = caches[(font.syntheticBold << 2) | (font.syntheticOblique << 1) | font.forPrinter];256 WebTextRenderer*renderer = cache->get(font.font);253 - (FontData *)rendererWithFont:(FontPlatformData)font 254 { 255 HashMap<NSFont*, FontData*>* cache = caches[(font.syntheticBold << 2) | (font.syntheticOblique << 1) | font.forPrinter]; 256 FontData *renderer = cache->get(font.font); 257 257 if (!renderer) { 258 renderer = new WebTextRenderer(font);258 renderer = new FontData(font); 259 259 cache->set(font.font, renderer); 260 260 } … … 277 277 } 278 278 279 - ( WebCoreFont)fontWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size279 - (FontPlatformData)fontWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size 280 280 { 281 281 NSFont *font = nil; … … 322 322 actualTraits = [[NSFontManager sharedFontManager] traitsOfFont:font]; 323 323 324 WebCoreFontresult;324 FontPlatformData result; 325 325 result.font = font; 326 326 result.syntheticBold = (traits & NSBoldFontMask) && !(actualTraits & NSBoldFontMask); -
trunk/WebCore/platform/win/FontWin.cpp
r14215 r14216 29 29 #include <cairo-win32.h> 30 30 #include "FontData.h" 31 #include "Font DataSet.h"31 #include "FontFallbackList.h" 32 32 #include "GraphicsContext.h" 33 33 #include "IntRect.h" … … 102 102 } 103 103 104 Font DataSet::FontDataSet()104 FontFallbackList::FontFallbackList() 105 105 :m_pitch(UnknownPitch) 106 106 { … … 108 108 } 109 109 110 Font DataSet::~FontDataSet()111 { 112 deleteAllValues(m_font Set);113 } 114 115 void Font DataSet::determinePitch(const FontDescription& fontDescription) const110 FontFallbackList::~FontFallbackList() 111 { 112 deleteAllValues(m_fontList); 113 } 114 115 void FontFallbackList::determinePitch(const FontDescription& fontDescription) const 116 116 { 117 117 // FIXME: Implement this. … … 119 119 } 120 120 121 void Font DataSet::invalidate()121 void FontFallbackList::invalidate() 122 122 { 123 123 // Delete the Cairo fonts. 124 124 m_pitch = UnknownPitch; 125 deleteAllValues(m_fontSet); 126 } 127 128 FontData* FontDataSet::primaryFont(const FontDescription& fontDescription) const 129 { 130 if (!m_fontSet.isEmpty()) 131 return m_fontSet[0]; 125 deleteAllValues(m_fontList); 126 m_fontList.clear(); 127 } 128 129 FontData* FontFallbackList::primaryFont(const FontDescription& fontDescription) const 130 { 131 if (!m_fontList.isEmpty()) 132 return m_fontList[0]; 132 133 133 134 // We want to ensure that the primary Cairo font face exists. … … 139 140 FontData* font = getFontData(fontDescription, currFamily->family()); 140 141 if (font) { 141 m_font Set.append(font);142 m_fontList.append(font); 142 143 return font; 143 144 } … … 150 151 FontData* defaultFont = getFontData(fontDescription, AtomicString("Times New Roman")); 151 152 if (defaultFont) 152 m_font Set.append(defaultFont);153 m_fontList.append(defaultFont); 153 154 return defaultFont; 154 155 } … … 179 180 int tabWidth, int xpos, bool runRounding) const 180 181 { 181 FontData* font = m_ dataSet->primaryFont(fontDescription());182 FontData* font = m_fontList->primaryFont(fontDescription()); 182 183 if (!font) 183 184 return 0; … … 187 188 ReleaseDC(0, dc); 188 189 return runSize.width(); 189 }190 191 int Font::ascent() const192 {193 FontData* font = m_dataSet->primaryFont(fontDescription());194 if (font)195 return font->ascent();196 return 0;197 }198 199 int Font::descent() const200 {201 FontData* font = m_dataSet->primaryFont(fontDescription());202 if (font)203 return font->descent();204 return 0;205 }206 207 float Font::xHeight() const208 {209 FontData* font = m_dataSet->primaryFont(fontDescription());210 if (font)211 return font->xHeight();212 return 0;213 }214 215 int Font::lineSpacing() const216 {217 FontData* font = m_dataSet->primaryFont(fontDescription());218 if (font)219 return font->lineSpacing();220 return 0;221 }222 223 bool Font::isFixedPitch() const224 {225 return m_dataSet->isFixedPitch(fontDescription());226 190 } 227 191 … … 242 206 int toAdd, TextDirection d, bool visuallyOrdered) const 243 207 { 244 FontData* font = m_ dataSet->primaryFont(fontDescription());208 FontData* font = m_fontList->primaryFont(fontDescription()); 245 209 if (!font) 246 210 return; … … 275 239 return; 276 240 277 FontData* font = m_ dataSet->primaryFont(fontDescription());241 FontData* font = m_fontList->primaryFont(fontDescription()); 278 242 if (!font) 279 243 return; … … 293 257 int pos, int len, int toAdd, bool rtl, bool visuallyOrdered, int from, int to) const 294 258 { 295 FontData* font = m_ dataSet->primaryFont(fontDescription());259 FontData* font = m_fontList->primaryFont(fontDescription()); 296 260 if (!font) 297 261 return IntRect(); … … 309 273 TextDirection, bool visuallyOrdered, bool includePartialGlyphs) const 310 274 { 311 FontData* font = m_ dataSet->primaryFont(fontDescription());275 FontData* font = m_fontList->primaryFont(fontDescription()); 312 276 if (!font) 313 277 return 0;
Note: See TracChangeset
for help on using the changeset viewer.