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 | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 143 } |
144 | 144 |
145 FontFace::FontFace(ExecutionContext* context, const AtomicString& family, const
FontFaceDescriptors& descriptors) | 145 FontFace::FontFace(ExecutionContext* context, const AtomicString& family, const
FontFaceDescriptors& descriptors) |
146 : ActiveDOMObject(context) | 146 : ActiveDOMObject(context) |
147 , m_family(family) | 147 , m_family(family) |
148 , m_status(Unloaded) | 148 , m_status(Unloaded) |
149 { | 149 { |
150 Document* document = toDocument(context); | 150 Document* document = toDocument(context); |
151 setPropertyFromString(document, descriptors.style(), CSSPropertyFontStyle); | 151 setPropertyFromString(document, descriptors.style(), CSSPropertyFontStyle); |
152 setPropertyFromString(document, descriptors.weight(), CSSPropertyFontWeight)
; | 152 setPropertyFromString(document, descriptors.weight(), CSSPropertyFontWeight)
; |
153 // FIXME: we don't implement 'font-strech' property yet so we can't set the
property. | 153 setPropertyFromString(document, descriptors.stretch(), CSSPropertyFontStretc
h); |
154 setPropertyFromString(document, descriptors.unicodeRange(), CSSPropertyUnico
deRange); | 154 setPropertyFromString(document, descriptors.unicodeRange(), CSSPropertyUnico
deRange); |
155 setPropertyFromString(document, descriptors.variant(), CSSPropertyFontVarian
t); | 155 setPropertyFromString(document, descriptors.variant(), CSSPropertyFontVarian
t); |
156 setPropertyFromString(document, descriptors.featureSettings(), CSSPropertyWe
bkitFontFeatureSettings); | 156 setPropertyFromString(document, descriptors.featureSettings(), CSSPropertyWe
bkitFontFeatureSettings); |
157 | 157 |
158 suspendIfNeeded(); | 158 suspendIfNeeded(); |
159 } | 159 } |
160 | 160 |
161 FontFace::~FontFace() | 161 FontFace::~FontFace() |
162 { | 162 { |
163 } | 163 } |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 { | 391 { |
392 if (m_status != Unloaded) | 392 if (m_status != Unloaded) |
393 return; | 393 return; |
394 | 394 |
395 m_cssFontFace->load(); | 395 m_cssFontFace->load(); |
396 toDocument(context)->styleEngine().fontSelector()->fontLoader()->loadPending
Fonts(); | 396 toDocument(context)->styleEngine().fontSelector()->fontLoader()->loadPending
Fonts(); |
397 } | 397 } |
398 | 398 |
399 FontTraits FontFace::traits() const | 399 FontTraits FontFace::traits() const |
400 { | 400 { |
| 401 FontStretch stretch = FontStretchNormal; |
| 402 if (m_stretch) { |
| 403 if (!m_stretch->isPrimitiveValue()) |
| 404 return 0; |
| 405 |
| 406 switch (toCSSPrimitiveValue(m_stretch.get())->getValueID()) { |
| 407 case CSSValueUltraCondensed: |
| 408 stretch = FontStretchUltraCondensed; |
| 409 break; |
| 410 case CSSValueExtraCondensed: |
| 411 stretch = FontStretchExtraCondensed; |
| 412 break; |
| 413 case CSSValueCondensed: |
| 414 stretch = FontStretchCondensed; |
| 415 break; |
| 416 case CSSValueSemiCondensed: |
| 417 stretch = FontStretchSemiCondensed; |
| 418 break; |
| 419 case CSSValueSemiExpanded: |
| 420 stretch = FontStretchSemiExpanded; |
| 421 break; |
| 422 case CSSValueExpanded: |
| 423 stretch = FontStretchExpanded; |
| 424 break; |
| 425 case CSSValueExtraExpanded: |
| 426 stretch = FontStretchExtraExpanded; |
| 427 break; |
| 428 case CSSValueUltraExpanded: |
| 429 stretch = FontStretchUltraExpanded; |
| 430 break; |
| 431 default: |
| 432 break; |
| 433 } |
| 434 } |
| 435 |
401 FontStyle style = FontStyleNormal; | 436 FontStyle style = FontStyleNormal; |
402 if (m_style) { | 437 if (m_style) { |
403 if (!m_style->isPrimitiveValue()) | 438 if (!m_style->isPrimitiveValue()) |
404 return 0; | 439 return 0; |
405 | 440 |
406 switch (toCSSPrimitiveValue(m_style.get())->getValueID()) { | 441 switch (toCSSPrimitiveValue(m_style.get())->getValueID()) { |
407 case CSSValueNormal: | 442 case CSSValueNormal: |
408 style = FontStyleNormal; | 443 style = FontStyleNormal; |
409 break; | 444 break; |
| 445 case CSSValueOblique: |
| 446 style = FontStyleOblique; |
| 447 break; |
410 case CSSValueItalic: | 448 case CSSValueItalic: |
411 case CSSValueOblique: | |
412 style = FontStyleItalic; | 449 style = FontStyleItalic; |
413 break; | 450 break; |
414 default: | 451 default: |
415 break; | 452 break; |
416 } | 453 } |
417 } | 454 } |
418 | 455 |
419 FontWeight weight = FontWeight400; | 456 FontWeight weight = FontWeight400; |
420 if (m_weight) { | 457 if (m_weight) { |
421 if (!m_weight->isPrimitiveValue()) | 458 if (!m_weight->isPrimitiveValue()) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 break; | 522 break; |
486 case CSSValueSmallCaps: | 523 case CSSValueSmallCaps: |
487 variant = FontVariantSmallCaps; | 524 variant = FontVariantSmallCaps; |
488 break; | 525 break; |
489 default: | 526 default: |
490 break; | 527 break; |
491 } | 528 } |
492 } | 529 } |
493 } | 530 } |
494 | 531 |
495 return FontTraits(style, variant, weight, FontStretchNormal); | 532 return FontTraits(style, variant, weight, stretch); |
496 } | 533 } |
497 | 534 |
498 static PassOwnPtrWillBeRawPtr<CSSFontFace> createCSSFontFace(FontFace* fontFace,
CSSValue* unicodeRange) | 535 static PassOwnPtrWillBeRawPtr<CSSFontFace> createCSSFontFace(FontFace* fontFace,
CSSValue* unicodeRange) |
499 { | 536 { |
500 Vector<CSSFontFace::UnicodeRange> ranges; | 537 Vector<CSSFontFace::UnicodeRange> ranges; |
501 if (CSSValueList* rangeList = toCSSValueList(unicodeRange)) { | 538 if (CSSValueList* rangeList = toCSSValueList(unicodeRange)) { |
502 unsigned numRanges = rangeList->length(); | 539 unsigned numRanges = rangeList->length(); |
503 for (unsigned i = 0; i < numRanges; i++) { | 540 for (unsigned i = 0; i < numRanges; i++) { |
504 CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item
(i)); | 541 CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item
(i)); |
505 ranges.append(CSSFontFace::UnicodeRange(range->from(), range->to()))
; | 542 ranges.append(CSSFontFace::UnicodeRange(range->from(), range->to()))
; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 { | 617 { |
581 return m_cssFontFace->hadBlankText(); | 618 return m_cssFontFace->hadBlankText(); |
582 } | 619 } |
583 | 620 |
584 bool FontFace::hasPendingActivity() const | 621 bool FontFace::hasPendingActivity() const |
585 { | 622 { |
586 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); | 623 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); |
587 } | 624 } |
588 | 625 |
589 } // namespace blink | 626 } // namespace blink |
OLD | NEW |