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

Side by Side Diff: sky/engine/core/css/parser/CSSPropertyParser.cpp

Issue 1223843003: Remove support for loading remote font faces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 16 matching lines...) Expand all
27 #include "sky/engine/core/css/parser/CSSPropertyParser.h" 27 #include "sky/engine/core/css/parser/CSSPropertyParser.h"
28 28
29 // FIXME: Way too many! 29 // FIXME: Way too many!
30 #include <limits.h> 30 #include <limits.h>
31 #include "gen/sky/core/CSSValueKeywords.h" 31 #include "gen/sky/core/CSSValueKeywords.h"
32 #include "gen/sky/core/StylePropertyShorthand.h" 32 #include "gen/sky/core/StylePropertyShorthand.h"
33 #include "gen/sky/platform/RuntimeEnabledFeatures.h" 33 #include "gen/sky/platform/RuntimeEnabledFeatures.h"
34 #include "sky/engine/core/css/CSSAspectRatioValue.h" 34 #include "sky/engine/core/css/CSSAspectRatioValue.h"
35 #include "sky/engine/core/css/CSSBasicShapes.h" 35 #include "sky/engine/core/css/CSSBasicShapes.h"
36 #include "sky/engine/core/css/CSSBorderImage.h" 36 #include "sky/engine/core/css/CSSBorderImage.h"
37 #include "sky/engine/core/css/CSSFontFaceSrcValue.h"
38 #include "sky/engine/core/css/CSSFontFeatureValue.h" 37 #include "sky/engine/core/css/CSSFontFeatureValue.h"
39 #include "sky/engine/core/css/CSSFunctionValue.h" 38 #include "sky/engine/core/css/CSSFunctionValue.h"
40 #include "sky/engine/core/css/CSSGradientValue.h" 39 #include "sky/engine/core/css/CSSGradientValue.h"
41 #include "sky/engine/core/css/CSSInheritedValue.h" 40 #include "sky/engine/core/css/CSSInheritedValue.h"
42 #include "sky/engine/core/css/CSSInitialValue.h" 41 #include "sky/engine/core/css/CSSInitialValue.h"
43 #include "sky/engine/core/css/CSSLineBoxContainValue.h" 42 #include "sky/engine/core/css/CSSLineBoxContainValue.h"
44 #include "sky/engine/core/css/CSSPrimitiveValue.h" 43 #include "sky/engine/core/css/CSSPrimitiveValue.h"
45 #include "sky/engine/core/css/CSSPropertyMetadata.h" 44 #include "sky/engine/core/css/CSSPropertyMetadata.h"
46 #include "sky/engine/core/css/CSSPropertySourceData.h" 45 #include "sky/engine/core/css/CSSPropertySourceData.h"
47 #include "sky/engine/core/css/CSSSelector.h" 46 #include "sky/engine/core/css/CSSSelector.h"
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 case CSSPropertyWebkitTextDecorationsInEffect: 698 case CSSPropertyWebkitTextDecorationsInEffect:
700 case CSSPropertyTextDecorationLine: 699 case CSSPropertyTextDecorationLine:
701 // none | [ underline || overline || line-through || blink ] | inherit 700 // none | [ underline || overline || line-through || blink ] | inherit
702 return parseTextDecoration(propId); 701 return parseTextDecoration(propId);
703 702
704 case CSSPropertyTextUnderlinePosition: 703 case CSSPropertyTextUnderlinePosition:
705 // auto | under | inherit 704 // auto | under | inherit
706 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); 705 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
707 return parseTextUnderlinePosition(); 706 return parseTextUnderlinePosition();
708 707
709 case CSSPropertySrc: // Only used within @font-face and @-webkit-filter, so cannot use inherit | initial. This is a list of urls or local references.
710 parsedValue = parseFontFaceSrc();
711 break;
712
713 case CSSPropertyUnicodeRange: 708 case CSSPropertyUnicodeRange:
714 parsedValue = parseFontFaceUnicodeRange(); 709 parsedValue = parseFontFaceUnicodeRange();
715 break; 710 break;
716 711
717 /* CSS3 properties */ 712 /* CSS3 properties */
718 713
719 case CSSPropertyBorderImage: 714 case CSSPropertyBorderImage:
720 return parseBorderImageShorthand(propId); 715 return parseBorderImageShorthand(propId);
721 case CSSPropertyWebkitBorderImage: { 716 case CSSPropertyWebkitBorderImage: {
722 if (RefPtr<CSSValue> result = parseBorderImage(propId)) { 717 if (RefPtr<CSSValue> result = parseBorderImage(propId)) {
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3192 if (value->unit == CSSPrimitiveValue::CSS_NUMBER) { 3187 if (value->unit == CSSPrimitiveValue::CSS_NUMBER) {
3193 int weight = static_cast<int>(value->fValue); 3188 int weight = static_cast<int>(value->fValue);
3194 if (!(weight % 100) && weight >= 100 && weight <= 900) { 3189 if (!(weight % 100) && weight >= 100 && weight <= 900) {
3195 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1))); 3190 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)));
3196 return true; 3191 return true;
3197 } 3192 }
3198 } 3193 }
3199 return false; 3194 return false;
3200 } 3195 }
3201 3196
3202 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList)
3203 {
3204 RefPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(completeURL (m_valueList->current()->string)));
3205 uriValue->setReferrer(m_context.referrer());
3206
3207 CSSParserValue* value = m_valueList->next();
3208 if (!value) {
3209 valueList->append(uriValue.release());
3210 return true;
3211 }
3212 if (value->unit == CSSParserValue::Operator && value->iValue == ',') {
3213 m_valueList->next();
3214 valueList->append(uriValue.release());
3215 return true;
3216 }
3217
3218 if (value->unit != CSSParserValue::Function || !equalIgnoringCase(value->fun ction->name, "format("))
3219 return false;
3220
3221 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20111004/ says that format () contains a comma-separated list of strings,
3222 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n ow.
3223 CSSParserValueList* args = value->function->args.get();
3224 if (!args || args->size() != 1 || (args->current()->unit != CSSPrimitiveValu e::CSS_STRING && args->current()->unit != CSSPrimitiveValue::CSS_IDENT))
3225 return false;
3226 uriValue->setFormat(args->current()->string);
3227 valueList->append(uriValue.release());
3228 value = m_valueList->next();
3229 if (value && value->unit == CSSParserValue::Operator && value->iValue == ',' )
3230 m_valueList->next();
3231 return true;
3232 }
3233
3234 bool CSSPropertyParser::parseFontFaceSrcLocal(CSSValueList* valueList)
3235 {
3236 CSSParserValueList* args = m_valueList->current()->function->args.get();
3237 if (!args || !args->size())
3238 return false;
3239
3240 if (args->size() == 1 && args->current()->unit == CSSPrimitiveValue::CSS_STR ING)
3241 valueList->append(CSSFontFaceSrcValue::createLocal(args->current()->stri ng));
3242 else if (args->current()->unit == CSSPrimitiveValue::CSS_IDENT) {
3243 StringBuilder builder;
3244 for (CSSParserValue* localValue = args->current(); localValue; localValu e = args->next()) {
3245 if (localValue->unit != CSSPrimitiveValue::CSS_IDENT)
3246 return false;
3247 if (!builder.isEmpty())
3248 builder.append(' ');
3249 builder.append(localValue->string);
3250 }
3251 valueList->append(CSSFontFaceSrcValue::createLocal(builder.toString()));
3252 } else
3253 return false;
3254
3255 if (CSSParserValue* value = m_valueList->next()) {
3256 if (value->unit == CSSParserValue::Operator && value->iValue == ',')
3257 m_valueList->next();
3258 }
3259 return true;
3260 }
3261
3262 PassRefPtr<CSSValueList> CSSPropertyParser::parseFontFaceSrc()
3263 {
3264 RefPtr<CSSValueList> values(CSSValueList::createCommaSeparated());
3265
3266 while (CSSParserValue* value = m_valueList->current()) {
3267 if (value->unit == CSSPrimitiveValue::CSS_URI) {
3268 if (!parseFontFaceSrcURI(values.get()))
3269 return nullptr;
3270 } else if (value->unit == CSSParserValue::Function && equalIgnoringCase( value->function->name, "local(")) {
3271 if (!parseFontFaceSrcLocal(values.get()))
3272 return nullptr;
3273 } else {
3274 return nullptr;
3275 }
3276 }
3277 if (!values->length())
3278 return nullptr;
3279
3280 m_valueList->next();
3281 return values.release();
3282 }
3283
3284 PassRefPtr<CSSValueList> CSSPropertyParser::parseFontFaceUnicodeRange() 3197 PassRefPtr<CSSValueList> CSSPropertyParser::parseFontFaceUnicodeRange()
3285 { 3198 {
3286 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); 3199 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
3287 3200
3288 do { 3201 do {
3289 CSSParserValue* current = m_valueList->current(); 3202 CSSParserValue* current = m_valueList->current();
3290 if (!current || current->unit != CSSPrimitiveValue::CSS_UNICODE_RANGE) 3203 if (!current || current->unit != CSSPrimitiveValue::CSS_UNICODE_RANGE)
3291 return nullptr; 3204 return nullptr;
3292 3205
3293 String rangeString = current->string; 3206 String rangeString = current->string;
(...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after
5684 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 5597 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
5685 } 5598 }
5686 5599
5687 bool CSSPropertyParser::isSystemColor(int id) 5600 bool CSSPropertyParser::isSystemColor(int id)
5688 { 5601 {
5689 // FIXME(sky): remove 5602 // FIXME(sky): remove
5690 return false; 5603 return false;
5691 } 5604 }
5692 5605
5693 } // namespace blink 5606 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/parser/CSSPropertyParser.h ('k') | sky/engine/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698