Bug 811391 - Part 1: Ignore @page declarations involving viewport units. r=dbaron

* * *
Bug 811391 followup: Fix out-of-order init list, to fix build warning (treated as error).
This commit is contained in:
Seth Fowler 2013-01-09 16:03:55 -08:00
Родитель b5846cd75f
Коммит 19481d1320
1 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -753,6 +753,9 @@ protected:
// True if unsafe rules should be allowed
bool mUnsafeRulesEnabled : 1;
// True if viewport units should be allowed.
bool mViewportUnitsEnabled : 1;
// True for parsing media lists for HTML attributes, where we have to
// ignore CSS comments.
bool mHTMLMediaMode : 1;
@ -835,6 +838,7 @@ CSSParserImpl::CSSParserImpl()
mHashlessColorQuirk(false),
mUnitlessLengthQuirk(false),
mUnsafeRulesEnabled(false),
mViewportUnitsEnabled(true),
mHTMLMediaMode(false),
mParsingCompoundProperty(false),
mInFailingSupportsRule(false),
@ -2399,9 +2403,16 @@ CSSParserImpl::ParsePageRule(RuleAppendFunc aAppendFunc, void* aData)
// TODO: There can be page selectors after @page such as ":first", ":left".
uint32_t parseFlags = eParseDeclaration_InBraces |
eParseDeclaration_AllowImportant;
// Forbid viewport units in @page rules. See bug 811391.
NS_ABORT_IF_FALSE(mViewportUnitsEnabled,
"Viewport units should be enabled outside of @page rules.");
mViewportUnitsEnabled = false;
nsAutoPtr<css::Declaration> declaration(
ParseDeclarationBlock(parseFlags,
eCSSContext_Page));
mViewportUnitsEnabled = true;
if (!declaration) {
return false;
}
@ -4676,6 +4687,16 @@ CSSParserImpl::TranslateDimension(nsCSSValue& aValue,
}
}
if (!mViewportUnitsEnabled &&
(eCSSUnit_ViewportWidth == units ||
eCSSUnit_ViewportHeight == units ||
eCSSUnit_ViewportMin == units ||
eCSSUnit_ViewportMax == units)) {
// Viewport units aren't allowed right now, probably because we're
// inside an @page declaration. Fail.
return false;
}
if (i == ArrayLength(UnitData)) {
// Unknown unit
return false;