Title: [134453] trunk/Source/WebCore
Revision
134453
Author
par...@webkit.org
Date
2012-11-13 11:31:14 -0800 (Tue, 13 Nov 2012)

Log Message

Port SimpleFontDataWin.cpp to WinCE
https://bugs.webkit.org/show_bug.cgi?id=97889

Reviewed by Brent Fulgham.

Add #if !OS(WINCE) around some parts of the code, so it can be used by the WinCE port too in a next step.
Also cleaned up the include headers.

* platform/graphics/win/SimpleFontDataWin.cpp:
(WebCore::SimpleFontData::initGDIFont):
(WebCore::SimpleFontData::platformDestroy):
(WebCore::SimpleFontData::boundsForGDIGlyph):
(WebCore):
(WebCore::SimpleFontData::widthForGDIGlyph):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134452 => 134453)


--- trunk/Source/WebCore/ChangeLog	2012-11-13 19:29:40 UTC (rev 134452)
+++ trunk/Source/WebCore/ChangeLog	2012-11-13 19:31:14 UTC (rev 134453)
@@ -1,3 +1,20 @@
+2012-11-13  Patrick Gansterer  <par...@webkit.org>
+
+        Port SimpleFontDataWin.cpp to WinCE
+        https://bugs.webkit.org/show_bug.cgi?id=97889
+
+        Reviewed by Brent Fulgham.
+
+        Add #if !OS(WINCE) around some parts of the code, so it can be used by the WinCE port too in a next step.
+        Also cleaned up the include headers.
+
+        * platform/graphics/win/SimpleFontDataWin.cpp:
+        (WebCore::SimpleFontData::initGDIFont):
+        (WebCore::SimpleFontData::platformDestroy):
+        (WebCore::SimpleFontData::boundsForGDIGlyph):
+        (WebCore):
+        (WebCore::SimpleFontData::widthForGDIGlyph):
+
 2012-11-13  Pavel Feldman  <pfeld...@chromium.org>
 
         Web Inspector: [Chromium] move spectrum.css into the standalone css files group.

Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp (134452 => 134453)


--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp	2012-11-13 19:29:40 UTC (rev 134452)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp	2012-11-13 19:31:14 UTC (rev 134453)
@@ -35,18 +35,10 @@
 #include "FontDescription.h"
 #include "HWndDC.h"
 #include <mlang.h>
-#include <winsock2.h>
 #include <wtf/MathExtras.h>
 
-#if USE(CG)
-#include <ApplicationServices/ApplicationServices.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#endif
-
 namespace WebCore {
 
-using std::max;
-
 const float cSmallCapsFontSizeMultiplier = 0.7f;
 
 static bool g_shouldApplyMacAscentHack;
@@ -103,13 +95,13 @@
      m_avgCharWidth = textMetrics.tmAveCharWidth;
      m_maxCharWidth = textMetrics.tmMaxCharWidth;
      float xHeight = ascent * 0.56f; // Best guess for xHeight if no x glyph is present.
-
+#if !OS(WINCE)
      GLYPHMETRICS gm;
      MAT2 mat = { 1, 0, 0, 1 };
      DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat);
      if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0)
          xHeight = gm.gmptGlyphOrigin.y;
-
+#endif
      m_fontMetrics.setXHeight(xHeight);
      m_fontMetrics.setUnitsPerEm(metrics.otmEMSquare);
 
@@ -128,8 +120,10 @@
 
 void SimpleFontData::platformDestroy()
 {
+#if !OS(WINCE)
     ScriptFreeCache(&m_scriptCache);
     delete m_scriptFontProperties;
+#endif
 }
 
 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
@@ -205,35 +199,50 @@
 
 FloatRect SimpleFontData::boundsForGDIGlyph(Glyph glyph) const
 {
+#if OS(WINCE)
+    return FloatRect();
+#else
     HWndDC hdc(0);
     SetGraphicsMode(hdc, GM_ADVANCED);
     HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
-    
+
     GLYPHMETRICS gdiMetrics;
     static const MAT2 identity = { 0, 1,  0, 0,  0, 0,  0, 1 };
     GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity);
-    
+
     SelectObject(hdc, oldFont);
-    
+
     return FloatRect(gdiMetrics.gmptGlyphOrigin.x, -gdiMetrics.gmptGlyphOrigin.y,
         gdiMetrics.gmBlackBoxX + m_syntheticBoldOffset, gdiMetrics.gmBlackBoxY); 
+#endif
 }
-    
+
 float SimpleFontData::widthForGDIGlyph(Glyph glyph) const
 {
     HWndDC hdc(0);
+#if !OS(WINCE)
     SetGraphicsMode(hdc, GM_ADVANCED);
+#endif
     HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
 
+#if OS(WINCE)
+    WCHAR c = glyph;
+    SIZE fontSize;
+    GetTextExtentPoint32W(hdc, &c, 1, &fontSize);
+    float result = fontSize.cx * m_platformData.size() / 72.f;
+#else
     GLYPHMETRICS gdiMetrics;
     static const MAT2 identity = { 0, 1,  0, 0,  0, 0,  0, 1 };
     GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity);
+    float result = gdiMetrics.gmCellIncX + m_syntheticBoldOffset;
+#endif
 
     SelectObject(hdc, oldFont);
 
-    return gdiMetrics.gmCellIncX + m_syntheticBoldOffset;
+    return result;
 }
 
+#if !OS(WINCE)
 SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const
 {
     if (!m_scriptFontProperties) {
@@ -251,5 +260,6 @@
     }
     return m_scriptFontProperties;
 }
+#endif
 
-}
+} // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to