From 3d3cc72e20df1815cdb1540257c3bc3dcdcc20b1 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 30 May 2013 08:10:02 -0400 Subject: [PATCH] Bug 875287 - font-family: Do not require whitespace between unquoted idents. r=dbaron When 'font-family' is secified with unquoted identifiers rather than a quoted string, a single space should be inserted between identifier tokens, even if they are separated by a comment rather than a whitespace token. --- .../font-familiy-whitespace-1-notref.html | 9 ++++++++ .../font-familiy-whitespace-1-ref.html | 9 ++++++++ .../font-face/font-familiy-whitespace-1.html | 9 ++++++++ layout/reftests/font-face/reftest.list | 4 ++++ layout/style/nsCSSParser.cpp | 21 ++++++++----------- 5 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 layout/reftests/font-face/font-familiy-whitespace-1-notref.html create mode 100644 layout/reftests/font-face/font-familiy-whitespace-1-ref.html create mode 100644 layout/reftests/font-face/font-familiy-whitespace-1.html diff --git a/layout/reftests/font-face/font-familiy-whitespace-1-notref.html b/layout/reftests/font-face/font-familiy-whitespace-1-notref.html new file mode 100644 index 00000000000..3e6a46566b4 --- /dev/null +++ b/layout/reftests/font-face/font-familiy-whitespace-1-notref.html @@ -0,0 +1,9 @@ + + +

A diff --git a/layout/reftests/font-face/font-familiy-whitespace-1-ref.html b/layout/reftests/font-face/font-familiy-whitespace-1-ref.html new file mode 100644 index 00000000000..5baf0ece11f --- /dev/null +++ b/layout/reftests/font-face/font-familiy-whitespace-1-ref.html @@ -0,0 +1,9 @@ + + +

A diff --git a/layout/reftests/font-face/font-familiy-whitespace-1.html b/layout/reftests/font-face/font-familiy-whitespace-1.html new file mode 100644 index 00000000000..237945b4c75 --- /dev/null +++ b/layout/reftests/font-face/font-familiy-whitespace-1.html @@ -0,0 +1,9 @@ + + +

A diff --git a/layout/reftests/font-face/reftest.list b/layout/reftests/font-face/reftest.list index 630110ec57f..fee5f560cc3 100644 --- a/layout/reftests/font-face/reftest.list +++ b/layout/reftests/font-face/reftest.list @@ -141,6 +141,10 @@ fails-if(cocoaWidget) fails-if(winWidget) HTTP(..) != underline-offset-change-1- HTTP(..) != 534352-1-extra-cmap-sentinel.html 534352-1-extra-cmap-sentinel-ref.html HTTP(..) == bug533251.html bug533251-ref.html +# Bug 875287 +HTTP(..) == font-familiy-whitespace-1.html font-familiy-whitespace-1-ref.html +HTTP(..) != font-familiy-whitespace-1.html font-familiy-whitespace-1-notref.html + skip-if(B2G) fails-if(Android) HTTP(..) == ivs-1.html ivs-1-ref.html # bug 773482 skip-if(B2G) HTTP(..) == missing-names.html missing-names-ref.html # bug 773482 diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 92f5b674b39..3ffd9375abf 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -9005,19 +9005,16 @@ CSSParserImpl::ParseOneFamily(nsAString& aFamily, bool& aOneKeyword) if (eCSSToken_Ident == tk->mType) { aOneKeyword = false; + // We had at least another keyword before. + // "If a sequence of identifiers is given as a font family name, + // the computed value is the name converted to a string by joining + // all the identifiers in the sequence by single spaces." + // -- CSS 2.1, section 15.3 + // Whitespace tokens do not actually matter, + // identifier tokens can be separated by comments. + aFamily.Append(PRUnichar(' ')); aFamily.Append(tk->mIdent); - } else if (eCSSToken_Whitespace == tk->mType) { - // Lookahead one token and drop whitespace if we are ending the - // font name. - if (!GetToken(true)) - break; - - UngetToken(); - if (eCSSToken_Ident == tk->mType) - aFamily.Append(PRUnichar(' ')); - else - break; - } else { + } else if (eCSSToken_Whitespace != tk->mType) { UngetToken(); break; }