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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/css/FontFace.h" | 32 #include "core/css/FontFace.h" |
33 | 33 |
34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
35 #include "bindings/core/v8/ScriptState.h" | 35 #include "bindings/core/v8/ScriptState.h" |
| 36 #include "bindings/core/v8/UnionTypesCore.h" |
36 #include "core/CSSValueKeywords.h" | 37 #include "core/CSSValueKeywords.h" |
37 #include "core/css/BinaryDataFontFaceSource.h" | 38 #include "core/css/BinaryDataFontFaceSource.h" |
38 #include "core/css/CSSFontFace.h" | 39 #include "core/css/CSSFontFace.h" |
39 #include "core/css/CSSFontFaceSrcValue.h" | 40 #include "core/css/CSSFontFaceSrcValue.h" |
40 #include "core/css/CSSFontSelector.h" | 41 #include "core/css/CSSFontSelector.h" |
41 #include "core/css/CSSPrimitiveValue.h" | 42 #include "core/css/CSSPrimitiveValue.h" |
42 #include "core/css/CSSUnicodeRangeValue.h" | 43 #include "core/css/CSSUnicodeRangeValue.h" |
43 #include "core/css/CSSValueList.h" | 44 #include "core/css/CSSValueList.h" |
44 #include "core/css/FontFaceDescriptors.h" | 45 #include "core/css/FontFaceDescriptors.h" |
45 #include "core/css/LocalFontFaceSource.h" | 46 #include "core/css/LocalFontFaceSource.h" |
(...skipping 15 matching lines...) Expand all Loading... |
61 #include "wtf/ArrayBufferView.h" | 62 #include "wtf/ArrayBufferView.h" |
62 | 63 |
63 namespace blink { | 64 namespace blink { |
64 | 65 |
65 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document,
const String& s, CSSPropertyID propertyID) | 66 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document,
const String& s, CSSPropertyID propertyID) |
66 { | 67 { |
67 CSSParserContext context(*document, UseCounter::getFrom(document)); | 68 CSSParserContext context(*document, UseCounter::getFrom(document)); |
68 return CSSParser::parseSingleValue(propertyID, s, context); | 69 return CSSParser::parseSingleValue(propertyID, s, context); |
69 } | 70 } |
70 | 71 |
| 72 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, StringOrArrayBufferOrArrayBufferView& source, const Fon
tFaceDescriptors& descriptors) |
| 73 { |
| 74 if (source.isString()) |
| 75 return create(context, family, source.getAsString(), descriptors); |
| 76 if (source.isArrayBuffer()) |
| 77 return create(context, family, source.getAsArrayBuffer(), descriptors); |
| 78 if (source.isArrayBufferView()) |
| 79 return create(context, family, source.getAsArrayBufferView(), descriptor
s); |
| 80 ASSERT_NOT_REACHED(); |
| 81 return nullptr; |
| 82 } |
| 83 |
71 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, const String& source, const FontFaceDescriptors& descri
ptors) | 84 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, const String& source, const FontFaceDescriptors& descri
ptors) |
72 { | 85 { |
73 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); | 86 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); |
74 | 87 |
75 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source
, CSSPropertySrc); | 88 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source
, CSSPropertySrc); |
76 if (!src || !src->isValueList()) | 89 if (!src || !src->isValueList()) |
77 fontFace->setError(DOMException::create(SyntaxError, "The source provide
d ('" + source + "') could not be parsed as a value list.")); | 90 fontFace->setError(DOMException::create(SyntaxError, "The source provide
d ('" + source + "') could not be parsed as a value list.")); |
78 | 91 |
79 fontFace->initCSSFontFace(toDocument(context), src); | 92 fontFace->initCSSFontFace(toDocument(context), src); |
80 return fontFace.release(); | 93 return fontFace.release(); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 { | 580 { |
568 return m_cssFontFace->hadBlankText(); | 581 return m_cssFontFace->hadBlankText(); |
569 } | 582 } |
570 | 583 |
571 bool FontFace::hasPendingActivity() const | 584 bool FontFace::hasPendingActivity() const |
572 { | 585 { |
573 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); | 586 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); |
574 } | 587 } |
575 | 588 |
576 } // namespace blink | 589 } // namespace blink |
OLD | NEW |