| Index: Source/core/css/FontFace.cpp
|
| diff --git a/Source/core/css/FontFace.cpp b/Source/core/css/FontFace.cpp
|
| index e4265aa631eefdfb96b464849303283196492f3e..1bae4c4ff1c8ccd21e55812558997b51b3bdfc0b 100644
|
| --- a/Source/core/css/FontFace.cpp
|
| +++ b/Source/core/css/FontFace.cpp
|
| @@ -62,7 +62,7 @@
|
|
|
| namespace blink {
|
|
|
| -static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& value, CSSPropertyID propertyID)
|
| +static NullableCSSValue parseCSSValue(const Document* document, const String& value, CSSPropertyID propertyID)
|
| {
|
| CSSParserContext context(*document, UseCounter::getFrom(document));
|
| return CSSParser::parseFontFaceDescriptor(propertyID, value, context);
|
| @@ -84,11 +84,13 @@ PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
|
| {
|
| RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(context, family, descriptors));
|
|
|
| - RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source, CSSPropertySrc);
|
| - if (!src || !src->isValueList())
|
| + NullableCSSValue src = parseCSSValue(toDocument(context), source, CSSPropertySrc);
|
| + if (!src || !src->isValueList()) {
|
| fontFace->setError(DOMException::create(SyntaxError, "The source provided ('" + source + "') could not be parsed as a value list."));
|
| + return fontFace;
|
| + }
|
|
|
| - fontFace->initCSSFontFace(toDocument(context), src);
|
| + fontFace->initCSSFontFace(toDocument(context), *src);
|
| return fontFace.release();
|
| }
|
|
|
| @@ -111,16 +113,16 @@ PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl
|
| const StylePropertySet& properties = fontFaceRule->properties();
|
|
|
| // Obtain the font-family property and the src property. Both must be defined.
|
| - RefPtrWillBeRawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSPropertyFontFamily);
|
| + NullableCSSValue family = properties.getPropertyCSSValue(CSSPropertyFontFamily);
|
| if (!family || !family->isValueList())
|
| return nullptr;
|
| - RefPtrWillBeRawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropertySrc);
|
| + NullableCSSValue src = properties.getPropertyCSSValue(CSSPropertySrc);
|
| if (!src || !src->isValueList())
|
| return nullptr;
|
|
|
| RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(document));
|
|
|
| - if (fontFace->setFamilyValue(toCSSValueList(family.get()))
|
| + if (fontFace->setFamilyValue(toCSSValueList(family))
|
| && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle)
|
| && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight)
|
| && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch)
|
| @@ -129,7 +131,7 @@ PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl
|
| && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatureSettings)
|
| && !fontFace->family().isEmpty()
|
| && fontFace->traits().bitfield()) {
|
| - fontFace->initCSSFontFace(document, src);
|
| + fontFace->initCSSFontFace(document, *src);
|
| return fontFace.release();
|
| }
|
| return nullptr;
|
| @@ -224,7 +226,7 @@ void FontFace::setFeatureSettings(ExecutionContext* context, const String& s, Ex
|
|
|
| void FontFace::setPropertyFromString(const Document* document, const String& s, CSSPropertyID propertyID, ExceptionState* exceptionState)
|
| {
|
| - RefPtrWillBeRawPtr<CSSValue> value = parseCSSValue(document, s, propertyID);
|
| + NullableCSSValue value = parseCSSValue(document, s, propertyID);
|
| if (value && setPropertyValue(value, propertyID))
|
| return;
|
|
|
| @@ -240,7 +242,7 @@ bool FontFace::setPropertyFromStyle(const StylePropertySet& properties, CSSPrope
|
| return setPropertyValue(properties.getPropertyCSSValue(propertyID), propertyID);
|
| }
|
|
|
| -bool FontFace::setPropertyValue(PassRefPtrWillBeRawPtr<CSSValue> value, CSSPropertyID propertyID)
|
| +bool FontFace::setPropertyValue(NullableCSSValue value, CSSPropertyID propertyID)
|
| {
|
| switch (propertyID) {
|
| case CSSPropertyFontStyle:
|
| @@ -276,14 +278,14 @@ bool FontFace::setFamilyValue(CSSValueList* familyList)
|
| if (familyList->length() != 1)
|
| return false;
|
|
|
| - CSSPrimitiveValue* familyValue = toCSSPrimitiveValue(familyList->item(0));
|
| + CSSPrimitiveValue& familyValue = toCSSPrimitiveValue(familyList->item(0));
|
| AtomicString family;
|
| - if (familyValue->isCustomIdent()) {
|
| - family = AtomicString(familyValue->getStringValue());
|
| - } else if (familyValue->isValueID()) {
|
| + if (familyValue.isCustomIdent()) {
|
| + family = AtomicString(familyValue.getStringValue());
|
| + } else if (familyValue.isValueID()) {
|
| // We need to use the raw text for all the generic family types, since @font-face is a way of actually
|
| // defining what font to use for those types.
|
| - switch (familyValue->getValueID()) {
|
| + switch (familyValue.getValueID()) {
|
| case CSSValueSerif:
|
| family = FontFamilyNames::webkit_serif;
|
| break;
|
| @@ -403,7 +405,7 @@ FontTraits FontFace::traits() const
|
| if (!m_style->isPrimitiveValue())
|
| return 0;
|
|
|
| - switch (toCSSPrimitiveValue(m_style.get())->getValueID()) {
|
| + switch (toCSSPrimitiveValue(m_style)->getValueID()) {
|
| case CSSValueNormal:
|
| style = FontStyleNormal;
|
| break;
|
| @@ -421,7 +423,7 @@ FontTraits FontFace::traits() const
|
| if (!m_weight->isPrimitiveValue())
|
| return 0;
|
|
|
| - switch (toCSSPrimitiveValue(m_weight.get())->getValueID()) {
|
| + switch (toCSSPrimitiveValue(m_weight)->getValueID()) {
|
| case CSSValueBold:
|
| case CSSValue700:
|
| weight = FontWeight700;
|
| @@ -463,23 +465,23 @@ FontTraits FontFace::traits() const
|
| }
|
|
|
| FontVariant variant = FontVariantNormal;
|
| - if (RefPtrWillBeRawPtr<CSSValue> fontVariant = m_variant) {
|
| + if (NullableCSSValue fontVariant = m_variant) {
|
| // font-variant descriptor can be a value list.
|
| if (fontVariant->isPrimitiveValue()) {
|
| RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
|
| - list->append(fontVariant);
|
| + list->append(*fontVariant);
|
| fontVariant = list;
|
| } else if (!fontVariant->isValueList()) {
|
| return 0;
|
| }
|
|
|
| - CSSValueList* variantList = toCSSValueList(fontVariant.get());
|
| + CSSValueList* variantList = toCSSValueList(fontVariant);
|
| unsigned numVariants = variantList->length();
|
| if (!numVariants)
|
| return 0;
|
|
|
| for (unsigned i = 0; i < numVariants; ++i) {
|
| - switch (toCSSPrimitiveValue(variantList->item(i))->getValueID()) {
|
| + switch (toCSSPrimitiveValue(variantList->item(i)).getValueID()) {
|
| case CSSValueNormal:
|
| variant = FontVariantNormal;
|
| break;
|
| @@ -495,49 +497,48 @@ FontTraits FontFace::traits() const
|
| return FontTraits(style, variant, weight, FontStretchNormal);
|
| }
|
|
|
| -static PassOwnPtrWillBeRawPtr<CSSFontFace> createCSSFontFace(FontFace* fontFace, CSSValue* unicodeRange)
|
| +static PassOwnPtrWillBeRawPtr<CSSFontFace> createCSSFontFace(FontFace* fontFace, NullableCSSValue unicodeRange)
|
| {
|
| Vector<CSSFontFace::UnicodeRange> ranges;
|
| if (CSSValueList* rangeList = toCSSValueList(unicodeRange)) {
|
| unsigned numRanges = rangeList->length();
|
| for (unsigned i = 0; i < numRanges; i++) {
|
| - CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item(i));
|
| - ranges.append(CSSFontFace::UnicodeRange(range->from(), range->to()));
|
| + CSSUnicodeRangeValue& range = toCSSUnicodeRangeValue(rangeList->item(i));
|
| + ranges.append(CSSFontFace::UnicodeRange(range.from(), range.to()));
|
| }
|
| }
|
|
|
| return adoptPtrWillBeNoop(new CSSFontFace(fontFace, ranges));
|
| }
|
|
|
| -void FontFace::initCSSFontFace(Document* document, PassRefPtrWillBeRawPtr<CSSValue> src)
|
| +void FontFace::initCSSFontFace(Document* document, CSSValue src)
|
| {
|
| - m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get());
|
| + m_cssFontFace = createCSSFontFace(this, m_unicodeRange);
|
| if (m_error)
|
| return;
|
|
|
| // Each item in the src property's list is a single CSSFontFaceSource. Put them all into a CSSFontFace.
|
| - ASSERT(src);
|
| - ASSERT(src->isValueList());
|
| - CSSValueList* srcList = toCSSValueList(src.get());
|
| - int srcLength = srcList->length();
|
| + ASSERT(src.isValueList());
|
| + CSSValueList& srcList = toCSSValueList(src);
|
| + int srcLength = srcList.length();
|
|
|
| for (int i = 0; i < srcLength; i++) {
|
| // An item in the list either specifies a string (local font name) or a URL (remote font to download).
|
| - CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i));
|
| + CSSFontFaceSrcValue& item = toCSSFontFaceSrcValue(srcList.item(i));
|
| OwnPtrWillBeRawPtr<CSSFontFaceSource> source = nullptr;
|
|
|
| - if (!item->isLocal()) {
|
| + if (!item.isLocal()) {
|
| Settings* settings = document ? document->frame() ? document->frame()->settings() : 0 : 0;
|
| bool allowDownloading = settings && settings->downloadableBinaryFontsEnabled();
|
| - if (allowDownloading && item->isSupportedFormat() && document) {
|
| - FontResource* fetched = item->fetch(document);
|
| + if (allowDownloading && item.isSupportedFormat() && document) {
|
| + FontResource* fetched = item.fetch(document);
|
| if (fetched) {
|
| FontLoader* fontLoader = document->styleEngine().fontSelector()->fontLoader();
|
| source = adoptPtrWillBeNoop(new RemoteFontFaceSource(fetched, fontLoader));
|
| }
|
| }
|
| } else {
|
| - source = adoptPtrWillBeNoop(new LocalFontFaceSource(item->resource()));
|
| + source = adoptPtrWillBeNoop(new LocalFontFaceSource(item.resource()));
|
| }
|
|
|
| if (source)
|
| @@ -547,7 +548,7 @@ void FontFace::initCSSFontFace(Document* document, PassRefPtrWillBeRawPtr<CSSVal
|
|
|
| void FontFace::initCSSFontFace(const unsigned char* data, unsigned size)
|
| {
|
| - m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get());
|
| + m_cssFontFace = createCSSFontFace(this, m_unicodeRange);
|
| if (m_error)
|
| return;
|
|
|
|
|