Changeset 126312 in webkit


Ignore:
Timestamp:
Aug 22, 2012 9:53:51 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

FontMetrics.unitsPerEm(), FontPlatformData.orientation(), SimpleFontData::platformBoundsForGlyph are not implemented on Chromium Windows
https://bugs.webkit.org/show_bug.cgi?id=83512

Patch by Koji Ishii <Koji Ishii> on 2012-08-22
Reviewed by Tony Chang.

Source/WebCore:

Chromium Windows does not implement following 3 functions that are required for bug 51450.

  1. FontMetrics.unitsPerEm() always returns the default value (gDefaultUnitsPerEm = 1000).
  2. FontPlatformData.orientation() always returns Horizontal.
  3. SimpleFontData::platformBoundsForGlyph() always returns FloatRect().

Tony suggested in bug 51450 review to split code that is not behind
#if ENABLE(OPENTYPE_VERTICAL) to a separate patch.

Test: Following 3 existing but skipped tests are now enabled and pass.

fast/text/emphasis-overlap.html
fast/text/emphasis-avoid-ruby.html
fast/repaint/text-emphasis-v.html

  • platform/graphics/chromium/FontCacheChromiumWin.cpp:

(WebCore::FontCache::createFontPlatformData): Add orientation.

  • platform/graphics/chromium/FontPlatformDataChromiumWin.cpp:

(WebCore::FontPlatformData::FontPlatformData): Add orientation.
(WebCore::FontPlatformData::operator=): Add orientation.

  • platform/graphics/chromium/FontPlatformDataChromiumWin.h:

(FontPlatformData):
(WebCore::FontPlatformData::orientation): Add orientation.
(WebCore::FontPlatformData::setOrientation): Add orientation.
(WebCore::FontPlatformData::operator==): Add orientation.

  • platform/graphics/chromium/SimpleFontDataChromiumWin.cpp:

(WebCore::SimpleFontData::platformInit): Set FontMetrics.unitsPerEm.
(WebCore::SimpleFontData::createScaledFontData): Add orientation.
(WebCore::SimpleFontData::platformBoundsForGlyph): Implemented.

  • platform/graphics/skia/FontCustomPlatformData.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData): Add orientation.

LayoutTests:

Chromium Windows does not implement following 3 functions that are required for bug 51450.

  1. FontMetrics.unitsPerEm() always returns the default value (gDefaultUnitsPerEm = 1000). This change requires rebaseline of fast/repaint/stacked-diacritics and fast/text/emphasis-overlap.
  2. FontPlatformData.orientation() always returns Horizontal. This has no effect as of this patch.
  3. SimpleFontData::platformBoundsForGlyph() always returns FloatRect(). This change improves rendering of text-emphasis and 3 existing tests pass now.

Tony suggested in bug 51450 review to split code that is not behind
#if ENABLE(OPENTYPE_VERTICAL) to a separate patch.

  • platform/chromium-win/fast/repaint/stacked-diacritics-expected.png:
  • platform/chromium-win/fast/text/emphasis-overlap-expected.txt: Added due to metrics change.
  • platform/chromium/TestExpectations: Enabled 3 tests for Chromium Win.
Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r126309 r126312  
     12012-08-22  Koji Ishii  <kojiishi@gmail.com>
     2
     3        FontMetrics.unitsPerEm(), FontPlatformData.orientation(), SimpleFontData::platformBoundsForGlyph are not implemented on Chromium Windows
     4        https://bugs.webkit.org/show_bug.cgi?id=83512
     5
     6        Reviewed by Tony Chang.
     7
     8        Chromium Windows does not implement following 3 functions that are required for bug 51450.
     9        1. FontMetrics.unitsPerEm() always returns the default value (gDefaultUnitsPerEm = 1000).
     10           This change requires rebaseline of fast/repaint/stacked-diacritics and fast/text/emphasis-overlap.
     11        2. FontPlatformData.orientation() always returns Horizontal. This has no effect as of this patch.
     12        3. SimpleFontData::platformBoundsForGlyph() always returns FloatRect().
     13           This change improves rendering of text-emphasis and 3 existing tests pass now.
     14        Tony suggested in bug 51450 review to split code that is not behind
     15        #if ENABLE(OPENTYPE_VERTICAL) to a separate patch.
     16
     17        * platform/chromium-win/fast/repaint/stacked-diacritics-expected.png:
     18        * platform/chromium-win/fast/text/emphasis-overlap-expected.txt: Added due to metrics change.
     19        * platform/chromium/TestExpectations: Enabled 3 tests for Chromium Win.
     20
    1212012-08-22  Dominic Mazzoni  <dmazzoni@google.com>
    222
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r126288 r126312  
    21932193BUGCR67416 LINUX ANDROID WIN : fast/text/emphasis.html = IMAGE+TEXT
    21942194BUGCR67416 : fast/text/emphasis-vertical.html = IMAGE IMAGE+TEXT
    2195 BUGCR67540 LINUX ANDROID WIN : fast/text/emphasis-overlap.html = IMAGE+TEXT
    2196 BUGCR67540 LINUX ANDROID WIN : fast/text/emphasis-avoid-ruby.html = IMAGE
     2195BUGCR67540 LINUX ANDROID : fast/text/emphasis-overlap.html = IMAGE+TEXT
     2196BUGCR67540 LINUX ANDROID : fast/text/emphasis-avoid-ruby.html = IMAGE
    21972197BUGCR67540 LINUX ANDROID WIN SNOWLEOPARD : fast/repaint/text-emphasis-h.html = IMAGE
    2198 BUGCR67540 LINUX ANDROID WIN : fast/repaint/text-emphasis-v.html = IMAGE
     2198BUGCR67540 LINUX ANDROID : fast/repaint/text-emphasis-v.html = IMAGE
    21992199
    22002200BUGCR67442 LINUX WIN : fast/canvas/fillText-shadow.html = TEXT
  • trunk/Source/WebCore/ChangeLog

    r126310 r126312  
     12012-08-22  Koji Ishii  <kojiishi@gmail.com>
     2
     3        FontMetrics.unitsPerEm(), FontPlatformData.orientation(), SimpleFontData::platformBoundsForGlyph are not implemented on Chromium Windows
     4        https://bugs.webkit.org/show_bug.cgi?id=83512
     5
     6        Reviewed by Tony Chang.
     7
     8        Chromium Windows does not implement following 3 functions that are required for bug 51450.
     9        1. FontMetrics.unitsPerEm() always returns the default value (gDefaultUnitsPerEm = 1000).
     10        2. FontPlatformData.orientation() always returns Horizontal.
     11        3. SimpleFontData::platformBoundsForGlyph() always returns FloatRect().
     12        Tony suggested in bug 51450 review to split code that is not behind
     13        #if ENABLE(OPENTYPE_VERTICAL) to a separate patch.
     14
     15        Test: Following 3 existing but skipped tests are now enabled and pass.
     16              fast/text/emphasis-overlap.html
     17              fast/text/emphasis-avoid-ruby.html
     18              fast/repaint/text-emphasis-v.html
     19
     20        * platform/graphics/chromium/FontCacheChromiumWin.cpp:
     21        (WebCore::FontCache::createFontPlatformData): Add orientation.
     22        * platform/graphics/chromium/FontPlatformDataChromiumWin.cpp:
     23        (WebCore::FontPlatformData::FontPlatformData): Add orientation.
     24        (WebCore::FontPlatformData::operator=): Add orientation.
     25        * platform/graphics/chromium/FontPlatformDataChromiumWin.h:
     26        (FontPlatformData):
     27        (WebCore::FontPlatformData::orientation): Add orientation.
     28        (WebCore::FontPlatformData::setOrientation): Add orientation.
     29        (WebCore::FontPlatformData::operator==): Add orientation.
     30        * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp:
     31        (WebCore::SimpleFontData::platformInit): Set FontMetrics.unitsPerEm.
     32        (WebCore::SimpleFontData::createScaledFontData): Add orientation.
     33        (WebCore::SimpleFontData::platformBoundsForGlyph): Implemented.
     34        * platform/graphics/skia/FontCustomPlatformData.cpp:
     35        (WebCore::FontCustomPlatformData::fontPlatformData): Add orientation.
     36
    1372012-08-22  Robert Hogan  <robert@webkit.org>
    238
  • trunk/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp

    r123424 r126312  
    630630
    631631    return new FontPlatformData(hfont,
    632                                 fontDescription.computedPixelSize());
    633 }
    634 
    635 }
     632                                fontDescription.computedPixelSize(),
     633                                fontDescription.orientation());
     634}
     635
     636}
  • trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp

    r111344 r126312  
    3333#include "FontPlatformData.h"
    3434
    35 #include <windows.h>
    36 #include <objidl.h>
    37 #include <mlang.h>
    38 
     35#include "FontCache.h"
    3936#include "HWndDC.h"
    4037#include "PlatformSupport.h"
     38#include "SharedBuffer.h"
    4139#include "SkTypeface_win.h"
    4240#include "SkiaFontWin.h"
     41
     42#include <mlang.h>
     43#include <objidl.h>
     44#include <windows.h>
    4345#include <wtf/StdLibExtras.h>
    4446
     
    6365    : m_font(hashTableDeletedFontValue())
    6466    , m_size(-1)
     67    , m_orientation(Horizontal)
    6568    , m_scriptCache(0)
    6669    , m_scriptFontProperties(0)
     
    7376    : m_font(0)
    7477    , m_size(0)
     78    , m_orientation(Horizontal)
    7579    , m_scriptCache(0)
    7680    , m_scriptFontProperties(0)
     
    8084}
    8185
    82 FontPlatformData::FontPlatformData(HFONT font, float size)
     86FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orientation)
    8387    : m_font(RefCountedHFONT::create(font))
    8488    , m_size(size)
     89    , m_orientation(orientation)
    8590    , m_scriptCache(0)
    8691    , m_scriptFontProperties(0)
     
    9398    : m_font(0)
    9499    , m_size(size)
     100    , m_orientation(Horizontal)
    95101    , m_scriptCache(0)
    96102    , m_scriptFontProperties(0)
     
    103109    : m_font(data.m_font)
    104110    , m_size(data.m_size)
     111    , m_orientation(data.m_orientation)
    105112    , m_scriptCache(0)
    106113    , m_scriptFontProperties(0)
     
    116123        m_font = data.m_font;
    117124        m_size = data.m_size;
     125        m_orientation = data.m_orientation;
    118126        SkRefCnt_SafeAssign(m_typeface, data.m_typeface);
    119127        m_lfQuality = data.m_lfQuality;
  • trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h

    r103262 r126312  
    6565    FontPlatformData();
    6666    // This constructor takes ownership of the HFONT
    67     FontPlatformData(HFONT, float size);
     67    FontPlatformData(HFONT, float size, FontOrientation);
    6868    FontPlatformData(float size, bool bold, bool oblique);
    6969    FontPlatformData(const FontPlatformData&);
     
    8080    int lfQuality() const { return m_lfQuality; }
    8181
    82     FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
    83     void setOrientation(FontOrientation) { } // FIXME: Implement.
     82    FontOrientation orientation() const { return m_orientation; }
     83    void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
    8484
    8585    unsigned hash() const
     
    9090    bool operator==(const FontPlatformData& other) const
    9191    {
    92         return m_font == other.m_font && m_size == other.m_size;
     92        return m_font == other.m_font && m_size == other.m_size && m_orientation == other.m_orientation;
    9393    }
    9494
     
    138138    RefPtr<RefCountedHFONT> m_font;
    139139    float m_size;  // Point size of the font in pixels.
     140    FontOrientation m_orientation;
    140141
    141142    SkTypeface* m_typeface; // cached from m_font
  • trunk/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp

    r105654 r126312  
    8282    OUTLINETEXTMETRIC outlineTextMetric;
    8383    if (GetOutlineTextMetrics(dc, sizeof(outlineTextMetric), &outlineTextMetric) > 0) {
     84        m_fontMetrics.setUnitsPerEm(outlineTextMetric.otmEMSquare);
     85
    8486        // This is a TrueType font.  We might be able to get an accurate xHeight.
    8587        GLYPHMETRICS glyphMetrics = {0};
     
    115117    winFont.lfHeight = -lroundf(scaledSize);
    116118    HFONT hfont = CreateFontIndirect(&winFont);
    117     return adoptPtr(new SimpleFontData(FontPlatformData(hfont, scaledSize), isCustomFont(), false));
     119    return adoptPtr(new SimpleFontData(FontPlatformData(hfont, scaledSize, m_platformData.orientation()), isCustomFont(), false));
    118120}
    119121
     
    169171}
    170172
    171 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const
    172 {
    173     return FloatRect();
     173FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
     174{
     175    HWndDC hdc(0);
     176    SetGraphicsMode(hdc, GM_ADVANCED);
     177    HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
     178
     179    GLYPHMETRICS gdiMetrics;
     180    static const MAT2 identity = { 0, 1,  0, 0,  0, 0,  0, 1 };
     181    if (GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity) == -1) {
     182        if (PlatformSupport::ensureFontLoaded(m_platformData.hfont())) {
     183            // Retry GetTextMetrics.
     184            // FIXME: Handle gracefully the error if this call also fails.
     185            // See http://crbug.com/6401.
     186            if (GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity) == -1)
     187                LOG_ERROR("Unable to get the glyph metrics after second attempt");
     188        }
     189    }
     190
     191    SelectObject(hdc, oldFont);
     192
     193    return FloatRect(gdiMetrics.gmptGlyphOrigin.x, -gdiMetrics.gmptGlyphOrigin.y,
     194        gdiMetrics.gmBlackBoxX, gdiMetrics.gmBlackBoxY);
    174195}
    175196
  • trunk/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp

    r123424 r126312  
    101101
    102102    HFONT hfont = CreateFontIndirect(&logFont);
    103     return FontPlatformData(hfont, size);
     103    return FontPlatformData(hfont, size, orientation);
    104104#elif OS(UNIX)
    105105    ASSERT(m_fontReference);
Note: See TracChangeset for help on using the changeset viewer.