Changeset 176298 in webkit
- Timestamp:
- Nov 18, 2014, 5:19:43 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
- 2 moved
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-thickness-expected.html (moved) (moved from trunk/LayoutTests/platform/mac/fast/css3-text/css3-text-decoration/text-decoration-thickness-expected.html )
-
LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-thickness.html (moved) (moved from trunk/LayoutTests/platform/mac/fast/css3-text/css3-text-decoration/text-decoration-thickness.html ) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/graphics/FontMetrics.h (modified) (3 diffs)
-
Source/WebCore/platform/graphics/SimpleFontData.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm (modified) (4 diffs)
-
Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm (modified) (2 diffs)
-
Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp (modified) (2 diffs)
-
Source/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp (modified) (2 diffs)
-
Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp (modified) (1 diff)
-
Source/WebCore/rendering/InlineTextBox.cpp (modified) (2 diffs)
-
Source/WebCore/style/InlineTextBoxStyle.cpp (modified) (3 diffs)
-
Source/WebCore/style/InlineTextBoxStyle.h (modified) (2 diffs)
-
Source/WebCore/svg/SVGFontData.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r176295 r176298 1 2014-11-18 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r176263 and r176273. 4 https://bugs.webkit.org/show_bug.cgi?id=138854 5 6 Underlines are hideous. (Requested by litherum on #webkit). 7 8 Reverted changesets: 9 10 "Use underlining metrics from the font file" 11 https://bugs.webkit.org/show_bug.cgi?id=138762 12 http://trac.webkit.org/changeset/176263 13 14 "iOS build fix." 15 http://trac.webkit.org/changeset/176273 16 1 17 2014-11-18 David Hyatt <hyatt@apple.com> 2 18 -
trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-thickness.html
r176297 r176298 8 8 to text size. The comparison is to a box that has its background color set. 9 9 <div style="position: relative; width: 600px; height: 600px; overflow: hidden;"> 10 <div style="font-family: Ahem; text-decoration: underline; font-size: 31000px; position: absolute; left: 0px; top: -28925px;"> </div>10 <div style="font-family: Ahem; text-decoration: underline; font-size: 10000px; position: absolute; left: 0px; top: -8350px;"> </div> 11 11 </div> 12 12 </body> -
trunk/Source/WebCore/ChangeLog
r176297 r176298 1 2014-11-18 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r176263 and r176273. 4 https://bugs.webkit.org/show_bug.cgi?id=138854 5 6 Underlines are hideous. (Requested by litherum on #webkit). 7 8 Reverted changesets: 9 10 "Use underlining metrics from the font file" 11 https://bugs.webkit.org/show_bug.cgi?id=138762 12 http://trac.webkit.org/changeset/176263 13 14 "iOS build fix." 15 http://trac.webkit.org/changeset/176273 16 1 17 2014-11-18 Chris Dumez <cdumez@apple.com> 2 18 -
trunk/Source/WebCore/platform/graphics/FontMetrics.h
r176263 r176298 38 38 , m_xHeight(0) 39 39 , m_zeroWidth(0) 40 , m_decorationThickness(1)41 , m_underlinePosition(1)42 40 , m_hasXHeight(false) 43 41 , m_hasZeroWidth(false) … … 135 133 void setHasZeroWidth(bool hasZeroWidth) { m_hasZeroWidth = hasZeroWidth; } 136 134 137 float decorationThickness() const { return m_decorationThickness; }138 void setDecorationThickness(float decorationThickness) { m_decorationThickness = decorationThickness; }139 140 float underlinePosition() const { return m_underlinePosition; }141 void setUnderlinePosition(float underlinePosition) { m_underlinePosition = underlinePosition; }142 143 135 private: 144 136 friend class SimpleFontData; … … 163 155 float m_capHeight; 164 156 float m_zeroWidth; 165 float m_decorationThickness;166 float m_underlinePosition;167 157 bool m_hasXHeight; 168 158 bool m_hasCapHeight; -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r176263 r176298 363 363 } 364 364 365 static inline void populateDecorationMetrics(float fontSize, float& decorationThickness, float& underlinePosition)366 {367 // Decoration underlines should be proportional to the font size368 decorationThickness = fontSize / 16.0f;369 // An amount to lower the underline below the baseline370 underlinePosition = std::max(1.0f, ceilf(decorationThickness / 2.0));371 }372 373 365 } // namespace WebCore 374 366 -
trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
r176263 r176298 66 66 float capHeight = narrowPrecisionToFloat(fontExtents.height); 67 67 float lineGap = narrowPrecisionToFloat(fontExtents.height - fontExtents.ascent - fontExtents.descent); 68 float decorationThickness;69 float underlinePosition;70 populateDecorationMetrics(m_platformData.m_size, decorationThickness, underlinePosition);71 68 72 69 m_fontMetrics.setAscent(ascent); 73 70 m_fontMetrics.setDescent(descent); 74 71 m_fontMetrics.setCapHeight(capHeight); 75 m_fontMetrics.setDecorationThickness(decorationThickness);76 m_fontMetrics.setUnderlinePosition(underlinePosition);77 72 78 73 #if PLATFORM(EFL) -
trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm
r176273 r176298 80 80 float lineSpacing; 81 81 float xHeight; 82 float decorationThickness;83 float underlinePosition;84 82 RetainPtr<CFStringRef> familyName; 85 83 if (CTFontRef ctFont = m_platformData.font()) { … … 90 88 lineGap = fontService.lineGap(); 91 89 xHeight = fontService.xHeight(); 92 decorationThickness = CTFontGetUnderlineThickness(ctFont);93 underlinePosition = -CTFontGetUnderlinePosition(ctFont);94 90 capHeight = fontService.capHeight(); 95 91 unitsPerEm = fontService.unitsPerEm(); … … 106 102 xHeight = scaleEmToUnits(CGFontGetXHeight(cgFont), unitsPerEm) * pointSize; 107 103 capHeight = scaleEmToUnits(CGFontGetCapHeight(cgFont), unitsPerEm) * pointSize; 108 populateDecorationMetrics(m_platformData.size(), decorationThickness, underlinePosition);109 104 110 105 lineSpacing = ascent + descent + lineGap; … … 119 114 m_fontMetrics.setXHeight(xHeight); 120 115 m_fontMetrics.setCapHeight(capHeight); 121 m_fontMetrics.setDecorationThickness(decorationThickness);122 m_fontMetrics.setUnderlinePosition(underlinePosition);123 116 m_shouldNotBeUsedForArabic = fontFamilyShouldNotBeUsedForArabic(familyName.get()); 124 117 -
trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
r176263 r176298 194 194 195 195 float lineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize; 196 float decorationThickness = CTFontGetUnderlineThickness(m_platformData.ctFont());197 float underlinePosition = -CTFontGetUnderlinePosition(m_platformData.ctFont());198 196 199 197 // We need to adjust Times, Helvetica, and Courier to closely match the … … 239 237 m_fontMetrics.setLineGap(lineGap); 240 238 m_fontMetrics.setXHeight(xHeight); 241 m_fontMetrics.setDecorationThickness(decorationThickness);242 m_fontMetrics.setUnderlinePosition(underlinePosition);243 239 } 244 240 -
trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
r176263 r176298 70 70 float fCapHeight = scaleEmToUnits(iCapHeight, unitsPerEm) * pointSize; 71 71 float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize; 72 float decorationThickness;73 float underlinePosition;74 populateDecorationMetrics(m_platformData.size(), decorationThickness, underlinePosition);75 72 76 73 if (!isCustomFont()) { … … 91 88 m_fontMetrics.setLineGap(fLineGap); 92 89 m_fontMetrics.setLineSpacing(lroundf(fAscent) + lroundf(fDescent) + lroundf(fLineGap)); 93 m_fontMetrics.setDecorationThickness(decorationThickness);94 m_fontMetrics.setUnderlinePosition(underlinePosition);95 90 96 91 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); -
trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp
r176263 r176298 77 77 float xHeight = ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts. 78 78 float lineGap = textMetrics.tmExternalLeading * metricsMultiplier; 79 float decorationThickness;80 float underlinePosition;81 populateDecorationMetrics(m_platformData.size(), decorationThickness, underlinePosition);82 79 83 80 int faceLength = ::GetTextFace(dc, 0, 0); … … 92 89 m_fontMetrics.setLineGap(lineGap); 93 90 m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap)); 94 m_fontMetrics.setDecorationThickness(decorationThickness);95 m_fontMetrics.setUnderlinePosition(underlinePosition);96 91 m_avgCharWidth = textMetrics.tmAveCharWidth * metricsMultiplier; 97 92 m_maxCharWidth = textMetrics.tmMaxCharWidth * metricsMultiplier; -
trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
r176263 r176298 90 90 float descent = textMetrics.tmDescent; 91 91 float lineGap = textMetrics.tmExternalLeading; 92 float decorationThickness;93 float underlinePosition;94 populateDecorationMetrics(m_platformData.size(), decorationThickness, underlinePosition);95 92 m_fontMetrics.setAscent(ascent); 96 93 m_fontMetrics.setDescent(descent); 97 94 m_fontMetrics.setLineGap(lineGap); 98 95 m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap)); 99 m_fontMetrics.setDecorationThickness(decorationThickness);100 m_fontMetrics.setUnderlinePosition(underlinePosition);101 96 m_avgCharWidth = textMetrics.tmAveCharWidth; 102 97 m_maxCharWidth = textMetrics.tmMaxCharWidth; -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r176263 r176298 926 926 bool isPrinting = renderer().document().printing(); 927 927 928 float textDecorationThickness = renderer().style().fontMetrics().decorationThickness();928 float textDecorationThickness = textDecorationStrokeThickness(renderer().style().fontSize()); 929 929 context.setStrokeThickness(textDecorationThickness); 930 930 … … 978 978 if (decoration & TextDecorationUnderline) { 979 979 context.setStrokeColor(underline, colorSpace); 980 const int underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), this );980 const int underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), this, textDecorationThickness); 981 981 982 982 switch (decorationStyle) { -
trunk/Source/WebCore/style/InlineTextBoxStyle.cpp
r176263 r176298 33 33 namespace WebCore { 34 34 35 int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, InlineTextBox* inlineTextBox )35 int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, InlineTextBox* inlineTextBox, int textDecorationThickness) 36 36 { 37 37 // This represents the gap between the baseline and the closest edge of the underline. 38 float gap = fontMetrics.underlinePosition();38 int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.0)); 39 39 40 40 // According to the specification TextUnderlinePositionAuto should default to 'alphabetic' for horizontal text … … 84 84 return GlyphOverflow(); 85 85 86 float strokeThickness = lineStyle.fontMetrics().decorationThickness();86 float strokeThickness = textDecorationStrokeThickness(lineStyle.fontSize()); 87 87 float controlPointDistance; 88 88 float step; … … 102 102 // These metrics must match where underlines get drawn. 103 103 if (decoration & TextDecorationUnderline) { 104 float underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), inlineTextBox );104 float underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), inlineTextBox, strokeThickness); 105 105 if (decorationStyle == TextDecorationStyleWavy) { 106 106 extendIntToFloat(overflowResult.bottom, underlineOffset + wavyOffset + controlPointDistance + strokeThickness - height); -
trunk/Source/WebCore/style/InlineTextBoxStyle.h
r176263 r176298 34 34 class InlineTextBox; 35 35 36 inline float textDecorationStrokeThickness(float fontSize) 37 { 38 const float textDecorationBaseFontSize = 16; 39 return fontSize / textDecorationBaseFontSize; 40 } 41 36 42 inline float wavyOffsetFromDecoration() 37 43 { … … 41 47 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, InlineTextBox*); 42 48 void getWavyStrokeParameters(float strokeThickness, float& controlPointDistance, float& step); 43 int computeUnderlineOffset(TextUnderlinePosition, const FontMetrics&, InlineTextBox* );49 int computeUnderlineOffset(TextUnderlinePosition, const FontMetrics&, InlineTextBox*, int textDecorationThickness); 44 50 45 51 } -
trunk/Source/WebCore/svg/SVGFontData.cpp
r176263 r176298 80 80 float descent = svgFontFaceElement->descent() * scale; 81 81 float lineGap = 0.1f * fontSize; 82 float decorationThickness;83 float underlinePosition;84 populateDecorationMetrics(fontSize, decorationThickness, underlinePosition);85 82 86 83 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(fontData, 0)->page(); … … 99 96 fontMetrics.setLineSpacing(roundf(ascent) + roundf(descent) + roundf(lineGap)); 100 97 fontMetrics.setXHeight(xHeight); 101 fontMetrics.setDecorationThickness(decorationThickness);102 fontMetrics.setUnderlinePosition(underlinePosition);103 98 104 99 if (!glyphPageZero) {
Note:
See TracChangeset
for help on using the changeset viewer.