Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: Source/core/css/FontFace.cpp

Issue 481453003: Add FontFaceDescriptors IDL dictionary (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@idl_gyp
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/FontFace.h ('k') | Source/core/css/FontFace.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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/Dictionary.h"
35 #include "bindings/core/v8/ExceptionState.h" 34 #include "bindings/core/v8/ExceptionState.h"
36 #include "bindings/core/v8/ScriptState.h" 35 #include "bindings/core/v8/ScriptState.h"
37 #include "core/CSSValueKeywords.h" 36 #include "core/CSSValueKeywords.h"
38 #include "core/css/BinaryDataFontFaceSource.h" 37 #include "core/css/BinaryDataFontFaceSource.h"
39 #include "core/css/CSSFontFace.h" 38 #include "core/css/CSSFontFace.h"
40 #include "core/css/CSSFontFaceSrcValue.h" 39 #include "core/css/CSSFontFaceSrcValue.h"
41 #include "core/css/CSSFontSelector.h" 40 #include "core/css/CSSFontSelector.h"
42 #include "core/css/CSSPrimitiveValue.h" 41 #include "core/css/CSSPrimitiveValue.h"
43 #include "core/css/CSSUnicodeRangeValue.h" 42 #include "core/css/CSSUnicodeRangeValue.h"
44 #include "core/css/CSSValueList.h" 43 #include "core/css/CSSValueList.h"
44 #include "core/css/FontFaceDescriptors.h"
45 #include "core/css/LocalFontFaceSource.h" 45 #include "core/css/LocalFontFaceSource.h"
46 #include "core/css/RemoteFontFaceSource.h" 46 #include "core/css/RemoteFontFaceSource.h"
47 #include "core/css/StylePropertySet.h" 47 #include "core/css/StylePropertySet.h"
48 #include "core/css/StyleRule.h" 48 #include "core/css/StyleRule.h"
49 #include "core/css/parser/BisonCSSParser.h" 49 #include "core/css/parser/BisonCSSParser.h"
50 #include "core/dom/DOMException.h" 50 #include "core/dom/DOMException.h"
51 #include "core/dom/Document.h" 51 #include "core/dom/Document.h"
52 #include "core/dom/ExceptionCode.h" 52 #include "core/dom/ExceptionCode.h"
53 #include "core/dom/StyleEngine.h" 53 #include "core/dom/StyleEngine.h"
54 #include "core/frame/LocalFrame.h" 54 #include "core/frame/LocalFrame.h"
55 #include "core/frame/Settings.h" 55 #include "core/frame/Settings.h"
56 #include "core/svg/SVGFontFaceElement.h" 56 #include "core/svg/SVGFontFaceElement.h"
57 #include "core/svg/SVGFontFaceSource.h" 57 #include "core/svg/SVGFontFaceSource.h"
58 #include "core/svg/SVGRemoteFontFaceSource.h" 58 #include "core/svg/SVGRemoteFontFaceSource.h"
59 #include "platform/FontFamilyNames.h" 59 #include "platform/FontFamilyNames.h"
60 #include "platform/SharedBuffer.h" 60 #include "platform/SharedBuffer.h"
61 61
62 namespace blink { 62 namespace blink {
63 63
64 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID) 64 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID)
65 { 65 {
66 if (s.isEmpty()) 66 if (s.isEmpty())
67 return nullptr; 67 return nullptr;
68 RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStyleProper tySet::create(); 68 RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStyleProper tySet::create();
69 BisonCSSParser::parseValue(parsedStyle.get(), propertyID, s, true, *document ); 69 BisonCSSParser::parseValue(parsedStyle.get(), propertyID, s, true, *document );
70 return parsedStyle->getPropertyCSSValue(propertyID); 70 return parsedStyle->getPropertyCSSValue(propertyID);
71 } 71 }
72 72
73 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, const String& source, const Dictionary& descriptors) 73 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, const String& source, const FontFaceDescriptors* descri ptors)
74 { 74 {
75 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont ext, family, descriptors)); 75 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont ext, family, descriptors));
76 76
77 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source , CSSPropertySrc); 77 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source , CSSPropertySrc);
78 if (!src || !src->isValueList()) 78 if (!src || !src->isValueList())
79 fontFace->setError(DOMException::create(SyntaxError, "The source provide d ('" + source + "') could not be parsed as a value list.")); 79 fontFace->setError(DOMException::create(SyntaxError, "The source provide d ('" + source + "') could not be parsed as a value list."));
80 80
81 fontFace->initCSSFontFace(toDocument(context), src); 81 fontFace->initCSSFontFace(toDocument(context), src);
82 return fontFace.release(); 82 return fontFace.release();
83 } 83 }
84 84
85 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, PassRefPtr<ArrayBuffer> source, const Dictionary& descr iptors) 85 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, PassRefPtr<ArrayBuffer> source, const FontFaceDescripto rs* descriptors)
86 { 86 {
87 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont ext, family, descriptors)); 87 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont ext, family, descriptors));
88 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()), source->byteLength()); 88 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()), source->byteLength());
89 return fontFace.release(); 89 return fontFace.release();
90 } 90 }
91 91
92 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, PassRefPtr<ArrayBufferView> source, const Dictionary& d escriptors) 92 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, PassRefPtr<ArrayBufferView> source, const FontFaceDescr iptors* descriptors)
93 { 93 {
94 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont ext, family, descriptors)); 94 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont ext, family, descriptors));
95 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddr ess()), source->byteLength()); 95 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddr ess()), source->byteLength());
96 return fontFace.release(); 96 return fontFace.release();
97 } 97 }
98 98
99 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl eRuleFontFace* fontFaceRule) 99 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl eRuleFontFace* fontFaceRule)
100 { 100 {
101 const StylePropertySet& properties = fontFaceRule->properties(); 101 const StylePropertySet& properties = fontFaceRule->properties();
102 102
(...skipping 21 matching lines...) Expand all
124 } 124 }
125 return nullptr; 125 return nullptr;
126 } 126 }
127 127
128 FontFace::FontFace() 128 FontFace::FontFace()
129 : m_status(Unloaded) 129 : m_status(Unloaded)
130 { 130 {
131 ScriptWrappable::init(this); 131 ScriptWrappable::init(this);
132 } 132 }
133 133
134 FontFace::FontFace(ExecutionContext* context, const AtomicString& family, const Dictionary& descriptors) 134 FontFace::FontFace(ExecutionContext* context, const AtomicString& family, const FontFaceDescriptors* descriptors)
135 : m_family(family) 135 : m_family(family)
136 , m_status(Unloaded) 136 , m_status(Unloaded)
137 { 137 {
138 ScriptWrappable::init(this); 138 ScriptWrappable::init(this);
139 139
140 Document* document = toDocument(context); 140 Document* document = toDocument(context);
141 String value; 141 setPropertyFromString(document, descriptors->style(), CSSPropertyFontStyle);
142 if (DictionaryHelper::get(descriptors, "style", value)) 142 setPropertyFromString(document, descriptors->weight(), CSSPropertyFontWeight );
143 setPropertyFromString(document, value, CSSPropertyFontStyle); 143 // FIXME: we don't implement 'font-strech' property so we can't set the prop erty.
144 if (DictionaryHelper::get(descriptors, "weight", value)) 144 setPropertyFromString(document, descriptors->unicodeRange(), CSSPropertyUnic odeRange);
145 setPropertyFromString(document, value, CSSPropertyFontWeight); 145 setPropertyFromString(document, descriptors->variant(), CSSPropertyFontVaria nt);
146 if (DictionaryHelper::get(descriptors, "stretch", value)) 146 setPropertyFromString(document, descriptors->featureSettings(), CSSPropertyW ebkitFontFeatureSettings);
147 setPropertyFromString(document, value, CSSPropertyFontStretch);
148 if (DictionaryHelper::get(descriptors, "unicodeRange", value))
149 setPropertyFromString(document, value, CSSPropertyUnicodeRange);
150 if (DictionaryHelper::get(descriptors, "variant", value))
151 setPropertyFromString(document, value, CSSPropertyFontVariant);
152 if (DictionaryHelper::get(descriptors, "featureSettings", value))
153 setPropertyFromString(document, value, CSSPropertyWebkitFontFeatureSetti ngs);
154 } 147 }
155 148
156 FontFace::~FontFace() 149 FontFace::~FontFace()
157 { 150 {
158 } 151 }
159 152
160 String FontFace::style() const 153 String FontFace::style() const
161 { 154 {
162 return m_style ? m_style->cssText() : "normal"; 155 return m_style ? m_style->cssText() : "normal";
163 } 156 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 visitor->trace(m_cssFontFace); 583 visitor->trace(m_cssFontFace);
591 visitor->trace(m_callbacks); 584 visitor->trace(m_callbacks);
592 } 585 }
593 586
594 bool FontFace::hadBlankText() const 587 bool FontFace::hadBlankText() const
595 { 588 {
596 return m_cssFontFace->hadBlankText(); 589 return m_cssFontFace->hadBlankText();
597 } 590 }
598 591
599 } // namespace blink 592 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/FontFace.h ('k') | Source/core/css/FontFace.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698