зеркало из https://github.com/mozilla/pjs.git
Bug 234789 - SVG text ignores font-size if no unit specified.
Patch by scootermorris@comcast.net, r=tor, sr=dbaron.
This commit is contained in:
Родитель
de52cbcc7d
Коммит
18f0eb76c7
|
@ -72,6 +72,11 @@ public:
|
|||
// Set whether or not to emulate Nav quirks
|
||||
NS_IMETHOD SetQuirkMode(PRBool aQuirkMode) = 0;
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// Set whether or not we are in an SVG element
|
||||
NS_IMETHOD SetSVGMode(PRBool aSVGMode) = 0;
|
||||
#endif
|
||||
|
||||
// Set loader to use for child sheets
|
||||
NS_IMETHOD SetChildLoader(nsICSSLoader* aChildLoader) = 0;
|
||||
|
||||
|
|
|
@ -99,6 +99,10 @@ public:
|
|||
|
||||
NS_IMETHOD SetQuirkMode(PRBool aQuirkMode);
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
NS_IMETHOD SetSVGMode(PRBool aSVGMode);
|
||||
#endif
|
||||
|
||||
NS_IMETHOD SetChildLoader(nsICSSLoader* aChildLoader);
|
||||
|
||||
NS_IMETHOD Parse(nsIUnicharInputStream* aInput,
|
||||
|
@ -338,6 +342,11 @@ protected:
|
|||
// True if we are in quirks mode; false in standards or almost standards mode
|
||||
PRPackedBool mNavQuirkMode;
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// True if we are in SVG mode; false in "normal" CSS
|
||||
PRPackedBool mSVGMode;
|
||||
#endif
|
||||
|
||||
// True if tagnames and attributes are case-sensitive
|
||||
PRPackedBool mCaseSensitive;
|
||||
|
||||
|
@ -431,6 +440,9 @@ CSSParserImpl::CSSParserImpl()
|
|||
mSection(eCSSSection_Charset),
|
||||
mHavePushBack(PR_FALSE),
|
||||
mNavQuirkMode(PR_FALSE),
|
||||
#ifdef MOZ_SVG
|
||||
mSVGMode(PR_FALSE),
|
||||
#endif
|
||||
mCaseSensitive(PR_FALSE),
|
||||
mParsingCompoundProperty(PR_FALSE)
|
||||
{
|
||||
|
@ -476,6 +488,15 @@ CSSParserImpl::SetQuirkMode(PRBool aQuirkMode)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::SetSVGMode(PRBool aSVGMode)
|
||||
{
|
||||
mSVGMode = aSVGMode;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::SetChildLoader(nsICSSLoader* aChildLoader)
|
||||
{
|
||||
|
@ -3515,6 +3536,19 @@ PRBool CSSParserImpl::ParseVariant(nsresult& aErrorCode, nsCSSValue& aValue,
|
|||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
if (mSVGMode && !IsParsingCompoundProperty()) {
|
||||
// STANDARD: SVG Spec states that lengths and coordinates can be unitless
|
||||
// in which case they default to user-units (1 px = 1 user unit)
|
||||
if (((aVariantMask & VARIANT_LENGTH) != 0) &&
|
||||
(eCSSToken_Number == tk->mType)) {
|
||||
aValue.SetFloatValue(tk->mNumber, eCSSUnit_Pixel);
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (((aVariantMask & VARIANT_URL) != 0) &&
|
||||
(eCSSToken_Function == tk->mType) &&
|
||||
tk->mIdent.LowerCaseEqualsLiteral("url")) {
|
||||
|
|
|
@ -738,6 +738,16 @@ nsSVGElement::UpdateContentStyleRule()
|
|||
if (!parser)
|
||||
return;
|
||||
|
||||
// SVG and CSS differ slightly in their interpretation of some of
|
||||
// the attributes. SVG allows attributes of the form: font-size="5"
|
||||
// (style="font-size: 5" if using a style attribute)
|
||||
// where CSS requires units: font-size="5pt" (style="font-size: 5pt")
|
||||
// Set a flag to pass information to the parser so that we can use
|
||||
// the CSS parser to parse the font-size attribute. Note that this
|
||||
// does *not* effect the use of CSS stylesheets, which will still
|
||||
// require units
|
||||
parser->SetSVGMode(PR_TRUE);
|
||||
|
||||
PRUint32 attrCount = mAttrsAndChildren.AttrCount();
|
||||
for (PRUint32 i = 0; i < attrCount; ++i) {
|
||||
const nsAttrName* attrName = mAttrsAndChildren.GetSafeAttrNameAt(i);
|
||||
|
|
|
@ -99,6 +99,10 @@ public:
|
|||
|
||||
NS_IMETHOD SetQuirkMode(PRBool aQuirkMode);
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
NS_IMETHOD SetSVGMode(PRBool aSVGMode);
|
||||
#endif
|
||||
|
||||
NS_IMETHOD SetChildLoader(nsICSSLoader* aChildLoader);
|
||||
|
||||
NS_IMETHOD Parse(nsIUnicharInputStream* aInput,
|
||||
|
@ -338,6 +342,11 @@ protected:
|
|||
// True if we are in quirks mode; false in standards or almost standards mode
|
||||
PRPackedBool mNavQuirkMode;
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// True if we are in SVG mode; false in "normal" CSS
|
||||
PRPackedBool mSVGMode;
|
||||
#endif
|
||||
|
||||
// True if tagnames and attributes are case-sensitive
|
||||
PRPackedBool mCaseSensitive;
|
||||
|
||||
|
@ -431,6 +440,9 @@ CSSParserImpl::CSSParserImpl()
|
|||
mSection(eCSSSection_Charset),
|
||||
mHavePushBack(PR_FALSE),
|
||||
mNavQuirkMode(PR_FALSE),
|
||||
#ifdef MOZ_SVG
|
||||
mSVGMode(PR_FALSE),
|
||||
#endif
|
||||
mCaseSensitive(PR_FALSE),
|
||||
mParsingCompoundProperty(PR_FALSE)
|
||||
{
|
||||
|
@ -476,6 +488,15 @@ CSSParserImpl::SetQuirkMode(PRBool aQuirkMode)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::SetSVGMode(PRBool aSVGMode)
|
||||
{
|
||||
mSVGMode = aSVGMode;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSParserImpl::SetChildLoader(nsICSSLoader* aChildLoader)
|
||||
{
|
||||
|
@ -3515,6 +3536,19 @@ PRBool CSSParserImpl::ParseVariant(nsresult& aErrorCode, nsCSSValue& aValue,
|
|||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
if (mSVGMode && !IsParsingCompoundProperty()) {
|
||||
// STANDARD: SVG Spec states that lengths and coordinates can be unitless
|
||||
// in which case they default to user-units (1 px = 1 user unit)
|
||||
if (((aVariantMask & VARIANT_LENGTH) != 0) &&
|
||||
(eCSSToken_Number == tk->mType)) {
|
||||
aValue.SetFloatValue(tk->mNumber, eCSSUnit_Pixel);
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (((aVariantMask & VARIANT_URL) != 0) &&
|
||||
(eCSSToken_Function == tk->mType) &&
|
||||
tk->mIdent.LowerCaseEqualsLiteral("url")) {
|
||||
|
|
|
@ -72,6 +72,11 @@ public:
|
|||
// Set whether or not to emulate Nav quirks
|
||||
NS_IMETHOD SetQuirkMode(PRBool aQuirkMode) = 0;
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// Set whether or not we are in an SVG element
|
||||
NS_IMETHOD SetSVGMode(PRBool aSVGMode) = 0;
|
||||
#endif
|
||||
|
||||
// Set loader to use for child sheets
|
||||
NS_IMETHOD SetChildLoader(nsICSSLoader* aChildLoader) = 0;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче