Changeset 176298 in webkit


Ignore:
Timestamp:
Nov 18, 2014, 5:19:43 PM (11 years ago)
Author:
mmaxfield@apple.com
Message:

Unreviewed, rolling out r176263 and r176273.
https://bugs.webkit.org/show_bug.cgi?id=138854

Underlines are hideous. (Requested by litherum on #webkit).

Reverted changesets:

"Use underlining metrics from the font file"
https://bugs.webkit.org/show_bug.cgi?id=138762
http://trac.webkit.org/changeset/176263

"iOS build fix."
http://trac.webkit.org/changeset/176273

Patch by Commit Queue <commit-queue@webkit.org> on 2014-11-18# Please enter the commit message for your changes. Lines starting

Location:
trunk
Files:
14 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r176295 r176298  
     12014-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
    1172014-11-18  David Hyatt  <hyatt@apple.com>
    218
  • trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-thickness.html

    r176297 r176298  
    88to text size. The comparison is to a box that has its background color set.
    99<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;">&nbsp;</div>
     10<div style="font-family: Ahem; text-decoration: underline; font-size: 10000px; position: absolute; left: 0px; top: -8350px;">&nbsp;</div>
    1111</div>
    1212</body>
  • trunk/Source/WebCore/ChangeLog

    r176297 r176298  
     12014-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
    1172014-11-18  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/Source/WebCore/platform/graphics/FontMetrics.h

    r176263 r176298  
    3838        , m_xHeight(0)
    3939        , m_zeroWidth(0)
    40         , m_decorationThickness(1)
    41         , m_underlinePosition(1)
    4240        , m_hasXHeight(false)
    4341        , m_hasZeroWidth(false)
     
    135133    void setHasZeroWidth(bool hasZeroWidth) { m_hasZeroWidth = hasZeroWidth; }
    136134
    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 
    143135private:
    144136    friend class SimpleFontData;
     
    163155    float m_capHeight;
    164156    float m_zeroWidth;
    165     float m_decorationThickness;
    166     float m_underlinePosition;
    167157    bool m_hasXHeight;
    168158    bool m_hasCapHeight;
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.h

    r176263 r176298  
    363363}
    364364
    365 static inline void populateDecorationMetrics(float fontSize, float& decorationThickness, float& underlinePosition)
    366 {
    367     // Decoration underlines should be proportional to the font size
    368     decorationThickness = fontSize / 16.0f;
    369     // An amount to lower the underline below the baseline
    370     underlinePosition = std::max(1.0f, ceilf(decorationThickness / 2.0));
    371 }
    372 
    373365} // namespace WebCore
    374366
  • trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp

    r176263 r176298  
    6666    float capHeight = narrowPrecisionToFloat(fontExtents.height);
    6767    float lineGap = narrowPrecisionToFloat(fontExtents.height - fontExtents.ascent - fontExtents.descent);
    68     float decorationThickness;
    69     float underlinePosition;
    70     populateDecorationMetrics(m_platformData.m_size, decorationThickness, underlinePosition);
    7168
    7269    m_fontMetrics.setAscent(ascent);
    7370    m_fontMetrics.setDescent(descent);
    7471    m_fontMetrics.setCapHeight(capHeight);
    75     m_fontMetrics.setDecorationThickness(decorationThickness);
    76     m_fontMetrics.setUnderlinePosition(underlinePosition);
    7772
    7873#if PLATFORM(EFL)
  • trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm

    r176273 r176298  
    8080    float lineSpacing;
    8181    float xHeight;
    82     float decorationThickness;
    83     float underlinePosition;
    8482    RetainPtr<CFStringRef> familyName;
    8583    if (CTFontRef ctFont = m_platformData.font()) {
     
    9088        lineGap = fontService.lineGap();
    9189        xHeight = fontService.xHeight();
    92         decorationThickness = CTFontGetUnderlineThickness(ctFont);
    93         underlinePosition = -CTFontGetUnderlinePosition(ctFont);
    9490        capHeight = fontService.capHeight();
    9591        unitsPerEm = fontService.unitsPerEm();
     
    106102        xHeight = scaleEmToUnits(CGFontGetXHeight(cgFont), unitsPerEm) * pointSize;
    107103        capHeight = scaleEmToUnits(CGFontGetCapHeight(cgFont), unitsPerEm) * pointSize;
    108         populateDecorationMetrics(m_platformData.size(), decorationThickness, underlinePosition);
    109104
    110105        lineSpacing = ascent + descent + lineGap;
     
    119114    m_fontMetrics.setXHeight(xHeight);
    120115    m_fontMetrics.setCapHeight(capHeight);
    121     m_fontMetrics.setDecorationThickness(decorationThickness);
    122     m_fontMetrics.setUnderlinePosition(underlinePosition);
    123116    m_shouldNotBeUsedForArabic = fontFamilyShouldNotBeUsedForArabic(familyName.get());
    124117
  • trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

    r176263 r176298  
    194194   
    195195    float lineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
    196     float decorationThickness = CTFontGetUnderlineThickness(m_platformData.ctFont());
    197     float underlinePosition = -CTFontGetUnderlinePosition(m_platformData.ctFont());
    198196
    199197    // We need to adjust Times, Helvetica, and Courier to closely match the
     
    239237    m_fontMetrics.setLineGap(lineGap);
    240238    m_fontMetrics.setXHeight(xHeight);
    241     m_fontMetrics.setDecorationThickness(decorationThickness);
    242     m_fontMetrics.setUnderlinePosition(underlinePosition);
    243239}
    244240
  • trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp

    r176263 r176298  
    7070    float fCapHeight = scaleEmToUnits(iCapHeight, unitsPerEm) * pointSize;
    7171    float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
    72     float decorationThickness;
    73     float underlinePosition;
    74     populateDecorationMetrics(m_platformData.size(), decorationThickness, underlinePosition);
    7572
    7673    if (!isCustomFont()) {
     
    9188    m_fontMetrics.setLineGap(fLineGap);
    9289    m_fontMetrics.setLineSpacing(lroundf(fAscent) + lroundf(fDescent) + lroundf(fLineGap));
    93     m_fontMetrics.setDecorationThickness(decorationThickness);
    94     m_fontMetrics.setUnderlinePosition(underlinePosition);
    9590
    9691    GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
  • trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp

    r176263 r176298  
    7777    float xHeight = ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts.
    7878    float lineGap = textMetrics.tmExternalLeading * metricsMultiplier;
    79     float decorationThickness;
    80     float underlinePosition;
    81     populateDecorationMetrics(m_platformData.size(), decorationThickness, underlinePosition);
    8279
    8380    int faceLength = ::GetTextFace(dc, 0, 0);
     
    9289    m_fontMetrics.setLineGap(lineGap);
    9390    m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
    94     m_fontMetrics.setDecorationThickness(decorationThickness);
    95     m_fontMetrics.setUnderlinePosition(underlinePosition);
    9691    m_avgCharWidth = textMetrics.tmAveCharWidth * metricsMultiplier;
    9792    m_maxCharWidth = textMetrics.tmMaxCharWidth * metricsMultiplier;
  • trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp

    r176263 r176298  
    9090    float descent = textMetrics.tmDescent;
    9191    float lineGap = textMetrics.tmExternalLeading;
    92     float decorationThickness;
    93     float underlinePosition;
    94     populateDecorationMetrics(m_platformData.size(), decorationThickness, underlinePosition);
    9592    m_fontMetrics.setAscent(ascent);
    9693    m_fontMetrics.setDescent(descent);
    9794    m_fontMetrics.setLineGap(lineGap);
    9895    m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
    99     m_fontMetrics.setDecorationThickness(decorationThickness);
    100     m_fontMetrics.setUnderlinePosition(underlinePosition);
    10196    m_avgCharWidth = textMetrics.tmAveCharWidth;
    10297    m_maxCharWidth = textMetrics.tmMaxCharWidth;
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r176263 r176298  
    926926    bool isPrinting = renderer().document().printing();
    927927
    928     float textDecorationThickness = renderer().style().fontMetrics().decorationThickness();
     928    float textDecorationThickness = textDecorationStrokeThickness(renderer().style().fontSize());
    929929    context.setStrokeThickness(textDecorationThickness);
    930930
     
    978978        if (decoration & TextDecorationUnderline) {
    979979            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);
    981981
    982982            switch (decorationStyle) {
  • trunk/Source/WebCore/style/InlineTextBoxStyle.cpp

    r176263 r176298  
    3333namespace WebCore {
    3434   
    35 int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, InlineTextBox* inlineTextBox)
     35int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, InlineTextBox* inlineTextBox, int textDecorationThickness)
    3636{
    3737    // 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));
    3939
    4040    // According to the specification TextUnderlinePositionAuto should default to 'alphabetic' for horizontal text
     
    8484        return GlyphOverflow();
    8585   
    86     float strokeThickness = lineStyle.fontMetrics().decorationThickness();
     86    float strokeThickness = textDecorationStrokeThickness(lineStyle.fontSize());
    8787    float controlPointDistance;
    8888    float step;
     
    102102    // These metrics must match where underlines get drawn.
    103103    if (decoration & TextDecorationUnderline) {
    104         float underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), inlineTextBox);
     104        float underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), inlineTextBox, strokeThickness);
    105105        if (decorationStyle == TextDecorationStyleWavy) {
    106106            extendIntToFloat(overflowResult.bottom, underlineOffset + wavyOffset + controlPointDistance + strokeThickness - height);
  • trunk/Source/WebCore/style/InlineTextBoxStyle.h

    r176263 r176298  
    3434class InlineTextBox;
    3535
     36inline float textDecorationStrokeThickness(float fontSize)
     37{
     38    const float textDecorationBaseFontSize = 16;
     39    return fontSize / textDecorationBaseFontSize;
     40}
     41
    3642inline float wavyOffsetFromDecoration()
    3743{
     
    4147GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, InlineTextBox*);
    4248void getWavyStrokeParameters(float strokeThickness, float& controlPointDistance, float& step);
    43 int computeUnderlineOffset(TextUnderlinePosition, const FontMetrics&, InlineTextBox*);
     49int computeUnderlineOffset(TextUnderlinePosition, const FontMetrics&, InlineTextBox*, int textDecorationThickness);
    4450   
    4551}
  • trunk/Source/WebCore/svg/SVGFontData.cpp

    r176263 r176298  
    8080    float descent = svgFontFaceElement->descent() * scale;
    8181    float lineGap = 0.1f * fontSize;
    82     float decorationThickness;
    83     float underlinePosition;
    84     populateDecorationMetrics(fontSize, decorationThickness, underlinePosition);
    8582
    8683    GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(fontData, 0)->page();
     
    9996    fontMetrics.setLineSpacing(roundf(ascent) + roundf(descent) + roundf(lineGap));
    10097    fontMetrics.setXHeight(xHeight);
    101     fontMetrics.setDecorationThickness(decorationThickness);
    102     fontMetrics.setUnderlinePosition(underlinePosition);
    10398
    10499    if (!glyphPageZero) {
Note: See TracChangeset for help on using the changeset viewer.