mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Revert incorrect changes made in http://hg.mozilla.org/mozilla-central/rev/f6beeb315747 (Bug 508452) r=bzbarsky
Note: the tests in this patch don't actually pass until the next one is applied as well.
This commit is contained in:
parent
049124e527
commit
11a03de1b8
@ -2243,28 +2243,36 @@ CreateFontStyleRule(const nsAString& aFont,
|
||||
nsCSSParser parser;
|
||||
NS_ENSURE_TRUE(parser, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// aFont is to be parsed as the value of a CSS 'font' shorthand,
|
||||
// and then any line-height setting in that shorthand is to be
|
||||
// overridden with "normal". Because of the way style rules are
|
||||
// stored, it is more efficient to fabricate a text string that
|
||||
// can be processed in one go with ParseStyleAttribute than to
|
||||
// make two calls to ParseDeclaration.
|
||||
|
||||
nsAutoString styleAttr(NS_LITERAL_STRING("font:"));
|
||||
styleAttr.Append(aFont);
|
||||
styleAttr.AppendLiteral(";line-height:normal");
|
||||
nsCOMPtr<nsICSSStyleRule> rule;
|
||||
PRBool changed;
|
||||
|
||||
nsIPrincipal* principal = aNode->NodePrincipal();
|
||||
nsIDocument* document = aNode->GetOwnerDoc();
|
||||
|
||||
nsIURI* docURL = document->GetDocumentURI();
|
||||
nsIURI* baseURL = document->GetDocBaseURI();
|
||||
|
||||
nsresult rv = parser.ParseStyleAttribute(styleAttr, docURL, baseURL,
|
||||
principal, aResult);
|
||||
nsresult rv = parser.ParseStyleAttribute(EmptyString(), docURL, baseURL,
|
||||
principal, getter_AddRefs(rule));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
(*aResult)->RuleMatched();
|
||||
rv = parser.ParseProperty(eCSSProperty_font, aFont, docURL, baseURL,
|
||||
principal, rule->GetDeclaration(), &changed,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = parser.ParseProperty(eCSSProperty_line_height,
|
||||
NS_LITERAL_STRING("normal"), docURL, baseURL,
|
||||
principal, rule->GetDeclaration(), &changed,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rule->RuleMatched();
|
||||
|
||||
rule.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,7 @@ _TEST_FILES_0 = \
|
||||
image_green-redirect \
|
||||
image_green-redirect^headers^ \
|
||||
test_drawImageIncomplete.html \
|
||||
test_canvas_font_setter.html \
|
||||
$(NULL)
|
||||
|
||||
# xor and lighter aren't well handled by cairo; they mostly work, but we don't want
|
||||
|
29
content/canvas/test/test_canvas_font_setter.html
Normal file
29
content/canvas/test/test_canvas_font_setter.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug </title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
|
||||
<canvas id="display" height="200" width="200"></canvas>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
var canvas = document.getElementById("display");
|
||||
var cx = canvas.getContext("2d");
|
||||
|
||||
cx.font = "italic 16px sans-serif";
|
||||
is(cx.font, "italic 16px sans-serif", "valid font should round-trip");
|
||||
cx.font = "bold 12px serif; background: green";
|
||||
is(cx.font, "italic 16px sans-serif", "invalid font should be ignored");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user