diff options
-rw-r--r-- | layout/style/nsCSSParser.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index f3df2df208..387f6ed27f 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -2300,8 +2300,20 @@ CSSParserImpl::ParseMarginString(const nsSubstring& aBuffer, nsAutoSuppressErrors suppressErrors(this, aSuppressErrors); - // Parse a margin, and check that there's nothing else after it. - bool marginParsed = ParseGroupedBoxProperty(VARIANT_LP, aValue, 0) && !GetToken(true); + bool marginParsed = false; + + // Treat margin as zero length if there are no tokens, i.e., the specified + // margin string is empty or consists only of whitespace characters. + if (!GetToken(true)) { + nsCSSRect& zeroRootMargin = aValue.SetRectValue(); + zeroRootMargin.SetAllSidesTo(nsCSSValue(0.0f, eCSSUnit_Pixel)); + marginParsed = true; + } else { + UngetToken(); + // Parse a margin, and check that there's nothing else after it. + marginParsed = ParseGroupedBoxProperty(VARIANT_LP, aValue, 0) && + !GetToken(true); + } if (aSuppressErrors) { CLEAR_ERROR(); |