| Differences between
and this patch
- a/Source/WebCore/ChangeLog +29 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2016-04-05  Myles C. Maxfield  <mmaxfield@apple.com>
2
3
        REGRESSION (r188591): thingiverse.com direct messaging UI is not rendered properly
4
        https://bugs.webkit.org/show_bug.cgi?id=156241
5
        <rdar://problem/25262213>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        text-rendering: optimizeLegibility enables optical sizing. When using an optical
10
        size of 0, CoreText actually uses a size of 12. In this situation, a space character
11
        will have a non-zero advance, causing it to take some space in inline layout. This
12
        was causing an unexpected line-wrap.
13
14
        Other browsers don't turn on optical sizing when text-rendering: optimizeLegibility
15
        is specified, so they don't have this problem.
16
17
        The solution is to detect a zero-sized font, and force the advances to 0.
18
19
        Test: fast/text/zero-sized-fonts.html
20
21
        * platform/graphics/FontCascade.cpp:
22
        (WebCore::FontCascade::width):
23
        * platform/graphics/WidthIterator.cpp:
24
        (WebCore::WidthIterator::advanceInternal):
25
        * platform/graphics/cocoa/FontCacheCoreText.cpp:
26
        (WebCore::preparePlatformFont):
27
        * platform/graphics/mac/ComplexTextController.cpp:
28
        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
29
1
2016-04-04  Dean Jackson  <dino@apple.com>
30
2016-04-04  Dean Jackson  <dino@apple.com>
2
31
3
        Add color-gamut media query support
32
        Add color-gamut media query support
- a/Source/WebCore/platform/graphics/FontCascade.cpp +3 lines
Lines 348-353 void FontCascade::drawEmphasisMarks(GraphicsContext& context, const TextRun& run a/Source/WebCore/platform/graphics/FontCascade.cpp_sec1
348
348
349
float FontCascade::width(const TextRun& run, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
349
float FontCascade::width(const TextRun& run, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
350
{
350
{
351
    if (!fontDescription().computedPixelSize() && !fallbackFonts && !glyphOverflow)
352
        return 0;
353
351
    CodePath codePathToUse = codePath(run);
354
    CodePath codePathToUse = codePath(run);
352
    if (codePathToUse != Complex) {
355
    if (codePathToUse != Complex) {
353
        // The complex path is more restrictive about returning fallback fonts than the simple path, so we need an explicit test to make their behaviors match.
356
        // The complex path is more restrictive about returning fallback fonts than the simple path, so we need an explicit test to make their behaviors match.
- a/Source/WebCore/platform/graphics/WidthIterator.cpp -2 / +2 lines
Lines 202-211 inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph a/Source/WebCore/platform/graphics/WidthIterator.cpp_sec1
202
        ASSERT(font);
202
        ASSERT(font);
203
203
204
        // Now that we have a glyph and font data, get its width.
204
        // Now that we have a glyph and font data, get its width.
205
        float width;
205
        float width = 0;
206
        if (character == '\t' && m_run.allowTabs())
206
        if (character == '\t' && m_run.allowTabs())
207
            width = m_font->tabWidth(*font, m_run.tabSize(), m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding);
207
            width = m_font->tabWidth(*font, m_run.tabSize(), m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding);
208
        else {
208
        else if (m_font->fontDescription().computedSize()) {
209
            width = font->widthForGlyph(glyph);
209
            width = font->widthForGlyph(glyph);
210
210
211
            // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squeeze text.
211
            // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squeeze text.
- a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp -2 / +2 lines
Lines 408-415 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMo a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp_sec1
408
        }
408
        }
409
        CFDictionaryAddValue(attributes.get(), kCTFontFeatureSettingsAttribute, featureArray.get());
409
        CFDictionaryAddValue(attributes.get(), kCTFontFeatureSettingsAttribute, featureArray.get());
410
    }
410
    }
411
    if (textRenderingMode == OptimizeLegibility) {
411
    CGFloat size = CTFontGetSize(originalFont);
412
        CGFloat size = CTFontGetSize(originalFont);
412
    if (textRenderingMode == OptimizeLegibility && size) {
413
        RetainPtr<CFNumberRef> sizeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &size));
413
        RetainPtr<CFNumberRef> sizeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &size));
414
        CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, sizeNumber.get());
414
        CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, sizeNumber.get());
415
    }
415
    }
- a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp +2 lines
Lines 710-715 void ComplexTextController::adjustGlyphsAndAdvances() a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp_sec1
710
710
711
            if (ch == '\t' && m_run.allowTabs())
711
            if (ch == '\t' && m_run.allowTabs())
712
                advance.width = m_font.tabWidth(font, m_run.tabSize(), m_run.xPos() + m_totalWidth + widthSinceLastCommit);
712
                advance.width = m_font.tabWidth(font, m_run.tabSize(), m_run.xPos() + m_totalWidth + widthSinceLastCommit);
713
            else if (!m_font.fontDescription().computedPixelSize())
714
                advance.width = 0;
713
            else if (FontCascade::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
715
            else if (FontCascade::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
714
                advance.width = 0;
716
                advance.width = 0;
715
                glyph = font.spaceGlyph();
717
                glyph = font.spaceGlyph();
- a/LayoutTests/ChangeLog +11 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2016-04-05  Myles C. Maxfield  <mmaxfield@apple.com>
2
3
        REGRESSION (r188591): thingiverse.com direct messaging UI is not rendered properly
4
        https://bugs.webkit.org/show_bug.cgi?id=156241
5
        <rdar://problem/25262213>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        * fast/text/zero-sized-fonts-expected.html: Added.
10
        * fast/text/zero-sized-fonts.html: Added.
11
1
2016-04-04  Dean Jackson  <dino@apple.com>
12
2016-04-04  Dean Jackson  <dino@apple.com>
2
13
3
        Add color-gamut media query support
14
        Add color-gamut media query support
- a/LayoutTests/fast/text/zero-sized-fonts-expected.html +8 lines
Line 0 a/LayoutTests/fast/text/zero-sized-fonts-expected.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
</head>
5
<body style="text-rendering: optimizeLegibility;">
6
This test makes sure that 0-sized fonts have 0-sized advances. The two green rectangles below should have a height of 20 pixels.
7
<div style="width: 970px; height: 20px; background: green;"></div></body>
8
</html>
- a/LayoutTests/fast/text/zero-sized-fonts.html +8 lines
Line 0 a/LayoutTests/fast/text/zero-sized-fonts.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
</head>
5
<body style="text-rendering: optimizeLegibility;">
6
This test makes sure that 0-sized fonts have 0-sized advances. The two green rectangles below should have a height of 20 pixels.
7
<div style="font-size: 0; width: 970px; background: green;"><div style="display: inline-block; width: 320px; height: 20px; font-size: 16px; background: green;"></div> <div style="display: inline-block; width: 648px; height: 10px; font-size: 16px; background: green;"></div></div></body>
8
</html>

Return to Bug 156241