Skip to content

Commit

Permalink
Reviewed by David Kilzer.
Browse files Browse the repository at this point in the history
        http://bugs.webkit.org/show_bug.cgi?id=17201
        Bug 17201: Use RefPtr in CSSParser::parseFont() to get rid of goto silliness

        Gets rid of goto usage in parseFont.



Canonical link: https://commits.webkit.org/23963@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30152 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Rob Buis committed Feb 11, 2008
1 parent dc7cf51 commit 2752cda
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
12 changes: 12 additions & 0 deletions WebCore/ChangeLog
@@ -1,3 +1,15 @@
2008-02-11 Rob Buis <buis@kde.org>

Reviewed by David Kilzer.

http://bugs.webkit.org/show_bug.cgi?id=17201
Bug 17201: Use RefPtr in CSSParser::parseFont() to get rid of goto silliness

Gets rid of goto usage in parseFont.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseFont):

2008-02-11 David Hyatt <hyatt@apple.com>

Fix for bug 17298, Acid3 text should be black and not red. Make sure stylesheets with the wrong MIME type
Expand Down
26 changes: 11 additions & 15 deletions WebCore/css/CSSParser.cpp
Expand Up @@ -2558,7 +2558,7 @@ bool CSSParser::parseFont(bool important)
{
bool valid = true;
Value *value = valueList->current();
FontValue *font = new FontValue;
RefPtr<FontValue> font = new FontValue;
// optional font-style, font-variant and font-weight
while (value) {
int id = value->id;
Expand All @@ -2567,15 +2567,15 @@ bool CSSParser::parseFont(bool important)
// do nothing, it's the inital value for all three
} else if (id == CSS_VAL_ITALIC || id == CSS_VAL_OBLIQUE) {
if (font->style)
goto invalid;
return false;
font->style = new CSSPrimitiveValue(id);
} else if (id == CSS_VAL_SMALL_CAPS) {
if (font->variant)
goto invalid;
return false;
font->variant = new CSSPrimitiveValue(id);
} else if (id >= CSS_VAL_BOLD && id <= CSS_VAL_LIGHTER) {
if (font->weight)
goto invalid;
return false;
font->weight = new CSSPrimitiveValue(id);
} else {
valid = false;
Expand Down Expand Up @@ -2614,7 +2614,7 @@ bool CSSParser::parseFont(bool important)
value = valueList->next();
}
if (!value)
goto invalid;
return false;

// set undefined values to default
if (!font->style)
Expand All @@ -2632,22 +2632,22 @@ bool CSSParser::parseFont(bool important)
font->size = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
value = valueList->next();
if (!font->size || !value)
goto invalid;
return false;

if (value->unit == Value::Operator && value->iValue == '/') {
// line-height
value = valueList->next();
if (!value)
goto invalid;
return false;
if (value->id == CSS_VAL_NORMAL) {
// default value, nothing to do
} else if (validUnit(value, FNumber|FLength|FPercent, strict))
font->lineHeight = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
else
goto invalid;
return false;
value = valueList->next();
if (!value)
goto invalid;
return false;
}

if (!font->lineHeight)
Expand All @@ -2657,14 +2657,10 @@ bool CSSParser::parseFont(bool important)
font->family = parseFontFamily();

if (valueList->current() || !font->family)
goto invalid;
return false;

addProperty(CSS_PROP_FONT, font, important);
addProperty(CSS_PROP_FONT, font.release(), important);
return true;

invalid:
delete font;
return false;
}

PassRefPtr<CSSValueList> CSSParser::parseFontFamily()
Expand Down

0 comments on commit 2752cda

Please sign in to comment.