Bug 580685. We might not have a root element to resolve 'rem' against. r=dbaron

This commit is contained in:
Boris Zbarsky 2010-07-22 17:33:37 -04:00
Родитель f86987c51a
Коммит 69d8c3830b
5 изменённых файлов: 62 добавлений и 5 удалений

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

@ -0,0 +1,10 @@
<html>
<head></head>
<body style="outline-offset: 0.1rem; ">
<script>
var body = document.body;
document.removeChild(document.documentElement);
var compstyle = window.getComputedStyle(body, null).getPropertyValue('outline-offset');
</script>
</body>
</html>

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

@ -59,3 +59,4 @@ load 565248-1.html
load 558943-1.xhtml
load 571105-1.xhtml
load 573127-1.html
load 580685.html

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

@ -277,14 +277,17 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
const nsStyleFont *rootStyleFont = styleFont;
Element* docElement = aPresContext->Document()->GetRootElement();
if (docElement) {
rootStyle = aPresContext->StyleSet()->ResolveStyleFor(docElement,
nsnull);
if (rootStyle) {
rootStyleFont = rootStyle->GetStyleFont();
rootFontSize = rootStyleFont->mFont.size;
}
}
rootFontSize = rootStyleFont->mFont.size;
}
return ScaleCoord(aValue, float(rootFontSize));
}
case eCSSUnit_EM: {

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

@ -132,6 +132,7 @@ _TEST_FILES = test_acid3_test46.html \
test_bug524175.html \
test_bug534804.html \
test_bug573255.html \
test_bug580685.html \
test_cascade.html \
test_compute_data_with_start_struct.html \
test_computed_style_no_pseudo.html \

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

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=580685
-->
<head>
<title>Test for Bug 580685</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=580685">Mozilla Bug 580685</a>
<p id="display">
<iframe id="f" src="data:text/html,<body style='outline-offset: 1rem'>">
</iframe>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 580685 **/
SimpleTest.waitForExplicitFinish()
addLoadEvent(function() {
var doc = $("f").contentDocument;
var b = doc.body;
doc.removeChild(doc.documentElement);
is(doc.defaultView.getComputedStyle(b, "").outlineOffset,
doc.defaultView.getComputedStyle(b, "").fontSize,
"1rem did not compute correctly");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>