Changeset 76442 in webkit
- Timestamp:
- Jan 22, 2011 3:46:23 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 68 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r76438 r76442 1 2011-01-21 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 Introduce FontMetrics abstraction 6 https://bugs.webkit.org/show_bug.cgi?id=51456 7 8 Encapsulate ascent/descent/lineHeight/lineGap methods in a single FontMetrics class, instead of 9 having to define them in both Font & SimpleFontData. Changed to store floating point values 10 as default, in order to get accurate information for small sized fonts. All these methods 11 now have floating-point and integer versions. Whenever an integer variant of these functions 12 is called, lroundf() is used to round the value. 13 14 This makes it possible to support small font-sizes for SVG in a follow-up patch, as well 15 as fixing rounding issues when using SVG Fonts. 16 17 Shouldn't affect existing tests. 18 19 * GNUmakefile.am: Add FontMetrics.h to build. 20 * WebCore.gypi: Ditto. 21 * WebCore.pro: Ditto. 22 * WebCore.vcproj/WebCore.vcproj: Ditto. 23 * WebCore.xcodeproj/project.pbxproj: Ditto. 24 * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp: Use style->fontMetrics() instead of style->font() to access the metrics. 25 (baselinePositionForAccessibilityRenderObject): 26 * css/CSSPrimitiveValue.cpp: 27 (WebCore::CSSPrimitiveValue::computeLengthDouble): 28 * html/canvas/CanvasRenderingContext2D.cpp: Ditto. 29 (WebCore::CanvasRenderingContext2D::drawTextInternal): 30 * inspector/InspectorController.cpp: Ditto. 31 (WebCore::InspectorController::drawElementTitle): 32 * platform/chromium/PopupMenuChromium.cpp: Ditto. 33 (WebCore::PopupListBox::paintRow): 34 (WebCore::PopupListBox::getRowHeight): 35 * platform/graphics/Font.h: Remove ascent/descent/height/lineGap/lineSpacing/xHeight/unitsPerEm accessor... 36 (WebCore::Font::fontMetrics): ... and only expose a single FontMetrics object here. 37 * platform/graphics/FontFastPath.cpp: Use fontMetrics() to query metrics information. 38 (WebCore::Font::emphasisMarkAscent): 39 (WebCore::Font::emphasisMarkDescent): 40 (WebCore::Font::emphasisMarkHeight): 41 (WebCore::Font::floatWidthForSimpleText): 42 * platform/graphics/FontMetrics.h: Added. 43 (WebCore::FontMetrics::FontMetrics): Creates a FontMetrics object, stored in SimpleFontData. 44 (WebCore::FontMetrics::unitsPerEm): Returns an unsigned describing the unitsPerEm. 45 (WebCore::FontMetrics::setUnitsPerEm): Sets the unitsPerEm value. 46 (WebCore::FontMetrics::floatAscent): Returns the stored m_ascent float. 47 (WebCore::FontMetrics::setAscent): Sets the stored m_ascent float. 48 (WebCore::FontMetrics::floatDescent): Returns the stored m_descent float. 49 (WebCore::FontMetrics::setDescent): Sets the stored m_descent float. 50 (WebCore::FontMetrics::floatHeight): Returns floatAscent() + floatDescent(). 51 (WebCore::FontMetrics::floatLineGap): Returns the stored m_lineGap float. 52 (WebCore::FontMetrics::setLineGap): Sets the stored m_lineGap float. 53 (WebCore::FontMetrics::floatLineSpacing): Returns the stored m_lineSpacing float. 54 (WebCore::FontMetrics::setLineSpacing): Sets the stored m_lineSpacing float. 55 (WebCore::FontMetrics::xHeight): Returns the stored m_xHeight float (no integer version available, hence no 'float' prefix). 56 (WebCore::FontMetrics::setXHeight): Sets the stored m_xHeight float. 57 (WebCore::FontMetrics::ascent): Returns a rounded version of ascent(). 58 (WebCore::FontMetrics::descent): Ditto (for descent). 59 (WebCore::FontMetrics::height): Returns ascent() + descent(). 60 (WebCore::FontMetrics::lineGap): Returns a rounded version of lineGap(). 61 (WebCore::FontMetrics::lineSpacing): Ditto (for lineSpacing). 62 (WebCore::FontMetrics::reset): Nulls all members, used only by the platform variants of SimpleFontData. 63 * platform/graphics/SimpleFontData.cpp: Adapt SVG Fonts code, to initialize the FontMetrics object, as the m_ascent/etc.. members are gone. 64 (WebCore::SimpleFontData::SimpleFontData): 65 (WebCore::SimpleFontData::initCharWidths): 66 * platform/graphics/SimpleFontData.h: Remove ascent/descent/height/lineSpacing/lineGap/xHeight/unitsPerEm accessors, and members, just store a FontMetrics object and expose it. 67 (WebCore::SimpleFontData::fontMetrics): 68 (WebCore::SimpleFontData::avgCharWidth): 69 * platform/graphics/chromium/FontChromiumWin.cpp: Use fontMetrics() to query font metrics. 70 (WebCore::TransparencyAwareFontPainter::TransparencyAwareGlyphPainter::estimateTextBounds): 71 (WebCore::TransparencyAwareFontPainter::TransparencyAwareGlyphPainter::drawGlyphs): 72 (WebCore::TransparencyAwareFontPainter::TransparencyAwareUniscribePainter::estimateTextBounds): 73 (WebCore::Font::drawComplexText): 74 * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp: Adapt platform code, to initialize the FontMetrics object. 75 (WebCore::SimpleFontData::platformInit): 76 * platform/graphics/chromium/SimpleFontDataLinux.cpp: Ditto. 77 (WebCore::SimpleFontData::platformInit): 78 * platform/graphics/chromium/UniscribeHelperTextRun.cpp: Use fontMetrics() to query font metrics. 79 (WebCore::UniscribeHelperTextRun::UniscribeHelperTextRun): 80 (WebCore::UniscribeHelperTextRun::nextWinFontData): 81 * platform/graphics/freetype/SimpleFontDataFreeType.cpp: Adapt platform code, to initialize the FontMetrics object. 82 (WebCore::SimpleFontData::platformInit): 83 * platform/graphics/haiku/SimpleFontDataHaiku.cpp: Ditto. 84 (WebCore::SimpleFontData::platformInit): 85 * platform/graphics/mac/FontComplexTextMac.cpp: Use fontMetrics() to query font metrics. 86 (WebCore::Font::floatWidthForComplexText): 87 * platform/graphics/mac/FontMac.mm: Ditto. 88 (WebCore::showGlyphsWithAdvances): 89 * platform/graphics/mac/SimpleFontDataMac.mm: Adapt platform code, to initialize the FontMetrics object. 90 (WebCore::SimpleFontData::platformInit): 91 (WebCore::SimpleFontData::platformCharWidthInit): 92 * platform/graphics/pango/SimpleFontDataPango.cpp: Ditto. 93 (WebCore::SimpleFontData::platformInit): 94 * platform/graphics/qt/SimpleFontDataQt.cpp: Ditto. (+ Switch to QFontMetricsF to get floating-point accurancy.) 95 (WebCore::SimpleFontData::platformInit): 96 * platform/graphics/win/FontCGWin.cpp: Use fontMetrics() to query font metrics. 97 (WebCore::drawGDIGlyphs): 98 * platform/graphics/win/FontWin.cpp: Ditto. 99 (WebCore::Font::floatWidthForComplexText): 100 * platform/graphics/win/SimpleFontDataCGWin.cpp: Adapt platform code, to initialize the FontMetrics object. 101 (WebCore::SimpleFontData::platformInit): 102 (WebCore::SimpleFontData::platformBoundsForGlyph): 103 * platform/graphics/win/SimpleFontDataCairoWin.cpp: Ditto. 104 (WebCore::SimpleFontData::platformInit): 105 * platform/graphics/win/SimpleFontDataWin.cpp: Ditto. 106 (WebCore::SimpleFontData::initGDIFont): 107 * platform/graphics/wince/GraphicsContextWinCE.cpp: Use fontMetrics() to query font metrics. 108 (WebCore::GraphicsContext::drawText): 109 * platform/graphics/wince/SimpleFontDataWinCE.cpp: Adapt platform code, to initialize the FontMetrics object. 110 (WebCore::SimpleFontData::platformInit): 111 * platform/graphics/wx/SimpleFontDataWx.cpp: Ditto. 112 (WebCore::SimpleFontData::platformInit): 113 * platform/win/PopupMenuWin.cpp: Use style->fontMetrics() instead of style->font() to access the metrics. 114 (WebCore::PopupMenuWin::calculatePositionAndSize): 115 (WebCore::PopupMenuWin::paint): 116 * rendering/EllipsisBox.cpp: Ditto. 117 (WebCore::EllipsisBox::paint): 118 (WebCore::EllipsisBox::nodeAtPoint): 119 * rendering/InlineBox.cpp: Ditto. 120 (WebCore::InlineBox::logicalHeight): 121 * rendering/InlineFlowBox.cpp: Ditto. 122 (WebCore::verticalPositionForBox): 123 (WebCore::InlineFlowBox::computeLogicalBoxHeights): 124 (WebCore::InlineFlowBox::placeBoxesInBlockDirection): 125 * rendering/InlineTextBox.cpp: Ditto. 126 (WebCore::InlineTextBox::paint): 127 (WebCore::InlineTextBox::paintDecoration): 128 (WebCore::InlineTextBox::paintSpellingOrGrammarMarker): 129 (WebCore::InlineTextBox::paintCompositionUnderline): 130 * rendering/RenderBlock.cpp: Ditto. 131 (WebCore::RenderBlock::baselinePosition): 132 (WebCore::RenderBlock::firstLineBoxBaseline): 133 (WebCore::RenderBlock::lastLineBoxBaseline): 134 * rendering/RenderBox.cpp: Ditto. 135 (WebCore::RenderBox::localCaretRect): 136 * rendering/RenderEmbeddedObject.cpp: Ditto. 137 (WebCore::RenderEmbeddedObject::paintReplaced): 138 * rendering/RenderImage.cpp: Ditto. 139 (WebCore::RenderImage::setImageSizeForAltText): 140 (WebCore::RenderImage::paintReplaced): 141 * rendering/RenderInline.cpp: Ditto. 142 (WebCore::RenderInline::baselinePosition): 143 * rendering/RenderListBox.cpp: Ditto. 144 (WebCore::RenderListBox::paintItemForeground): 145 (WebCore::RenderListBox::itemHeight): 146 * rendering/RenderListMarker.cpp: Ditto. 147 (WebCore::RenderListMarker::paint): 148 (WebCore::RenderListMarker::layout): 149 (WebCore::RenderListMarker::computePreferredLogicalWidths): 150 (WebCore::RenderListMarker::updateMargins): 151 (WebCore::RenderListMarker::getRelativeMarkerRect): 152 * rendering/RenderTextControl.cpp: Ditto. 153 (WebCore::RenderTextControl::paintPlaceholder): 154 * rendering/RenderTextControlSingleLine.cpp: Ditto. 155 (WebCore::RenderTextControlSingleLine::createInnerTextStyle): 156 * rendering/RenderThemeWin.cpp: Ditto. 157 (WebCore::RenderThemeWin::adjustMenuListButtonStyle): 158 * rendering/mathml/RenderMathMLFraction.cpp: Ditto. 159 (WebCore::RenderMathMLFraction::baselinePosition): 160 * rendering/style/RenderStyle.h: Add "const FontMetrics& fontMetrics() const" accessor. 161 (WebCore::InheritedFlags::fontMetrics): 162 (WebCore::InheritedFlags::computedLineHeight): 163 * rendering/svg/RenderSVGInlineText.cpp: Use style->fontMetrics() instead of style->font() to access the metrics. 164 (WebCore::RenderSVGInlineText::positionForPoint): 165 * rendering/svg/SVGInlineTextBox.cpp: Ditto. 166 (WebCore::SVGInlineTextBox::selectionRectForTextFragment): 167 (WebCore::positionOffsetForDecoration): 168 (WebCore::SVGInlineTextBox::paintDecorationWithStyle): 169 (WebCore::SVGInlineTextBox::paintTextWithShadows): 170 (WebCore::SVGInlineTextBox::calculateBoundaries): 171 * rendering/svg/SVGTextLayoutEngineBaseline.cpp: Ditto. 172 (WebCore::SVGTextLayoutEngineBaseline::calculateBaselineShift): 173 (WebCore::SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift): 174 (WebCore::SVGTextLayoutEngineBaseline::calculateGlyphAdvanceAndOrientation): 175 * rendering/svg/SVGTextLayoutEngineSpacing.cpp: Ditto. 176 (WebCore::SVGTextLayoutEngineSpacing::calculateSVGKerning): 177 * rendering/svg/SVGTextMetrics.cpp: Ditto. 178 (WebCore::SVGTextMetrics::SVGTextMetrics): 179 * rendering/svg/SVGTextQuery.cpp: Ditto. 180 (WebCore::calculateGlyphBoundaries): 181 * svg/SVGFontFaceElement.cpp: 182 (WebCore::SVGFontFaceElement::unitsPerEm): Rename defaultUnitsPerEm global to gDefaultUnitsPerEm. 183 * svg/SVGLength.cpp: Use style->fontMetrics() instead of style->font() to access the metrics. 184 (WebCore::SVGLength::convertValueFromUserUnitsToEXS): 185 (WebCore::SVGLength::convertValueFromEXSToUserUnits): 186 1 187 2011-01-22 Ryosuke Niwa <rniwa@webkit.org> 2 188 -
trunk/Source/WebCore/GNUmakefile.am
r76378 r76442 2403 2403 Source/WebCore/platform/graphics/FontFastPath.cpp \ 2404 2404 Source/WebCore/platform/graphics/Font.h \ 2405 Source/WebCore/platform/graphics/FontMetrics.h \ 2405 2406 Source/WebCore/platform/graphics/FontOrientation.h \ 2406 2407 Source/WebCore/platform/graphics/FontRenderingMode.h \ -
trunk/Source/WebCore/WebCore.gypi
r76397 r76442 2908 2908 'platform/graphics/FontFamily.h', 2909 2909 'platform/graphics/FontFastPath.cpp', 2910 'platform/graphics/FontMetrics.h', 2910 2911 'platform/graphics/FontRenderingMode.h', 2911 2912 'platform/graphics/FontSelector.h', -
trunk/Source/WebCore/WebCore.pro
r76378 r76442 2118 2118 platform/graphics/FontDescription.h \ 2119 2119 platform/graphics/FontFamily.h \ 2120 platform/graphics/FontMetrics.h \ 2120 2121 platform/graphics/Font.h \ 2121 2122 platform/graphics/GeneratedImage.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r76378 r76442 26550 26550 </File> 26551 26551 <File 26552 RelativePath="..\platform\graphics\FontMetrics.h" 26553 > 26554 </File> 26555 <File 26552 26556 RelativePath="..\platform\graphics\FontRenderingMode.h" 26553 26557 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r76378 r76442 103 103 083DAEA80F01A7FB00342754 /* RenderTextControlSingleLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 083DAEA40F01A7FB00342754 /* RenderTextControlSingleLine.cpp */; }; 104 104 083DAEA90F01A7FB00342754 /* RenderTextControlSingleLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 083DAEA50F01A7FB00342754 /* RenderTextControlSingleLine.h */; }; 105 0845680812B90DA600960A9F /* FontMetrics.h in Headers */ = {isa = PBXBuildFile; fileRef = 0845680712B90DA600960A9F /* FontMetrics.h */; settings = {ATTRIBUTES = (Private, ); }; }; 105 106 084A0829128D7867002DB1F1 /* SVGPathSegListPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 084A0828128D7867002DB1F1 /* SVGPathSegListPropertyTearOff.h */; }; 106 107 084AEBE40FB505FA0038483E /* SelectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 084AEBE20FB505FA0038483E /* SelectElement.cpp */; }; … … 6417 6418 083DAEA40F01A7FB00342754 /* RenderTextControlSingleLine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextControlSingleLine.cpp; sourceTree = "<group>"; }; 6418 6419 083DAEA50F01A7FB00342754 /* RenderTextControlSingleLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextControlSingleLine.h; sourceTree = "<group>"; }; 6420 0845680712B90DA600960A9F /* FontMetrics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontMetrics.h; sourceTree = "<group>"; }; 6419 6421 084A0828128D7867002DB1F1 /* SVGPathSegListPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegListPropertyTearOff.h; sourceTree = "<group>"; }; 6420 6422 084AEBE20FB505FA0038483E /* SelectElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectElement.cpp; sourceTree = "<group>"; }; … … 17460 17462 B2C3DA590D006CD600EF6F26 /* FontFamily.h */, 17461 17463 72626E010EF022FE00A07E20 /* FontFastPath.cpp */, 17464 0845680712B90DA600960A9F /* FontMetrics.h */, 17462 17465 F7A034C3126BF6BE007DC19E /* FontOrientation.h */, 17463 17466 37ACCE410DA2980F0089E602 /* FontRenderingMode.h */, … … 20631 20634 B2C3DA6A0D006CD600EF6F26 /* FontFamily.h in Headers */, 20632 20635 A80E6CF30A1989CA007FB8C5 /* FontFamilyValue.h in Headers */, 20636 0845680812B90DA600960A9F /* FontMetrics.h in Headers */, 20633 20637 F7A034C4126BF6BE007DC19E /* FontOrientation.h in Headers */, 20634 20638 B5320D6B122A24E9002D1440 /* FontPlatformData.h in Headers */, -
trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
r75250 r76442 1231 1231 // removed in r70072. The implementation looks incorrect though, because this is not the 1232 1232 // baseline of the underlying RenderObject, but of the AccessibilityRenderObject. 1233 const Font & f = renderObject->firstLineStyle()->font();1234 return f .ascent() + (renderObject->firstLineStyle()->computedLineHeight() - f.height()) / 2;1233 const FontMetrics& fontMetrics = renderObject->firstLineStyle()->fontMetrics(); 1234 return fontMetrics.ascent() + (renderObject->firstLineStyle()->computedLineHeight() - fontMetrics.height()) / 2; 1235 1235 } 1236 1236 -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r72205 r76442 401 401 // our actual constructed rendering font. 402 402 applyZoomMultiplier = false; 403 factor = style->font ().xHeight();403 factor = style->fontMetrics().xHeight(); 404 404 break; 405 405 case CSS_REMS: -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r76235 r76442 1761 1761 1762 1762 const Font& font = accessFont(); 1763 1763 const FontMetrics& fontMetrics = font.fontMetrics(); 1764 1764 1765 // FIXME: Handle maxWidth. 1765 1766 // FIXME: Need to turn off font smoothing. … … 1778 1779 case TopTextBaseline: 1779 1780 case HangingTextBaseline: 1780 location.setY(y + font .ascent());1781 location.setY(y + fontMetrics.ascent()); 1781 1782 break; 1782 1783 case BottomTextBaseline: 1783 1784 case IdeographicTextBaseline: 1784 location.setY(y - font .descent());1785 location.setY(y - fontMetrics.descent()); 1785 1786 break; 1786 1787 case MiddleTextBaseline: 1787 location.setY(y - font .descent() + font.height() / 2);1788 location.setY(y - fontMetrics.descent() + fontMetrics.height() / 2); 1788 1789 break; 1789 1790 case AlphabeticTextBaseline: … … 1813 1814 1814 1815 // The slop built in to this mask rect matches the heuristic used in FontCGWin.cpp for GDI text. 1815 FloatRect textRect = FloatRect(location.x() - font .height() / 2, location.y() - font.ascent() - font.lineGap(),1816 width + font .height(), font.lineSpacing());1816 FloatRect textRect = FloatRect(location.x() - fontMetrics.height() / 2, location.y() - fontMetrics.ascent() - fontMetrics.lineGap(), 1817 width + fontMetrics.height(), fontMetrics.lineSpacing()); 1817 1818 if (!fill) 1818 1819 textRect.inflate(c->strokeThickness() / 2); -
trunk/Source/WebCore/inspector/InspectorController.cpp
r76392 r76442 1346 1346 context.drawRect(titleRect); 1347 1347 context.setFillColor(tooltipFontColor, ColorSpaceDeviceRGB); 1348 context.drawText(font, nodeTitleRun, IntPoint(titleRect.x() + rectInflatePx, titleRect.y() + font. height()));1348 context.drawText(font, nodeTitleRun, IntPoint(titleRect.x() + rectInflatePx, titleRect.y() + font.fontMetrics().height())); 1349 1349 } 1350 1350 -
trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp
r76170 r76442 981 981 982 982 // Draw the item text. 983 int textY = rowRect.y() + itemFont. ascent() + (rowRect.height() - itemFont.height()) / 2;983 int textY = rowRect.y() + itemFont.fontMetrics().ascent() + (rowRect.height() - itemFont.fontMetrics().height()) / 2; 984 984 gc->drawBidiText(itemFont, textRun, IntPoint(textX, textY)); 985 985 … … 1121 1121 RefPtr<Image> image(Image::loadPlatformResource(icon.utf8().data())); 1122 1122 1123 int fontHeight = getRowFont(index). height();1123 int fontHeight = getRowFont(index).fontMetrics().height(); 1124 1124 int iconHeight = (image && !image->isNull()) ? image->rect().height() : 0; 1125 1125 -
trunk/Source/WebCore/platform/graphics/Font.h
r76170 r76442 44 44 class FloatRect; 45 45 class FontData; 46 class Font FallbackList;46 class FontMetrics; 47 47 class FontPlatformData; 48 48 class FontSelector; … … 54 54 55 55 struct GlyphData; 56 57 const unsigned defaultUnitsPerEm = 1000;58 56 59 57 struct GlyphOverflow { … … 129 127 130 128 // Metrics that we query the FontFallbackList for. 131 int ascent(FontBaseline baselineType = AlphabeticBaseline) const { return primaryFont()->ascent(baselineType); } 132 int descent(FontBaseline baselineType = AlphabeticBaseline) const { return primaryFont()->descent(baselineType); } 133 int height() const { return ascent() + descent(); } 134 int lineSpacing() const { return primaryFont()->lineSpacing(); } 135 int lineGap() const { return primaryFont()->lineGap(); } 136 float xHeight() const { return primaryFont()->xHeight(); } 137 unsigned unitsPerEm() const { return primaryFont()->unitsPerEm(); } 129 const FontMetrics& fontMetrics() const { return primaryFont()->fontMetrics(); } 138 130 int spaceWidth() const { return (int)ceilf(primaryFont()->adjustedSpaceWidth() + m_letterSpacing); } 139 131 float tabWidth(const SimpleFontData& fontData) const { return 8 * ceilf(fontData.adjustedSpaceWidth() + letterSpacing()); } -
trunk/Source/WebCore/platform/graphics/FontFastPath.cpp
r76170 r76442 253 253 return 0; 254 254 255 return markFontData-> ascent();255 return markFontData->fontMetrics().ascent(); 256 256 } 257 257 … … 267 267 return 0; 268 268 269 return markFontData-> descent();269 return markFontData->fontMetrics().descent(); 270 270 } 271 271 … … 281 281 return 0; 282 282 283 return markFontData-> height();283 return markFontData->fontMetrics().height(); 284 284 } 285 285 … … 415 415 416 416 if (glyphOverflow) { 417 glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-it.minGlyphBoundingBoxY()) - ascent());418 glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(it.maxGlyphBoundingBoxY()) - descent());417 glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-it.minGlyphBoundingBoxY()) - fontMetrics().ascent()); 418 glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(it.maxGlyphBoundingBoxY()) - fontMetrics().descent()); 419 419 glyphOverflow->left = ceilf(it.firstGlyphOverflow()); 420 420 glyphOverflow->right = ceilf(it.lastGlyphOverflow()); -
trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp
r74169 r76442 51 51 : m_maxCharWidth(-1) 52 52 , m_avgCharWidth(-1) 53 , m_unitsPerEm(defaultUnitsPerEm)54 53 , m_orientation(platformData.orientation()) 55 54 , m_platformData(platformData) … … 75 74 { 76 75 SVGFontFaceElement* svgFontFaceElement = m_svgFontData->svgFontFaceElement(); 77 m_unitsPerEm = svgFontFaceElement->unitsPerEm(); 78 79 double scale = size; 80 if (m_unitsPerEm) 81 scale /= m_unitsPerEm; 82 83 m_ascent = static_cast<int>(svgFontFaceElement->ascent() * scale); 84 m_descent = static_cast<int>(svgFontFaceElement->descent() * scale); 85 m_xHeight = static_cast<int>(svgFontFaceElement->xHeight() * scale); 86 m_lineGap = 0.1f * size; 87 m_lineSpacing = m_ascent + m_descent + m_lineGap; 76 unsigned unitsPerEm = svgFontFaceElement->unitsPerEm(); 77 78 float scale = size; 79 if (unitsPerEm) 80 scale /= unitsPerEm; 81 82 // FIXME: Use floating-point metrics, now that they're exposed! 83 int xHeight = static_cast<int>(svgFontFaceElement->xHeight() * scale); 84 int ascent = static_cast<int>(svgFontFaceElement->ascent() * scale); 85 int descent = static_cast<int>(svgFontFaceElement->descent() * scale); 86 int lineGap = static_cast<int>(0.1f * size); 87 m_fontMetrics.setUnitsPerEm(unitsPerEm); 88 m_fontMetrics.setAscent(ascent); 89 m_fontMetrics.setDescent(descent); 90 m_fontMetrics.setLineGap(lineGap); 91 m_fontMetrics.setXHeight(xHeight); 88 92 89 93 SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontElement(); … … 91 95 Vector<SVGGlyphIdentifier> spaceGlyphs; 92 96 associatedFontElement->getGlyphIdentifiersForString(String(" ", 1), spaceGlyphs); 93 m_spaceWidth = spaceGlyphs.isEmpty() ? m_xHeight : static_cast<float>(spaceGlyphs.first().horizontalAdvanceX * scale);97 m_spaceWidth = spaceGlyphs.isEmpty() ? xHeight : static_cast<float>(spaceGlyphs.first().horizontalAdvanceX * scale); 94 98 95 99 Vector<SVGGlyphIdentifier> numeralZeroGlyphs; … … 99 103 Vector<SVGGlyphIdentifier> letterWGlyphs; 100 104 associatedFontElement->getGlyphIdentifiersForString(String("W", 1), letterWGlyphs); 101 m_maxCharWidth = letterWGlyphs.isEmpty() ? m_ascent : static_cast<float>(letterWGlyphs.first().horizontalAdvanceX * scale);105 m_maxCharWidth = letterWGlyphs.isEmpty() ? ascent : static_cast<float>(letterWGlyphs.first().horizontalAdvanceX * scale); 102 106 103 107 // FIXME: is there a way we can get the space glyph from the SVGGlyphIdentifier above? … … 127 131 // If we can't retrieve the width of a '0', fall back to the x height. 128 132 if (m_avgCharWidth <= 0.f) 129 m_avgCharWidth = m_xHeight; 130 133 m_avgCharWidth = m_fontMetrics.xHeight(); 134 135 // FIXME: Use floating-point metrics, now that they're exposed! 131 136 if (m_maxCharWidth <= 0.f) 132 m_maxCharWidth = max<float>(m_avgCharWidth, m_ ascent);137 m_maxCharWidth = max<float>(m_avgCharWidth, m_fontMetrics.ascent()); 133 138 } 134 139 -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r74169 r76442 27 27 #include "FontBaseline.h" 28 28 #include "FontData.h" 29 #include "FontMetrics.h" 29 30 #include "FontPlatformData.h" 30 31 #include "FloatRect.h" … … 102 103 // a broken ideographic font, then just hard-code to split ascent/descent down the middle. Otherwise we should actually use the metrics 103 104 // from the font itself. 104 int ascent(FontBaseline baselineType = AlphabeticBaseline) const { return baselineType == AlphabeticBaseline ? m_ascent : height() - height() / 2; } 105 int descent(FontBaseline baselineType = AlphabeticBaseline) const { return baselineType == AlphabeticBaseline ? m_descent : height() / 2; } 106 int height() const { return m_ascent + m_descent; } 107 int lineSpacing() const { return m_lineSpacing; } 108 int lineGap() const { return m_lineGap; } 105 const FontMetrics& fontMetrics() const { return m_fontMetrics; } 109 106 float maxCharWidth() const { return m_maxCharWidth; } 110 107 float avgCharWidth() const { return m_avgCharWidth; } 111 float xHeight() const { return m_xHeight; }112 unsigned unitsPerEm() const { return m_unitsPerEm; }113 108 114 109 FloatRect boundsForGlyph(Glyph) const; … … 212 207 #endif 213 208 214 int m_ascent; 215 int m_descent; 216 int m_lineSpacing; 217 int m_lineGap; 209 FontMetrics m_fontMetrics; 218 210 float m_maxCharWidth; 219 211 float m_avgCharWidth; 220 float m_xHeight;221 unsigned m_unitsPerEm;222 212 223 213 FontOrientation m_orientation; // This is our supported orientation according to the tables in the font. FontPlatformData will just always have the desired orientation. -
trunk/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
r76340 r76442 247 247 totalWidth += lroundf(m_glyphBuffer.advanceAt(m_from + i)); 248 248 249 return IntRect(m_point.x() - (m_font->ascent() + m_font->descent()) / 2, 250 m_point.y() - m_font->ascent() - m_font->lineGap(), 251 totalWidth + m_font->ascent() + m_font->descent(), 252 m_font->lineSpacing()); 249 const FontMetrics& fontMetrics = m_font->fontMetrics(); 250 return IntRect(m_point.x() - (fontMetrics.ascent() + fontMetrics.descent()) / 2, 251 m_point.y() - fontMetrics.ascent() - fontMetrics.lineGap(), 252 totalWidth + fontMetrics.ascent() + fontMetrics.descent(), 253 fontMetrics.lineSpacing()); 253 254 } 254 255 … … 271 272 // to subtract off the font ascent to get it. 272 273 int x = lroundf(m_point.x() + startAdvance); 273 int y = lroundf(m_point.y() - m_font-> ascent());274 int y = lroundf(m_point.y() - m_font->fontMetrics().ascent()); 274 275 275 276 // If there is a non-blur shadow and both the fill color and shadow color … … 355 356 // go outside the selection rect) is based roughly on 356 357 // TransparencyAwareGlyphPainter::estimateTextBounds above. 357 return IntRect(left - (m_font->ascent() + m_font->descent()) / 2, 358 m_point.y() - m_font->ascent() - m_font->lineGap(), 359 (right - left) + m_font->ascent() + m_font->descent(), 360 m_font->lineSpacing()); 358 const FontMetrics& fontMetrics = m_font->fontMetrics(); 359 return IntRect(left - (fontMetrics.ascent() + fontMetrics.descent()) / 2, 360 m_point.y() - fontMetrics.ascent() - fontMetrics.lineGap(), 361 (right - left) + fontMetrics.ascent() + fontMetrics.descent(), 362 fontMetrics.lineSpacing()); 361 363 } 362 364 … … 497 499 SetTextColor(hdc, textColor); 498 500 state.draw(graphicsContext, hdc, static_cast<int>(point.x()) + shadowOffset.width(), 499 static_cast<int>(point.y() - ascent()) + shadowOffset.height(), from, to);501 static_cast<int>(point.y() - fontMetrics().ascent()) + shadowOffset.height(), from, to); 500 502 SetTextColor(hdc, savedTextColor); 501 503 } … … 504 506 // the baseline, so we have to subtract off the ascent. 505 507 state.draw(graphicsContext, hdc, static_cast<int>(point.x()), 506 static_cast<int>(point.y() - ascent()), from, to);508 static_cast<int>(point.y() - fontMetrics().ascent()), from, to); 507 509 508 510 context->canvas()->endPlatformPaint(); -
trunk/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
r76340 r76442 55 55 { 56 56 if (!m_platformData.size()) { 57 m_ascent = 0; 58 m_descent = 0; 59 m_lineGap = 0; 60 m_lineSpacing = 0; 57 m_fontMetrics.reset(); 61 58 m_avgCharWidth = 0; 62 59 m_maxCharWidth = 0; 63 m_xHeight = 0;64 m_unitsPerEm = 0;65 60 return; 66 61 } … … 83 78 m_maxCharWidth = textMetric.tmMaxCharWidth; 84 79 85 m_ascent = textMetric.tmAscent; 86 m_descent = textMetric.tmDescent; 87 m_lineGap = textMetric.tmExternalLeading; 88 m_xHeight = m_ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts. 80 // FIXME: Access ascent/descent/lineGap with floating point precision. 81 float ascent = textMetric.tmAscent; 82 float descent = textMetric.tmDescent; 83 float lineGap = textMetric.tmExternalLeading; 84 float xHeight = ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts. 89 85 90 86 OUTLINETEXTMETRIC outlineTextMetric; … … 95 91 DWORD len = GetGlyphOutlineW(dc, 'x', GGO_METRICS, &glyphMetrics, 0, 0, &identityMatrix); 96 92 if (len != GDI_ERROR && glyphMetrics.gmBlackBoxY > 0) 97 m_xHeight = static_cast<float>(glyphMetrics.gmBlackBoxY); 98 } 99 100 m_lineSpacing = m_ascent + m_descent + m_lineGap; 93 xHeight = static_cast<float>(glyphMetrics.gmBlackBoxY); 94 } 95 96 m_fontMetrics.setAscent(ascent); 97 m_fontMetrics.setDescent(descent); 98 m_fontMetrics.setLineGap(lineGap); 99 m_fontMetrics.setXHeight(xHeight); 101 100 102 101 SelectObject(dc, oldFont); -
trunk/Source/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp
r74232 r76442 56 56 { 57 57 if (!m_platformData.size()) { 58 m_ascent = 0; 59 m_descent = 0; 60 m_lineGap = 0; 61 m_lineSpacing = 0; 58 m_fontMetrics.reset(); 62 59 m_avgCharWidth = 0; 63 60 m_maxCharWidth = 0; 64 m_xHeight = 0;65 m_unitsPerEm = 0;66 61 return; 67 62 } … … 89 84 } 90 85 86 float ascent; 87 float descent; 88 91 89 // Beware those who step here: This code is designed to match Win32 font 92 90 // metrics *exactly*. 93 91 if (isVDMXValid) { 94 m_ascent = vdmxAscent; 95 m_descent = -vdmxDescent; 92 // FIXME: Access ascent/descent with floating point precision. 93 ascent = vdmxAscent; 94 descent = -vdmxDescent; 96 95 } else { 97 96 SkScalar height = -metrics.fAscent + metrics.fDescent + metrics.fLeading; 98 m_ascent = SkScalarRound(-metrics.fAscent); 99 m_descent = SkScalarRound(height) - m_ascent; 100 } 101 97 ascent = SkScalarToFloat(-metrics.fAscent); 98 descent = SkScalarToFloat(height) - ascent; 99 } 100 101 m_fontMetrics.setAscent(ascent); 102 m_fontMetrics.setDescent(descent); 103 104 float xHeight; 102 105 if (metrics.fXHeight) 103 m_xHeight = metrics.fXHeight;106 xHeight = metrics.fXHeight; 104 107 else { 105 108 // hack taken from the Windows port 106 m_xHeight = static_cast<float>(m_ascent) * 0.56;107 } 108 109 m_ lineGap = SkScalarRound(metrics.fLeading);110 m_ lineSpacing = m_ascent + m_descent + m_lineGap;109 xHeight = ascent * 0.56f; 110 } 111 112 m_fontMetrics.setLineGap(SkScalarToFloat(metrics.fLeading)); 113 m_fontMetrics.setXHeight(xHeight); 111 114 112 115 if (m_orientation == Vertical) { … … 129 132 m_avgCharWidth = SkScalarRound(metrics.fAvgCharWidth); 130 133 else { 131 m_avgCharWidth = m_xHeight;134 m_avgCharWidth = xHeight; 132 135 133 136 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); -
trunk/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp
r76340 r76442 52 52 setSpaceWidth(font.spaceWidth()); 53 53 setWordSpacing(font.wordSpacing()); 54 setAscent(font. primaryFont()->ascent());54 setAscent(font.fontMetrics()->ascent()); 55 55 56 56 init(); … … 122 122 m_scriptCaches.append(simpleFontData->platformData().scriptCache()); 123 123 m_fontProperties.append(simpleFontData->platformData().scriptFontProperties()); 124 m_ascents.append(simpleFontData-> ascent());124 m_ascents.append(simpleFontData->fontMetrics().ascent()); 125 125 } 126 126 -
trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
r74169 r76442 51 51 cairo_text_extents_t text_extents; 52 52 cairo_scaled_font_extents(m_platformData.scaledFont(), &font_extents); 53 m_ascent = static_cast<int>(lroundf(font_extents.ascent)); 54 m_descent = static_cast<int>(lroundf(font_extents.descent)); 55 m_lineSpacing = static_cast<int>(lroundf(font_extents.height)); 53 54 m_fontMetrics.setAscent(font_extents.ascent); 55 m_fontMetrics.setDescent(font_extents.descent); 56 56 57 // There seems to be some rounding error in cairo (or in how we 57 58 // use cairo) with some fonts, like DejaVu Sans Mono, which makes … … 59 60 // wrong and confuses WebCore's layout system. Workaround this 60 61 // while we figure out what's going on. 61 if (m_lineSpacing < m_ascent + m_descent) 62 m_lineSpacing = m_ascent + m_descent; 62 float lineSpacing = font_extents.height; 63 if (lineSpacing < font_extents.ascent + font_extents.descent) 64 lineSpacing = font_extents.ascent + font_extents.descent; 65 m_fontMetrics.setLineGap(lineSpacing - font_extents.ascent - font_extents.descent); 66 63 67 cairo_scaled_font_text_extents(m_platformData.scaledFont(), "x", &text_extents); 64 m_xHeight = text_extents.height; 68 m_fontMetrics.setXHeight(text_extents.height); 69 65 70 cairo_scaled_font_text_extents(m_platformData.scaledFont(), " ", &text_extents); 66 71 m_spaceWidth = static_cast<float>(text_extents.x_advance); 67 m_lineGap = m_lineSpacing - m_ascent - m_descent;72 68 73 m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f; 69 74 } -
trunk/Source/WebCore/platform/graphics/haiku/SimpleFontDataHaiku.cpp
r74169 r76442 49 49 font_height height; 50 50 font->GetHeight(&height); 51 m_ascent = static_cast<int>(height.ascent); 52 m_descent = static_cast<int>(height.descent); 53 m_lineSpacing = m_ascent + m_descent; 54 m_xHeight = height.ascent * 0.56f; // Hack taken from the win port. 55 m_lineGap = height.leading; 51 m_fontMetrics.setAscent(height.ascent); 52 m_fontMetrics.setDescent(height.descent); 53 m_fontMetrics.setXHeight(height.ascent * 0.56f); // Hack taken from the win port. 54 m_fontMetrics.setLineGap(height.leading); 56 55 } 57 56 -
trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp
r76170 r76442 112 112 ComplexTextController controller(this, run, true, fallbackFonts); 113 113 if (glyphOverflow) { 114 glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - ascent());115 glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - descent());114 glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - fontMetrics().ascent()); 115 glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - fontMetrics().descent()); 116 116 glyphOverflow->left = max<int>(0, ceilf(-controller.minGlyphBoundingBoxX())); 117 117 glyphOverflow->right = max<int>(0, ceilf(controller.maxGlyphBoundingBoxX() - controller.totalWidth())); -
trunk/Source/WebCore/platform/graphics/mac/FontMac.mm
r74532 r76442 61 61 CGAffineTransform runMatrix = CGAffineTransformConcat(savedMatrix, rotateLeftTransform); 62 62 // Move start point to put glyphs into original region. 63 runMatrix.tx = savedMatrix.tx + font-> ascent();64 runMatrix.ty = savedMatrix.ty + font-> descent();63 runMatrix.tx = savedMatrix.tx + font->fontMetrics().ascent(); 64 runMatrix.ty = savedMatrix.ty + font->fontMetrics().descent(); 65 65 CGContextSetTextMatrix(context, runMatrix); 66 66 } -
trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
r74178 r76442 219 219 int iDescent; 220 220 int iLineGap; 221 unsigned unitsPerEm; 221 222 #ifdef BUILDING_ON_TIGER 222 wkGetFontMetrics(m_platformData.cgFont(), &iAscent, &iDescent, &iLineGap, & m_unitsPerEm);223 wkGetFontMetrics(m_platformData.cgFont(), &iAscent, &iDescent, &iLineGap, &unitsPerEm); 223 224 #else 224 225 iAscent = CGFontGetAscent(m_platformData.cgFont()); 225 226 iDescent = CGFontGetDescent(m_platformData.cgFont()); 226 227 iLineGap = CGFontGetLeading(m_platformData.cgFont()); 227 m_unitsPerEm = CGFontGetUnitsPerEm(m_platformData.cgFont());228 unitsPerEm = CGFontGetUnitsPerEm(m_platformData.cgFont()); 228 229 #endif 229 230 230 231 float pointSize = m_platformData.m_size; 231 float fAscent = scaleEmToUnits(iAscent, m_unitsPerEm) * pointSize;232 float fDescent = -scaleEmToUnits(iDescent, m_unitsPerEm) * pointSize;233 float fLineGap = scaleEmToUnits(iLineGap, m_unitsPerEm) * pointSize;232 float ascent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize; 233 float descent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize; 234 float lineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize; 234 235 235 236 // We need to adjust Times, Helvetica, and Courier to closely match the … … 240 241 NSString *familyName = [m_platformData.font() familyName]; 241 242 if ([familyName isEqualToString:@"Times"] || [familyName isEqualToString:@"Helvetica"] || [familyName isEqualToString:@"Courier"]) 242 fAscent += floorf(((fAscent + fDescent) * 0.15f) + 0.5f);243 ascent += floorf(((ascent + descent) * 0.15f) + 0.5f); 243 244 else if ([familyName isEqualToString:@"Geeza Pro"]) { 244 245 // Geeza Pro has glyphs that draw slightly above the ascent or far below the descent. Adjust 245 246 // those vertical metrics to better match reality, so that diacritics at the bottom of one line 246 247 // do not overlap diacritics at the top of the next line. 247 fAscent *= 1.08f; 248 fDescent *= 2.f; 249 } 250 251 m_ascent = lroundf(fAscent); 252 m_descent = lroundf(fDescent); 253 m_lineGap = lroundf(fLineGap); 254 m_lineSpacing = m_ascent + m_descent + m_lineGap; 255 248 ascent *= 1.08f; 249 descent *= 2.f; 250 } 251 256 252 // Hack Hiragino line metrics to allow room for marked text underlines. 257 253 // <rdar://problem/5386183> 258 if ( m_descent < 3 && m_lineGap >= 3 && [familyName hasPrefix:@"Hiragino"]) {259 m_lineGap -= 3 - m_descent;260 m_descent = 3;254 if (descent < 3 && lineGap >= 3 && [familyName hasPrefix:@"Hiragino"]) { 255 lineGap -= 3 - descent; 256 descent = 3; 261 257 } 262 258 … … 279 275 } 280 276 277 float xHeight; 278 281 279 // Measure the actual character "x", because AppKit synthesizes X height rather than getting it from the font. 282 280 // Unfortunately, NSFont will round this for us so we don't quite get the right value. … … 289 287 // poorly if we return an accurate height. Classic case is Times 13 point, 290 288 // which has an "x" that is 7x6 pixels. 291 m_xHeight = static_cast<float>(max(CGRectGetMaxX(xBox), -CGRectGetMinY(xBox)));289 xHeight = static_cast<float>(max(CGRectGetMaxX(xBox), -CGRectGetMinY(xBox))); 292 290 } else { 293 291 #ifndef BUILDING_ON_TIGER 294 m_xHeight = static_cast<float>(CGFontGetXHeight(m_platformData.cgFont())) / m_unitsPerEm;295 #else 296 m_xHeight = m_platformData.font() ? [m_platformData.font() xHeight] : 0;292 xHeight = static_cast<float>(CGFontGetXHeight(m_platformData.cgFont())) / unitsPerEm; 293 #else 294 xHeight = m_platformData.font() ? [m_platformData.font() xHeight] : 0; 297 295 #endif 298 296 // CGFontGetXHeight() returns a wrong value for "Apple Symbols" font (a float close to 0, but not strictly 0). 299 // The following code makes a guess for m_xHeight in that case.297 // The following code makes a guess for xHeight in that case. 300 298 // The int cast is a workaround for the "almost" zero value returned by CGFontGetXHeight(). 301 if (!static_cast<int>(m_xHeight) && fAscent) 302 m_xHeight = 2 * fAscent / 3; 303 } 304 } 305 299 if (!static_cast<int>(xHeight) && ascent) 300 xHeight = 2 * ascent / 3; 301 } 302 303 m_fontMetrics.setUnitsPerEm(unitsPerEm); 304 m_fontMetrics.setAscent(ascent); 305 m_fontMetrics.setDescent(descent); 306 m_fontMetrics.setLineGap(lineGap); 307 m_fontMetrics.setXHeight(xHeight); 308 } 309 306 310 static CFDataRef copyFontTableForTag(FontPlatformData& platformData, FourCharCode tableName) 307 311 { … … 338 342 const UInt8* os2 = CFDataGetBytePtr(os2Table.get()); 339 343 SInt16 os2AvgCharWidth = os2[2] * 256 + os2[3]; 340 m_avgCharWidth = scaleEmToUnits(os2AvgCharWidth, m_ unitsPerEm) * m_platformData.m_size;344 m_avgCharWidth = scaleEmToUnits(os2AvgCharWidth, m_fontMetrics.unitsPerEm()) * m_platformData.m_size; 341 345 } 342 346 … … 349 353 SInt16 xMax = static_cast<SInt16>(uxMax); 350 354 float diff = static_cast<float>(xMax - xMin); 351 m_maxCharWidth = scaleEmToUnits(diff, m_ unitsPerEm) * m_platformData.m_size;355 m_maxCharWidth = scaleEmToUnits(diff, m_fontMetrics.unitsPerEm()) * m_platformData.m_size; 352 356 } 353 357 -
trunk/Source/WebCore/platform/graphics/pango/SimpleFontDataPango.cpp
r74169 r76442 50 50 cairo_text_extents_t text_extents; 51 51 cairo_scaled_font_extents(m_platformData.m_scaledFont, &font_extents); 52 m_ascent = static_cast<int>(lroundf(font_extents.ascent)); 53 m_descent = static_cast<int>(lroundf(font_extents.descent)); 54 m_lineSpacing = static_cast<int>(lroundf(font_extents.height)); 52 53 m_fontMetrics.setAscent(font_extents.ascent); 54 m_fontMetrics.setDescent(font_extents.descent); 55 55 56 // There seems to be some rounding error in cairo (or in how we 56 57 // use cairo) with some fonts, like DejaVu Sans Mono, which makes … … 58 59 // wrong and confuses WebCore's layout system. Workaround this 59 60 // while we figure out what's going on. 60 if (m_lineSpacing < m_ascent + m_descent) 61 m_lineSpacing = m_ascent + m_descent; 61 float lineSpacing = font_extents.height; 62 if (lineSpacing < font_extents.ascent + font_extents.descent) 63 lineSpacing = font_extents.ascent + font_extents.descent; 64 m_fontMetrics.setLineGap(lineSpacing - font_extents.ascent - font_extents.descent); 65 62 66 cairo_scaled_font_text_extents(m_platformData.m_scaledFont, "x", &text_extents); 63 m_xHeight = text_extents.height; 67 m_fontMetrics.setXHeight(text_extents.height); 68 64 69 cairo_scaled_font_text_extents(m_platformData.m_scaledFont, " ", &text_extents); 65 m_spaceWidth = 66 m_lineGap = m_lineSpacing - m_ascent - m_descent;70 m_spaceWidth = static_cast<float>(text_extents.x_advance); 71 67 72 m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f; 68 73 } -
trunk/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
r73341 r76442 25 25 #include "SimpleFontData.h" 26 26 27 #include <QFontMetrics >27 #include <QFontMetricsF> 28 28 29 29 namespace WebCore { … … 42 42 { 43 43 if (!m_platformData.size()) { 44 m_ascent = 0; 45 m_descent = 0; 46 m_lineGap = 0; 47 m_lineSpacing = 0; 44 m_fontMetrics.reset(); 48 45 m_avgCharWidth = 0; 49 46 m_maxCharWidth = 0; 50 m_xHeight = 0;51 m_unitsPerEm = 0;52 47 return; 53 48 } 54 49 55 QFontMetrics fm(m_platformData.font()); 56 57 m_ascent = fm.ascent(); 58 m_descent = fm.descent(); 59 m_lineSpacing = fm.lineSpacing(); 60 m_xHeight = fm.xHeight(); 50 QFontMetricsF fm(m_platformData.font()); 51 m_fontMetrics.setAscent(fm.ascent()); 52 m_fontMetrics.setDescent(fm.descent()); 53 m_fontMetrics.setXHeight(fm.xHeight()); 54 m_fontMetrics.setLineGap(fm.leading()); 61 55 m_spaceWidth = fm.width(QLatin1Char(' ')); 62 m_lineGap = fm.leading();63 56 } 64 57 -
trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp
r74532 r76442 168 168 // We put slop into this rect, since glyphs can overflow the ascent/descent bounds and the left/right edges. 169 169 // FIXME: Can get glyphs' optical bounds (even from CG) to get this right. 170 int lineGap = font->lineGap(); 171 textRect = IntRect(point.x() - (font->ascent() + font->descent()) / 2, point.y() - font->ascent() - lineGap, totalWidth + font->ascent() + font->descent(), font->lineSpacing()); 170 const FontMetrics& fontMetrics = font->fontMetrics(); 171 int lineGap = fontMetrics.lineGap(); 172 textRect = IntRect(point.x() - (fontMetrics.ascent() + fontMetrics.descent()) / 2, 173 point.y() - fontMetrics.ascent() - lineGap, 174 totalWidth + fontMetrics.ascent() + fontMetrics.descent(), 175 fontMetrics.lineSpacing()); 172 176 bitmap.set(graphicsContext->createWindowsBitmap(textRect.size())); 173 177 memset(bitmap->buffer(), 255, bitmap->bufferLength()); -
trunk/Source/WebCore/platform/graphics/win/FontWin.cpp
r76170 r76442 123 123 controller.advance(run.length()); 124 124 if (glyphOverflow) { 125 glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - ascent());126 glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - descent());125 glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - fontMetrics().ascent()); 126 glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - fontMetrics().descent()); 127 127 glyphOverflow->left = max<int>(0, ceilf(-controller.minGlyphBoundingBoxX())); 128 128 glyphOverflow->right = max<int>(0, ceilf(controller.maxGlyphBoundingBoxX() - controller.runWidthSoFar())); -
trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
r58192 r76442 65 65 int iDescent = CGFontGetDescent(font); 66 66 int iLineGap = CGFontGetLeading(font); 67 m_unitsPerEm = CGFontGetUnitsPerEm(font);67 unsigned unitsPerEm = CGFontGetUnitsPerEm(font); 68 68 float pointSize = m_platformData.size(); 69 float fAscent = scaleEmToUnits(iAscent, m_unitsPerEm) * pointSize;70 float fDescent = -scaleEmToUnits(iDescent, m_unitsPerEm) * pointSize;71 float fLineGap = scaleEmToUnits(iLineGap, m_unitsPerEm) * pointSize;69 float fAscent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize; 70 float fDescent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize; 71 float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize; 72 72 73 73 if (!isCustomFont()) { … … 94 94 } 95 95 96 m_ascent = lroundf(fAscent); 97 m_descent = lroundf(fDescent); 98 m_lineGap = lroundf(fLineGap); 99 m_lineSpacing = m_ascent + m_descent + m_lineGap; 96 m_fontMetrics.setAscent(fAscent); 97 m_fontMetrics.setDescent(fDescent); 98 m_fontMetrics.setLineGap(fLineGap); 100 99 101 100 // Measure the actual character "x", because AppKit synthesizes X height rather than getting it from the font. … … 110 109 // poorly if we return an accurate height. Classic case is Times 13 point, 111 110 // which has an "x" that is 7x6 pixels. 112 m_ xHeight = scaleEmToUnits(max(CGRectGetMaxX(xBox), CGRectGetMaxY(xBox)), m_unitsPerEm) * pointSize;111 m_fontMetrics.setXHeight(scaleEmToUnits(max(CGRectGetMaxX(xBox), CGRectGetMaxY(xBox)), unitsPerEm) * pointSize); 113 112 } else { 114 113 int iXHeight = CGFontGetXHeight(font); 115 m_ xHeight = scaleEmToUnits(iXHeight, m_unitsPerEm) * pointSize;114 m_fontMetrics.setXHeight(scaleEmToUnits(iXHeight, unitsPerEm) * pointSize); 116 115 } 116 117 m_fontMetrics.setUnitsPerEm(unitsPerEm); 117 118 } 118 119 … … 134 135 CGFontGetGlyphBBoxes(m_platformData.cgFont(), &glyph, 1, &box); 135 136 float pointSize = m_platformData.size(); 136 CGFloat scale = pointSize / unitsPerEm();137 CGFloat scale = pointSize / fontMetrics().unitsPerEm(); 137 138 FloatRect boundingBox = CGRectApplyAffineTransform(box, CGAffineTransformMakeScale(scale, -scale)); 138 139 if (m_syntheticBoldOffset) -
trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp
r58192 r76442 64 64 TEXTMETRIC textMetrics; 65 65 GetTextMetrics(hdc, &textMetrics); 66 m_ascent = lroundf(textMetrics.tmAscent * metricsMultiplier); 67 m_descent = lroundf(textMetrics.tmDescent * metricsMultiplier); 68 m_xHeight = m_ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts. 69 m_lineGap = lroundf(textMetrics.tmExternalLeading * metricsMultiplier); 70 m_lineSpacing = m_ascent + m_descent + m_lineGap; 71 m_avgCharWidth = lroundf(textMetrics.tmAveCharWidth * metricsMultiplier); 72 m_maxCharWidth = lroundf(textMetrics.tmMaxCharWidth * metricsMultiplier); 66 float ascent = textMetrics.tmAscent * metricsMultiplier; 67 float descent = textMetrics.tmDescent * metricsMultiplier; 68 float xHeight = ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts. 69 float lineGap = textMetrics.tmExternalLeading * metricsMultiplier; 70 m_fontMetrics.setAscent(ascent); 71 m_fontMetrics.setDescent(descent); 72 m_fontMetrics.setLineGap(lineGap); 73 m_avgCharWidth = textMetrics.tmAveCharWidth * metricsMultiplier; 74 m_maxCharWidth = textMetrics.tmMaxCharWidth * metricsMultiplier; 73 75 74 76 OUTLINETEXTMETRIC metrics; … … 79 81 DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat); 80 82 if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0) 81 m_xHeight = gm.gmptGlyphOrigin.y * metricsMultiplier;83 xHeight = gm.gmptGlyphOrigin.y * metricsMultiplier; 82 84 } 83 85 86 m_fontMetrics.setXHeight(xHeight); 84 87 cairo_win32_scaled_font_done_font(scaledFont); 85 88 -
trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
r74169 r76442 67 67 { 68 68 if (!m_platformData.size()) { 69 m_ascent = 0; 70 m_descent = 0; 71 m_lineGap = 0; 72 m_lineSpacing = 0; 69 m_fontMetrics.reset(); 73 70 m_avgCharWidth = 0; 74 71 m_maxCharWidth = 0; 75 m_xHeight = 0;76 m_unitsPerEm = 0;77 72 return; 78 73 } … … 83 78 GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics); 84 79 TEXTMETRIC& textMetrics = metrics.otmTextMetrics; 85 m_ascent = textMetrics.tmAscent; 86 m_descent = textMetrics.tmDescent; 87 m_lineGap = textMetrics.tmExternalLeading; 88 m_lineSpacing = m_ascent + m_descent + m_lineGap; 80 float ascent = textMetrics.tmAscent; 81 float descent = textMetrics.tmDescent; 82 float lineGap = textMetrics.tmExternalLeading; 83 m_fontMetrics.setAscent(ascent); 84 m_fontMetrics.setDescent(descent); 85 m_fontMetrics.setLineGap(lineGap); 89 86 m_avgCharWidth = textMetrics.tmAveCharWidth; 90 87 m_maxCharWidth = textMetrics.tmMaxCharWidth; 91 m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present.88 float xHeight = ascent * 0.56f; // Best guess for xHeight if no x glyph is present. 92 89 93 90 GLYPHMETRICS gm; … … 95 92 DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat); 96 93 if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0) 97 m_xHeight = gm.gmptGlyphOrigin.y; 98 99 m_unitsPerEm = metrics.otmEMSquare; 94 xHeight = gm.gmptGlyphOrigin.y; 95 96 m_fontMetrics.setXHeight(xHeight); 97 m_fontMetrics.setUnitsPerEm(metrics.otmEMSquare); 100 98 101 99 SelectObject(hdc, oldFont); -
trunk/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
r76248 r76442 1538 1538 1539 1539 FloatRect textRect = font.selectionRectForText(run, point, font.height(), from, to); 1540 textRect.setY(textRect.y() - font. ascent());1540 textRect.setY(textRect.y() - font.fontMetrics().ascent()); 1541 1541 IntRect trRect = enclosingIntRect(m_data->mapRect(textRect)); 1542 1542 RECT bmpRect; … … 1547 1547 gc.setBitmap(bmp); 1548 1548 gc.scale(FloatSize(m_data->m_transform.a(), m_data->m_transform.d())); 1549 font.drawText(&gc, run, IntPoint(0, font. ascent()), from, to);1549 font.drawText(&gc, run, IntPoint(0, font.fontMetrics().ascent()), from, to); 1550 1550 } 1551 1551 unsigned key1; … … 1592 1592 : 0; 1593 1593 1594 FloatPoint startPoint(point.x(), point.y() - fontData-> ascent());1594 FloatPoint startPoint(point.x(), point.y() - fontData->fontMetrics().ascent()); 1595 1595 FloatPoint trPoint = m_data->mapPoint(startPoint); 1596 1596 int y = stableRound(trPoint.y()); -
trunk/Source/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp
r74169 r76442 52 52 m_isSystemFont = m_platformData.isSystemFont(); 53 53 54 m_ascent = (tm.tmAscent * m_platformData.size() + 36) / 72; 55 m_descent = (tm.tmDescent * m_platformData.size() + 36) / 72; 56 m_lineGap = (tm.tmExternalLeading * m_platformData.size() + 36) / 72; 57 m_lineSpacing = m_ascent + m_descent + m_lineGap; 58 m_xHeight = m_ascent * 0.56f; 54 float ascent = (tm.tmAscent * m_platformData.size() + 36) / 72.0f; 55 float descent = (tm.tmDescent * m_platformData.size() + 36) / 72.0f; 56 float lineGap = (tm.tmExternalLeading * m_platformData.size() + 36) / 72.0f; 57 m_fontMetrics.setAscent(ascent); 58 m_fontMetrics.setDescent(descent); 59 m_fontMetrics.setLineGap(lineGap); 60 m_fontMetrics.setXHeight(ascent * 0.56f); 59 61 } 60 62 -
trunk/Source/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp
r74169 r76442 54 54 if (font && font->IsOk()) { 55 55 wxFontProperties props = wxFontProperties(font); 56 m_ascent = props.GetAscent(); 57 m_descent = props.GetDescent(); 58 m_lineSpacing = props.GetLineSpacing(); 59 m_xHeight = props.GetXHeight(); 60 m_unitsPerEm = 1; // FIXME! 61 m_lineGap = props.GetLineGap(); 56 m_fontMetrics.setAscent(props.GetAscent()); 57 m_fontMetrics.setDescent(props.GetDescent()); 58 m_fontMetrics.setXHeight(props.GetXHeight()); 59 m_fontMetrics.setUnitsPerEm(1); // FIXME! 60 m_fontMetrics.setLineGap(props.GetLineGap()); 62 61 } 63 62 -
trunk/Source/WebCore/platform/win/PopupMenuWin.cpp
r76378 r76442 307 307 // First, determine the popup's height 308 308 int itemCount = client()->listSize(); 309 m_itemHeight = client()->menuStyle().font(). height() + optionSpacingMiddle;309 m_itemHeight = client()->menuStyle().font().fontMetrics().height() + optionSpacingMiddle; 310 310 int naturalHeight = m_itemHeight * itemCount; 311 311 int popupHeight = min(maxPopupHeight, naturalHeight); … … 650 650 if (RenderTheme::defaultTheme()->popupOptionSupportsTextIndent() && itemStyle.textDirection() == LTR) 651 651 textX += itemStyle.textIndent().calcMinValue(itemRect.width()); 652 int textY = itemRect.y() + itemFont. ascent() + (itemRect.height() - itemFont.height()) / 2;652 int textY = itemRect.y() + itemFont.fontMetrics().ascent() + (itemRect.height() - itemFont.fontMetrics().height()) / 2; 653 653 context.drawBidiText(itemFont, textRun, IntPoint(textX, textY)); 654 654 } -
trunk/Source/WebCore/rendering/EllipsisBox.cpp
r76170 r76442 54 54 55 55 const String& str = m_str; 56 context->drawText(style->font(), TextRun(str.characters(), str.length(), false, 0, 0, false, style->visuallyOrdered()), IntPoint(m_x + tx, m_y + ty + style->font ().ascent()));56 context->drawText(style->font(), TextRun(str.characters(), str.length(), false, 0, 0, false, style->visuallyOrdered()), IntPoint(m_x + tx, m_y + ty + style->fontMetrics().ascent())); 57 57 58 58 // Restore the regular fill color. … … 66 66 // Paint the markup box 67 67 tx += m_x + m_logicalWidth - m_markupBox->x(); 68 ty += m_y + style->font ().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->font().ascent());68 ty += m_y + style->fontMetrics().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->fontMetrics().ascent()); 69 69 m_markupBox->paint(paintInfo, tx, ty); 70 70 } … … 109 109 RenderStyle* style = m_renderer->style(m_firstLine); 110 110 int mtx = tx + m_logicalWidth - m_markupBox->x(); 111 int mty = ty + style->font ().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->font().ascent());111 int mty = ty + style->fontMetrics().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->fontMetrics().ascent()); 112 112 if (m_markupBox->nodeAtPoint(request, result, x, y, mtx, mty)) { 113 113 renderer()->updateHitTestResult(result, IntPoint(x - mtx, y - mty)); -
trunk/Source/WebCore/rendering/InlineBox.cpp
r75837 r76442 95 95 96 96 if (renderer()->isText()) 97 return m_isText ? renderer()->style(m_firstLine)->font ().height() : 0;97 return m_isText ? renderer()->style(m_firstLine)->fontMetrics().height() : 0; 98 98 if (renderer()->isBox() && parent()) 99 99 return isHorizontal() ? toRenderBox(m_renderer)->height() : toRenderBox(m_renderer)->width(); … … 101 101 ASSERT(isInlineFlowBox()); 102 102 RenderBoxModelObject* flowObject = boxModelObject(); 103 const Font & font = renderer()->style(m_firstLine)->font();104 int result = font .height();103 const FontMetrics& fontMetrics = renderer()->style(m_firstLine)->fontMetrics(); 104 int result = fontMetrics.height(); 105 105 if (parent()) 106 106 result += flowObject->borderAndPaddingLogicalHeight(); -
trunk/Source/WebCore/rendering/InlineFlowBox.cpp
r75257 r76442 409 409 if (verticalAlign != BASELINE) { 410 410 const Font& font = parent->style(firstLine)->font(); 411 const FontMetrics& fontMetrics = font.fontMetrics(); 411 412 int fontSize = font.pixelSize(); 412 413 … … 418 419 verticalPosition -= fontSize / 3 + 1; 419 420 else if (verticalAlign == TEXT_TOP) 420 verticalPosition += renderer->baselinePosition(baselineType, firstLine, lineDirection) - font .ascent(baselineType);421 verticalPosition += renderer->baselinePosition(baselineType, firstLine, lineDirection) - fontMetrics.ascent(baselineType); 421 422 else if (verticalAlign == MIDDLE) 422 verticalPosition += -static_cast<int>(font .xHeight() / 2) - renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType, firstLine, lineDirection);423 verticalPosition += -static_cast<int>(fontMetrics.xHeight() / 2) - renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType, firstLine, lineDirection); 423 424 else if (verticalAlign == TEXT_BOTTOM) { 424 verticalPosition += font .descent(baselineType);425 verticalPosition += fontMetrics.descent(baselineType); 425 426 // lineHeight - baselinePosition is always 0 for replaced elements (except inline blocks), so don't bother wasting time in that case. 426 427 if (!renderer->isReplaced() || renderer->isInlineBlockOrInlineTable()) … … 504 505 int baselineToBottom = 0; 505 506 for (size_t i = 0; i < usedFonts->size(); ++i) { 506 int halfLeading = (usedFonts->at(i)->lineSpacing() - usedFonts->at(i)->height()) / 2; 507 int usedFontBaseline = halfLeading + usedFonts->at(i)->ascent(baselineType); 508 int usedFontBaselineToBottom = usedFonts->at(i)->lineSpacing() - usedFontBaseline; 507 const FontMetrics& fontMetrics = usedFonts->at(i)->fontMetrics(); 508 int halfLeading = (fontMetrics.lineSpacing() - fontMetrics.height()) / 2; 509 int usedFontBaseline = halfLeading + fontMetrics.ascent(baselineType); 510 int usedFontBaselineToBottom = fontMetrics.lineSpacing() - usedFontBaseline; 509 511 if (!baselineSet) { 510 512 baselineSet = true; … … 516 518 } 517 519 if (!affectsAscent) 518 affectsAscent = usedFonts->at(i)->ascent() - curr->logicalTop() > 0;520 affectsAscent = fontMetrics.ascent() - curr->logicalTop() > 0; 519 521 if (!affectsDescent) 520 affectsDescent = usedFonts->at(i)->descent() + curr->logicalTop() > 0;522 affectsDescent = fontMetrics.descent() + curr->logicalTop() > 0; 521 523 } 522 524 lineHeight = baseline + baselineToBottom; … … 528 530 // If the top of our font box relative to the root box baseline is above the root box baseline, then 529 531 // we are contributing to the maxAscent value. 530 affectsAscent = curr->renderer()->style(m_firstLine)->font().ascent(baselineType) - curr->logicalTop() > 0; 532 const FontMetrics& fontMetrics = curr->renderer()->style(m_firstLine)->fontMetrics(); 533 affectsAscent = fontMetrics.ascent(baselineType) - curr->logicalTop() > 0; 531 534 532 535 // Descent is similar. If any part of our font box is below the root box's baseline, then 533 536 // we contribute to the maxDescent value. 534 affectsDescent = curr->renderer()->style(m_firstLine)->font().descent(baselineType) + curr->logicalTop() > 0;537 affectsDescent = fontMetrics.descent(baselineType) + curr->logicalTop() > 0; 535 538 } else { 536 539 // Replaced elements always affect both the ascent and descent. … … 607 610 608 611 if (curr->isText() || curr->isInlineFlowBox()) { 609 const Font & font = curr->renderer()->style(m_firstLine)->font();610 newLogicalTop += curr->baselinePosition(baselineType) - font .ascent(baselineType);612 const FontMetrics& fontMetrics = curr->renderer()->style(m_firstLine)->fontMetrics(); 613 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType); 611 614 if (curr->isInlineFlowBox()) { 612 615 RenderBoxModelObject* boxObject = toRenderBoxModelObject(curr->renderer()); … … 669 672 670 673 if (isRootInlineBox()) { 671 const Font & font = renderer()->style(m_firstLine)->font();672 setLogicalTop(logicalTop() + baselinePosition(baselineType) - font .ascent(baselineType));674 const FontMetrics& fontMetrics = renderer()->style(m_firstLine)->fontMetrics(); 675 setLogicalTop(logicalTop() + baselinePosition(baselineType) - fontMetrics.ascent(baselineType)); 673 676 674 677 if (hasTextChildren() || strictMode) { -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r76170 r76442 486 486 boxOrigin.move(tx, ty); 487 487 IntRect boxRect(boxOrigin, IntSize(logicalWidth(), logicalHeight())); 488 IntPoint textOrigin = IntPoint(boxOrigin.x(), boxOrigin.y() + styleToUse->font ().ascent());488 IntPoint textOrigin = IntPoint(boxOrigin.x(), boxOrigin.y() + styleToUse->fontMetrics().ascent()); 489 489 490 490 if (!isHorizontal()) { … … 627 627 const AtomicString& emphasisMark = hasTextEmphasis ? styleToUse->textEmphasisMarkString() : nullAtom; 628 628 if (!emphasisMark.isEmpty()) 629 emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ? -font. ascent() - font.emphasisMarkDescent(emphasisMark) : font.descent() + font.emphasisMarkAscent(emphasisMark);629 emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fontMetrics().descent() + font.emphasisMarkAscent(emphasisMark); 630 630 631 631 if (!paintSelectedTextOnly) { … … 838 838 839 839 RenderStyle* styleToUse = renderer()->style(m_firstLine); 840 int baseline = styleToUse->font ().ascent();840 int baseline = styleToUse->fontMetrics().ascent(); 841 841 842 842 bool setClip = false; … … 971 971 // we pin to two pixels under the baseline. 972 972 int lineThickness = cMisspellingLineThickness; 973 int baseline = renderer()->style(m_firstLine)->font ().ascent();973 int baseline = renderer()->style(m_firstLine)->fontMetrics().ascent(); 974 974 int descent = logicalHeight() - baseline; 975 975 int underlineOffset; … … 1128 1128 // If there's not enough space the underline will touch or overlap characters. 1129 1129 int lineThickness = 1; 1130 int baseline = renderer()->style(m_firstLine)->font ().ascent();1130 int baseline = renderer()->style(m_firstLine)->fontMetrics().ascent(); 1131 1131 if (underline.thick && logicalHeight() - baseline >= 2) 1132 1132 lineThickness = 2; -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r76438 r76442 4959 4959 } 4960 4960 4961 const Font & f = style(firstLine)->font();4962 return f .ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - f.height()) / 2;4961 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); 4962 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2; 4963 4963 } 4964 4964 … … 4970 4970 if (childrenInline()) { 4971 4971 if (firstLineBox()) 4972 return firstLineBox()->logicalTop() + style(true)->font ().ascent(firstRootBox()->baselineType());4972 return firstLineBox()->logicalTop() + style(true)->fontMetrics().ascent(firstRootBox()->baselineType()); 4973 4973 else 4974 4974 return -1; … … 4996 4996 if (childrenInline()) { 4997 4997 if (!firstLineBox() && hasLineIfEmpty()) { 4998 const Font& f = firstLineStyle()->font(); 4999 return f.ascent() + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - f.height()) / 2 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); 4998 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); 4999 return fontMetrics.ascent() 5000 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 5001 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); 5000 5002 } 5001 5003 if (lastLineBox()) 5002 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLineBox())->font ().ascent(lastRootBox()->baselineType());5004 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLineBox())->fontMetrics().ascent(lastRootBox()->baselineType()); 5003 5005 return -1; 5004 5006 } else { … … 5013 5015 } 5014 5016 if (!haveNormalFlowChild && hasLineIfEmpty()) { 5015 const Font& f = firstLineStyle()->font(); 5016 return f.ascent() + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - f.height()) / 2 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); 5017 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); 5018 return fontMetrics.ascent() 5019 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 5020 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); 5017 5021 } 5018 5022 } -
trunk/Source/WebCore/rendering/RenderBox.cpp
r76141 r76442 2977 2977 // 2978 2978 // FIXME: ignoring :first-line, missing good reason to take care of 2979 int fontHeight = style()->font ().height();2979 int fontHeight = style()->fontMetrics().height(); 2980 2980 if (fontHeight > rect.height() || (!isReplaced() && !isTable())) 2981 2981 rect.setHeight(fontHeight); -
trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp
r76170 r76442 173 173 context->fillPath(path); 174 174 175 const FontMetrics& fontMetrics = font.fontMetrics(); 175 176 float labelX = roundf(replacementTextRect.location().x() + (replacementTextRect.size().width() - textWidth) / 2); 176 float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - font .height()) / 2 + font.ascent());177 float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent()); 177 178 context->setAlpha(m_missingPluginIndicatorIsPressed ? replacementTextPressedTextOpacity : replacementTextTextOpacity); 178 179 context->setFillColor(Color::black, style()->colorSpace()); -
trunk/Source/WebCore/rendering/RenderImage.cpp
r76170 r76442 113 113 if (!m_altText.isEmpty()) { 114 114 const Font& font = style()->font(); 115 IntSize textSize(min(font.width(TextRun(m_altText.characters(), m_altText.length())), maxAltTextWidth), min(font. height(), maxAltTextHeight));115 IntSize textSize(min(font.width(TextRun(m_altText.characters(), m_altText.length())), maxAltTextWidth), min(font.fontMetrics().height(), maxAltTextHeight)); 116 116 imageSize = imageSize.expandedTo(textSize); 117 117 } … … 290 290 int ay = ty + topBorder + topPad; 291 291 const Font& font = style()->font(); 292 int ascent = font.ascent(); 292 const FontMetrics& fontMetrics = font.fontMetrics(); 293 int ascent = fontMetrics.ascent(); 293 294 294 295 // Only draw the alt text if it'll fit within the content box, … … 297 298 int textWidth = font.width(textRun); 298 299 if (errorPictureDrawn) { 299 if (usableWidth >= textWidth && font .height() <= imageY)300 context->drawText( style()->font(), textRun, IntPoint(ax, ay + ascent));301 } else if (usableWidth >= textWidth && cHeight >= font .height())302 context->drawText( style()->font(), textRun, IntPoint(ax, ay + ascent));300 if (usableWidth >= textWidth && fontMetrics.height() <= imageY) 301 context->drawText(font, textRun, IntPoint(ax, ay + ascent)); 302 } else if (usableWidth >= textWidth && cHeight >= fontMetrics.height()) 303 context->drawText(font, textRun, IntPoint(ax, ay + ascent)); 303 304 } 304 305 } -
trunk/Source/WebCore/rendering/RenderInline.cpp
r74775 r76442 906 906 int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 907 907 { 908 const Font & f = style(firstLine)->font();909 return f .ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - f.height()) / 2;908 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); 909 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2; 910 910 } 911 911 -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r76378 r76442 304 304 // Determine where the item text should be placed 305 305 IntRect r = itemBoundingBoxRect(tx, ty, listIndex); 306 r.move(optionsSpacingHorizontal, style()->font ().ascent());306 r.move(optionsSpacingHorizontal, style()->fontMetrics().ascent()); 307 307 308 308 RenderStyle* itemStyle = element->renderStyle(); … … 551 551 int RenderListBox::itemHeight() const 552 552 { 553 return style()->font ().height() + rowSpacing;553 return style()->fontMetrics().height() + rowSpacing; 554 554 } 555 555 -
trunk/Source/WebCore/rendering/RenderListMarker.cpp
r76170 r76442 1266 1266 } 1267 1267 1268 IntPoint textOrigin = IntPoint(marker.x(), marker.y() + style()->font ().ascent());1268 IntPoint textOrigin = IntPoint(marker.x(), marker.y() + style()->fontMetrics().ascent()); 1269 1269 1270 1270 if (type == Asterisks || type == Footnotes) … … 1312 1312 } else { 1313 1313 setLogicalWidth(minPreferredLogicalWidth()); 1314 setLogicalHeight(style()->font ().height());1314 setLogicalHeight(style()->fontMetrics().height()); 1315 1315 } 1316 1316 … … 1347 1347 1348 1348 const Font& font = style()->font(); 1349 const FontMetrics& fontMetrics = font.fontMetrics(); 1349 1350 1350 1351 if (isImage()) { 1351 1352 // FIXME: This is a somewhat arbitrary width. Generated images for markers really won't become particularly useful 1352 1353 // until we support the CSS3 marker pseudoclass to allow control over the width and height of the marker box. 1353 int bulletWidth = font .ascent() / 2;1354 int bulletWidth = fontMetrics.ascent() / 2; 1354 1355 m_image->setImageContainerSize(IntSize(bulletWidth, bulletWidth)); 1355 1356 IntSize imageSize = m_image->imageSize(this, style()->effectiveZoom()); … … 1374 1375 case Square: 1375 1376 m_text = listMarkerText(type, 0); // value is ignored for these types 1376 logicalWidth = (font .ascent() * 2 / 3 + 1) / 2 + 2;1377 logicalWidth = (fontMetrics.ascent() * 2 / 3 + 1) / 2 + 2; 1377 1378 break; 1378 1379 case Afar: … … 1473 1474 void RenderListMarker::updateMargins() 1474 1475 { 1475 const Font & font = style()->font();1476 const FontMetrics& fontMetrics = style()->fontMetrics(); 1476 1477 1477 1478 int marginStart = 0; … … 1486 1487 case Square: 1487 1488 marginStart = -1; 1488 marginEnd = font .ascent() - minPreferredLogicalWidth() + 1;1489 marginEnd = fontMetrics.ascent() - minPreferredLogicalWidth() + 1; 1489 1490 break; 1490 1491 default: … … 1496 1497 marginStart = -minPreferredLogicalWidth() - cMarkerPadding; 1497 1498 else { 1498 int offset = font .ascent() * 2 / 3;1499 int offset = fontMetrics.ascent() * 2 / 3; 1499 1500 switch (style()->listStyleType()) { 1500 1501 case Disc: … … 1514 1515 marginEnd = cMarkerPadding; 1515 1516 else { 1516 int offset = font .ascent() * 2 / 3;1517 int offset = fontMetrics.ascent() * 2 / 3; 1517 1518 switch (style()->listStyleType()) { 1518 1519 case Disc: … … 1585 1586 case Footnotes: { 1586 1587 const Font& font = style()->font(); 1587 relativeRect = IntRect(0, 0, font.width(m_text), font. height());1588 relativeRect = IntRect(0, 0, font.width(m_text), font.fontMetrics().height()); 1588 1589 break; 1589 1590 } … … 1592 1593 case Square: { 1593 1594 // FIXME: Are these particular rounding rules necessary? 1594 const Font & font = style()->font();1595 int ascent = font .ascent();1595 const FontMetrics& fontMetrics = style()->fontMetrics(); 1596 int ascent = fontMetrics.ascent(); 1596 1597 int bulletWidth = (ascent * 2 / 3 + 1) / 2; 1597 1598 relativeRect = IntRect(1, 3 * (ascent - ascent * 2 / 3) / 2, bulletWidth, bulletWidth); … … 1681 1682 UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem->value()), ' ' }; 1682 1683 int suffixSpaceWidth = font.width(TextRun(suffixSpace, 2)); 1683 relativeRect = IntRect(0, 0, itemWidth + suffixSpaceWidth, font. height());1684 relativeRect = IntRect(0, 0, itemWidth + suffixSpaceWidth, font.fontMetrics().height()); 1684 1685 } 1685 1686 -
trunk/Source/WebCore/rendering/RenderTextControl.cpp
r76170 r76442 645 645 if (textRenderer) { 646 646 IntPoint textPoint; 647 textPoint.setY(ty + textBlockInsetTop() + placeholderStyle->font ().ascent());647 textPoint.setY(ty + textBlockInsetTop() + placeholderStyle->fontMetrics().ascent()); 648 648 if (placeholderStyle->isLeftToRightDirection()) 649 649 textPoint.setX(tx + textBlockInsetLeft()); -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
r76378 r76442 709 709 710 710 // Do not allow line-height to be smaller than our default. 711 if (textBlockStyle->font ().lineSpacing() > lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes))711 if (textBlockStyle->fontMetrics().lineSpacing() > lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes)) 712 712 textBlockStyle->setLineHeight(Length(-100.0f, Percent)); 713 713 -
trunk/Source/WebCore/rendering/RenderThemeWin.cpp
r68864 r76442 770 770 771 771 // Calculate our min-height 772 int minHeight = style->font ().height();772 int minHeight = style->fontMetrics().height(); 773 773 minHeight = max(minHeight, dropDownBoxMinHeight); 774 774 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp
r76375 r76442 177 177 else if (nextSibling()) 178 178 refStyle = nextSibling()->style(); 179 int shift = int(ceil((refStyle->font ().xHeight() + 1) / 2));179 int shift = int(ceil((refStyle->fontMetrics().xHeight() + 1) / 2)); 180 180 return numerator->offsetHeight() + shift; 181 181 } -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r76083 r76442 464 464 465 465 const Font& font() const { return inherited->font; } 466 const FontMetrics& fontMetrics() const { return inherited->font.fontMetrics(); } 466 467 const FontDescription& fontDescription() const { return inherited->font.fontDescription(); } 467 468 int fontSize() const { return inherited->font.pixelSize(); } … … 488 489 // Negative value means the line height is not set. Use the font's built-in spacing. 489 490 if (lh.isNegative()) 490 return font ().lineSpacing();491 return fontMetrics().lineSpacing(); 491 492 492 493 if (lh.isPercent()) -
trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp
r75325 r76442 162 162 RenderStyle* style = this->style(); 163 163 ASSERT(style); 164 int baseline = style->font ().ascent();164 int baseline = style->fontMetrics().ascent(); 165 165 166 166 RenderBlock* containingBlock = this->containingBlock(); -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r76170 r76442 85 85 86 86 const Font& font = style->font(); 87 FloatPoint textOrigin(fragment.x, fragment.y - font. ascent());87 FloatPoint textOrigin(fragment.x, fragment.y - font.fontMetrics().ascent()); 88 88 return font.selectionRectForText(constructTextRun(style, fragment), textOrigin, fragment.height, startPosition, endPosition); 89 89 } … … 410 410 } 411 411 412 static inline float positionOffsetForDecoration(ETextDecoration decoration, const Font & font, float thickness)412 static inline float positionOffsetForDecoration(ETextDecoration decoration, const FontMetrics& fontMetrics, float thickness) 413 413 { 414 414 // FIXME: For SVG Fonts we need to use the attributes defined in the <font-face> if specified. 415 415 // Compatible with Batik/Opera. 416 416 if (decoration == UNDERLINE) 417 return font .ascent() + thickness * 1.5f;417 return fontMetrics.ascent() + thickness * 1.5f; 418 418 if (decoration == OVERLINE) 419 419 return thickness; 420 420 if (decoration == LINE_THROUGH) 421 return font .ascent() * 5.0f / 8.0f;421 return fontMetrics.ascent() * 5.0f / 8.0f; 422 422 423 423 ASSERT_NOT_REACHED(); … … 488 488 489 489 const Font& font = decorationStyle->font(); 490 const FontMetrics& fontMetrics = font.fontMetrics(); 490 491 491 492 // The initial y value refers to overline position. … … 495 496 return; 496 497 497 float y = fragment.y - font .ascent() + positionOffsetForDecoration(decoration, font, thickness);498 float y = fragment.y - fontMetrics.ascent() + positionOffsetForDecoration(decoration, fontMetrics, thickness); 498 499 499 500 Path path; … … 514 515 515 516 FloatPoint textOrigin(fragment.x, fragment.y); 516 FloatRect shadowRect(FloatPoint(textOrigin.x(), textOrigin.y() - font. ascent()), FloatSize(fragment.width, fragment.height));517 FloatRect shadowRect(FloatPoint(textOrigin.x(), textOrigin.y() - font.fontMetrics().ascent()), FloatSize(fragment.width, fragment.height)); 517 518 518 519 do { … … 588 589 589 590 int baseline = baselinePosition(AlphabeticBaseline); 590 int heightDifference = baseline - style->font ().ascent();591 int heightDifference = baseline - style->fontMetrics().ascent(); 591 592 592 593 unsigned textFragmentsSize = m_textFragments.size(); -
trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
r75325 r76442 50 50 return 0; 51 51 case BS_SUB: 52 return -m_font. height() / 2;52 return -m_font.fontMetrics().height() / 2; 53 53 case BS_SUPER: 54 return m_font. height() / 2;54 return m_font.fontMetrics().height() / 2; 55 55 default: 56 56 ASSERT_NOT_REACHED(); … … 123 123 } 124 124 125 const FontMetrics& fontMetrics = m_font.fontMetrics(); 126 125 127 // Note: http://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling 126 128 switch (baseline) { … … 129 131 case AB_BEFORE_EDGE: 130 132 case AB_TEXT_BEFORE_EDGE: 131 return m_font.ascent();133 return fontMetrics.ascent(); 132 134 case AB_MIDDLE: 133 return m_font.xHeight() / 2;135 return fontMetrics.xHeight() / 2; 134 136 case AB_CENTRAL: 135 return ( m_font.ascent() - m_font.descent()) / 2;137 return (fontMetrics.ascent() - fontMetrics.descent()) / 2; 136 138 case AB_AFTER_EDGE: 137 139 case AB_TEXT_AFTER_EDGE: 138 140 case AB_IDEOGRAPHIC: 139 return m_font.descent();141 return fontMetrics.descent(); 140 142 case AB_ALPHABETIC: 141 143 return 0; 142 144 case AB_HANGING: 143 return m_font.ascent() * 8 / 10.f;145 return fontMetrics.ascent() * 8 / 10.f; 144 146 case AB_MATHEMATICAL: 145 return m_font.ascent() / 2;147 return fontMetrics.ascent() / 2; 146 148 default: 147 149 ASSERT_NOT_REACHED(); … … 193 195 // 180 degrees, then the current text position is incremented according to the horizontal metrics of the glyph. 194 196 197 const FontMetrics& fontMetrics = m_font.fontMetrics(); 198 195 199 // Vertical orientation handling. 196 200 if (isVerticalText) { 197 float ascentMinusDescent = m_font.ascent() - m_font.descent();201 float ascentMinusDescent = fontMetrics.ascent() - fontMetrics.descent(); 198 202 if (!angle) { 199 203 xOrientationShift = (ascentMinusDescent - metrics.width()) / 2; 200 yOrientationShift = m_font.ascent();204 yOrientationShift = fontMetrics.ascent(); 201 205 } else if (angle == 180) 202 206 xOrientationShift = (ascentMinusDescent + metrics.width()) / 2; … … 218 222 else if (angle == 180) { 219 223 xOrientationShift = metrics.width(); 220 yOrientationShift = - m_font.ascent();224 yOrientationShift = -fontMetrics.ascent(); 221 225 } else if (angle == 270) 222 226 xOrientationShift = metrics.width(); -
trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp
r68878 r76442 59 59 m_lastGlyph = currentGlyph; 60 60 m_lastGlyph.isValid = true; 61 kerning *= m_font.size() / m_font. primaryFont()->unitsPerEm();61 kerning *= m_font.size() / m_font.fontMetrics().unitsPerEm(); 62 62 return kerning; 63 63 #else -
trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp
r76170 r76442 44 44 45 45 m_width = font.floatWidth(run, extraCharsAvailable, length, m_glyph.name); 46 m_height = font. height();46 m_height = font.fontMetrics().height(); 47 47 m_glyph.unicodeString = String(run.characters(), length); 48 48 m_glyph.isValid = true; -
trunk/Source/WebCore/rendering/svg/SVGTextQuery.cpp
r75325 r76442 473 473 static inline void calculateGlyphBoundaries(SVGTextQuery::Data* queryData, const SVGTextFragment& fragment, int startPosition, FloatRect& extent) 474 474 { 475 extent.setLocation(FloatPoint(fragment.x, fragment.y - queryData->textRenderer->style()->font ().ascent()));475 extent.setLocation(FloatPoint(fragment.x, fragment.y - queryData->textRenderer->style()->fontMetrics().ascent())); 476 476 477 477 if (startPosition) { -
trunk/Source/WebCore/svg/SVGFontFaceElement.cpp
r74622 r76442 126 126 const AtomicString& value = getAttribute(units_per_emAttr); 127 127 if (value.isEmpty()) 128 return defaultUnitsPerEm;128 return gDefaultUnitsPerEm; 129 129 130 130 return static_cast<unsigned>(ceilf(value.toFloat())); -
trunk/Source/WebCore/svg/SVGLength.cpp
r74788 r76442 439 439 // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg 440 440 // if this causes problems in real world cases maybe it would be best to remove this 441 float xHeight = ceilf(style->font ().xHeight());441 float xHeight = ceilf(style->fontMetrics().xHeight()); 442 442 if (!xHeight) { 443 443 ec = NOT_SUPPORTED_ERR; … … 458 458 // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg 459 459 // if this causes problems in real world cases maybe it would be best to remove this 460 return value * ceilf(style->font ().xHeight());460 return value * ceilf(style->fontMetrics().xHeight()); 461 461 } 462 462 -
trunk/Source/WebKit/chromium/ChangeLog
r76412 r76442 1 2011-01-21 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 Introduce FontMetrics abstraction 6 https://bugs.webkit.org/show_bug.cgi?id=51456 7 8 * src/ExternalPopupMenu.cpp: Use FontMetrics instead of Font to access the metrics. 9 (WebKit::ExternalPopupMenu::getPopupMenuInfo): 10 * src/WebFontImpl.cpp: Ditto. 11 (WebKit::WebFontImpl::ascent): 12 (WebKit::WebFontImpl::descent): 13 (WebKit::WebFontImpl::height): 14 (WebKit::WebFontImpl::lineSpacing): 15 (WebKit::WebFontImpl::xHeight): 16 1 17 2011-01-21 Chris Rogers <crogers@google.com> 2 18 -
trunk/Source/WebKit/chromium/src/ExternalPopupMenu.cpp
r72586 r76442 143 143 } 144 144 145 info->itemHeight = m_popupMenuClient->menuStyle().font(). height();145 info->itemHeight = m_popupMenuClient->menuStyle().font().fontMetrics().height(); 146 146 info->itemFontSize = 147 147 static_cast<int>(m_popupMenuClient->menuStyle().font().size()); -
trunk/Source/WebKit/chromium/src/WebFontImpl.cpp
r76170 r76442 65 65 int WebFontImpl::ascent() const 66 66 { 67 return m_font. ascent();67 return m_font.fontMetrics().ascent(); 68 68 } 69 69 70 70 int WebFontImpl::descent() const 71 71 { 72 return m_font. descent();72 return m_font.fontMetrics().descent(); 73 73 } 74 74 75 75 int WebFontImpl::height() const 76 76 { 77 return m_font. height();77 return m_font.fontMetrics().height(); 78 78 } 79 79 80 80 int WebFontImpl::lineSpacing() const 81 81 { 82 return m_font. lineSpacing();82 return m_font.fontMetrics().lineSpacing(); 83 83 } 84 84 85 85 float WebFontImpl::xHeight() const 86 86 { 87 return m_font. xHeight();87 return m_font.fontMetrics().xHeight(); 88 88 } 89 89 -
trunk/Source/WebKit/win/ChangeLog
r76390 r76442 1 2011-01-21 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 Introduce FontMetrics abstraction 6 https://bugs.webkit.org/show_bug.cgi?id=51456 7 8 * FullscreenVideoController.cpp: Use FontMetrics instead of Font to access the metrics. 9 (FullscreenVideoController::draw): 10 * WebCoreSupport/WebDragClient.cpp: Ditto. 11 (WebDragClient::createDragImageForLink): 12 * WebKitGraphics.cpp: Ditto. 13 (FontMetrics): 14 1 15 2011-01-21 Chris Rogers <crogers@google.com> 2 16 -
trunk/Source/WebKit/win/FullscreenVideoController.cpp
r75262 r76442 533 533 // Left string 534 534 s = timeToString(currentTime()); 535 int fontHeight = font.fontMetrics().height(); 535 536 TextRun leftText(s); 536 537 context.setFillColor(Color(textColor), ColorSpaceDeviceRGB); 537 context.drawText(font, leftText, IntPoint(windowWidth / 2 - timeSliderWidth / 2 - margin - font.width(leftText), windowHeight - margin - sliderHeight / 2 + font .height()/ 4));538 context.drawText(font, leftText, IntPoint(windowWidth / 2 - timeSliderWidth / 2 - margin - font.width(leftText), windowHeight - margin - sliderHeight / 2 + fontHeight / 4)); 538 539 539 540 // Right string … … 541 542 TextRun rightText(s); 542 543 context.setFillColor(Color(textColor), ColorSpaceDeviceRGB); 543 context.drawText(font, rightText, IntPoint(windowWidth / 2 + timeSliderWidth / 2 + margin, windowHeight - margin - sliderHeight / 2 + font .height()/ 4));544 context.drawText(font, rightText, IntPoint(windowWidth / 2 + timeSliderWidth / 2 + margin, windowHeight - margin - sliderHeight / 2 + fontHeight / 4)); 544 545 545 546 // Copy to the window -
trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp
r76170 r76442 249 249 TextRun labelRun(label.impl()); 250 250 TextRun urlRun(urlString.impl()); 251 IntSize labelSize(labelFont->width(labelRun), labelFont-> ascent() + labelFont->descent());251 IntSize labelSize(labelFont->width(labelRun), labelFont->fontMetrics().ascent() + labelFont->fontMetrics().descent()); 252 252 253 253 if (labelSize.width() > MAX_DRAG_LABEL_STRING_WIDTH){ … … 262 262 if (drawURLString) { 263 263 urlStringSize.setWidth(urlFont->width(urlRun)); 264 urlStringSize.setHeight(urlFont-> ascent() + urlFont->descent());264 urlStringSize.setHeight(urlFont->fontMetrics().ascent() + urlFont->fontMetrics().descent()); 265 265 imageSize.setHeight(imageSize.height() + urlStringSize.height()); 266 266 if (urlStringSize.width() > MAX_DRAG_LABEL_STRING_WIDTH) { … … 305 305 if (clipURLString) 306 306 urlString = StringTruncator::rightTruncate(urlString, imageSize.width() - (DRAG_LABEL_BORDER_X * 2.0f), *urlFont, false); 307 IntPoint textPos(DRAG_LABEL_BORDER_X, imageSize.height() - (DRAG_LABEL_BORDER_Y_OFFSET + urlFont-> descent()));307 IntPoint textPos(DRAG_LABEL_BORDER_X, imageSize.height() - (DRAG_LABEL_BORDER_Y_OFFSET + urlFont->fontMetrics().descent())); 308 308 WebCoreDrawDoubledTextAtPoint(context, urlString, textPos, *urlFont, topColor, bottomColor); 309 309 } -
trunk/Source/WebKit/win/WebKitGraphics.cpp
r70143 r76442 134 134 135 135 Font font(makeFont(description)); 136 const WebCore::FontMetrics& fontMetrics(font.fontMetrics()); 136 137 137 138 if (ascent) 138 *ascent = font .ascent();139 *ascent = fontMetrics.ascent(); 139 140 140 141 if (descent) 141 *descent = font .descent();142 *descent = fontMetrics.descent(); 142 143 143 144 if (lineSpacing) 144 *lineSpacing = font .lineSpacing();145 *lineSpacing = fontMetrics.lineSpacing(); 145 146 } 146 147 -
trunk/Source/WebKit2/ChangeLog
r76434 r76442 1 2011-01-21 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 Introduce FontMetrics abstraction 6 https://bugs.webkit.org/show_bug.cgi?id=51456 7 8 * WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp: Use FontMetrics instead of Font to access the metrics. 9 (WebKit::WebPopupMenu::setUpPlatformData): 10 1 11 2011-01-22 Alexey Proskuryakov <ap@apple.com> 2 12 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp
r75532 r76442 50 50 data.m_clientInsetLeft = m_popupClient->clientInsetLeft(); 51 51 data.m_clientInsetRight = m_popupClient->clientInsetRight(); 52 data.m_itemHeight = m_popupClient->menuStyle().font(). height() + 1;52 data.m_itemHeight = m_popupClient->menuStyle().font().fontMetrics().height() + 1; 53 53 54 54 int popupWidth = 0; … … 134 134 if (RenderTheme::defaultTheme()->popupOptionSupportsTextIndent() && itemStyle.textDirection() == LTR) 135 135 textX += itemStyle.textIndent().calcMinValue(itemRect.width()); 136 int textY = itemRect.y() + itemFont. ascent() + (itemRect.height() - itemFont.height()) / 2;136 int textY = itemRect.y() + itemFont.fontMetrics().ascent() + (itemRect.height() - itemFont.fontMetrics().height()) / 2; 137 137 138 138 notSelectedBackingStoreContext->drawBidiText(itemFont, textRun, IntPoint(textX, textY));
Note: See TracChangeset
for help on using the changeset viewer.