Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
CSSFontFaceSrcValue constructors should return PassRef.
<https://webkit.org/b/123692>

Make functions that return non-null CSSFontFaceSrcValues return
PassRef instead of PassRefPtr. Tweak some call sites to be
slightly more efficient.

Reviewed by Anders Carlsson.


Canonical link: https://commits.webkit.org/141868@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158515 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Nov 3, 2013
1 parent 79b7d92 commit 7d3fc98
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
11 changes: 11 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,14 @@
2013-11-02 Andreas Kling <akling@apple.com>

CSSFontFaceSrcValue constructors should return PassRef.
<https://webkit.org/b/123692>

Make functions that return non-null CSSFontFaceSrcValues return
PassRef instead of PassRefPtr. Tweak some call sites to be
slightly more efficient.

Reviewed by Anders Carlsson.

2013-11-02 Andreas Kling <akling@apple.com>

CSSStyleSheet::contents() should return a reference.
Expand Down
8 changes: 4 additions & 4 deletions Source/WebCore/css/CSSFontFaceSrcValue.h
Expand Up @@ -39,13 +39,13 @@ class SVGFontFaceElement;

class CSSFontFaceSrcValue : public CSSValue {
public:
static PassRefPtr<CSSFontFaceSrcValue> create(const String& resource)
static PassRef<CSSFontFaceSrcValue> create(const String& resource)
{
return adoptRef(new CSSFontFaceSrcValue(resource, false));
return adoptRef(*new CSSFontFaceSrcValue(resource, false));
}
static PassRefPtr<CSSFontFaceSrcValue> createLocal(const String& resource)
static PassRef<CSSFontFaceSrcValue> createLocal(const String& resource)
{
return adoptRef(new CSSFontFaceSrcValue(resource, true));
return adoptRef(*new CSSFontFaceSrcValue(resource, true));
}

const String& resource() const { return m_resource; }
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/css/CSSParser.cpp
Expand Up @@ -5926,12 +5926,12 @@ bool CSSParser::parseFontFaceSrcURI(CSSValueList* valueList)

CSSParserValue* value = m_valueList->next();
if (!value) {
valueList->append(uriValue.release());
valueList->append(uriValue.releaseNonNull());
return true;
}
if (value->unit == CSSParserValue::Operator && value->iValue == ',') {
m_valueList->next();
valueList->append(uriValue.release());
valueList->append(uriValue.releaseNonNull());
return true;
}

Expand All @@ -5944,7 +5944,7 @@ bool CSSParser::parseFontFaceSrcURI(CSSValueList* valueList)
if (!args || args->size() != 1 || (args->current()->unit != CSSPrimitiveValue::CSS_STRING && args->current()->unit != CSSPrimitiveValue::CSS_IDENT))
return false;
uriValue->setFormat(args->current()->string);
valueList->append(uriValue.release());
valueList->append(uriValue.releaseNonNull());
value = m_valueList->next();
if (value && value->unit == CSSParserValue::Operator && value->iValue == ',')
m_valueList->next();
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/svg/SVGFontFaceNameElement.cpp
Expand Up @@ -38,7 +38,7 @@ PassRefPtr<SVGFontFaceNameElement> SVGFontFaceNameElement::create(const Qualifie
return adoptRef(new SVGFontFaceNameElement(tagName, document));
}

PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceNameElement::srcValue() const
PassRef<CSSFontFaceSrcValue> SVGFontFaceNameElement::srcValue() const
{
return CSSFontFaceSrcValue::createLocal(fastGetAttribute(SVGNames::nameAttr));
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/svg/SVGFontFaceNameElement.h
Expand Up @@ -31,7 +31,7 @@ class SVGFontFaceNameElement FINAL : public SVGElement {
public:
static PassRefPtr<SVGFontFaceNameElement> create(const QualifiedName&, Document&);

PassRefPtr<CSSFontFaceSrcValue> srcValue() const;
PassRef<CSSFontFaceSrcValue> srcValue() const;

private:
SVGFontFaceNameElement(const QualifiedName&, Document&);
Expand Down
8 changes: 4 additions & 4 deletions Source/WebCore/svg/SVGFontFaceUriElement.cpp
Expand Up @@ -54,12 +54,12 @@ SVGFontFaceUriElement::~SVGFontFaceUriElement()
m_cachedFont->removeClient(this);
}

PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceUriElement::srcValue() const
PassRef<CSSFontFaceSrcValue> SVGFontFaceUriElement::srcValue() const
{
RefPtr<CSSFontFaceSrcValue> src = CSSFontFaceSrcValue::create(getAttribute(XLinkNames::hrefAttr));
auto src = CSSFontFaceSrcValue::create(getAttribute(XLinkNames::hrefAttr));
AtomicString value(fastGetAttribute(formatAttr));
src->setFormat(value.isEmpty() ? "svg" : value); // Default format
return src.release();
src.get().setFormat(value.isEmpty() ? "svg" : value); // Default format
return src;
}

void SVGFontFaceUriElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/svg/SVGFontFaceUriElement.h
Expand Up @@ -35,7 +35,7 @@ class SVGFontFaceUriElement FINAL : public SVGElement, public CachedFontClient {

virtual ~SVGFontFaceUriElement();

PassRefPtr<CSSFontFaceSrcValue> srcValue() const;
PassRef<CSSFontFaceSrcValue> srcValue() const;

private:
SVGFontFaceUriElement(const QualifiedName&, Document&);
Expand Down

0 comments on commit 7d3fc98

Please sign in to comment.