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

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

Issue 429853002: IDL: Add build target for IDL dictionary impl generation in core (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
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/ScriptPromiseResolver.h" 35 #include "bindings/core/v8/ScriptPromiseResolver.h"
37 #include "bindings/core/v8/ScriptState.h" 36 #include "bindings/core/v8/ScriptState.h"
38 #include "core/CSSValueKeywords.h" 37 #include "core/CSSValueKeywords.h"
39 #include "core/css/BinaryDataFontFaceSource.h" 38 #include "core/css/BinaryDataFontFaceSource.h"
40 #include "core/css/CSSFontFace.h" 39 #include "core/css/CSSFontFace.h"
41 #include "core/css/CSSFontFaceSrcValue.h" 40 #include "core/css/CSSFontFaceSrcValue.h"
42 #include "core/css/CSSFontSelector.h" 41 #include "core/css/CSSFontSelector.h"
43 #include "core/css/CSSPrimitiveValue.h" 42 #include "core/css/CSSPrimitiveValue.h"
44 #include "core/css/CSSUnicodeRangeValue.h" 43 #include "core/css/CSSUnicodeRangeValue.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 95
97 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID) 96 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID)
98 { 97 {
99 if (s.isEmpty()) 98 if (s.isEmpty())
100 return nullptr; 99 return nullptr;
101 RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStyleProper tySet::create(); 100 RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStyleProper tySet::create();
102 BisonCSSParser::parseValue(parsedStyle.get(), propertyID, s, true, *document ); 101 BisonCSSParser::parseValue(parsedStyle.get(), propertyID, s, true, *document );
103 return parsedStyle->getPropertyCSSValue(propertyID); 102 return parsedStyle->getPropertyCSSValue(propertyID);
104 } 103 }
105 104
106 static bool initFontFace(FontFace* fontFace, ExecutionContext* context, const At omicString& family, const Dictionary& descriptors, ExceptionState& exceptionStat e) 105 static bool initFontFace(FontFace* fontFace, ExecutionContext* context, const At omicString& family, const FontFaceDescriptors* descriptors, ExceptionState& exce ptionState)
107 { 106 {
108 fontFace->setFamily(context, family, exceptionState); 107 fontFace->setFamily(context, family, exceptionState);
109 if (exceptionState.hadException()) 108 if (exceptionState.hadException())
110 return false; 109 return false;
111 110
112 String value; 111 fontFace->setStyle(context, descriptors->style(), exceptionState);
113 if (DictionaryHelper::get(descriptors, "style", value)) { 112 if (exceptionState.hadException())
114 fontFace->setStyle(context, value, exceptionState); 113 return false;
115 if (exceptionState.hadException()) 114 fontFace->setWeight(context, descriptors->weight(), exceptionState);
116 return false; 115 if (exceptionState.hadException())
117 } 116 return false;
118 if (DictionaryHelper::get(descriptors, "weight", value)) { 117 fontFace->setStretch(context, descriptors->stretch(), exceptionState);
119 fontFace->setWeight(context, value, exceptionState); 118 if (exceptionState.hadException())
120 if (exceptionState.hadException()) 119 return false;
121 return false; 120 fontFace->setUnicodeRange(context, descriptors->unicodeRange(), exceptionSta te);
122 } 121 if (exceptionState.hadException())
123 if (DictionaryHelper::get(descriptors, "stretch", value)) { 122 return false;
124 fontFace->setStretch(context, value, exceptionState); 123 fontFace->setVariant(context, descriptors->variant(), exceptionState);
125 if (exceptionState.hadException()) 124 if (exceptionState.hadException())
126 return false; 125 return false;
127 } 126 fontFace->setFeatureSettings(context, descriptors->featureSettings(), except ionState);
128 if (DictionaryHelper::get(descriptors, "unicodeRange", value)) { 127 if (exceptionState.hadException())
129 fontFace->setUnicodeRange(context, value, exceptionState); 128 return false;
130 if (exceptionState.hadException())
131 return false;
132 }
133 if (DictionaryHelper::get(descriptors, "variant", value)) {
134 fontFace->setVariant(context, value, exceptionState);
135 if (exceptionState.hadException())
136 return false;
137 }
138 if (DictionaryHelper::get(descriptors, "featureSettings", value)) {
139 fontFace->setFeatureSettings(context, value, exceptionState);
140 if (exceptionState.hadException())
141 return false;
142 }
143 return true; 129 return true;
144 } 130 }
145 131
146 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, const String& source, const Dictionary& descriptors, Ex ceptionState& exceptionState) 132 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, const String& source, const FontFaceDescriptors* descri ptors, ExceptionState& exceptionState)
147 { 133 {
148 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source , CSSPropertySrc); 134 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source , CSSPropertySrc);
149 if (!src || !src->isValueList()) { 135 if (!src || !src->isValueList()) {
150 exceptionState.throwDOMException(SyntaxError, "The source provided ('" + source + "') could not be parsed as a value list."); 136 exceptionState.throwDOMException(SyntaxError, "The source provided ('" + source + "') could not be parsed as a value list.");
151 return nullptr; 137 return nullptr;
152 } 138 }
153 139
154 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace()); 140 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace());
155 if (initFontFace(fontFace.get(), context, family, descriptors, exceptionStat e)) 141 if (initFontFace(fontFace.get(), context, family, descriptors, exceptionStat e))
156 fontFace->initCSSFontFace(toDocument(context), src); 142 fontFace->initCSSFontFace(toDocument(context), src);
157 return fontFace.release(); 143 return fontFace.release();
158 } 144 }
159 145
160 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, PassRefPtr<ArrayBuffer> source, const Dictionary& descr iptors, ExceptionState& exceptionState) 146 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, PassRefPtr<ArrayBuffer> source, const FontFaceDescripto rs* descriptors, ExceptionState& exceptionState)
161 { 147 {
162 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace()); 148 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace());
163 if (initFontFace(fontFace.get(), context, family, descriptors, exceptionStat e)) 149 if (initFontFace(fontFace.get(), context, family, descriptors, exceptionStat e))
164 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data ()), source->byteLength()); 150 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data ()), source->byteLength());
165 return fontFace.release(); 151 return fontFace.release();
166 } 152 }
167 153
168 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, PassRefPtr<ArrayBufferView> source, const Dictionary& d escriptors, ExceptionState& exceptionState) 154 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, PassRefPtr<ArrayBufferView> source, const FontFaceDescr iptors* descriptors, ExceptionState& exceptionState)
169 { 155 {
170 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace()); 156 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace());
171 if (initFontFace(fontFace.get(), context, family, descriptors, exceptionStat e)) 157 if (initFontFace(fontFace.get(), context, family, descriptors, exceptionStat e))
172 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->base Address()), source->byteLength()); 158 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->base Address()), source->byteLength());
173 return fontFace.release(); 159 return fontFace.release();
174 } 160 }
175 161
176 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl eRuleFontFace* fontFaceRule) 162 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl eRuleFontFace* fontFaceRule)
177 { 163 {
178 const StylePropertySet& properties = fontFaceRule->properties(); 164 const StylePropertySet& properties = fontFaceRule->properties();
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 visitor->trace(m_cssFontFace); 617 visitor->trace(m_cssFontFace);
632 visitor->trace(m_callbacks); 618 visitor->trace(m_callbacks);
633 } 619 }
634 620
635 bool FontFace::hadBlankText() const 621 bool FontFace::hadBlankText() const
636 { 622 {
637 return m_cssFontFace->hadBlankText(); 623 return m_cssFontFace->hadBlankText();
638 } 624 }
639 625
640 } // namespace blink 626 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698