| 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #include "bindings/core/v8/ExceptionState.h" | 33 #include "bindings/core/v8/ExceptionState.h" |
| 34 #include "bindings/core/v8/ScriptState.h" | 34 #include "bindings/core/v8/ScriptState.h" |
| 35 #include "bindings/core/v8/StringOrArrayBufferOrArrayBufferView.h" | 35 #include "bindings/core/v8/StringOrArrayBufferOrArrayBufferView.h" |
| 36 #include "core/CSSValueKeywords.h" | 36 #include "core/CSSValueKeywords.h" |
| 37 #include "core/css/BinaryDataFontFaceSource.h" | 37 #include "core/css/BinaryDataFontFaceSource.h" |
| 38 #include "core/css/CSSFontFace.h" | 38 #include "core/css/CSSFontFace.h" |
| 39 #include "core/css/CSSFontFaceSrcValue.h" | 39 #include "core/css/CSSFontFaceSrcValue.h" |
| 40 #include "core/css/CSSFontFamilyValue.h" | 40 #include "core/css/CSSFontFamilyValue.h" |
| 41 #include "core/css/CSSFontSelector.h" | 41 #include "core/css/CSSFontSelector.h" |
| 42 #include "core/css/CSSPrimitiveValue.h" | 42 #include "core/css/CSSIdentifierValue.h" |
| 43 #include "core/css/CSSUnicodeRangeValue.h" | 43 #include "core/css/CSSUnicodeRangeValue.h" |
| 44 #include "core/css/CSSValueList.h" | 44 #include "core/css/CSSValueList.h" |
| 45 #include "core/css/FontFaceDescriptors.h" | 45 #include "core/css/FontFaceDescriptors.h" |
| 46 #include "core/css/LocalFontFaceSource.h" | 46 #include "core/css/LocalFontFaceSource.h" |
| 47 #include "core/css/RemoteFontFaceSource.h" | 47 #include "core/css/RemoteFontFaceSource.h" |
| 48 #include "core/css/StylePropertySet.h" | 48 #include "core/css/StylePropertySet.h" |
| 49 #include "core/css/StyleRule.h" | 49 #include "core/css/StyleRule.h" |
| 50 #include "core/css/parser/CSSParser.h" | 50 #include "core/css/parser/CSSParser.h" |
| 51 #include "core/dom/DOMArrayBuffer.h" | 51 #include "core/dom/DOMArrayBuffer.h" |
| 52 #include "core/dom/DOMArrayBufferView.h" | 52 #include "core/dom/DOMArrayBufferView.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return fontFace; | 122 return fontFace; |
| 123 } | 123 } |
| 124 | 124 |
| 125 FontFace* FontFace::create(Document* document, | 125 FontFace* FontFace::create(Document* document, |
| 126 const StyleRuleFontFace* fontFaceRule) { | 126 const StyleRuleFontFace* fontFaceRule) { |
| 127 const StylePropertySet& properties = fontFaceRule->properties(); | 127 const StylePropertySet& properties = fontFaceRule->properties(); |
| 128 | 128 |
| 129 // Obtain the font-family property and the src property. Both must be defined. | 129 // Obtain the font-family property and the src property. Both must be defined. |
| 130 const CSSValue* family = | 130 const CSSValue* family = |
| 131 properties.getPropertyCSSValue(CSSPropertyFontFamily); | 131 properties.getPropertyCSSValue(CSSPropertyFontFamily); |
| 132 if (!family || (!family->isFontFamilyValue() && !family->isPrimitiveValue())) | 132 if (!family || (!family->isFontFamilyValue() && !family->isIdentifierValue())) |
| 133 return nullptr; | 133 return nullptr; |
| 134 const CSSValue* src = properties.getPropertyCSSValue(CSSPropertySrc); | 134 const CSSValue* src = properties.getPropertyCSSValue(CSSPropertySrc); |
| 135 if (!src || !src->isValueList()) | 135 if (!src || !src->isValueList()) |
| 136 return nullptr; | 136 return nullptr; |
| 137 | 137 |
| 138 FontFace* fontFace = new FontFace(document); | 138 FontFace* fontFace = new FontFace(document); |
| 139 | 139 |
| 140 if (fontFace->setFamilyValue(*family) && | 140 if (fontFace->setFamilyValue(*family) && |
| 141 fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) && | 141 fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) && |
| 142 fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) && | 142 fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) && |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 ASSERT_NOT_REACHED(); | 301 ASSERT_NOT_REACHED(); |
| 302 return false; | 302 return false; |
| 303 } | 303 } |
| 304 return true; | 304 return true; |
| 305 } | 305 } |
| 306 | 306 |
| 307 bool FontFace::setFamilyValue(const CSSValue& familyValue) { | 307 bool FontFace::setFamilyValue(const CSSValue& familyValue) { |
| 308 AtomicString family; | 308 AtomicString family; |
| 309 if (familyValue.isFontFamilyValue()) { | 309 if (familyValue.isFontFamilyValue()) { |
| 310 family = AtomicString(toCSSFontFamilyValue(familyValue).value()); | 310 family = AtomicString(toCSSFontFamilyValue(familyValue).value()); |
| 311 } else if (toCSSPrimitiveValue(familyValue).isValueID()) { | 311 } else if (familyValue.isIdentifierValue()) { |
| 312 // We need to use the raw text for all the generic family types, since @font
-face is a way of actually | 312 // We need to use the raw text for all the generic family types, since @font
-face is a way of actually |
| 313 // defining what font to use for those types. | 313 // defining what font to use for those types. |
| 314 switch (toCSSPrimitiveValue(familyValue).getValueID()) { | 314 switch (toCSSIdentifierValue(familyValue).getValueID()) { |
| 315 case CSSValueSerif: | 315 case CSSValueSerif: |
| 316 family = FontFamilyNames::webkit_serif; | 316 family = FontFamilyNames::webkit_serif; |
| 317 break; | 317 break; |
| 318 case CSSValueSansSerif: | 318 case CSSValueSansSerif: |
| 319 family = FontFamilyNames::webkit_sans_serif; | 319 family = FontFamilyNames::webkit_sans_serif; |
| 320 break; | 320 break; |
| 321 case CSSValueCursive: | 321 case CSSValueCursive: |
| 322 family = FontFamilyNames::webkit_cursive; | 322 family = FontFamilyNames::webkit_cursive; |
| 323 break; | 323 break; |
| 324 case CSSValueFantasy: | 324 case CSSValueFantasy: |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 void FontFace::loadInternal(ExecutionContext* context) { | 418 void FontFace::loadInternal(ExecutionContext* context) { |
| 419 if (m_status != Unloaded) | 419 if (m_status != Unloaded) |
| 420 return; | 420 return; |
| 421 | 421 |
| 422 m_cssFontFace->load(); | 422 m_cssFontFace->load(); |
| 423 } | 423 } |
| 424 | 424 |
| 425 FontTraits FontFace::traits() const { | 425 FontTraits FontFace::traits() const { |
| 426 FontStretch stretch = FontStretchNormal; | 426 FontStretch stretch = FontStretchNormal; |
| 427 if (m_stretch) { | 427 if (m_stretch) { |
| 428 if (!m_stretch->isPrimitiveValue()) | 428 if (!m_stretch->isIdentifierValue()) |
| 429 return 0; | 429 return 0; |
| 430 | 430 |
| 431 switch (toCSSPrimitiveValue(m_stretch.get())->getValueID()) { | 431 switch (toCSSIdentifierValue(m_stretch.get())->getValueID()) { |
| 432 case CSSValueUltraCondensed: | 432 case CSSValueUltraCondensed: |
| 433 stretch = FontStretchUltraCondensed; | 433 stretch = FontStretchUltraCondensed; |
| 434 break; | 434 break; |
| 435 case CSSValueExtraCondensed: | 435 case CSSValueExtraCondensed: |
| 436 stretch = FontStretchExtraCondensed; | 436 stretch = FontStretchExtraCondensed; |
| 437 break; | 437 break; |
| 438 case CSSValueCondensed: | 438 case CSSValueCondensed: |
| 439 stretch = FontStretchCondensed; | 439 stretch = FontStretchCondensed; |
| 440 break; | 440 break; |
| 441 case CSSValueSemiCondensed: | 441 case CSSValueSemiCondensed: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 453 case CSSValueUltraExpanded: | 453 case CSSValueUltraExpanded: |
| 454 stretch = FontStretchUltraExpanded; | 454 stretch = FontStretchUltraExpanded; |
| 455 break; | 455 break; |
| 456 default: | 456 default: |
| 457 break; | 457 break; |
| 458 } | 458 } |
| 459 } | 459 } |
| 460 | 460 |
| 461 FontStyle style = FontStyleNormal; | 461 FontStyle style = FontStyleNormal; |
| 462 if (m_style) { | 462 if (m_style) { |
| 463 if (!m_style->isPrimitiveValue()) | 463 if (!m_style->isIdentifierValue()) |
| 464 return 0; | 464 return 0; |
| 465 | 465 |
| 466 switch (toCSSPrimitiveValue(m_style.get())->getValueID()) { | 466 switch (toCSSIdentifierValue(m_style.get())->getValueID()) { |
| 467 case CSSValueNormal: | 467 case CSSValueNormal: |
| 468 style = FontStyleNormal; | 468 style = FontStyleNormal; |
| 469 break; | 469 break; |
| 470 case CSSValueOblique: | 470 case CSSValueOblique: |
| 471 style = FontStyleOblique; | 471 style = FontStyleOblique; |
| 472 break; | 472 break; |
| 473 case CSSValueItalic: | 473 case CSSValueItalic: |
| 474 style = FontStyleItalic; | 474 style = FontStyleItalic; |
| 475 break; | 475 break; |
| 476 default: | 476 default: |
| 477 break; | 477 break; |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 | 480 |
| 481 FontWeight weight = FontWeight400; | 481 FontWeight weight = FontWeight400; |
| 482 if (m_weight) { | 482 if (m_weight) { |
| 483 if (!m_weight->isPrimitiveValue()) | 483 if (!m_weight->isIdentifierValue()) |
| 484 return 0; | 484 return 0; |
| 485 | 485 |
| 486 switch (toCSSPrimitiveValue(m_weight.get())->getValueID()) { | 486 switch (toCSSIdentifierValue(m_weight.get())->getValueID()) { |
| 487 case CSSValueBold: | 487 case CSSValueBold: |
| 488 case CSSValue700: | 488 case CSSValue700: |
| 489 weight = FontWeight700; | 489 weight = FontWeight700; |
| 490 break; | 490 break; |
| 491 case CSSValueNormal: | 491 case CSSValueNormal: |
| 492 case CSSValue400: | 492 case CSSValue400: |
| 493 weight = FontWeight400; | 493 weight = FontWeight400; |
| 494 break; | 494 break; |
| 495 case CSSValue900: | 495 case CSSValue900: |
| 496 weight = FontWeight900; | 496 weight = FontWeight900; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 527 return FontTraits(style, weight, stretch); | 527 return FontTraits(style, weight, stretch); |
| 528 } | 528 } |
| 529 | 529 |
| 530 size_t FontFace::approximateBlankCharacterCount() const { | 530 size_t FontFace::approximateBlankCharacterCount() const { |
| 531 if (m_status == Loading) | 531 if (m_status == Loading) |
| 532 return m_cssFontFace->approximateBlankCharacterCount(); | 532 return m_cssFontFace->approximateBlankCharacterCount(); |
| 533 return 0; | 533 return 0; |
| 534 } | 534 } |
| 535 | 535 |
| 536 static FontDisplay CSSValueToFontDisplay(const CSSValue* value) { | 536 static FontDisplay CSSValueToFontDisplay(const CSSValue* value) { |
| 537 if (value && value->isPrimitiveValue()) { | 537 if (value && value->isIdentifierValue()) { |
| 538 switch (toCSSPrimitiveValue(value)->getValueID()) { | 538 switch (toCSSIdentifierValue(value)->getValueID()) { |
| 539 case CSSValueAuto: | 539 case CSSValueAuto: |
| 540 return FontDisplayAuto; | 540 return FontDisplayAuto; |
| 541 case CSSValueBlock: | 541 case CSSValueBlock: |
| 542 return FontDisplayBlock; | 542 return FontDisplayBlock; |
| 543 case CSSValueSwap: | 543 case CSSValueSwap: |
| 544 return FontDisplaySwap; | 544 return FontDisplaySwap; |
| 545 case CSSValueFallback: | 545 case CSSValueFallback: |
| 546 return FontDisplayFallback; | 546 return FontDisplayFallback; |
| 547 case CSSValueOptional: | 547 case CSSValueOptional: |
| 548 return FontDisplayOptional; | 548 return FontDisplayOptional; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 bool FontFace::hadBlankText() const { | 646 bool FontFace::hadBlankText() const { |
| 647 return m_cssFontFace->hadBlankText(); | 647 return m_cssFontFace->hadBlankText(); |
| 648 } | 648 } |
| 649 | 649 |
| 650 bool FontFace::hasPendingActivity() const { | 650 bool FontFace::hasPendingActivity() const { |
| 651 return m_status == Loading && getExecutionContext() && | 651 return m_status == Loading && getExecutionContext() && |
| 652 !getExecutionContext()->activeDOMObjectsAreStopped(); | 652 !getExecutionContext()->activeDOMObjectsAreStopped(); |
| 653 } | 653 } |
| 654 | 654 |
| 655 } // namespace blink | 655 } // namespace blink |
| OLD | NEW |