[Win] Reduce the use of WKSI library calls: Font Handling
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2018 22:38:39 +0000 (22:38 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2018 22:38:39 +0000 (22:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191701
<rdar://problem/46104809>

Reviewed by Myles C. Maxfield.

Source/WebCore:

Move the old Windows font handling code out of WKSI to our regular
repository. We now handle SPI differently, and don't need to keep
these implementations in a separate library. This should also help
avoid the somewhat frequent build failures caused when WKSI is not
updated in sync with WebKit.

Tested by existing Windows test cases.

* platform/graphics/FontCascade.h:
* platform/graphics/win/FontCGWin.cpp:
(WebCore::FontCascade::drawGlyphs):
(WebCore::FontCascade::setFontSmoothingLevel):
(WebCore::setCGFontSmoothingStyle):
(WebCore::FontCascade::setFontSmoothingStyle):
(WebCore::FontCascade::setFontSmoothingContrast):
(WebCore::clearTypeContrast):
(WebCore::FontCascade::systemFontSmoothingChanged):
(WebCore::FontCascade::setCGContextFontRenderingStyle):
(WebCore::renderingStyleForFont):
(WebCore::FontCascade::getGlyphAdvances):
* platform/graphics/win/GlyphPageTreeNodeCGWin.cpp:
(WebCore::GlyphPage::fill):
* platform/graphics/win/GraphicsContextCGWin.cpp:
(WebCore::GraphicsContext::drawFocusRing):
(WebCore::GraphicsContext::drawDotsForDocumentMarker):
* platform/graphics/win/SimpleFontDataCGWin.cpp:
(WebCore::Font::platformWidthForGlyph const):
* rendering/RenderMediaControls.cpp:
(WebCore::RenderMediaControls::adjustMediaSliderThumbSize):

Source/WebKitLegacy/win:

Update to use the old font handling routines moved from WKSI to FontCascade.

* WebPreferences.cpp:
(WebPreferences::setFontSmoothing):
(WebPreferences::setFontSmoothingContrast):
* WebView.cpp:
(systemParameterChanged):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238253 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/FontCascade.h
Source/WebCore/platform/graphics/win/FontCGWin.cpp
Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp
Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
Source/WebCore/rendering/RenderMediaControls.cpp
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebPreferences.cpp
Source/WebKitLegacy/win/WebView.cpp

index 242beca..71ae0b9 100644 (file)
@@ -1,3 +1,41 @@
+2018-11-15  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win] Reduce the use of WKSI library calls: Font Handling
+        https://bugs.webkit.org/show_bug.cgi?id=191701
+        <rdar://problem/46104809>
+
+        Reviewed by Myles C. Maxfield.
+
+        Move the old Windows font handling code out of WKSI to our regular
+        repository. We now handle SPI differently, and don't need to keep
+        these implementations in a separate library. This should also help
+        avoid the somewhat frequent build failures caused when WKSI is not
+        updated in sync with WebKit.
+
+        Tested by existing Windows test cases.
+
+        * platform/graphics/FontCascade.h:
+        * platform/graphics/win/FontCGWin.cpp:
+        (WebCore::FontCascade::drawGlyphs):
+        (WebCore::FontCascade::setFontSmoothingLevel):
+        (WebCore::setCGFontSmoothingStyle):
+        (WebCore::FontCascade::setFontSmoothingStyle):
+        (WebCore::FontCascade::setFontSmoothingContrast):
+        (WebCore::clearTypeContrast):
+        (WebCore::FontCascade::systemFontSmoothingChanged):
+        (WebCore::FontCascade::setCGContextFontRenderingStyle):
+        (WebCore::renderingStyleForFont):
+        (WebCore::FontCascade::getGlyphAdvances):
+        * platform/graphics/win/GlyphPageTreeNodeCGWin.cpp:
+        (WebCore::GlyphPage::fill):
+        * platform/graphics/win/GraphicsContextCGWin.cpp:
+        (WebCore::GraphicsContext::drawFocusRing):
+        (WebCore::GraphicsContext::drawDotsForDocumentMarker):
+        * platform/graphics/win/SimpleFontDataCGWin.cpp:
+        (WebCore::Font::platformWidthForGlyph const):
+        * rendering/RenderMediaControls.cpp:
+        (WebCore::RenderMediaControls::adjustMediaSliderThumbSize):
+
 2018-11-15  Jiewen Tan  <jiewen_tan@apple.com>
 
         [WebAuthN] Use a real nonce for CTAPHID_INIT
index 059f76f..a792de3 100644 (file)
@@ -189,7 +189,15 @@ public:
     bool primaryFontIsSystemFont() const;
 
     std::unique_ptr<DisplayList::DisplayList> displayListForTextRun(GraphicsContext&, const TextRun&, unsigned from = 0, std::optional<unsigned> to = { }, CustomFontNotReadyAction = CustomFontNotReadyAction::DoNotPaintIfFontNotReady) const;
-    
+
+#if PLATFORM(WIN) && USE(CG)
+    static void setFontSmoothingLevel(int);
+    static uint32_t setFontSmoothingStyle(CGContextRef, bool fontAllowsSmoothing);
+    static void setFontSmoothingContrast(CGFloat);
+    static void systemFontSmoothingChanged();
+    static void setCGContextFontRenderingStyle(CGContextRef, bool isSystemFont, bool isPrinterFont, bool usePlatformNativeGlyphs);
+    static void getPlatformGlyphAdvances(CGFontRef, const CGAffineTransform&, bool isSystemFont, bool isPrinterFont, CGGlyph, CGSize& advance);
+#endif
 private:
     enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };
 
@@ -298,6 +306,15 @@ private:
 
     static int syntheticObliqueAngle() { return 14; }
 
+#if PLATFORM(WIN) && USE(CG)
+    static double s_fontSmoothingContrast;
+    static uint32_t s_fontSmoothingType;
+    static int s_fontSmoothingLevel;
+    static uint32_t s_systemFontSmoothingType;
+    static bool s_systemFontSmoothingSet;
+    static bool s_systemFontSmoothingEnabled;
+#endif
+
     FontCascadeDescription m_fontDescription;
     mutable RefPtr<FontCascadeFonts> m_fonts;
     float m_letterSpacing { 0 };
index 7aaf068..0ef655d 100644 (file)
@@ -36,7 +36,7 @@
 #include "IntRect.h"
 #include "UniscribeController.h"
 #include "WebCoreTextRenderer.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cg/CoreGraphicsSPI.h>
 #include <wtf/MathExtras.h>
 
 namespace WebCore {
@@ -156,7 +156,7 @@ void FontCascade::drawGlyphs(GraphicsContext& graphicsContext, const Font& font,
         ASSERT_NOT_REACHED();
     }
 
-    uint32_t oldFontSmoothingStyle = wkSetFontSmoothingStyle(cgContext, shouldUseFontSmoothing);
+    uint32_t oldFontSmoothingStyle = FontCascade::setFontSmoothingStyle(cgContext, shouldUseFontSmoothing);
 
     const FontPlatformData& platformData = font.platformData();
 
@@ -175,7 +175,7 @@ void FontCascade::drawGlyphs(GraphicsContext& graphicsContext, const Font& font,
     CGContextSetTextMatrix(cgContext, matrix);
 
     CGContextSetFontSize(cgContext, platformData.size());
-    wkSetCGContextFontRenderingStyle(cgContext, font.platformData().isSystemFont(), false, font.platformData().useGDI());
+    FontCascade::setCGContextFontRenderingStyle(cgContext, font.platformData().isSystemFont(), false, font.platformData().useGDI());
 
     FloatSize shadowOffset;
     float shadowBlur;
@@ -211,10 +211,251 @@ void FontCascade::drawGlyphs(GraphicsContext& graphicsContext, const Font& font,
     if (hasSimpleShadow)
         graphicsContext.setShadow(shadowOffset, shadowBlur, shadowColor);
 
-    wkRestoreFontSmoothingStyle(cgContext, oldFontSmoothingStyle);
+    FontCascade::setFontSmoothingStyle(cgContext, oldFontSmoothingStyle);
     CGContextSetTextMatrix(cgContext, savedMatrix);
 }
 
+constexpr uint32_t kCGFontSmoothingStyleMinimum = (1 << 4);
+constexpr uint32_t kCGFontSmoothingStyleLight = (2 << 4);
+constexpr uint32_t kCGFontSmoothingStyleMedium = (3 << 4);
+constexpr uint32_t kCGFontSmoothingStyleHeavy = (4 << 4);
+
+constexpr int fontSmoothingLevelMedium = 2;
+constexpr CGFloat antialiasingGamma = 2.3;
+
+double FontCascade::s_fontSmoothingContrast = 2;
+uint32_t FontCascade::s_fontSmoothingType = kCGFontSmoothingStyleMedium;
+int FontCascade::s_fontSmoothingLevel = fontSmoothingLevelMedium;
+bool FontCascade::s_systemFontSmoothingEnabled;
+uint32_t FontCascade::s_systemFontSmoothingType;
+bool FontCascade::s_systemFontSmoothingSet;
+
+void FontCascade::setFontSmoothingLevel(int level)
+{
+    const uint32_t smoothingType[] = { 
+        0, // FontSmoothingTypeStandard
+        kCGFontSmoothingStyleLight, // FontSmoothingTypeLight
+        kCGFontSmoothingStyleMedium, // FontSmoothingTypeMedium
+        kCGFontSmoothingStyleHeavy, // FontSmoothingTypeStrong
+    };
+
+    if (level < 0 || static_cast<size_t>(level) > ARRAYSIZE(smoothingType))
+        return;
+
+    s_fontSmoothingType = smoothingType[level];
+    s_fontSmoothingLevel = level;
+}
+
+static void setCGFontSmoothingStyle(CGContextRef cgContext, uint32_t smoothingType, bool fontAllowsSmoothing = true)
+{
+    if (smoothingType) {
+        CGContextSetShouldSmoothFonts(cgContext, fontAllowsSmoothing);
+        CGContextSetFontSmoothingStyle(cgContext, smoothingType);
+    } else
+        CGContextSetShouldSmoothFonts(cgContext, false);
+}
+
+uint32_t FontCascade::setFontSmoothingStyle(CGContextRef cgContext, bool fontAllowsSmoothing)
+{
+    uint32_t oldFontSmoothingStyle = 0;
+    if (CGContextGetShouldSmoothFonts(cgContext))
+        oldFontSmoothingStyle = CGContextGetFontSmoothingStyle(cgContext);
+    setCGFontSmoothingStyle(cgContext, s_fontSmoothingType, fontAllowsSmoothing);
+
+    return oldFontSmoothingStyle;
+}
+
+void FontCascade::setFontSmoothingContrast(CGFloat contrast)
+{
+    s_fontSmoothingContrast = contrast;
+}
+
+static float clearTypeContrast()
+{
+    const WCHAR referenceCharacter = '\\';
+    static UINT lastContrast = 2000;
+    static float gamma = 2;
+    UINT contrast;
+
+    if (!SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0) || contrast == lastContrast)
+        return gamma;
+
+    lastContrast = contrast;
+
+    auto dc = adoptGDIObject(::CreateCompatibleDC(0));
+
+    HGDIOBJ oldHFONT = ::SelectObject(dc.get(), GetStockObject(DEFAULT_GUI_FONT));
+    GLYPHMETRICS glyphMetrics;
+
+    static const MAT2 identity = { 0, 1,  0, 0,  0, 0,  0, 1 };
+    if (::GetGlyphOutline(dc.get(), referenceCharacter, GGO_METRICS, &glyphMetrics, 0, 0, &identity) == GDI_ERROR)
+        return contrast / 1000.0f;
+
+    BITMAPINFO bitmapInfo;
+    bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    bitmapInfo.bmiHeader.biPlanes = 1;
+    bitmapInfo.bmiHeader.biCompression = BI_RGB;
+    bitmapInfo.bmiHeader.biSizeImage = 0;
+    bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
+    bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
+    bitmapInfo.bmiHeader.biClrImportant = 0;
+    bitmapInfo.bmiHeader.biWidth = glyphMetrics.gmBlackBoxX;
+    bitmapInfo.bmiHeader.biHeight = -static_cast<int>(glyphMetrics.gmBlackBoxY);
+    bitmapInfo.bmiHeader.biBitCount = 32;
+    bitmapInfo.bmiHeader.biClrUsed = 0;
+
+    uint8_t* pixels = nullptr;
+    auto bitmap = adoptGDIObject(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, reinterpret_cast<void**>(&pixels), 0, 0));
+    if (!bitmap)
+        return contrast / 1000.0f;
+
+    HGDIOBJ oldBitmap = ::SelectObject(dc.get(), bitmap.get());
+
+    BITMAP bmpInfo;
+    ::GetObject(bitmap.get(), sizeof(bmpInfo), &bmpInfo);
+    memset(pixels, 0, glyphMetrics.gmBlackBoxY * bmpInfo.bmWidthBytes);
+
+    ::SetBkMode(dc.get(), OPAQUE);
+    ::SetTextAlign(dc.get(), TA_LEFT | TA_TOP);
+
+    ::SetTextColor(dc.get(), RGB(255, 255, 255));
+    ::SetBkColor(dc.get(), RGB(0, 0, 0));
+    ::ExtTextOutW(dc.get(), 0, 0, 0, 0, &referenceCharacter, 1, 0);
+
+    uint8_t* referencePixel = nullptr;
+    uint8_t whiteReferenceValue = 0;
+    for (size_t i = 0; i < glyphMetrics.gmBlackBoxY && !referencePixel; ++i) {
+        for (size_t j = 0; j < 4 * glyphMetrics.gmBlackBoxX; ++j) {
+            whiteReferenceValue = pixels[i * bmpInfo.bmWidthBytes + j];
+            // Look for a pixel value in the range that allows us to estimate
+            // gamma within 0.1 without an error.
+            if (whiteReferenceValue > 32 && whiteReferenceValue < 240) {
+                referencePixel = pixels + i * bmpInfo.bmWidthBytes + j;
+                break;
+            }
+        }
+    }
+
+    if (referencePixel) {
+        ::SetTextColor(dc.get(), RGB(0, 0, 0));
+        ::SetBkColor(dc.get(), RGB(255, 255, 255));
+        ::ExtTextOutW(dc.get(), 0, 0, 0, 0, &referenceCharacter, 1, 0);
+        uint8_t blackReferenceValue = *referencePixel;
+
+        float minDelta = 1;
+        for (float g = 1; g < 2.3f; g += 0.1f) {
+            float delta = fabs(powf((whiteReferenceValue / 255.0f), g) + powf((blackReferenceValue / 255.0f), g) - 1);
+            if (delta < minDelta) {
+                minDelta = delta;
+                gamma = g;
+            }
+        }
+    } else
+        gamma = contrast / 1000.0f;
+
+    ::SelectObject(dc.get(), oldBitmap);
+    ::SelectObject(dc.get(), oldHFONT);
+
+    return gamma;
+}
+
+void FontCascade::systemFontSmoothingChanged()
+{
+    ::SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &s_systemFontSmoothingEnabled, 0);
+    ::SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &s_systemFontSmoothingType, 0);
+    s_fontSmoothingContrast = clearTypeContrast();
+    s_systemFontSmoothingSet = true;
+}
+
+void FontCascade::setCGContextFontRenderingStyle(CGContextRef cgContext, bool isSystemFont, bool /*isPrinterFont*/, bool usePlatformNativeGlyphs)
+{
+    bool shouldAntialias = true;
+    bool maySubpixelPosition = true;
+    CGFloat contrast = 2;
+    if (usePlatformNativeGlyphs) {
+        // <rdar://6564501> GDI can't subpixel-position, so don't bother asking.
+        maySubpixelPosition = false;
+        if (!s_systemFontSmoothingSet)
+            systemFontSmoothingChanged();
+        contrast = s_fontSmoothingContrast;
+        shouldAntialias = s_systemFontSmoothingEnabled;
+        if (s_systemFontSmoothingType == FE_FONTSMOOTHINGSTANDARD) {
+            CGContextSetFontSmoothingStyle(cgContext, kCGFontSmoothingStyleMinimum);
+            contrast = antialiasingGamma;
+        }
+    }
+    CGContextSetFontSmoothingContrast(cgContext, contrast);
+    CGContextSetShouldUsePlatformNativeGlyphs(cgContext, usePlatformNativeGlyphs);
+    CGContextSetShouldAntialiasFonts(cgContext, shouldAntialias);
+    CGAffineTransform contextTransform = CGContextGetCTM(cgContext);
+    bool isPureTranslation = contextTransform.a == 1 && (contextTransform.d == 1 || contextTransform.d == -1) && !contextTransform.b && !contextTransform.c;
+    CGContextSetShouldSubpixelPositionFonts(cgContext, maySubpixelPosition && (isSystemFont || !isPureTranslation));
+    CGContextSetShouldSubpixelQuantizeFonts(cgContext, isPureTranslation);
+}
+
+static inline CGFontRenderingStyle renderingStyleForFont(bool isSystemFont, bool isPrinterFont)
+{
+    // FIXME: Need to support a minimum antialiased font size.
+
+    if (isSystemFont || isPrinterFont)
+        return kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization;
+
+    return kCGFontRenderingStyleAntialiasing;
+}
+
+void FontCascade::getPlatformGlyphAdvances(CGFontRef font, const CGAffineTransform& m, bool isSystemFont, bool isPrinterFont, CGGlyph glyph, CGSize& advance)
+{
+    CGFontRenderingStyle style = renderingStyleForFont(isSystemFont, isPrinterFont);
+    CGFontGetGlyphAdvancesForStyle(font, &m, style, &glyph, 1, &advance);
+
+    // <rdar://problem/7761165> The GDI back end in Core Graphics sometimes returns advances that
+    // differ from what the font's hmtx table specifies. The following code corrects that.
+    CFDataRef hmtxTable = CGFontCopyTableForTag(font, 'hmtx');
+    if (!hmtxTable)
+        return;
+    CFDataRef hheaTable = CGFontCopyTableForTag(font, 'hhea');
+    if (!hheaTable) {
+        CFRelease(hmtxTable);
+        return;
+    }
+
+    const CFIndex hheaTableSize = 36;
+    const ptrdiff_t hheaTableNumberOfHMetricsOffset = 34;
+    if (CFDataGetLength(hheaTable) < hheaTableSize) {
+        CFRelease(hmtxTable);
+        CFRelease(hheaTable);
+        return;
+    }
+
+    unsigned short numberOfHMetrics = *reinterpret_cast<const unsigned short*>(CFDataGetBytePtr(hheaTable) + hheaTableNumberOfHMetricsOffset);
+    numberOfHMetrics = ((numberOfHMetrics & 0xFF) << 8) | (numberOfHMetrics >> 8);
+    if (!numberOfHMetrics) {
+        CFRelease(hmtxTable);
+        CFRelease(hheaTable);
+        return;
+    }
+
+    if (glyph >= numberOfHMetrics)
+        glyph = numberOfHMetrics - 1;
+
+    if (CFDataGetLength(hmtxTable) < 4 * (glyph + 1)) {
+        CFRelease(hmtxTable);
+        CFRelease(hheaTable);
+        return;
+    }
+
+    unsigned short advanceInDesignUnits = *reinterpret_cast<const unsigned short*>(CFDataGetBytePtr(hmtxTable) + 4 * glyph);
+    advanceInDesignUnits = ((advanceInDesignUnits & 0xFF) << 8) | (advanceInDesignUnits >> 8);
+    CGSize horizontalAdvance = CGSizeMake(static_cast<CGFloat>(advanceInDesignUnits) / CGFontGetUnitsPerEm(font), 0);
+    horizontalAdvance = CGSizeApplyAffineTransform(horizontalAdvance, m);
+    advance.width = horizontalAdvance.width;
+    if (!(style & kCGFontRenderingStyleSubpixelPositioning))
+        advance.width = roundf(advance.width);
+
+    CFRelease(hheaTable);
+    CFRelease(hmtxTable);
+}
+
 }
 
 #endif
index ae3cab3..47631da 100644 (file)
@@ -32,7 +32,6 @@
 #if USE(CG)
 
 #include "Font.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
 
 namespace WebCore {
 
@@ -46,7 +45,7 @@ bool GlyphPage::fill(UChar* buffer, unsigned bufferLength)
     const Font& font = this->font();
     bool haveGlyphs = false;
     CGGlyph localGlyphBuffer[GlyphPage::size];
-    wkGetGlyphs(font.platformData().cgFont(), buffer, localGlyphBuffer, bufferLength);
+    CGFontGetGlyphsForUnichars(font.platformData().cgFont(), reinterpret_cast<const UniChar*>(buffer), localGlyphBuffer, bufferLength);
     for (unsigned i = 0; i < GlyphPage::size; i++) {
         Glyph glyph = localGlyphBuffer[i];
         if (!glyph)
index e0e2380..3974747 100644 (file)
@@ -34,7 +34,6 @@
 #include "Path.h"
 
 #include <CoreGraphics/CGBitmapContext.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <wtf/win/GDIObject.h>
 
 
@@ -160,7 +159,12 @@ void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float width,
     CGContextBeginPath(context);
     CGContextAddPath(context, focusRingPath);
 
-    wkDrawFocusRing(context, colorRef, radius);
+    // FIXME: We clear the fill color here to avoid getting a black fill when drawing the focus ring.
+    // Find out from CG if this is their bug.
+    CGContextSetRGBFillColor(context, 0, 0, 0, 0);
+
+    CGContextSetFocusRingWithColor(context, radius, colorRef, 0, (CFDictionaryRef)0);
+    CGContextFillPath(context);
 
     CGPathRelease(focusRingPath);
 
@@ -216,7 +220,10 @@ void GraphicsContext::drawDotsForDocumentMarker(const FloatRect& rect, DocumentM
     const Color& patternColor = style.mode == DocumentMarkerLineStyle::Mode::Grammar ? grammarPatternColor() : spellingPatternColor();
     setCGStrokeColor(context, patternColor);
 
-    wkSetPatternPhaseInUserSpace(context, point);
+    CGAffineTransform userToBase = getUserToBaseCTM(context);
+    CGPoint phase = CGPointApplyAffineTransform(point, userToBase);
+
+    CGContextSetPatternPhase(context, CGSizeMake(phase.x, phase.y));
     CGContextSetBlendMode(context, kCGBlendModeNormal);
     
     // 3 rows, each offset by half a pixel for blending purposes
index 3b3ee8e..07cd533 100644 (file)
 
 #include "FloatRect.h"
 #include "FontCache.h"
+#include "FontCascade.h"
 #include "FontDescription.h"
 #include "GlyphPage.h"
 #include "HWndDC.h"
 #include "OpenTypeCG.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <mlang.h>
 #include <pal/spi/win/CoreTextSPIWin.h>
 #include <unicode/uchar.h>
@@ -147,7 +147,7 @@ float Font::platformWidthForGlyph(Glyph glyph) const
     CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
  
     bool isPrinterFont = false;
-    wkGetGlyphAdvances(font, m, m_platformData.isSystemFont(), isPrinterFont, glyph, advance);
+    FontCascade::getPlatformGlyphAdvances(font, m, m_platformData.isSystemFont(), isPrinterFont, glyph, advance);
 
     return advance.width + m_syntheticBoldOffset;
 }
index 2d682f9..a50c1be 100644 (file)
 
 #if ENABLE(VIDEO) && PLATFORM(WIN) && USE(CG)
 
-#include "MediaControlElementTypes.h"
-#include "RenderStyle.h"
-#include <CoreGraphics/CoreGraphics.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-
 namespace WebCore {
 
-static const int mediaSliderThumbWidth = 13;
-static const int mediaSliderThumbHeight = 14;
-
 void RenderMediaControls::adjustMediaSliderThumbSize(RenderStyle& style)
 {
-    int part;
-    switch (style.appearance()) {
-    case MediaSliderThumbPart:
-        part = MediaSliderThumb;
-        break;
-    case MediaVolumeSliderThumbPart:
-        part = MediaVolumeSliderThumb;
-        break;
-    case MediaFullScreenVolumeSliderThumbPart:
-        part = MediaFullScreenVolumeSliderThumb;
-        break;
-    default:
-        return;
-    }
-
-    CGSize size;
-    WKMeasureMediaUIPart(part, 0, &size);
-
-    float zoomLevel = style.effectiveZoom();
-    style.setWidth(Length(static_cast<int>(size.width * zoomLevel), Fixed));
-    style.setHeight(Length(static_cast<int>(size.height * zoomLevel), Fixed));
+    ASSERT_NOT_REACHED();
 }
 
 }
index 1158fbb..0934704 100644 (file)
@@ -1,3 +1,19 @@
+2018-11-15  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win] Reduce the use of WKSI library calls: Font Handling
+        https://bugs.webkit.org/show_bug.cgi?id=191701
+        <rdar://problem/46104809>
+
+        Reviewed by Myles C. Maxfield.
+
+        Update to use the old font handling routines moved from WKSI to FontCascade.
+
+        * WebPreferences.cpp:
+        (WebPreferences::setFontSmoothing):
+        (WebPreferences::setFontSmoothingContrast):
+        * WebView.cpp:
+        (systemParameterChanged):
+
 2018-11-14  Timothy Hatcher  <timothy@apple.com>
 
         Default the view background color and text color to different values when in dark mode.
index 4de93fa..2234614 100644 (file)
@@ -1271,7 +1271,7 @@ HRESULT WebPreferences::setFontSmoothing(FontSmoothingType smoothingType)
     if (smoothingType == FontSmoothingTypeWindows)
         smoothingType = FontSmoothingTypeMedium;
 #if USE(CG)
-    wkSetFontSmoothingLevel((int)smoothingType);
+    FontCascade::setFontSmoothingLevel((int)smoothingType);
 #endif
     return S_OK;
 }
@@ -1288,7 +1288,7 @@ HRESULT WebPreferences::setFontSmoothingContrast(float contrast)
 {
     setFloatValue(WebKitFontSmoothingContrastPreferenceKey, contrast);
 #if USE(CG)
-    wkSetFontSmoothingContrast(contrast);
+    FontCascade::setFontSmoothingContrast(contrast);
 #endif
     return S_OK;
 }
index 1ea915a..ec45e39 100644 (file)
@@ -3719,7 +3719,7 @@ static void systemParameterChanged(WPARAM parameter)
 {
 #if USE(CG)
     if (parameter == SPI_SETFONTSMOOTHING || parameter == SPI_SETFONTSMOOTHINGTYPE || parameter == SPI_SETFONTSMOOTHINGCONTRAST || parameter == SPI_SETFONTSMOOTHINGORIENTATION)
-        wkSystemFontSmoothingChanged();
+        FontCascade::systemFontSmoothingChanged();
 #endif
 }