@@ -39,7 +39,8 @@ webfont.FontWatchRunner = function(activeCallback, inactiveCallback, domHelper,
39
39
*/
40
40
webfont . FontWatchRunner . LastResortFonts = {
41
41
SERIF : 'serif' ,
42
- SANS_SERIF : 'sans-serif'
42
+ SANS_SERIF : 'sans-serif' ,
43
+ MOCK_FONT : 'FontWatchRunnerMockFont'
43
44
} ;
44
45
45
46
/**
@@ -70,7 +71,7 @@ goog.scope(function () {
70
71
71
72
/**
72
73
* Returns true if this browser is WebKit and it has the fallback bug
73
- * which is present in WebKit 536.11 and earlier.
74
+ * which is present in WebKit 602.*, 603.* ,and 536.11 and earlier
74
75
*
75
76
* @return {boolean }
76
77
*/
@@ -81,7 +82,9 @@ goog.scope(function () {
81
82
FontWatchRunner . HAS_WEBKIT_FALLBACK_BUG = ! ! match &&
82
83
( parseInt ( match [ 1 ] , 10 ) < 536 ||
83
84
( parseInt ( match [ 1 ] , 10 ) === 536 &&
84
- parseInt ( match [ 2 ] , 10 ) <= 11 ) ) ;
85
+ parseInt ( match [ 2 ] , 10 ) <= 11 ) ||
86
+ parseInt ( match [ 1 ] , 10 ) === 602 ||
87
+ parseInt ( match [ 1 ] , 10 ) === 603 ) ;
85
88
}
86
89
return FontWatchRunner . HAS_WEBKIT_FALLBACK_BUG ;
87
90
} ;
@@ -110,6 +113,10 @@ goog.scope(function () {
110
113
this . lastResortWidths_ [ FontWatchRunner . LastResortFonts . SERIF ] = this . lastResortRulerA_ . getWidth ( ) ;
111
114
this . lastResortWidths_ [ FontWatchRunner . LastResortFonts . SANS_SERIF ] = this . lastResortRulerB_ . getWidth ( ) ;
112
115
116
+ if ( FontWatchRunner . hasWebKitFallbackBug ( ) ) {
117
+ this . lastResortWidths_ [ FontWatchRunner . LastResortFonts . MOCK_FONT ] = this . getMockFontWidth_ ( ) ;
118
+ }
119
+
113
120
this . started_ = goog . now ( ) ;
114
121
115
122
this . check_ ( ) ;
@@ -193,6 +200,35 @@ goog.scope(function () {
193
200
return this . metricCompatibleFonts_ === null || this . metricCompatibleFonts_ . hasOwnProperty ( this . font_ . getName ( ) ) ;
194
201
} ;
195
202
203
+
204
+ /**
205
+ * Calculates the width of a mock font with the current font's variation css style
206
+ * before it has finished loading.
207
+ *
208
+ * @private
209
+ * @return {number }
210
+ */
211
+ FontWatchRunner . prototype . getMockFontWidth_ = function ( ) {
212
+
213
+ var mockFontStyle = "@font-face\{font-family: '" + FontWatchRunner . LastResortFonts . MOCK_FONT + "';" +
214
+ this . font_ . getCssVariation ( ) +
215
+ "src: url(some.woff2) format('woff2');\}"
216
+
217
+ var mockFontCss = this . domHelper_ . createStyle ( mockFontStyle ) ;
218
+ this . domHelper_ . insertInto ( 'head' , mockFontCss )
219
+
220
+ var mockFontRuler = new FontRuler ( this . domHelper_ , this . fontTestString_ ) ;
221
+ mockFontRuler . setFont ( new Font ( FontWatchRunner . LastResortFonts . MOCK_FONT , this . font_ . getVariation ( ) ) ) ;
222
+ mockFontRuler . insert ( ) ;
223
+
224
+ var mockFontWidth = mockFontRuler . getWidth ( ) ;
225
+
226
+ mockFontRuler . remove ( )
227
+ this . domHelper_ . removeElement ( mockFontCss )
228
+
229
+ return mockFontWidth
230
+ }
231
+
196
232
/**
197
233
* Checks the width of the two spans against their original widths during each
198
234
* async loop. If the width of one of the spans is different than the original
0 commit comments