Bug 1112474 part 1 - Make utils of CSS Ruby reftests writing-mode aware. r=dholbert

--HG--
extra : rebase_source : 5a4be10876e45a8bb17edcca6e25be4dd5a31c0c
extra : source : 3d79017794b0718d7a382e7197e79544d00e25b4
This commit is contained in:
Xidorn Quan 2015-03-19 19:04:50 +11:00
Родитель 8ebd1684f7
Коммит a85af6a361
9 изменённых файлов: 32 добавлений и 24 удалений

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

@ -22,8 +22,8 @@
// normal height of an one-line inline-block is the line-height,
// we need to adjust it to the height of the inline box to simulate
// the ruby text box.
makeHeightMatchInlineBox(document.getElementById('rtblock'),
document.getElementById('inline'));
makeBSizeMatchInlineBox(document.getElementById('rtblock'),
document.getElementById('inline'));
</script>
</body>
</html>

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

@ -18,8 +18,8 @@
</ruby>
<script type="text/javascript">
// alter the height to make it easier to match the reference page
makeHeightMatchInlineBox(document.getElementById('rtblock'),
document.getElementById('inline'));
makeBSizeMatchInlineBox(document.getElementById('rtblock'),
document.getElementById('inline'));
</script>
</body>
</html>

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

@ -14,8 +14,8 @@
<script>
// Simulate the behavior of ruby layout.
var base = document.getElementById('base');
makeHeightMatchInlineBox(base, document.getElementById('inline'));
base.style.paddingTop = getHeight(document.getElementById('text'));
makeBSizeMatchInlineBox(base, document.getElementById('inline'));
base.style.paddingTop = getBSize(document.getElementById('text'));
</script>
</body>
</html>

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

@ -15,8 +15,8 @@
<script>
// Simulate the behavior of ruby layout.
var base = document.getElementById('base');
makeHeightMatchInlineBox(base, document.getElementById('inline'));
base.style.paddingBottom = getHeight(document.getElementById('text'));
makeBSizeMatchInlineBox(base, document.getElementById('inline'));
base.style.paddingBottom = getBSize(document.getElementById('text'));
</script>
</body>
</html>

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

@ -16,9 +16,9 @@
<script>
// Simulate the behavior of ruby layout.
var base = document.getElementById('base');
makeHeightMatchInlineBox(base, document.getElementById('inline'));
base.style.paddingTop = getHeight(document.getElementById('text1'));
base.style.paddingBottom = getHeight(document.getElementById('text2'));
makeBSizeMatchInlineBox(base, document.getElementById('inline'));
base.style.paddingTop = getBSize(document.getElementById('text1'));
base.style.paddingBottom = getBSize(document.getElementById('text2'));
</script>
</body>
</html>

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

@ -9,7 +9,7 @@ next line
<script>
// Simulate the behavior of ruby layout.
var base = document.getElementById('base');
makeHeightMatchInlineBox(base, document.getElementById('inline'));
base.style.paddingTop = getHeight(document.getElementById('text1'));
base.style.paddingBottom = getHeight(document.getElementById('text2'));
makeBSizeMatchInlineBox(base, document.getElementById('inline'));
base.style.paddingTop = getBSize(document.getElementById('text1'));
base.style.paddingBottom = getBSize(document.getElementById('text2'));
</script>

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

@ -15,8 +15,8 @@
</span>
</div>
<script type="text/javascript">
makeHeightMatchInlineBox(document.getElementById('annotation'),
document.getElementById('inline'));
makeBSizeMatchInlineBox(document.getElementById('annotation'),
document.getElementById('inline'));
</script>
</body>
</html>

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

@ -23,8 +23,8 @@
after
</div>
<script type="text/javascript">
makeHeightMatchInlineBox(document.getElementById('annotation'),
document.getElementById('inline'));
makeBSizeMatchInlineBox(document.getElementById('annotation'),
document.getElementById('inline'));
</script>
</body>
</html>

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

@ -1,9 +1,17 @@
function getHeight(elem) {
return elem.getBoundingClientRect().height + 'px';
function getBlockAxisName(elem) {
var wm = getComputedStyle(elem).writingMode;
return (!wm || wm == 'horizontal-tb') ? 'height' : 'width';
}
function makeHeightMatchInlineBox(block, inline) {
var height = getHeight(inline);
block.style.height = height;
block.style.lineHeight = height;
function getBSize(elem) {
return elem.getBoundingClientRect()[getBlockAxisName(elem)] + 'px';
}
function setBSize(elem, bsize) {
elem.style[getBlockAxisName(elem)] = bsize;
elem.style.lineHeight = bsize;
}
function makeBSizeMatchInlineBox(block, inline) {
setBSize(block, getBSize(inline));
}