<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[178578] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/178578">178578</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2015-01-16 08:07:46 -0800 (Fri, 16 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Correct naming for FontCascade implementation files
https://bugs.webkit.org/show_bug.cgi?id=140544
Reviewed by Zalan Bujtas.
Also reduce their number.
Merge FontFastPath.cpp into FontCascade.cpp
Merge FontMac.mm and FontComplexTextMac.cpp into FontCascadeCocoa.mm
* CMakeLists.txt:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::getEmphasisMarkGlyphData):
(WebCore::FontCascade::emphasisMarkAscent):
(WebCore::FontCascade::emphasisMarkDescent):
(WebCore::FontCascade::emphasisMarkHeight):
(WebCore::FontCascade::getGlyphsAndAdvancesForSimpleText):
(WebCore::FontCascade::drawSimpleText):
(WebCore::FontCascade::drawEmphasisMarksForSimpleText):
(WebCore::FontCascade::drawGlyphBuffer):
(WebCore::offsetToMiddleOfGlyph):
(WebCore::offsetToMiddleOfGlyphAtIndex):
(WebCore::FontCascade::drawEmphasisMarks):
(WebCore::FontCascade::floatWidthForSimpleText):
(WebCore::FontCascade::adjustSelectionRectForSimpleText):
(WebCore::FontCascade::offsetForPositionForSimpleText):
* platform/graphics/FontFastPath.cpp: Removed.
* platform/graphics/cocoa/FontCascadeCocoa.mm: Copied from Source/WebCore/platform/graphics/mac/FontMac.mm.
(WebCore::FontCascade::drawGlyphs):
(WebCore::FontCascade::adjustSelectionRectForComplexText):
(WebCore::FontCascade::getGlyphsAndAdvancesForComplexText):
(WebCore::FontCascade::drawComplexText):
(WebCore::FontCascade::drawEmphasisMarksForComplexText):
(WebCore::FontCascade::floatWidthForComplexText):
(WebCore::FontCascade::offsetForPositionForComplexText):
(WebCore::FontCascade::fontDataForCombiningCharacterSequence):
* platform/graphics/mac/FontComplexTextMac.cpp: Removed.
* platform/graphics/mac/FontMac.mm: Removed.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCascadecpp">trunk/Source/WebCore/platform/graphics/FontCascade.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCascadeCocoamm">trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontFastPathcpp">trunk/Source/WebCore/platform/graphics/FontFastPath.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacFontComplexTextMaccpp">trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacFontMacmm">trunk/Source/WebCore/platform/graphics/mac/FontMac.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (178577 => 178578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-01-16 10:22:45 UTC (rev 178577)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-01-16 16:07:46 UTC (rev 178578)
</span><span class="lines">@@ -2052,7 +2052,6 @@
</span><span class="cx"> platform/graphics/FontCache.cpp
</span><span class="cx"> platform/graphics/FontCascade.cpp
</span><span class="cx"> platform/graphics/FontDescription.cpp
</span><del>- platform/graphics/FontFastPath.cpp
</del><span class="cx"> platform/graphics/FontFeatureSettings.cpp
</span><span class="cx"> platform/graphics/FontGenericFamilies.cpp
</span><span class="cx"> platform/graphics/FontGlyphs.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (178577 => 178578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-16 10:22:45 UTC (rev 178577)
+++ trunk/Source/WebCore/ChangeLog        2015-01-16 16:07:46 UTC (rev 178578)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2015-01-16 Antti Koivisto <antti@apple.com>
+
+ Correct naming for FontCascade implementation files
+ https://bugs.webkit.org/show_bug.cgi?id=140544
+
+ Reviewed by Zalan Bujtas.
+
+ Also reduce their number.
+
+ Merge FontFastPath.cpp into FontCascade.cpp
+ Merge FontMac.mm and FontComplexTextMac.cpp into FontCascadeCocoa.mm
+
+ * CMakeLists.txt:
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::getEmphasisMarkGlyphData):
+ (WebCore::FontCascade::emphasisMarkAscent):
+ (WebCore::FontCascade::emphasisMarkDescent):
+ (WebCore::FontCascade::emphasisMarkHeight):
+ (WebCore::FontCascade::getGlyphsAndAdvancesForSimpleText):
+ (WebCore::FontCascade::drawSimpleText):
+ (WebCore::FontCascade::drawEmphasisMarksForSimpleText):
+ (WebCore::FontCascade::drawGlyphBuffer):
+ (WebCore::offsetToMiddleOfGlyph):
+ (WebCore::offsetToMiddleOfGlyphAtIndex):
+ (WebCore::FontCascade::drawEmphasisMarks):
+ (WebCore::FontCascade::floatWidthForSimpleText):
+ (WebCore::FontCascade::adjustSelectionRectForSimpleText):
+ (WebCore::FontCascade::offsetForPositionForSimpleText):
+ * platform/graphics/FontFastPath.cpp: Removed.
+ * platform/graphics/cocoa/FontCascadeCocoa.mm: Copied from Source/WebCore/platform/graphics/mac/FontMac.mm.
+ (WebCore::FontCascade::drawGlyphs):
+ (WebCore::FontCascade::adjustSelectionRectForComplexText):
+ (WebCore::FontCascade::getGlyphsAndAdvancesForComplexText):
+ (WebCore::FontCascade::drawComplexText):
+ (WebCore::FontCascade::drawEmphasisMarksForComplexText):
+ (WebCore::FontCascade::floatWidthForComplexText):
+ (WebCore::FontCascade::offsetForPositionForComplexText):
+ (WebCore::FontCascade::fontDataForCombiningCharacterSequence):
+ * platform/graphics/mac/FontComplexTextMac.cpp: Removed.
+ * platform/graphics/mac/FontMac.mm: Removed.
+
</ins><span class="cx"> 2014-11-26 Sergio Villar Senin <svillar@igalia.com>
</span><span class="cx">
</span><span class="cx"> [CSS Grid Layout] Tracks shrink sometimes with indefinite remaining space
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (178577 => 178578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-01-16 10:22:45 UTC (rev 178577)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-01-16 16:07:46 UTC (rev 178578)
</span><span class="lines">@@ -7983,7 +7983,6 @@
</span><span class="cx"> <ClCompile Include="..\platform\graphics\FontDescription.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\graphics\FontGenericFamilies.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\graphics\FontGlyphs.cpp" />
</span><del>- <ClCompile Include="..\platform\graphics\FontFastPath.cpp" />
</del><span class="cx"> <ClCompile Include="..\platform\graphics\FontFeatureSettings.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\graphics\FontPlatformData.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\graphics\FontRanges.cpp" />
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (178577 => 178578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-01-16 10:22:45 UTC (rev 178577)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-01-16 16:07:46 UTC (rev 178578)
</span><span class="lines">@@ -1387,7 +1387,6 @@
</span><span class="cx">                 37ACCE420DA2980F0089E602 /* FontRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 37ACCE410DA2980F0089E602 /* FontRenderingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 37ACCF690DA414E70089E602 /* FontDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37ACCE620DA2AA960089E602 /* FontDescription.cpp */; };
</span><span class="cx">                 37BAAE581980D1DD005DFE71 /* ProtectionSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 37BAAE571980D1DD005DFE71 /* ProtectionSpace.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                37C2360B1097EDED00EF9F72 /* FontComplexTextMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2360A1097EDED00EF9F72 /* FontComplexTextMac.cpp */; };
</del><span class="cx">                 37C236101097EE7700EF9F72 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */; };
</span><span class="cx">                 37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */; };
</span><span class="cx">                 37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */; };
</span><span class="lines">@@ -2339,7 +2338,6 @@
</span><span class="cx">                 724ED32C1A3A7E5400F5F13C /* EXTBlendMinMax.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 724ED3291A3A7E5400F5F13C /* EXTBlendMinMax.cpp */; };
</span><span class="cx">                 724ED3311A3A8B2300F5F13C /* JSEXTBlendMinMax.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 724ED32F1A3A8B2300F5F13C /* JSEXTBlendMinMax.cpp */; };
</span><span class="cx">                 724ED3321A3A8B2300F5F13C /* JSEXTBlendMinMax.h in Headers */ = {isa = PBXBuildFile; fileRef = 724ED3301A3A8B2300F5F13C /* JSEXTBlendMinMax.h */; };
</span><del>-                72626E020EF022FE00A07E20 /* FontFastPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72626E010EF022FE00A07E20 /* FontFastPath.cpp */; };
</del><span class="cx">                 727AFED41A2EA6AE000442E8 /* EXTsRGB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 727AFED11A2EA6A0000442E8 /* EXTsRGB.cpp */; };
</span><span class="cx">                 72E417631A2E8D2F004C562A /* JSEXTsRGB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72E417611A2E8D2F004C562A /* JSEXTsRGB.cpp */; };
</span><span class="cx">                 72F1ADA21A3904DC00014E18 /* EXTFragDepth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72F1AD9F1A3904C300014E18 /* EXTFragDepth.cpp */; };
</span><span class="lines">@@ -4670,7 +4668,7 @@
</span><span class="cx">                 B2AFFC7D0D00A5C10030074D /* FontCustomPlatformData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */; };
</span><span class="cx">                 B2AFFC7E0D00A5C10030074D /* FontCustomPlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = B2AFFC760D00A5C10030074D /* FontCustomPlatformData.h */; };
</span><span class="cx">                 B2AFFC7F0D00A5C10030074D /* SimpleFontDataMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC770D00A5C10030074D /* SimpleFontDataMac.mm */; };
</span><del>-                B2AFFC800D00A5C10030074D /* FontMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC780D00A5C10030074D /* FontMac.mm */; };
</del><ins>+                B2AFFC800D00A5C10030074D /* FontCascadeCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */; };
</ins><span class="cx">                 B2AFFC830D00A5C10030074D /* GlyphPageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC7B0D00A5C10030074D /* GlyphPageMac.cpp */; };
</span><span class="cx">                 B2AFFC970D00A5DF0030074D /* TextBoundaries.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC8C0D00A5DF0030074D /* TextBoundaries.mm */; };
</span><span class="cx">                 B2AFFC980D00A5DF0030074D /* TextBreakIteratorInternalICUMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC8D0D00A5DF0030074D /* TextBreakIteratorInternalICUMac.mm */; };
</span><span class="lines">@@ -8430,7 +8428,6 @@
</span><span class="cx">                 37ACCE410DA2980F0089E602 /* FontRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontRenderingMode.h; sourceTree = "<group>"; };
</span><span class="cx">                 37ACCE620DA2AA960089E602 /* FontDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontDescription.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 37BAAE571980D1DD005DFE71 /* ProtectionSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtectionSpace.h; sourceTree = "<group>"; };
</span><del>-                37C2360A1097EDED00EF9F72 /* FontComplexTextMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontComplexTextMac.cpp; sourceTree = "<group>"; };
</del><span class="cx">                 37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplexTextController.h; sourceTree = "<group>"; };
</span><span class="cx">                 37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ComplexTextControllerCoreText.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
</span><span class="lines">@@ -9477,7 +9474,6 @@
</span><span class="cx">                 724ED32B1A3A7E5400F5F13C /* EXTBlendMinMax.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = EXTBlendMinMax.idl; path = canvas/EXTBlendMinMax.idl; sourceTree = "<group>"; };
</span><span class="cx">                 724ED32F1A3A8B2300F5F13C /* JSEXTBlendMinMax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEXTBlendMinMax.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 724ED3301A3A8B2300F5F13C /* JSEXTBlendMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEXTBlendMinMax.h; sourceTree = "<group>"; };
</span><del>-                72626E010EF022FE00A07E20 /* FontFastPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFastPath.cpp; sourceTree = "<group>"; };
</del><span class="cx">                 727AFED11A2EA6A0000442E8 /* EXTsRGB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EXTsRGB.cpp; path = canvas/EXTsRGB.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 727AFED21A2EA6A0000442E8 /* EXTsRGB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EXTsRGB.h; path = canvas/EXTsRGB.h; sourceTree = "<group>"; };
</span><span class="cx">                 727AFED31A2EA6A0000442E8 /* EXTsRGB.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = EXTsRGB.idl; path = canvas/EXTsRGB.idl; sourceTree = "<group>"; };
</span><span class="lines">@@ -12044,7 +12040,7 @@
</span><span class="cx">                 B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FontCustomPlatformData.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 B2AFFC760D00A5C10030074D /* FontCustomPlatformData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontCustomPlatformData.h; sourceTree = "<group>"; };
</span><span class="cx">                 B2AFFC770D00A5C10030074D /* SimpleFontDataMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleFontDataMac.mm; sourceTree = "<group>"; };
</span><del>-                B2AFFC780D00A5C10030074D /* FontMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FontMac.mm; sourceTree = "<group>"; };
</del><ins>+                B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FontCascadeCocoa.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 B2AFFC7B0D00A5C10030074D /* GlyphPageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphPageMac.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 B2AFFC850D00A5DF0030074D /* character-sets.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "character-sets.txt"; sourceTree = "<group>"; };
</span><span class="cx">                 B2AFFC860D00A5DF0030074D /* mac-encodings.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "mac-encodings.txt"; sourceTree = "<group>"; };
</span><span class="lines">@@ -20362,10 +20358,8 @@
</span><span class="cx">                                 B275354C0B053814002CE64F /* FloatRectMac.mm */,
</span><span class="cx">                                 B275354D0B053814002CE64F /* FloatSizeMac.mm */,
</span><span class="cx">                                 B2AFFC740D00A5C10030074D /* FontCacheMac.mm */,
</span><del>-                                37C2360A1097EDED00EF9F72 /* FontComplexTextMac.cpp */,
</del><span class="cx">                                 B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */,
</span><span class="cx">                                 B2AFFC760D00A5C10030074D /* FontCustomPlatformData.h */,
</span><del>-                                B2AFFC780D00A5C10030074D /* FontMac.mm */,
</del><span class="cx">                                 B2AFFC7B0D00A5C10030074D /* GlyphPageMac.cpp */,
</span><span class="cx">                                 49FFBF1C11C8550E006A7118 /* GraphicsContext3DMac.mm */,
</span><span class="cx">                                 B277B4030B22F37C0004BEC6 /* GraphicsContextMac.mm */,
</span><span class="lines">@@ -20446,7 +20440,6 @@
</span><span class="cx">                                 B2C3DA520D006CD600EF6F26 /* FontCache.h */,
</span><span class="cx">                                 37ACCE620DA2AA960089E602 /* FontDescription.cpp */,
</span><span class="cx">                                 B2C3DA550D006CD600EF6F26 /* FontDescription.h */,
</span><del>-                                72626E010EF022FE00A07E20 /* FontFastPath.cpp */,
</del><span class="cx">                                 4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */,
</span><span class="cx">                                 4A6E9FC613C17D570046A7F8 /* FontFeatureSettings.h */,
</span><span class="cx">                                 E44EE3A617576E5500EEE8CF /* FontGenericFamilies.cpp */,
</span><span class="lines">@@ -20714,6 +20707,7 @@
</span><span class="cx">                 B5320D68122A24E9002D1440 /* cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
</ins><span class="cx">                                 B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
</span><span class="cx">                                 2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */,
</span><span class="cx">                                 2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
</span><span class="lines">@@ -27820,15 +27814,13 @@
</span><span class="cx">                                 B2C3DA620D006CD600EF6F26 /* FontCache.cpp in Sources */,
</span><span class="cx">                                 3727DFD5142AAE4500D449CB /* FontCacheIOS.mm in Sources */,
</span><span class="cx">                                 B2AFFC7C0D00A5C10030074D /* FontCacheMac.mm in Sources */,
</span><del>-                                37C2360B1097EDED00EF9F72 /* FontComplexTextMac.cpp in Sources */,
</del><span class="cx">                                 B2AFFC7D0D00A5C10030074D /* FontCustomPlatformData.cpp in Sources */,
</span><span class="cx">                                 37ACCF690DA414E70089E602 /* FontDescription.cpp in Sources */,
</span><del>-                                72626E020EF022FE00A07E20 /* FontFastPath.cpp in Sources */,
</del><span class="cx">                                 4A6E9FC713C17D570046A7F8 /* FontFeatureSettings.cpp in Sources */,
</span><span class="cx">                                 E44EE3A817577EBD00EEE8CF /* FontGenericFamilies.cpp in Sources */,
</span><span class="cx">                                 B2C3DA670D006CD600EF6F26 /* FontGlyphs.cpp in Sources */,
</span><span class="cx">                                 FD96C9971982FBDF0086E156 /* FontLoader.cpp in Sources */,
</span><del>-                                B2AFFC800D00A5C10030074D /* FontMac.mm in Sources */,
</del><ins>+                                B2AFFC800D00A5C10030074D /* FontCascadeCocoa.mm in Sources */,
</ins><span class="cx">                                 84B62685133138F90095A489 /* FontPlatformData.cpp in Sources */,
</span><span class="cx">                                 B5320D6C122A24E9002D1440 /* FontPlatformDataCocoa.mm in Sources */,
</span><span class="cx">                                 C58361AA1744523F00173511 /* FontServicesIOS.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCascadecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (178577 => 178578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp        2015-01-16 10:22:45 UTC (rev 178577)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp        2015-01-16 16:07:46 UTC (rev 178578)
</span><span class="lines">@@ -1139,4 +1139,304 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// FIXME: This function may not work if the emphasis mark uses a complex script, but none of the
+// standard emphasis marks do so.
+bool FontCascade::getEmphasisMarkGlyphData(const AtomicString& mark, GlyphData& glyphData) const
+{
+ if (mark.isEmpty())
+ return false;
+
+ UChar32 character = mark[0];
+
+ if (U16_IS_SURROGATE(character)) {
+ if (!U16_IS_SURROGATE_LEAD(character))
+ return false;
+
+ if (mark.length() < 2)
+ return false;
+
+ UChar low = mark[1];
+ if (!U16_IS_TRAIL(low))
+ return false;
+
+ character = U16_GET_SUPPLEMENTARY(character, low);
+ }
+
+ glyphData = glyphDataForCharacter(character, false, EmphasisMarkVariant);
+ return true;
</ins><span class="cx"> }
</span><ins>+
+int FontCascade::emphasisMarkAscent(const AtomicString& mark) const
+{
+ GlyphData markGlyphData;
+ if (!getEmphasisMarkGlyphData(mark, markGlyphData))
+ return 0;
+
+ const SimpleFontData* markFontData = markGlyphData.fontData;
+ ASSERT(markFontData);
+ if (!markFontData)
+ return 0;
+
+ return markFontData->fontMetrics().ascent();
+}
+
+int FontCascade::emphasisMarkDescent(const AtomicString& mark) const
+{
+ GlyphData markGlyphData;
+ if (!getEmphasisMarkGlyphData(mark, markGlyphData))
+ return 0;
+
+ const SimpleFontData* markFontData = markGlyphData.fontData;
+ ASSERT(markFontData);
+ if (!markFontData)
+ return 0;
+
+ return markFontData->fontMetrics().descent();
+}
+
+int FontCascade::emphasisMarkHeight(const AtomicString& mark) const
+{
+ GlyphData markGlyphData;
+ if (!getEmphasisMarkGlyphData(mark, markGlyphData))
+ return 0;
+
+ const SimpleFontData* markFontData = markGlyphData.fontData;
+ ASSERT(markFontData);
+ if (!markFontData)
+ return 0;
+
+ return markFontData->fontMetrics().height();
+}
+
+float FontCascade::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
+{
+ float initialAdvance;
+
+ WidthIterator it(this, run, 0, false, forTextEmphasis);
+ // FIXME: Using separate glyph buffers for the prefix and the suffix is incorrect when kerning or
+ // ligatures are enabled.
+ GlyphBuffer localGlyphBuffer;
+ it.advance(from, &localGlyphBuffer);
+ float beforeWidth = it.m_runWidthSoFar;
+ it.advance(to, &glyphBuffer);
+
+ if (glyphBuffer.isEmpty())
+ return 0;
+
+ float afterWidth = it.m_runWidthSoFar;
+
+ if (run.rtl()) {
+ float finalRoundingWidth = it.m_finalRoundingWidth;
+ it.advance(run.length(), &localGlyphBuffer);
+ initialAdvance = finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
+ } else
+ initialAdvance = beforeWidth;
+
+ if (run.rtl())
+ glyphBuffer.reverse(0, glyphBuffer.size());
+
+ return initialAdvance;
+}
+
+float FontCascade::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
+{
+ // This glyph buffer holds our glyphs+advances+font data for each glyph.
+ GlyphBuffer glyphBuffer;
+
+ float startX = point.x() + getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer);
+
+ if (glyphBuffer.isEmpty())
+ return 0;
+
+ FloatPoint startPoint(startX, point.y());
+ drawGlyphBuffer(context, run, glyphBuffer, startPoint);
+
+ return startPoint.x() - startX;
+}
+
+void FontCascade::drawEmphasisMarksForSimpleText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
+{
+ GlyphBuffer glyphBuffer;
+ float initialAdvance = getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer, ForTextEmphasis);
+
+ if (glyphBuffer.isEmpty())
+ return;
+
+ drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
+}
+
+void FontCascade::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, FloatPoint& point) const
+{
+#if !ENABLE(SVG_FONTS)
+ UNUSED_PARAM(run);
+#endif
+
+ // Draw each contiguous run of glyphs that use the same font data.
+ const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
+ FloatSize offset = glyphBuffer.offsetAt(0);
+ FloatPoint startPoint(point.x(), point.y() - glyphBuffer.initialAdvance().height());
+ float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width();
+ float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height();
+ int lastFrom = 0;
+ int nextGlyph = 1;
+#if ENABLE(SVG_FONTS)
+ TextRun::RenderingContext* renderingContext = run.renderingContext();
+#endif
+ while (nextGlyph < glyphBuffer.size()) {
+ const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph);
+ FloatSize nextOffset = glyphBuffer.offsetAt(nextGlyph);
+
+ if (nextFontData != fontData || nextOffset != offset) {
+#if ENABLE(SVG_FONTS)
+ if (renderingContext && fontData->isSVGFont())
+ renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
+ else
+#endif
+ drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
+
+ lastFrom = nextGlyph;
+ fontData = nextFontData;
+ offset = nextOffset;
+ startPoint.setX(nextX);
+ startPoint.setY(nextY);
+ }
+ nextX += glyphBuffer.advanceAt(nextGlyph).width();
+ nextY += glyphBuffer.advanceAt(nextGlyph).height();
+ nextGlyph++;
+ }
+
+#if ENABLE(SVG_FONTS)
+ if (renderingContext && fontData->isSVGFont())
+ renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
+ else
+#endif
+ {
+ drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
+ point.setX(nextX);
+ }
+}
+
+inline static float offsetToMiddleOfGlyph(const SimpleFontData* fontData, Glyph glyph)
+{
+ if (fontData->platformData().orientation() == Horizontal) {
+ FloatRect bounds = fontData->boundsForGlyph(glyph);
+ return bounds.x() + bounds.width() / 2;
+ }
+ // FIXME: Use glyph bounds once they make sense for vertical fonts.
+ return fontData->widthForGlyph(glyph) / 2;
+}
+
+inline static float offsetToMiddleOfGlyphAtIndex(const GlyphBuffer& glyphBuffer, size_t i)
+{
+ return offsetToMiddleOfGlyph(glyphBuffer.fontDataAt(i), glyphBuffer.glyphAt(i));
+}
+
+void FontCascade::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoint& point) const
+{
+ GlyphData markGlyphData;
+ if (!getEmphasisMarkGlyphData(mark, markGlyphData))
+ return;
+
+ const SimpleFontData* markFontData = markGlyphData.fontData;
+ ASSERT(markFontData);
+ if (!markFontData)
+ return;
+
+ Glyph markGlyph = markGlyphData.glyph;
+ Glyph spaceGlyph = markFontData->spaceGlyph();
+
+ float middleOfLastGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, 0);
+ FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph(markFontData, markGlyph), point.y());
+
+ GlyphBuffer markBuffer;
+ for (int i = 0; i + 1 < glyphBuffer.size(); ++i) {
+ float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1);
+ float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph;
+ markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFontData, advance);
+ middleOfLastGlyph = middleOfNextGlyph;
+ }
+ markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spaceGlyph, markFontData, 0);
+
+ drawGlyphBuffer(context, run, markBuffer, startPoint);
+}
+
+float FontCascade::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
+{
+ WidthIterator it(this, run, fallbackFonts, glyphOverflow);
+ GlyphBuffer glyphBuffer;
+ it.advance(run.length(), (typesettingFeatures() & (Kerning | Ligatures)) ? &glyphBuffer : 0);
+
+ if (glyphOverflow) {
+ glyphOverflow->top = std::max<int>(glyphOverflow->top, ceilf(-it.minGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().ascent()));
+ glyphOverflow->bottom = std::max<int>(glyphOverflow->bottom, ceilf(it.maxGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().descent()));
+ glyphOverflow->left = ceilf(it.firstGlyphOverflow());
+ glyphOverflow->right = ceilf(it.lastGlyphOverflow());
+ }
+
+ return it.m_runWidthSoFar;
+}
+
+void FontCascade::adjustSelectionRectForSimpleText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
+{
+ GlyphBuffer glyphBuffer;
+ WidthIterator it(this, run);
+ it.advance(from, &glyphBuffer);
+ float beforeWidth = it.m_runWidthSoFar;
+ it.advance(to, &glyphBuffer);
+ float afterWidth = it.m_runWidthSoFar;
+ float totalWidth = -1;
+
+ if (run.rtl()) {
+ it.advance(run.length(), &glyphBuffer);
+ totalWidth = it.m_runWidthSoFar;
+ selectionRect.move(totalWidth - afterWidth, 0);
+ } else
+ selectionRect.move(beforeWidth, 0);
+ selectionRect.setWidth(afterWidth - beforeWidth);
+}
+
+int FontCascade::offsetForPositionForSimpleText(const TextRun& run, float x, bool includePartialGlyphs) const
+{
+ float delta = x;
+
+ WidthIterator it(this, run);
+ GlyphBuffer localGlyphBuffer;
+ unsigned offset;
+ if (run.rtl()) {
+ delta -= floatWidthForSimpleText(run);
+ while (1) {
+ offset = it.m_currentCharacter;
+ float w;
+ if (!it.advanceOneCharacter(w, localGlyphBuffer))
+ break;
+ delta += w;
+ if (includePartialGlyphs) {
+ if (delta - w / 2 >= 0)
+ break;
+ } else {
+ if (delta >= 0)
+ break;
+ }
+ }
+ } else {
+ while (1) {
+ offset = it.m_currentCharacter;
+ float w;
+ if (!it.advanceOneCharacter(w, localGlyphBuffer))
+ break;
+ delta -= w;
+ if (includePartialGlyphs) {
+ if (delta + w / 2 <= 0)
+ break;
+ } else {
+ if (delta <= 0)
+ break;
+ }
+ }
+ }
+
+ return offset;
+}
+
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontFastPathcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/FontFastPath.cpp (178577 => 178578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontFastPath.cpp        2015-01-16 10:22:45 UTC (rev 178577)
+++ trunk/Source/WebCore/platform/graphics/FontFastPath.cpp        2015-01-16 16:07:46 UTC (rev 178578)
</span><span class="lines">@@ -1,341 +0,0 @@
</span><del>-/**
- * Copyright (C) 2003, 2006, 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Holger Hans Peter Freyther
- * Copyright (C) 2009 Torch Mobile, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCascade.h"
-
-#include "FloatRect.h"
-#include "FontGlyphs.h"
-#include "GlyphBuffer.h"
-#include "LayoutRect.h"
-#include "SimpleFontData.h"
-#include "TextRun.h"
-#include "WidthIterator.h"
-#include <wtf/MainThread.h>
-#include <wtf/MathExtras.h>
-#include <wtf/unicode/CharacterNames.h>
-
-using namespace WTF;
-using namespace Unicode;
-
-namespace WebCore {
-
-// FIXME: This function may not work if the emphasis mark uses a complex script, but none of the
-// standard emphasis marks do so.
-bool FontCascade::getEmphasisMarkGlyphData(const AtomicString& mark, GlyphData& glyphData) const
-{
- if (mark.isEmpty())
- return false;
-
- UChar32 character = mark[0];
-
- if (U16_IS_SURROGATE(character)) {
- if (!U16_IS_SURROGATE_LEAD(character))
- return false;
-
- if (mark.length() < 2)
- return false;
-
- UChar low = mark[1];
- if (!U16_IS_TRAIL(low))
- return false;
-
- character = U16_GET_SUPPLEMENTARY(character, low);
- }
-
- glyphData = glyphDataForCharacter(character, false, EmphasisMarkVariant);
- return true;
-}
-
-int FontCascade::emphasisMarkAscent(const AtomicString& mark) const
-{
- GlyphData markGlyphData;
- if (!getEmphasisMarkGlyphData(mark, markGlyphData))
- return 0;
-
- const SimpleFontData* markFontData = markGlyphData.fontData;
- ASSERT(markFontData);
- if (!markFontData)
- return 0;
-
- return markFontData->fontMetrics().ascent();
-}
-
-int FontCascade::emphasisMarkDescent(const AtomicString& mark) const
-{
- GlyphData markGlyphData;
- if (!getEmphasisMarkGlyphData(mark, markGlyphData))
- return 0;
-
- const SimpleFontData* markFontData = markGlyphData.fontData;
- ASSERT(markFontData);
- if (!markFontData)
- return 0;
-
- return markFontData->fontMetrics().descent();
-}
-
-int FontCascade::emphasisMarkHeight(const AtomicString& mark) const
-{
- GlyphData markGlyphData;
- if (!getEmphasisMarkGlyphData(mark, markGlyphData))
- return 0;
-
- const SimpleFontData* markFontData = markGlyphData.fontData;
- ASSERT(markFontData);
- if (!markFontData)
- return 0;
-
- return markFontData->fontMetrics().height();
-}
-
-float FontCascade::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
-{
- float initialAdvance;
-
- WidthIterator it(this, run, 0, false, forTextEmphasis);
- // FIXME: Using separate glyph buffers for the prefix and the suffix is incorrect when kerning or
- // ligatures are enabled.
- GlyphBuffer localGlyphBuffer;
- it.advance(from, &localGlyphBuffer);
- float beforeWidth = it.m_runWidthSoFar;
- it.advance(to, &glyphBuffer);
-
- if (glyphBuffer.isEmpty())
- return 0;
-
- float afterWidth = it.m_runWidthSoFar;
-
- if (run.rtl()) {
- float finalRoundingWidth = it.m_finalRoundingWidth;
- it.advance(run.length(), &localGlyphBuffer);
- initialAdvance = finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
- } else
- initialAdvance = beforeWidth;
-
- if (run.rtl())
- glyphBuffer.reverse(0, glyphBuffer.size());
-
- return initialAdvance;
-}
-
-float FontCascade::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- // This glyph buffer holds our glyphs+advances+font data for each glyph.
- GlyphBuffer glyphBuffer;
-
- float startX = point.x() + getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer);
-
- if (glyphBuffer.isEmpty())
- return 0;
-
- FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, run, glyphBuffer, startPoint);
-
- return startPoint.x() - startX;
-}
-
-void FontCascade::drawEmphasisMarksForSimpleText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
-{
- GlyphBuffer glyphBuffer;
- float initialAdvance = getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer, ForTextEmphasis);
-
- if (glyphBuffer.isEmpty())
- return;
-
- drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
-}
-
-void FontCascade::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, FloatPoint& point) const
-{
-#if !ENABLE(SVG_FONTS)
- UNUSED_PARAM(run);
-#endif
-
- // Draw each contiguous run of glyphs that use the same font data.
- const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
- FloatSize offset = glyphBuffer.offsetAt(0);
- FloatPoint startPoint(point.x(), point.y() - glyphBuffer.initialAdvance().height());
- float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width();
- float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height();
- int lastFrom = 0;
- int nextGlyph = 1;
-#if ENABLE(SVG_FONTS)
- TextRun::RenderingContext* renderingContext = run.renderingContext();
-#endif
- while (nextGlyph < glyphBuffer.size()) {
- const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph);
- FloatSize nextOffset = glyphBuffer.offsetAt(nextGlyph);
-
- if (nextFontData != fontData || nextOffset != offset) {
-#if ENABLE(SVG_FONTS)
- if (renderingContext && fontData->isSVGFont())
- renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
- else
-#endif
- drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
-
- lastFrom = nextGlyph;
- fontData = nextFontData;
- offset = nextOffset;
- startPoint.setX(nextX);
- startPoint.setY(nextY);
- }
- nextX += glyphBuffer.advanceAt(nextGlyph).width();
- nextY += glyphBuffer.advanceAt(nextGlyph).height();
- nextGlyph++;
- }
-
-#if ENABLE(SVG_FONTS)
- if (renderingContext && fontData->isSVGFont())
- renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
- else
-#endif
- {
- drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
- point.setX(nextX);
- }
-}
-
-inline static float offsetToMiddleOfGlyph(const SimpleFontData* fontData, Glyph glyph)
-{
- if (fontData->platformData().orientation() == Horizontal) {
- FloatRect bounds = fontData->boundsForGlyph(glyph);
- return bounds.x() + bounds.width() / 2;
- }
- // FIXME: Use glyph bounds once they make sense for vertical fonts.
- return fontData->widthForGlyph(glyph) / 2;
-}
-
-inline static float offsetToMiddleOfGlyphAtIndex(const GlyphBuffer& glyphBuffer, size_t i)
-{
- return offsetToMiddleOfGlyph(glyphBuffer.fontDataAt(i), glyphBuffer.glyphAt(i));
-}
-
-void FontCascade::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoint& point) const
-{
- GlyphData markGlyphData;
- if (!getEmphasisMarkGlyphData(mark, markGlyphData))
- return;
-
- const SimpleFontData* markFontData = markGlyphData.fontData;
- ASSERT(markFontData);
- if (!markFontData)
- return;
-
- Glyph markGlyph = markGlyphData.glyph;
- Glyph spaceGlyph = markFontData->spaceGlyph();
-
- float middleOfLastGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, 0);
- FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph(markFontData, markGlyph), point.y());
-
- GlyphBuffer markBuffer;
- for (int i = 0; i + 1 < glyphBuffer.size(); ++i) {
- float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1);
- float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph;
- markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFontData, advance);
- middleOfLastGlyph = middleOfNextGlyph;
- }
- markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spaceGlyph, markFontData, 0);
-
- drawGlyphBuffer(context, run, markBuffer, startPoint);
-}
-
-float FontCascade::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
-{
- WidthIterator it(this, run, fallbackFonts, glyphOverflow);
- GlyphBuffer glyphBuffer;
- it.advance(run.length(), (typesettingFeatures() & (Kerning | Ligatures)) ? &glyphBuffer : 0);
-
- if (glyphOverflow) {
- glyphOverflow->top = std::max<int>(glyphOverflow->top, ceilf(-it.minGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().ascent()));
- glyphOverflow->bottom = std::max<int>(glyphOverflow->bottom, ceilf(it.maxGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().descent()));
- glyphOverflow->left = ceilf(it.firstGlyphOverflow());
- glyphOverflow->right = ceilf(it.lastGlyphOverflow());
- }
-
- return it.m_runWidthSoFar;
-}
-
-void FontCascade::adjustSelectionRectForSimpleText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
-{
- GlyphBuffer glyphBuffer;
- WidthIterator it(this, run);
- it.advance(from, &glyphBuffer);
- float beforeWidth = it.m_runWidthSoFar;
- it.advance(to, &glyphBuffer);
- float afterWidth = it.m_runWidthSoFar;
- float totalWidth = -1;
-
- if (run.rtl()) {
- it.advance(run.length(), &glyphBuffer);
- totalWidth = it.m_runWidthSoFar;
- selectionRect.move(totalWidth - afterWidth, 0);
- } else
- selectionRect.move(beforeWidth, 0);
- selectionRect.setWidth(afterWidth - beforeWidth);
-}
-
-int FontCascade::offsetForPositionForSimpleText(const TextRun& run, float x, bool includePartialGlyphs) const
-{
- float delta = x;
-
- WidthIterator it(this, run);
- GlyphBuffer localGlyphBuffer;
- unsigned offset;
- if (run.rtl()) {
- delta -= floatWidthForSimpleText(run);
- while (1) {
- offset = it.m_currentCharacter;
- float w;
- if (!it.advanceOneCharacter(w, localGlyphBuffer))
- break;
- delta += w;
- if (includePartialGlyphs) {
- if (delta - w / 2 >= 0)
- break;
- } else {
- if (delta >= 0)
- break;
- }
- }
- } else {
- while (1) {
- offset = it.m_currentCharacter;
- float w;
- if (!it.advanceOneCharacter(w, localGlyphBuffer))
- break;
- delta -= w;
- if (includePartialGlyphs) {
- if (delta + w / 2 <= 0)
- break;
- } else {
- if (delta <= 0)
- break;
- }
- }
- }
-
- return offset;
-}
-
-}
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCascadeCocoammfromrev178510trunkSourceWebCoreplatformgraphicsmacFontMacmm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (from rev 178510, trunk/Source/WebCore/platform/graphics/mac/FontMac.mm) (0 => 178578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm        2015-01-16 16:07:46 UTC (rev 178578)
</span><span class="lines">@@ -0,0 +1,751 @@
</span><ins>+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ * (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#import "config.h"
+#import "FontCascade.h"
+
+#import "ComplexTextController.h"
+#import "CoreGraphicsSPI.h"
+#import "CoreTextSPI.h"
+#import "DashArray.h"
+#import "GlyphBuffer.h"
+#import "GraphicsContext.h"
+#import "LayoutRect.h"
+#import "Logging.h"
+#import "SimpleFontData.h"
+#import "WebCoreSystemInterface.h"
+#if USE(APPKIT)
+#import <AppKit/AppKit.h>
+#endif
+#import <wtf/MathExtras.h>
+
+#if ENABLE(LETTERPRESS)
+#import "CoreUISPI.h"
+#import "SoftLinking.h"
+
+SOFT_LINK_PRIVATE_FRAMEWORK(CoreUI)
+SOFT_LINK_CLASS(CoreUI, CUICatalog)
+SOFT_LINK_CLASS(CoreUI, CUIStyleEffectConfiguration)
+
+SOFT_LINK_FRAMEWORK(UIKit)
+SOFT_LINK(UIKit, _UIKitGetTextEffectsCatalog, CUICatalog *, (void), ())
+#endif
+
+#define SYNTHETIC_OBLIQUE_ANGLE 14
+
+#ifdef __LP64__
+#define URefCon void*
+#else
+#define URefCon UInt32
+#endif
+
+namespace WebCore {
+
+bool FontCascade::canReturnFallbackFontsForComplexText()
+{
+ return true;
+}
+
+bool FontCascade::canExpandAroundIdeographsInComplexText()
+{
+ return true;
+}
+
+static inline void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef context, const CGSize* advances, size_t count)
+{
+ CGAffineTransform matrix = CGAffineTransformInvert(CGContextGetTextMatrix(context));
+ positions[0] = CGPointZero;
+ for (size_t i = 1; i < count; ++i) {
+ CGSize advance = CGSizeApplyAffineTransform(advances[i - 1], matrix);
+ positions[i].x = positions[i - 1].x + advance.width;
+ positions[i].y = positions[i - 1].y + advance.height;
+ }
+}
+
+static inline bool shouldUseLetterpressEffect(const GraphicsContext& context)
+{
+#if ENABLE(LETTERPRESS)
+ return context.textDrawingMode() & TextModeLetterpress;
+#else
+ UNUSED_PARAM(context);
+ return false;
+#endif
+}
+
+static void showLetterpressedGlyphsWithAdvances(const FloatPoint& point, const SimpleFontData* font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, size_t count)
+{
+#if ENABLE(LETTERPRESS)
+ if (!count)
+ return;
+
+ const FontPlatformData& platformData = font->platformData();
+ if (platformData.orientation() == Vertical) {
+ // FIXME: Implement support for vertical text. See <rdar://problem/13737298>.
+ return;
+ }
+
+ CGContextSetTextPosition(context, point.x(), point.y());
+ Vector<CGPoint, 256> positions(count);
+ fillVectorWithHorizontalGlyphPositions(positions, context, advances, count);
+
+ CTFontRef ctFont = platformData.ctFont();
+ CGContextSetFontSize(context, CTFontGetSize(ctFont));
+
+ static CUICatalog *catalog = _UIKitGetTextEffectsCatalog();
+ if (!catalog)
+ return;
+
+ static CUIStyleEffectConfiguration *styleConfiguration;
+ if (!styleConfiguration) {
+ styleConfiguration = [allocCUIStyleEffectConfigurationInstance() init];
+ styleConfiguration.useSimplifiedEffect = YES;
+ }
+
+ [catalog drawGlyphs:glyphs atPositions:positions.data() inContext:context withFont:ctFont count:count stylePresetName:@"_UIKitNewLetterpressStyle" styleConfiguration:styleConfiguration foregroundColor:CGContextGetFillColorAsColor(context)];
+#else
+ UNUSED_PARAM(point);
+ UNUSED_PARAM(font);
+ UNUSED_PARAM(context);
+ UNUSED_PARAM(glyphs);
+ UNUSED_PARAM(advances);
+ UNUSED_PARAM(count);
+#endif
+}
+
+static void showGlyphsWithAdvances(const FloatPoint& point, const SimpleFontData* font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, size_t count)
+{
+ if (!count)
+ return;
+
+ CGContextSetTextPosition(context, point.x(), point.y());
+
+ const FontPlatformData& platformData = font->platformData();
+ Vector<CGPoint, 256> positions(count);
+ if (platformData.isColorBitmapFont())
+ fillVectorWithHorizontalGlyphPositions(positions, context, advances, count);
+ if (platformData.orientation() == Vertical) {
+ CGAffineTransform savedMatrix;
+ CGAffineTransform rotateLeftTransform = CGAffineTransformMake(0, -1, 1, 0, 0, 0);
+ savedMatrix = CGContextGetTextMatrix(context);
+ CGAffineTransform runMatrix = CGAffineTransformConcat(savedMatrix, rotateLeftTransform);
+ CGContextSetTextMatrix(context, runMatrix);
+
+ Vector<CGSize, 256> translations(count);
+ CTFontGetVerticalTranslationsForGlyphs(platformData.ctFont(), glyphs, translations.data(), count);
+
+ CGAffineTransform transform = CGAffineTransformInvert(CGContextGetTextMatrix(context));
+
+ CGPoint position = FloatPoint(point.x(), point.y() + font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent());
+ for (size_t i = 0; i < count; ++i) {
+ CGSize translation = CGSizeApplyAffineTransform(translations[i], rotateLeftTransform);
+ positions[i] = CGPointApplyAffineTransform(CGPointMake(position.x - translation.width, position.y + translation.height), transform);
+ position.x += advances[i].width;
+ position.y += advances[i].height;
+ }
+ if (!platformData.isColorBitmapFont())
+ CGContextShowGlyphsAtPositions(context, glyphs, positions.data(), count);
+ else
+ CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
+ CGContextSetTextMatrix(context, savedMatrix);
+ } else {
+ if (!platformData.isColorBitmapFont())
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ CGContextShowGlyphsWithAdvances(context, glyphs, advances, count);
+#pragma clang diagnostic pop
+ else
+ CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
+ }
+}
+
+#if PLATFORM(MAC)
+static void setCGFontRenderingMode(CGContextRef cgContext, NSFontRenderingMode renderingMode, BOOL shouldSubpixelQuantize)
+{
+ if (renderingMode == NSFontIntegerAdvancementsRenderingMode) {
+ CGContextSetShouldAntialiasFonts(cgContext, false);
+ return;
+ }
+
+ CGContextSetShouldAntialiasFonts(cgContext, true);
+
+ CGAffineTransform contextTransform = CGContextGetCTM(cgContext);
+ BOOL isTranslationOrIntegralScale = WTF::isIntegral(contextTransform.a) && WTF::isIntegral(contextTransform.d) && contextTransform.b == 0.f && contextTransform.c == 0.f;
+ BOOL isRotated = ((contextTransform.b || contextTransform.c) && (contextTransform.a || contextTransform.d));
+ BOOL doSubpixelQuantization = isTranslationOrIntegralScale || (!isRotated && shouldSubpixelQuantize);
+
+ CGContextSetShouldSubpixelPositionFonts(cgContext, renderingMode != NSFontAntialiasedIntegerAdvancementsRenderingMode || !isTranslationOrIntegralScale);
+ CGContextSetShouldSubpixelQuantizeFonts(cgContext, doSubpixelQuantization);
+}
+#endif
+
+void FontCascade::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& anchorPoint) const
+{
+ const FontPlatformData& platformData = font->platformData();
+ if (!platformData.size())
+ return;
+
+ CGContextRef cgContext = context->platformContext();
+
+ bool shouldSmoothFonts;
+ bool changeFontSmoothing;
+
+ switch (fontDescription().fontSmoothing()) {
+ case Antialiased: {
+ context->setShouldAntialias(true);
+ shouldSmoothFonts = false;
+ changeFontSmoothing = true;
+ break;
+ }
+ case SubpixelAntialiased: {
+ context->setShouldAntialias(true);
+ shouldSmoothFonts = true;
+ changeFontSmoothing = true;
+ break;
+ }
+ case NoSmoothing: {
+ context->setShouldAntialias(false);
+ shouldSmoothFonts = false;
+ changeFontSmoothing = true;
+ break;
+ }
+ case AutoSmoothing: {
+ shouldSmoothFonts = true;
+ changeFontSmoothing = false;
+ break;
+ }
+ }
+
+ if (!shouldUseSmoothing()) {
+ shouldSmoothFonts = false;
+ changeFontSmoothing = true;
+ }
+
+#if !PLATFORM(IOS)
+ bool originalShouldUseFontSmoothing = false;
+ if (changeFontSmoothing) {
+ originalShouldUseFontSmoothing = CGContextGetShouldSmoothFonts(cgContext);
+ CGContextSetShouldSmoothFonts(cgContext, shouldSmoothFonts);
+ }
+#endif
+
+#if !PLATFORM(IOS)
+ NSFont* drawFont;
+ if (!isPrinterFont()) {
+ drawFont = [platformData.nsFont() screenFont];
+ if (drawFont != platformData.nsFont()) {
+ // We are getting this in too many places (3406411); use ERROR so it only prints on debug versions for now. (We should debug this also, eventually).
+ LOG_ERROR("Attempting to set non-screen font (%@) when drawing to screen. Using screen font anyway, may result in incorrect metrics.",
+ [[[platformData.nsFont() fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
+ }
+ } else {
+ drawFont = [platformData.nsFont() printerFont];
+ if (drawFont != platformData.nsFont()) {
+ NSLog(@"Attempting to set non-printer font (%@) when printing. Using printer font anyway, may result in incorrect metrics.",
+ [[[platformData.nsFont() fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
+ }
+ }
+#endif
+
+ CGContextSetFont(cgContext, platformData.cgFont());
+
+ bool useLetterpressEffect = shouldUseLetterpressEffect(*context);
+ FloatPoint point = anchorPoint;
+#if PLATFORM(IOS)
+ float fontSize = platformData.size();
+ CGAffineTransform matrix = useLetterpressEffect || platformData.isColorBitmapFont() ? CGAffineTransformIdentity : CGAffineTransformMakeScale(fontSize, fontSize);
+ if (platformData.m_isEmoji) {
+ if (!context->emojiDrawingEnabled())
+ return;
+
+ // Mimic the positioining of non-bitmap glyphs, which are not subpixel-positioned.
+ point.setY(ceilf(point.y()));
+
+ // Emoji glyphs snap to the CSS pixel grid.
+ point.setX(floorf(point.x()));
+
+ // Emoji glyphs are offset one CSS pixel to the right.
+ point.move(1, 0);
+
+ // Emoji glyphs are offset vertically based on font size.
+ float y = point.y();
+ if (fontSize <= 15) {
+ // Undo Core Text's y adjustment.
+ static float yAdjustmentFactor = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? .19 : .1;
+ point.setY(floorf(y - yAdjustmentFactor * (fontSize + 2) + 2));
+ } else {
+ if (fontSize < 26)
+ y -= .35f * fontSize - 10;
+
+ // Undo Core Text's y adjustment.
+ static float yAdjustment = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? 3.8 : 2;
+ point.setY(floorf(y - yAdjustment));
+ }
+ }
+#else
+ CGAffineTransform matrix = CGAffineTransformIdentity;
+ if (drawFont && !platformData.isColorBitmapFont())
+ memcpy(&matrix, [drawFont matrix], sizeof(matrix));
+#endif
+ matrix.b = -matrix.b;
+ matrix.d = -matrix.d;
+ if (platformData.m_syntheticOblique) {
+ static float obliqueSkew = tanf(SYNTHETIC_OBLIQUE_ANGLE * piFloat / 180);
+ if (platformData.orientation() == Vertical)
+ matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, obliqueSkew, 0, 1, 0, 0));
+ else
+ matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -obliqueSkew, 1, 0, 0));
+ }
+ CGContextSetTextMatrix(cgContext, matrix);
+
+#if PLATFORM(IOS)
+ CGContextSetFontSize(cgContext, 1);
+ CGContextSetShouldSubpixelQuantizeFonts(cgContext, context->shouldSubpixelQuantizeFonts());
+#else
+ setCGFontRenderingMode(cgContext, [drawFont renderingMode], context->shouldSubpixelQuantizeFonts());
+ if (drawFont)
+ CGContextSetFontSize(cgContext, 1);
+ else
+ CGContextSetFontSize(cgContext, platformData.m_size);
+#endif
+
+
+ FloatSize shadowOffset;
+ float shadowBlur;
+ Color shadowColor;
+ ColorSpace shadowColorSpace;
+ ColorSpace fillColorSpace = context->fillColorSpace();
+ context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
+
+ AffineTransform contextCTM = context->getCTM();
+ float syntheticBoldOffset = font->syntheticBoldOffset();
+ if (syntheticBoldOffset && !contextCTM.isIdentityOrTranslationOrFlipped()) {
+ FloatSize horizontalUnitSizeInDevicePixels = contextCTM.mapSize(FloatSize(1, 0));
+ float horizontalUnitLengthInDevicePixels = sqrtf(horizontalUnitSizeInDevicePixels.width() * horizontalUnitSizeInDevicePixels.width() + horizontalUnitSizeInDevicePixels.height() * horizontalUnitSizeInDevicePixels.height());
+ if (horizontalUnitLengthInDevicePixels)
+ syntheticBoldOffset /= horizontalUnitLengthInDevicePixels;
+ };
+
+ bool hasSimpleShadow = context->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont() && (!context->shadowsIgnoreTransforms() || contextCTM.isIdentityOrTranslationOrFlipped()) && !context->isInTransparencyLayer();
+ if (hasSimpleShadow) {
+ // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
+ context->clearShadow();
+ Color fillColor = context->fillColor();
+ Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
+ context->setFillColor(shadowFillColor, shadowColorSpace);
+ float shadowTextX = point.x() + shadowOffset.width();
+ // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.
+ float shadowTextY = point.y() + shadowOffset.height() * (context->shadowsIgnoreTransforms() ? -1 : 1);
+ showGlyphsWithAdvances(FloatPoint(shadowTextX, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+#if !PLATFORM(IOS)
+ if (syntheticBoldOffset)
+#else
+ if (syntheticBoldOffset && !platformData.m_isEmoji)
+#endif
+ showGlyphsWithAdvances(FloatPoint(shadowTextX + syntheticBoldOffset, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+ context->setFillColor(fillColor, fillColorSpace);
+ }
+
+ if (useLetterpressEffect)
+ showLetterpressedGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+ else
+ showGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+#if !PLATFORM(IOS)
+ if (syntheticBoldOffset)
+#else
+ if (syntheticBoldOffset && !platformData.m_isEmoji)
+#endif
+ showGlyphsWithAdvances(FloatPoint(point.x() + syntheticBoldOffset, point.y()), font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+
+ if (hasSimpleShadow)
+ context->setShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
+
+#if !PLATFORM(IOS)
+ if (changeFontSmoothing)
+ CGContextSetShouldSmoothFonts(cgContext, originalShouldUseFontSmoothing);
+#endif
+}
+
+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+struct GlyphIterationState {
+ GlyphIterationState(CGPoint startingPoint, CGPoint currentPoint, CGFloat y1, CGFloat y2, CGFloat minX, CGFloat maxX)
+ : startingPoint(startingPoint)
+ , currentPoint(currentPoint)
+ , y1(y1)
+ , y2(y2)
+ , minX(minX)
+ , maxX(maxX)
+ {
+ }
+ CGPoint startingPoint;
+ CGPoint currentPoint;
+ CGFloat y1;
+ CGFloat y2;
+ CGFloat minX;
+ CGFloat maxX;
+};
+
+static bool findIntersectionPoint(float y, CGPoint p1, CGPoint p2, CGFloat& x)
+{
+ x = p1.x + (y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y);
+ return (p1.y < y && p2.y > y) || (p1.y > y && p2.y < y);
+}
+
+static void updateX(GlyphIterationState& state, CGFloat x)
+{
+ state.minX = std::min(state.minX, x);
+ state.maxX = std::max(state.maxX, x);
+}
+
+// This function is called by CGPathApply and is therefore invoked for each
+// contour in a glyph. This function models each contours as a straight line
+// and calculates the intersections between each pseudo-contour and
+// two horizontal lines (the upper and lower bounds of an underline) found in
+// GlyphIterationState::y1 and GlyphIterationState::y2. It keeps track of the
+// leftmost and rightmost intersection in GlyphIterationState::minX and
+// GlyphIterationState::maxX.
+static void findPathIntersections(void* stateAsVoidPointer, const CGPathElement* e)
+{
+ auto& state = *static_cast<GlyphIterationState*>(stateAsVoidPointer);
+ bool doIntersection = false;
+ CGPoint point = CGPointZero;
+ switch (e->type) {
+ case kCGPathElementMoveToPoint:
+ state.startingPoint = e->points[0];
+ state.currentPoint = e->points[0];
+ break;
+ case kCGPathElementAddLineToPoint:
+ doIntersection = true;
+ point = e->points[0];
+ break;
+ case kCGPathElementAddQuadCurveToPoint:
+ doIntersection = true;
+ point = e->points[1];
+ break;
+ case kCGPathElementAddCurveToPoint:
+ doIntersection = true;
+ point = e->points[2];
+ break;
+ case kCGPathElementCloseSubpath:
+ doIntersection = true;
+ point = state.startingPoint;
+ break;
+ }
+ if (!doIntersection)
+ return;
+ CGFloat x;
+ if (findIntersectionPoint(state.y1, state.currentPoint, point, x))
+ updateX(state, x);
+ if (findIntersectionPoint(state.y2, state.currentPoint, point, x))
+ updateX(state, x);
+ if ((state.currentPoint.y >= state.y1 && state.currentPoint.y <= state.y2)
+ || (state.currentPoint.y <= state.y1 && state.currentPoint.y >= state.y2))
+ updateX(state, state.currentPoint.x);
+ state.currentPoint = point;
+}
+
+class MacGlyphToPathTranslator final : public GlyphToPathTranslator {
+public:
+ MacGlyphToPathTranslator(const TextRun& textRun, const GlyphBuffer& glyphBuffer, const FloatPoint& textOrigin)
+ : m_index(0)
+ , m_textRun(textRun)
+ , m_glyphBuffer(glyphBuffer)
+ , m_fontData(glyphBuffer.fontDataAt(m_index))
+ , m_translation(CGAffineTransformScale(CGAffineTransformMakeTranslation(textOrigin.x(), textOrigin.y()), 1, -1))
+ {
+ moveToNextValidGlyph();
+ }
+private:
+ virtual bool containsMorePaths() override
+ {
+ return m_index != m_glyphBuffer.size();
+ }
+ virtual Path path() override;
+ virtual std::pair<float, float> extents() override;
+ virtual GlyphUnderlineType underlineType() override;
+ virtual void advance() override;
+ void moveToNextValidGlyph();
+
+ int m_index;
+ const TextRun& m_textRun;
+ const GlyphBuffer& m_glyphBuffer;
+ const SimpleFontData* m_fontData;
+ CGAffineTransform m_translation;
+};
+
+Path MacGlyphToPathTranslator::path()
+{
+ RetainPtr<CGPathRef> result = adoptCF(CTFontCreatePathForGlyph(m_fontData->platformData().ctFont(), m_glyphBuffer.glyphAt(m_index), &m_translation));
+ return adoptCF(CGPathCreateMutableCopy(result.get()));
+}
+
+std::pair<float, float> MacGlyphToPathTranslator::extents()
+{
+ CGPoint beginning = CGPointApplyAffineTransform(CGPointMake(0, 0), m_translation);
+ CGSize end = CGSizeApplyAffineTransform(m_glyphBuffer.advanceAt(m_index), m_translation);
+ return std::make_pair(static_cast<float>(beginning.x), static_cast<float>(beginning.x + end.width));
+}
+
+auto MacGlyphToPathTranslator::underlineType() -> GlyphUnderlineType
+{
+ return computeUnderlineType(m_textRun, m_glyphBuffer, m_index);
+}
+
+void MacGlyphToPathTranslator::moveToNextValidGlyph()
+{
+ if (!m_fontData->isSVGFont())
+ return;
+ advance();
+}
+
+void MacGlyphToPathTranslator::advance()
+{
+ do {
+ GlyphBufferAdvance advance = m_glyphBuffer.advanceAt(m_index);
+ m_translation = CGAffineTransformTranslate(m_translation, advance.width(), advance.height());
+ ++m_index;
+ if (m_index >= m_glyphBuffer.size())
+ break;
+ m_fontData = m_glyphBuffer.fontDataAt(m_index);
+ } while (m_fontData->isSVGFont() && m_index < m_glyphBuffer.size());
+}
+
+DashArray FontCascade::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
+{
+ if (isLoadingCustomFonts())
+ return DashArray();
+
+ GlyphBuffer glyphBuffer;
+ glyphBuffer.saveOffsetsInString();
+ float deltaX;
+ if (codePath(run) != FontCascade::Complex)
+ deltaX = getGlyphsAndAdvancesForSimpleText(run, 0, run.length(), glyphBuffer);
+ else
+ deltaX = getGlyphsAndAdvancesForComplexText(run, 0, run.length(), glyphBuffer);
+
+ if (!glyphBuffer.size())
+ return DashArray();
+
+ // FIXME: Handle SVG + non-SVG interleaved runs. https://bugs.webkit.org/show_bug.cgi?id=133778
+ const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
+ std::unique_ptr<GlyphToPathTranslator> translator;
+ bool isSVG = false;
+ FloatPoint origin = FloatPoint(textOrigin.x() + deltaX, textOrigin.y());
+ if (!fontData->isSVGFont())
+ translator = std::make_unique<MacGlyphToPathTranslator>(run, glyphBuffer, origin);
+ else {
+ TextRun::RenderingContext* renderingContext = run.renderingContext();
+ if (!renderingContext)
+ return DashArray();
+ translator = renderingContext->createGlyphToPathTranslator(*fontData, &run, glyphBuffer, 0, glyphBuffer.size(), origin);
+ isSVG = true;
+ }
+ DashArray result;
+ for (int index = 0; translator->containsMorePaths(); ++index, translator->advance()) {
+ GlyphIterationState info = GlyphIterationState(CGPointMake(0, 0), CGPointMake(0, 0), lineExtents.y(), lineExtents.y() + lineExtents.height(), lineExtents.x() + lineExtents.width(), lineExtents.x());
+ const SimpleFontData* localFontData = glyphBuffer.fontDataAt(index);
+ if (!localFontData || (!isSVG && localFontData->isSVGFont()) || (isSVG && localFontData != fontData)) {
+ // The advances will get all messed up if we do anything other than bail here.
+ result.clear();
+ break;
+ }
+ switch (translator->underlineType()) {
+ case GlyphToPathTranslator::GlyphUnderlineType::SkipDescenders: {
+ Path path = translator->path();
+ CGPathApply(path.platformPath(), &info, &findPathIntersections);
+ if (info.minX < info.maxX) {
+ result.append(info.minX - lineExtents.x());
+ result.append(info.maxX - lineExtents.x());
+ }
+ break;
+ }
+ case GlyphToPathTranslator::GlyphUnderlineType::SkipGlyph: {
+ std::pair<float, float> extents = translator->extents();
+ result.append(extents.first - lineExtents.x());
+ result.append(extents.second - lineExtents.x());
+ break;
+ }
+ case GlyphToPathTranslator::GlyphUnderlineType::DrawOverGlyph:
+ // Nothing to do
+ break;
+ }
+ }
+ return result;
+}
+#endif
+
+bool FontCascade::primaryFontDataIsSystemFont() const
+{
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
+ const auto& fontData = primaryFontData();
+ return !fontData.isSVGFont() && CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(fontData.platformData().ctFont())).get());
+#else
+ // System fonts are hidden by having a name that begins with a period, so simply search
+ // for that here rather than try to keep the list up to date.
+ return firstFamily().startsWith('.');
+#endif
+}
+
+void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
+{
+ ComplexTextController controller(this, run);
+ controller.advance(from);
+ float beforeWidth = controller.runWidthSoFar();
+ controller.advance(to);
+ float afterWidth = controller.runWidthSoFar();
+
+ if (run.rtl())
+ selectionRect.move(controller.totalWidth() - afterWidth, 0);
+ else
+ selectionRect.move(beforeWidth, 0);
+ selectionRect.setWidth(afterWidth - beforeWidth);
+}
+
+float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
+{
+ float initialAdvance;
+
+ ComplexTextController controller(this, run, false, 0, forTextEmphasis);
+ controller.advance(from);
+ float beforeWidth = controller.runWidthSoFar();
+ controller.advance(to, &glyphBuffer);
+
+ if (glyphBuffer.isEmpty())
+ return 0;
+
+ float afterWidth = controller.runWidthSoFar();
+
+ if (run.rtl()) {
+ initialAdvance = controller.totalWidth() + controller.finalRoundingWidth() - afterWidth;
+ glyphBuffer.reverse(0, glyphBuffer.size());
+ } else
+ initialAdvance = beforeWidth;
+
+ return initialAdvance;
+}
+
+float FontCascade::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
+{
+ // This glyph buffer holds our glyphs + advances + font data for each glyph.
+ GlyphBuffer glyphBuffer;
+
+ float startX = point.x() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);
+
+ // We couldn't generate any glyphs for the run. Give up.
+ if (glyphBuffer.isEmpty())
+ return 0;
+
+ // Draw the glyph buffer now at the starting point returned in startX.
+ FloatPoint startPoint(startX, point.y());
+ drawGlyphBuffer(context, run, glyphBuffer, startPoint);
+
+ return startPoint.x() - startX;
+}
+
+void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
+{
+ GlyphBuffer glyphBuffer;
+ float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);
+
+ if (glyphBuffer.isEmpty())
+ return;
+
+ drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
+}
+
+float FontCascade::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
+{
+ ComplexTextController controller(this, run, true, fallbackFonts);
+ if (glyphOverflow) {
+ glyphOverflow->top = std::max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().ascent()));
+ glyphOverflow->bottom = std::max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().descent()));
+ glyphOverflow->left = std::max<int>(0, ceilf(-controller.minGlyphBoundingBoxX()));
+ glyphOverflow->right = std::max<int>(0, ceilf(controller.maxGlyphBoundingBoxX() - controller.totalWidth()));
+ }
+ return controller.totalWidth();
+}
+
+int FontCascade::offsetForPositionForComplexText(const TextRun& run, float x, bool includePartialGlyphs) const
+{
+ ComplexTextController controller(this, run);
+ return controller.offsetForPosition(x, includePartialGlyphs);
+}
+
+const SimpleFontData* FontCascade::fontDataForCombiningCharacterSequence(const UChar* characters, size_t length, FontDataVariant variant) const
+{
+ UChar32 baseCharacter;
+ size_t baseCharacterLength = 0;
+ U16_NEXT(characters, baseCharacterLength, length, baseCharacter);
+
+ GlyphData baseCharacterGlyphData = glyphDataForCharacter(baseCharacter, false, variant);
+
+ if (!baseCharacterGlyphData.glyph)
+ return 0;
+
+ if (length == baseCharacterLength)
+ return baseCharacterGlyphData.fontData;
+
+ bool triedBaseCharacterFontData = false;
+
+ for (unsigned i = 0; !fallbackRangesAt(i).isNull(); ++i) {
+ const SimpleFontData* simpleFontData = fallbackRangesAt(i).fontDataForCharacter(baseCharacter);
+ if (!simpleFontData)
+ continue;
+#if PLATFORM(IOS)
+ if (baseCharacter >= 0x0600 && baseCharacter <= 0x06ff && simpleFontData->shouldNotBeUsedForArabic())
+ continue;
+#endif
+ if (variant == NormalVariant) {
+ if (simpleFontData->platformData().orientation() == Vertical) {
+ if (isCJKIdeographOrSymbol(baseCharacter) && !simpleFontData->hasVerticalGlyphs()) {
+ variant = BrokenIdeographVariant;
+ simpleFontData = simpleFontData->brokenIdeographFontData().get();
+ } else if (m_fontDescription.nonCJKGlyphOrientation() == NonCJKGlyphOrientationVerticalRight) {
+ SimpleFontData* verticalRightFontData = simpleFontData->verticalRightOrientationFontData().get();
+ Glyph verticalRightGlyph = verticalRightFontData->glyphForCharacter(baseCharacter);
+ if (verticalRightGlyph == baseCharacterGlyphData.glyph)
+ simpleFontData = verticalRightFontData;
+ } else {
+ SimpleFontData* uprightFontData = simpleFontData->uprightOrientationFontData().get();
+ Glyph uprightGlyph = uprightFontData->glyphForCharacter(baseCharacter);
+ if (uprightGlyph != baseCharacterGlyphData.glyph)
+ simpleFontData = uprightFontData;
+ }
+ }
+ } else {
+ if (const SimpleFontData* variantFontData = simpleFontData->variantFontData(m_fontDescription, variant).get())
+ simpleFontData = variantFontData;
+ }
+
+ if (simpleFontData == baseCharacterGlyphData.fontData)
+ triedBaseCharacterFontData = true;
+
+ if (simpleFontData->canRenderCombiningCharacterSequence(characters, length))
+ return simpleFontData;
+ }
+
+ if (!triedBaseCharacterFontData && baseCharacterGlyphData.fontData && baseCharacterGlyphData.fontData->canRenderCombiningCharacterSequence(characters, length))
+ return baseCharacterGlyphData.fontData;
+
+ return SimpleFontData::systemFallback();
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontComplexTextMaccpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp (178577 => 178578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp        2015-01-16 10:22:45 UTC (rev 178577)
+++ trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp        2015-01-16 16:07:46 UTC (rev 178578)
</span><span class="lines">@@ -1,184 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCascade.h"
-
-#include "ComplexTextController.h"
-#include "FontGlyphs.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "LayoutRect.h"
-#include "SimpleFontData.h"
-#include "TextRun.h"
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
-{
- ComplexTextController controller(this, run);
- controller.advance(from);
- float beforeWidth = controller.runWidthSoFar();
- controller.advance(to);
- float afterWidth = controller.runWidthSoFar();
-
- if (run.rtl())
- selectionRect.move(controller.totalWidth() - afterWidth, 0);
- else
- selectionRect.move(beforeWidth, 0);
- selectionRect.setWidth(afterWidth - beforeWidth);
-}
-
-float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
-{
- float initialAdvance;
-
- ComplexTextController controller(this, run, false, 0, forTextEmphasis);
- controller.advance(from);
- float beforeWidth = controller.runWidthSoFar();
- controller.advance(to, &glyphBuffer);
-
- if (glyphBuffer.isEmpty())
- return 0;
-
- float afterWidth = controller.runWidthSoFar();
-
- if (run.rtl()) {
- initialAdvance = controller.totalWidth() + controller.finalRoundingWidth() - afterWidth;
- glyphBuffer.reverse(0, glyphBuffer.size());
- } else
- initialAdvance = beforeWidth;
-
- return initialAdvance;
-}
-
-float FontCascade::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- // This glyph buffer holds our glyphs + advances + font data for each glyph.
- GlyphBuffer glyphBuffer;
-
- float startX = point.x() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);
-
- // We couldn't generate any glyphs for the run. Give up.
- if (glyphBuffer.isEmpty())
- return 0;
-
- // Draw the glyph buffer now at the starting point returned in startX.
- FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, run, glyphBuffer, startPoint);
-
- return startPoint.x() - startX;
-}
-
-void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
-{
- GlyphBuffer glyphBuffer;
- float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);
-
- if (glyphBuffer.isEmpty())
- return;
-
- drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
-}
-
-float FontCascade::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
-{
- ComplexTextController controller(this, run, true, fallbackFonts);
- if (glyphOverflow) {
- glyphOverflow->top = std::max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().ascent()));
- glyphOverflow->bottom = std::max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().descent()));
- glyphOverflow->left = std::max<int>(0, ceilf(-controller.minGlyphBoundingBoxX()));
- glyphOverflow->right = std::max<int>(0, ceilf(controller.maxGlyphBoundingBoxX() - controller.totalWidth()));
- }
- return controller.totalWidth();
-}
-
-int FontCascade::offsetForPositionForComplexText(const TextRun& run, float x, bool includePartialGlyphs) const
-{
- ComplexTextController controller(this, run);
- return controller.offsetForPosition(x, includePartialGlyphs);
-}
-
-const SimpleFontData* FontCascade::fontDataForCombiningCharacterSequence(const UChar* characters, size_t length, FontDataVariant variant) const
-{
- UChar32 baseCharacter;
- size_t baseCharacterLength = 0;
- U16_NEXT(characters, baseCharacterLength, length, baseCharacter);
-
- GlyphData baseCharacterGlyphData = glyphDataForCharacter(baseCharacter, false, variant);
-
- if (!baseCharacterGlyphData.glyph)
- return 0;
-
- if (length == baseCharacterLength)
- return baseCharacterGlyphData.fontData;
-
- bool triedBaseCharacterFontData = false;
-
- for (unsigned i = 0; !fallbackRangesAt(i).isNull(); ++i) {
- const SimpleFontData* simpleFontData = fallbackRangesAt(i).fontDataForCharacter(baseCharacter);
- if (!simpleFontData)
- continue;
-#if PLATFORM(IOS)
- if (baseCharacter >= 0x0600 && baseCharacter <= 0x06ff && simpleFontData->shouldNotBeUsedForArabic())
- continue;
-#endif
- if (variant == NormalVariant) {
- if (simpleFontData->platformData().orientation() == Vertical) {
- if (isCJKIdeographOrSymbol(baseCharacter) && !simpleFontData->hasVerticalGlyphs()) {
- variant = BrokenIdeographVariant;
- simpleFontData = simpleFontData->brokenIdeographFontData().get();
- } else if (m_fontDescription.nonCJKGlyphOrientation() == NonCJKGlyphOrientationVerticalRight) {
- SimpleFontData* verticalRightFontData = simpleFontData->verticalRightOrientationFontData().get();
- Glyph verticalRightGlyph = verticalRightFontData->glyphForCharacter(baseCharacter);
- if (verticalRightGlyph == baseCharacterGlyphData.glyph)
- simpleFontData = verticalRightFontData;
- } else {
- SimpleFontData* uprightFontData = simpleFontData->uprightOrientationFontData().get();
- Glyph uprightGlyph = uprightFontData->glyphForCharacter(baseCharacter);
- if (uprightGlyph != baseCharacterGlyphData.glyph)
- simpleFontData = uprightFontData;
- }
- }
- } else {
- if (const SimpleFontData* variantFontData = simpleFontData->variantFontData(m_fontDescription, variant).get())
- simpleFontData = variantFontData;
- }
-
- if (simpleFontData == baseCharacterGlyphData.fontData)
- triedBaseCharacterFontData = true;
-
- if (simpleFontData->canRenderCombiningCharacterSequence(characters, length))
- return simpleFontData;
- }
-
- if (!triedBaseCharacterFontData && baseCharacterGlyphData.fontData && baseCharacterGlyphData.fontData->canRenderCombiningCharacterSequence(characters, length))
- return baseCharacterGlyphData.fontData;
-
- return SimpleFontData::systemFallback();
-}
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontMacmm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/mac/FontMac.mm (178577 => 178578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontMac.mm        2015-01-16 10:22:45 UTC (rev 178577)
+++ trunk/Source/WebCore/platform/graphics/mac/FontMac.mm        2015-01-16 16:07:46 UTC (rev 178578)
</span><span class="lines">@@ -1,605 +0,0 @@
</span><del>-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * (C) 1999 Antti Koivisto (koivisto@kde.org)
- * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#import "config.h"
-#import "FontCascade.h"
-
-#import "CoreGraphicsSPI.h"
-#import "CoreTextSPI.h"
-#import "DashArray.h"
-#import "GlyphBuffer.h"
-#import "GraphicsContext.h"
-#import "Logging.h"
-#import "SimpleFontData.h"
-#import "WebCoreSystemInterface.h"
-#if USE(APPKIT)
-#import <AppKit/AppKit.h>
-#endif
-#import <wtf/MathExtras.h>
-
-#if ENABLE(LETTERPRESS)
-#import "CoreUISPI.h"
-#import "SoftLinking.h"
-
-SOFT_LINK_PRIVATE_FRAMEWORK(CoreUI)
-SOFT_LINK_CLASS(CoreUI, CUICatalog)
-SOFT_LINK_CLASS(CoreUI, CUIStyleEffectConfiguration)
-
-SOFT_LINK_FRAMEWORK(UIKit)
-SOFT_LINK(UIKit, _UIKitGetTextEffectsCatalog, CUICatalog *, (void), ())
-#endif
-
-#define SYNTHETIC_OBLIQUE_ANGLE 14
-
-#ifdef __LP64__
-#define URefCon void*
-#else
-#define URefCon UInt32
-#endif
-
-namespace WebCore {
-
-bool FontCascade::canReturnFallbackFontsForComplexText()
-{
- return true;
-}
-
-bool FontCascade::canExpandAroundIdeographsInComplexText()
-{
- return true;
-}
-
-static inline void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef context, const CGSize* advances, size_t count)
-{
- CGAffineTransform matrix = CGAffineTransformInvert(CGContextGetTextMatrix(context));
- positions[0] = CGPointZero;
- for (size_t i = 1; i < count; ++i) {
- CGSize advance = CGSizeApplyAffineTransform(advances[i - 1], matrix);
- positions[i].x = positions[i - 1].x + advance.width;
- positions[i].y = positions[i - 1].y + advance.height;
- }
-}
-
-static inline bool shouldUseLetterpressEffect(const GraphicsContext& context)
-{
-#if ENABLE(LETTERPRESS)
- return context.textDrawingMode() & TextModeLetterpress;
-#else
- UNUSED_PARAM(context);
- return false;
-#endif
-}
-
-static void showLetterpressedGlyphsWithAdvances(const FloatPoint& point, const SimpleFontData* font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, size_t count)
-{
-#if ENABLE(LETTERPRESS)
- if (!count)
- return;
-
- const FontPlatformData& platformData = font->platformData();
- if (platformData.orientation() == Vertical) {
- // FIXME: Implement support for vertical text. See <rdar://problem/13737298>.
- return;
- }
-
- CGContextSetTextPosition(context, point.x(), point.y());
- Vector<CGPoint, 256> positions(count);
- fillVectorWithHorizontalGlyphPositions(positions, context, advances, count);
-
- CTFontRef ctFont = platformData.ctFont();
- CGContextSetFontSize(context, CTFontGetSize(ctFont));
-
- static CUICatalog *catalog = _UIKitGetTextEffectsCatalog();
- if (!catalog)
- return;
-
- static CUIStyleEffectConfiguration *styleConfiguration;
- if (!styleConfiguration) {
- styleConfiguration = [allocCUIStyleEffectConfigurationInstance() init];
- styleConfiguration.useSimplifiedEffect = YES;
- }
-
- [catalog drawGlyphs:glyphs atPositions:positions.data() inContext:context withFont:ctFont count:count stylePresetName:@"_UIKitNewLetterpressStyle" styleConfiguration:styleConfiguration foregroundColor:CGContextGetFillColorAsColor(context)];
-#else
- UNUSED_PARAM(point);
- UNUSED_PARAM(font);
- UNUSED_PARAM(context);
- UNUSED_PARAM(glyphs);
- UNUSED_PARAM(advances);
- UNUSED_PARAM(count);
-#endif
-}
-
-static void showGlyphsWithAdvances(const FloatPoint& point, const SimpleFontData* font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, size_t count)
-{
- if (!count)
- return;
-
- CGContextSetTextPosition(context, point.x(), point.y());
-
- const FontPlatformData& platformData = font->platformData();
- Vector<CGPoint, 256> positions(count);
- if (platformData.isColorBitmapFont())
- fillVectorWithHorizontalGlyphPositions(positions, context, advances, count);
- if (platformData.orientation() == Vertical) {
- CGAffineTransform savedMatrix;
- CGAffineTransform rotateLeftTransform = CGAffineTransformMake(0, -1, 1, 0, 0, 0);
- savedMatrix = CGContextGetTextMatrix(context);
- CGAffineTransform runMatrix = CGAffineTransformConcat(savedMatrix, rotateLeftTransform);
- CGContextSetTextMatrix(context, runMatrix);
-
- Vector<CGSize, 256> translations(count);
- CTFontGetVerticalTranslationsForGlyphs(platformData.ctFont(), glyphs, translations.data(), count);
-
- CGAffineTransform transform = CGAffineTransformInvert(CGContextGetTextMatrix(context));
-
- CGPoint position = FloatPoint(point.x(), point.y() + font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent());
- for (size_t i = 0; i < count; ++i) {
- CGSize translation = CGSizeApplyAffineTransform(translations[i], rotateLeftTransform);
- positions[i] = CGPointApplyAffineTransform(CGPointMake(position.x - translation.width, position.y + translation.height), transform);
- position.x += advances[i].width;
- position.y += advances[i].height;
- }
- if (!platformData.isColorBitmapFont())
- CGContextShowGlyphsAtPositions(context, glyphs, positions.data(), count);
- else
- CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
- CGContextSetTextMatrix(context, savedMatrix);
- } else {
- if (!platformData.isColorBitmapFont())
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- CGContextShowGlyphsWithAdvances(context, glyphs, advances, count);
-#pragma clang diagnostic pop
- else
- CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
- }
-}
-
-#if PLATFORM(MAC)
-static void setCGFontRenderingMode(CGContextRef cgContext, NSFontRenderingMode renderingMode, BOOL shouldSubpixelQuantize)
-{
- if (renderingMode == NSFontIntegerAdvancementsRenderingMode) {
- CGContextSetShouldAntialiasFonts(cgContext, false);
- return;
- }
-
- CGContextSetShouldAntialiasFonts(cgContext, true);
-
- CGAffineTransform contextTransform = CGContextGetCTM(cgContext);
- BOOL isTranslationOrIntegralScale = WTF::isIntegral(contextTransform.a) && WTF::isIntegral(contextTransform.d) && contextTransform.b == 0.f && contextTransform.c == 0.f;
- BOOL isRotated = ((contextTransform.b || contextTransform.c) && (contextTransform.a || contextTransform.d));
- BOOL doSubpixelQuantization = isTranslationOrIntegralScale || (!isRotated && shouldSubpixelQuantize);
-
- CGContextSetShouldSubpixelPositionFonts(cgContext, renderingMode != NSFontAntialiasedIntegerAdvancementsRenderingMode || !isTranslationOrIntegralScale);
- CGContextSetShouldSubpixelQuantizeFonts(cgContext, doSubpixelQuantization);
-}
-#endif
-
-void FontCascade::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& anchorPoint) const
-{
- const FontPlatformData& platformData = font->platformData();
- if (!platformData.size())
- return;
-
- CGContextRef cgContext = context->platformContext();
-
- bool shouldSmoothFonts;
- bool changeFontSmoothing;
-
- switch(fontDescription().fontSmoothing()) {
- case Antialiased: {
- context->setShouldAntialias(true);
- shouldSmoothFonts = false;
- changeFontSmoothing = true;
- break;
- }
- case SubpixelAntialiased: {
- context->setShouldAntialias(true);
- shouldSmoothFonts = true;
- changeFontSmoothing = true;
- break;
- }
- case NoSmoothing: {
- context->setShouldAntialias(false);
- shouldSmoothFonts = false;
- changeFontSmoothing = true;
- break;
- }
- case AutoSmoothing: {
- shouldSmoothFonts = true;
- changeFontSmoothing = false;
- break;
- }
- }
-
- if (!shouldUseSmoothing()) {
- shouldSmoothFonts = false;
- changeFontSmoothing = true;
- }
-
-#if !PLATFORM(IOS)
- bool originalShouldUseFontSmoothing = false;
- if (changeFontSmoothing) {
- originalShouldUseFontSmoothing = CGContextGetShouldSmoothFonts(cgContext);
- CGContextSetShouldSmoothFonts(cgContext, shouldSmoothFonts);
- }
-#endif
-
-#if !PLATFORM(IOS)
- NSFont* drawFont;
- if (!isPrinterFont()) {
- drawFont = [platformData.nsFont() screenFont];
- if (drawFont != platformData.nsFont()) {
- // We are getting this in too many places (3406411); use ERROR so it only prints on debug versions for now. (We should debug this also, eventually).
- LOG_ERROR("Attempting to set non-screen font (%@) when drawing to screen. Using screen font anyway, may result in incorrect metrics.",
- [[[platformData.nsFont() fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
- }
- } else {
- drawFont = [platformData.nsFont() printerFont];
- if (drawFont != platformData.nsFont()) {
- NSLog(@"Attempting to set non-printer font (%@) when printing. Using printer font anyway, may result in incorrect metrics.",
- [[[platformData.nsFont() fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
- }
- }
-#endif
-
- CGContextSetFont(cgContext, platformData.cgFont());
-
- bool useLetterpressEffect = shouldUseLetterpressEffect(*context);
- FloatPoint point = anchorPoint;
-#if PLATFORM(IOS)
- float fontSize = platformData.size();
- CGAffineTransform matrix = useLetterpressEffect || platformData.isColorBitmapFont() ? CGAffineTransformIdentity : CGAffineTransformMakeScale(fontSize, fontSize);
- if (platformData.m_isEmoji) {
- if (!context->emojiDrawingEnabled())
- return;
-
- // Mimic the positioining of non-bitmap glyphs, which are not subpixel-positioned.
- point.setY(ceilf(point.y()));
-
- // Emoji glyphs snap to the CSS pixel grid.
- point.setX(floorf(point.x()));
-
- // Emoji glyphs are offset one CSS pixel to the right.
- point.move(1, 0);
-
- // Emoji glyphs are offset vertically based on font size.
- float y = point.y();
- if (fontSize <= 15) {
- // Undo Core Text's y adjustment.
- static float yAdjustmentFactor = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? .19 : .1;
- point.setY(floorf(y - yAdjustmentFactor * (fontSize + 2) + 2));
- } else {
- if (fontSize < 26)
- y -= .35f * fontSize - 10;
-
- // Undo Core Text's y adjustment.
- static float yAdjustment = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? 3.8 : 2;
- point.setY(floorf(y - yAdjustment));
- }
- }
-#else
- CGAffineTransform matrix = CGAffineTransformIdentity;
- if (drawFont && !platformData.isColorBitmapFont())
- memcpy(&matrix, [drawFont matrix], sizeof(matrix));
-#endif
- matrix.b = -matrix.b;
- matrix.d = -matrix.d;
- if (platformData.m_syntheticOblique) {
- static float obliqueSkew = tanf(SYNTHETIC_OBLIQUE_ANGLE * piFloat / 180);
- if (platformData.orientation() == Vertical)
- matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, obliqueSkew, 0, 1, 0, 0));
- else
- matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -obliqueSkew, 1, 0, 0));
- }
- CGContextSetTextMatrix(cgContext, matrix);
-
-#if PLATFORM(IOS)
- CGContextSetFontSize(cgContext, 1);
- CGContextSetShouldSubpixelQuantizeFonts(cgContext, context->shouldSubpixelQuantizeFonts());
-#else
- setCGFontRenderingMode(cgContext, [drawFont renderingMode], context->shouldSubpixelQuantizeFonts());
- if (drawFont)
- CGContextSetFontSize(cgContext, 1);
- else
- CGContextSetFontSize(cgContext, platformData.m_size);
-#endif
-
-
- FloatSize shadowOffset;
- float shadowBlur;
- Color shadowColor;
- ColorSpace shadowColorSpace;
- ColorSpace fillColorSpace = context->fillColorSpace();
- context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
-
- AffineTransform contextCTM = context->getCTM();
- float syntheticBoldOffset = font->syntheticBoldOffset();
- if (syntheticBoldOffset && !contextCTM.isIdentityOrTranslationOrFlipped()) {
- FloatSize horizontalUnitSizeInDevicePixels = contextCTM.mapSize(FloatSize(1, 0));
- float horizontalUnitLengthInDevicePixels = sqrtf(horizontalUnitSizeInDevicePixels.width() * horizontalUnitSizeInDevicePixels.width() + horizontalUnitSizeInDevicePixels.height() * horizontalUnitSizeInDevicePixels.height());
- if (horizontalUnitLengthInDevicePixels)
- syntheticBoldOffset /= horizontalUnitLengthInDevicePixels;
- };
-
- bool hasSimpleShadow = context->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont() && (!context->shadowsIgnoreTransforms() || contextCTM.isIdentityOrTranslationOrFlipped()) && !context->isInTransparencyLayer();
- if (hasSimpleShadow) {
- // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
- context->clearShadow();
- Color fillColor = context->fillColor();
- Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
- context->setFillColor(shadowFillColor, shadowColorSpace);
- float shadowTextX = point.x() + shadowOffset.width();
- // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.
- float shadowTextY = point.y() + shadowOffset.height() * (context->shadowsIgnoreTransforms() ? -1 : 1);
- showGlyphsWithAdvances(FloatPoint(shadowTextX, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
-#if !PLATFORM(IOS)
- if (syntheticBoldOffset)
-#else
- if (syntheticBoldOffset && !platformData.m_isEmoji)
-#endif
- showGlyphsWithAdvances(FloatPoint(shadowTextX + syntheticBoldOffset, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
- context->setFillColor(fillColor, fillColorSpace);
- }
-
- if (useLetterpressEffect)
- showLetterpressedGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
- else
- showGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
-#if !PLATFORM(IOS)
- if (syntheticBoldOffset)
-#else
- if (syntheticBoldOffset && !platformData.m_isEmoji)
-#endif
- showGlyphsWithAdvances(FloatPoint(point.x() + syntheticBoldOffset, point.y()), font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
-
- if (hasSimpleShadow)
- context->setShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
-
-#if !PLATFORM(IOS)
- if (changeFontSmoothing)
- CGContextSetShouldSmoothFonts(cgContext, originalShouldUseFontSmoothing);
-#endif
-}
-
-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
-struct GlyphIterationState {
- GlyphIterationState(CGPoint startingPoint, CGPoint currentPoint, CGFloat y1, CGFloat y2, CGFloat minX, CGFloat maxX)
- : startingPoint(startingPoint)
- , currentPoint(currentPoint)
- , y1(y1)
- , y2(y2)
- , minX(minX)
- , maxX(maxX)
- {
- }
- CGPoint startingPoint;
- CGPoint currentPoint;
- CGFloat y1;
- CGFloat y2;
- CGFloat minX;
- CGFloat maxX;
-};
-
-static bool findIntersectionPoint(float y, CGPoint p1, CGPoint p2, CGFloat& x)
-{
- x = p1.x + (y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y);
- return (p1.y < y && p2.y > y) || (p1.y > y && p2.y < y);
-}
-
-static void updateX(GlyphIterationState& state, CGFloat x)
-{
- state.minX = std::min(state.minX, x);
- state.maxX = std::max(state.maxX, x);
-}
-
-// This function is called by CGPathApply and is therefore invoked for each
-// contour in a glyph. This function models each contours as a straight line
-// and calculates the intersections between each pseudo-contour and
-// two horizontal lines (the upper and lower bounds of an underline) found in
-// GlyphIterationState::y1 and GlyphIterationState::y2. It keeps track of the
-// leftmost and rightmost intersection in GlyphIterationState::minX and
-// GlyphIterationState::maxX.
-static void findPathIntersections(void* stateAsVoidPointer, const CGPathElement* e)
-{
- auto& state = *static_cast<GlyphIterationState*>(stateAsVoidPointer);
- bool doIntersection = false;
- CGPoint point = CGPointZero;
- switch (e->type) {
- case kCGPathElementMoveToPoint:
- state.startingPoint = e->points[0];
- state.currentPoint = e->points[0];
- break;
- case kCGPathElementAddLineToPoint:
- doIntersection = true;
- point = e->points[0];
- break;
- case kCGPathElementAddQuadCurveToPoint:
- doIntersection = true;
- point = e->points[1];
- break;
- case kCGPathElementAddCurveToPoint:
- doIntersection = true;
- point = e->points[2];
- break;
- case kCGPathElementCloseSubpath:
- doIntersection = true;
- point = state.startingPoint;
- break;
- }
- if (!doIntersection)
- return;
- CGFloat x;
- if (findIntersectionPoint(state.y1, state.currentPoint, point, x))
- updateX(state, x);
- if (findIntersectionPoint(state.y2, state.currentPoint, point, x))
- updateX(state, x);
- if ((state.currentPoint.y >= state.y1 && state.currentPoint.y <= state.y2)
- || (state.currentPoint.y <= state.y1 && state.currentPoint.y >= state.y2))
- updateX(state, state.currentPoint.x);
- state.currentPoint = point;
-}
-
-class MacGlyphToPathTranslator final : public GlyphToPathTranslator {
-public:
- MacGlyphToPathTranslator(const TextRun& textRun, const GlyphBuffer& glyphBuffer, const FloatPoint& textOrigin)
- : m_index(0)
- , m_textRun(textRun)
- , m_glyphBuffer(glyphBuffer)
- , m_fontData(glyphBuffer.fontDataAt(m_index))
- , m_translation(CGAffineTransformScale(CGAffineTransformMakeTranslation(textOrigin.x(), textOrigin.y()), 1, -1))
- {
- moveToNextValidGlyph();
- }
-private:
- virtual bool containsMorePaths() override
- {
- return m_index != m_glyphBuffer.size();
- }
- virtual Path path() override;
- virtual std::pair<float, float> extents() override;
- virtual GlyphUnderlineType underlineType() override;
- virtual void advance() override;
- void moveToNextValidGlyph();
-
- int m_index;
- const TextRun& m_textRun;
- const GlyphBuffer& m_glyphBuffer;
- const SimpleFontData* m_fontData;
- CGAffineTransform m_translation;
-};
-
-Path MacGlyphToPathTranslator::path()
-{
- RetainPtr<CGPathRef> result = adoptCF(CTFontCreatePathForGlyph(m_fontData->platformData().ctFont(), m_glyphBuffer.glyphAt(m_index), &m_translation));
- return adoptCF(CGPathCreateMutableCopy(result.get()));
-}
-
-std::pair<float, float> MacGlyphToPathTranslator::extents()
-{
- CGPoint beginning = CGPointApplyAffineTransform(CGPointMake(0, 0), m_translation);
- CGSize end = CGSizeApplyAffineTransform(m_glyphBuffer.advanceAt(m_index), m_translation);
- return std::make_pair(static_cast<float>(beginning.x), static_cast<float>(beginning.x + end.width));
-}
-
-auto MacGlyphToPathTranslator::underlineType() -> GlyphUnderlineType
-{
- return computeUnderlineType(m_textRun, m_glyphBuffer, m_index);
-}
-
-void MacGlyphToPathTranslator::moveToNextValidGlyph()
-{
- if (!m_fontData->isSVGFont())
- return;
- advance();
-}
-
-void MacGlyphToPathTranslator::advance()
-{
- do {
- GlyphBufferAdvance advance = m_glyphBuffer.advanceAt(m_index);
- m_translation = CGAffineTransformTranslate(m_translation, advance.width(), advance.height());
- ++m_index;
- if (m_index >= m_glyphBuffer.size())
- break;
- m_fontData = m_glyphBuffer.fontDataAt(m_index);
- } while (m_fontData->isSVGFont() && m_index < m_glyphBuffer.size());
-}
-
-DashArray FontCascade::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
-{
- if (isLoadingCustomFonts())
- return DashArray();
-
- GlyphBuffer glyphBuffer;
- glyphBuffer.saveOffsetsInString();
- float deltaX;
- if (codePath(run) != FontCascade::Complex)
- deltaX = getGlyphsAndAdvancesForSimpleText(run, 0, run.length(), glyphBuffer);
- else
- deltaX = getGlyphsAndAdvancesForComplexText(run, 0, run.length(), glyphBuffer);
-
- if (!glyphBuffer.size())
- return DashArray();
-
- // FIXME: Handle SVG + non-SVG interleaved runs. https://bugs.webkit.org/show_bug.cgi?id=133778
- const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
- std::unique_ptr<GlyphToPathTranslator> translator;
- bool isSVG = false;
- FloatPoint origin = FloatPoint(textOrigin.x() + deltaX, textOrigin.y());
- if (!fontData->isSVGFont())
- translator = std::make_unique<MacGlyphToPathTranslator>(run, glyphBuffer, origin);
- else {
- TextRun::RenderingContext* renderingContext = run.renderingContext();
- if (!renderingContext)
- return DashArray();
- translator = renderingContext->createGlyphToPathTranslator(*fontData, &run, glyphBuffer, 0, glyphBuffer.size(), origin);
- isSVG = true;
- }
- DashArray result;
- for (int index = 0; translator->containsMorePaths(); ++index, translator->advance()) {
- GlyphIterationState info = GlyphIterationState(CGPointMake(0, 0), CGPointMake(0, 0), lineExtents.y(), lineExtents.y() + lineExtents.height(), lineExtents.x() + lineExtents.width(), lineExtents.x());
- const SimpleFontData* localFontData = glyphBuffer.fontDataAt(index);
- if (!localFontData || (!isSVG && localFontData->isSVGFont()) || (isSVG && localFontData != fontData)) {
- // The advances will get all messed up if we do anything other than bail here.
- result.clear();
- break;
- }
- switch (translator->underlineType()) {
- case GlyphToPathTranslator::GlyphUnderlineType::SkipDescenders: {
- Path path = translator->path();
- CGPathApply(path.platformPath(), &info, &findPathIntersections);
- if (info.minX < info.maxX) {
- result.append(info.minX - lineExtents.x());
- result.append(info.maxX - lineExtents.x());
- }
- break;
- }
- case GlyphToPathTranslator::GlyphUnderlineType::SkipGlyph: {
- std::pair<float, float> extents = translator->extents();
- result.append(extents.first - lineExtents.x());
- result.append(extents.second - lineExtents.x());
- break;
- }
- case GlyphToPathTranslator::GlyphUnderlineType::DrawOverGlyph:
- // Nothing to do
- break;
- }
- }
- return result;
-}
-#endif
-
-bool FontCascade::primaryFontDataIsSystemFont() const
-{
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
- const auto& fontData = primaryFontData();
- return !fontData.isSVGFont() && CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(fontData.platformData().ctFont())).get());
-#else
- // System fonts are hidden by having a name that begins with a period, so simply search
- // for that here rather than try to keep the list up to date.
- return firstFamily().startsWith('.');
-#endif
-}
-
-}
</del></span></pre>
</div>
</div>
</body>
</html>