OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions are met: |
6 * | 6 * |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 { | 303 { |
304 Vector<RefPtr<FontFace> > matchedFonts; | 304 Vector<RefPtr<FontFace> > matchedFonts; |
305 | 305 |
306 Font font; | 306 Font font; |
307 if (!resolveFontStyle(fontString, font)) { | 307 if (!resolveFontStyle(fontString, font)) { |
308 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); | 308 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); |
309 return matchedFonts; | 309 return matchedFonts; |
310 } | 310 } |
311 | 311 |
312 for (const FontFamily* f = &font.family(); f; f = f->next()) { | 312 for (const FontFamily* f = &font.family(); f; f = f->next()) { |
313 CSSSegmentedFontFace* face = document()->ensureStyleResolver().fontSelec
tor()->getFontFace(font.fontDescription(), f->family()); | 313 CSSSegmentedFontFace* face = document()->styleEngine()->fontSelector()->
getFontFace(font.fontDescription(), f->family()); |
314 if (face) | 314 if (face) |
315 matchedFonts.append(face->fontFaces(nullToSpace(text))); | 315 matchedFonts.append(face->fontFaces(nullToSpace(text))); |
316 } | 316 } |
317 return matchedFonts; | 317 return matchedFonts; |
318 } | 318 } |
319 | 319 |
320 ScriptPromise FontFaceSet::load(const String& fontString, const String& text, Ex
ceptionState& exceptionState) | 320 ScriptPromise FontFaceSet::load(const String& fontString, const String& text, Ex
ceptionState& exceptionState) |
321 { | 321 { |
322 Font font; | 322 Font font; |
323 if (!resolveFontStyle(fontString, font)) { | 323 if (!resolveFontStyle(fontString, font)) { |
324 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); | 324 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); |
325 return ScriptPromise(); | 325 return ScriptPromise(); |
326 } | 326 } |
327 | 327 |
328 Document* d = document(); | 328 Document* d = document(); |
329 ScriptPromise promise = ScriptPromise::createPending(executionContext()); | 329 ScriptPromise promise = ScriptPromise::createPending(executionContext()); |
330 RefPtr<LoadFontPromiseResolver> resolver = LoadFontPromiseResolver::create(f
ont.family(), promise, executionContext()); | 330 RefPtr<LoadFontPromiseResolver> resolver = LoadFontPromiseResolver::create(f
ont.family(), promise, executionContext()); |
331 for (const FontFamily* f = &font.family(); f; f = f->next()) { | 331 for (const FontFamily* f = &font.family(); f; f = f->next()) { |
332 CSSSegmentedFontFace* face = d->ensureStyleResolver().fontSelector()->ge
tFontFace(font.fontDescription(), f->family()); | 332 CSSSegmentedFontFace* face = d->styleEngine()->fontSelector()->getFontFa
ce(font.fontDescription(), f->family()); |
333 if (!face) { | 333 if (!face) { |
334 resolver->error(d); | 334 resolver->error(d); |
335 continue; | 335 continue; |
336 } | 336 } |
337 face->loadFont(font.fontDescription(), nullToSpace(text), resolver); | 337 face->loadFont(font.fontDescription(), nullToSpace(text), resolver); |
338 } | 338 } |
339 return promise; | 339 return promise; |
340 } | 340 } |
341 | 341 |
342 bool FontFaceSet::check(const String& fontString, const String& text, ExceptionS
tate& exceptionState) | 342 bool FontFaceSet::check(const String& fontString, const String& text, ExceptionS
tate& exceptionState) |
343 { | 343 { |
344 Font font; | 344 Font font; |
345 if (!resolveFontStyle(fontString, font)) { | 345 if (!resolveFontStyle(fontString, font)) { |
346 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); | 346 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); |
347 return false; | 347 return false; |
348 } | 348 } |
349 | 349 |
350 for (const FontFamily* f = &font.family(); f; f = f->next()) { | 350 for (const FontFamily* f = &font.family(); f; f = f->next()) { |
351 CSSSegmentedFontFace* face = document()->ensureStyleResolver().fontSelec
tor()->getFontFace(font.fontDescription(), f->family()); | 351 CSSSegmentedFontFace* face = document()->styleEngine()->fontSelector()->
getFontFace(font.fontDescription(), f->family()); |
352 if (!face || !face->checkFont(nullToSpace(text))) | 352 if (!face || !face->checkFont(nullToSpace(text))) |
353 return false; | 353 return false; |
354 } | 354 } |
355 return true; | 355 return true; |
356 } | 356 } |
357 | 357 |
358 bool FontFaceSet::resolveFontStyle(const String& fontString, Font& font) | 358 bool FontFaceSet::resolveFontStyle(const String& fontString, Font& font) |
359 { | 359 { |
360 if (fontString.isEmpty()) | 360 if (fontString.isEmpty()) |
361 return false; | 361 return false; |
(...skipping 28 matching lines...) Expand all Loading... |
390 CSSPropertyValue(CSSPropertyFontStyle, *parsedStyle), | 390 CSSPropertyValue(CSSPropertyFontStyle, *parsedStyle), |
391 CSSPropertyValue(CSSPropertyFontVariant, *parsedStyle), | 391 CSSPropertyValue(CSSPropertyFontVariant, *parsedStyle), |
392 CSSPropertyValue(CSSPropertyFontWeight, *parsedStyle), | 392 CSSPropertyValue(CSSPropertyFontWeight, *parsedStyle), |
393 CSSPropertyValue(CSSPropertyFontSize, *parsedStyle), | 393 CSSPropertyValue(CSSPropertyFontSize, *parsedStyle), |
394 CSSPropertyValue(CSSPropertyLineHeight, *parsedStyle), | 394 CSSPropertyValue(CSSPropertyLineHeight, *parsedStyle), |
395 }; | 395 }; |
396 StyleResolver& styleResolver = document()->ensureStyleResolver(); | 396 StyleResolver& styleResolver = document()->ensureStyleResolver(); |
397 styleResolver.applyPropertiesToStyle(properties, WTF_ARRAY_LENGTH(properties
), style.get()); | 397 styleResolver.applyPropertiesToStyle(properties, WTF_ARRAY_LENGTH(properties
), style.get()); |
398 | 398 |
399 font = style->font(); | 399 font = style->font(); |
400 font.update(styleResolver.fontSelector()); | 400 font.update(document()->styleEngine()->fontSelector()); |
401 return true; | 401 return true; |
402 } | 402 } |
403 | 403 |
404 void FontFaceSet::FontLoadHistogram::record() | 404 void FontFaceSet::FontLoadHistogram::record() |
405 { | 405 { |
406 if (m_recorded) | 406 if (m_recorded) |
407 return; | 407 return; |
408 m_recorded = true; | 408 m_recorded = true; |
409 blink::Platform::current()->histogramCustomCounts("WebFont.WebFontsInPage",
m_count, 1, 100, 50); | 409 blink::Platform::current()->histogramCustomCounts("WebFont.WebFontsInPage",
m_count, 1, 100, 50); |
410 } | 410 } |
(...skipping 15 matching lines...) Expand all Loading... |
426 } | 426 } |
427 | 427 |
428 void FontFaceSet::didLayout(Document* document) | 428 void FontFaceSet::didLayout(Document* document) |
429 { | 429 { |
430 if (FontFaceSet* fonts = static_cast<FontFaceSet*>(SupplementType::from(docu
ment, supplementName()))) | 430 if (FontFaceSet* fonts = static_cast<FontFaceSet*>(SupplementType::from(docu
ment, supplementName()))) |
431 fonts->didLayout(); | 431 fonts->didLayout(); |
432 } | 432 } |
433 | 433 |
434 | 434 |
435 } // namespace WebCore | 435 } // namespace WebCore |
OLD | NEW |