PDA

View Full Version : [2.0b1] Bigger font-size on table captions using Extjs?



DelTorro
19 Oct 2007, 9:09 AM
I am using Extjs for a short while now and I've experienced something weird on my website which is in development right now: two table captions get a bigger font-size than the font-size I've set for them in my CSS-file. It happens as soon as I include the ext-all.js-file. If I do not include this file or if I disable JS in my webbrowser, everything is fine. It only occures in Firefox (latest version: 2.0.0.8 on WinXP) though.

For an example: http://test.webtrash.nl/spelregels/#puntentelling
Example without ext-all.js: http://test.webtrash.nl/spelregels/?ext=noinclude#puntentelling

tryanDLS
19 Oct 2007, 10:29 AM
Please see the guidelines before a bug. http://extjs.com/forum/showthread.php?t=13985. Produce a small sample than illustrates the problem so others don't have to wade thru your entire site. My first thought would be that you haven't included ext-all.css.

brian.moeskau
20 Oct 2007, 1:10 AM
I'm not sure why this would affect your CSS styles, but you are not loading Ext correctly. Notice the JS error in Firebug? It's because you are including the base file, but not the actual library. Don't forget the second include:


<script type="text/javascript" src="/media/js/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="/media/js/ext/adapter/ext/ext-all-debug.js"></script>


Again, not sure why that would affect your CSS as the style in question is your "table.spelregels caption" CSS rule, which obviously has nothing to do with Ext.

brian.moeskau
20 Oct 2007, 1:11 AM
BTW, as Ext is not even loaded in your site, I think we can safely mark this as not being an Ext bug... I am moving it to the discussion forum.

DelTorro
20 Oct 2007, 6:39 AM
tryanDLS: I'm sorry for not taking a close look at the guidelines before submitting my post. I've read them in the meantime though.

brian.moeskau: I think Ext is actually loading correctly at my site. I see no Javscript-errors and the functionality for my main menu works fine and without errors. Are you sure you've clicked the first link in my post (the one with ext-all.js included)?
By clicking the second link, the ext-all.js-file is not included on purpose to show you, Ext causes the problem with the bigger font-size. At least, I'm pretty sure Ext causes it since the weird problem does not occure when I disable JS or if I do not include the ext-all.js-file.

brian.moeskau
20 Oct 2007, 7:27 AM
What I'm saying is that on the "non-Ext" version, you're not just not loading Ext -- you are still referencing it from your "functies.js" file calling:


Ext.onReady( hoofdmenu );

This is causing a JS error, which could be affecting something else in your page. Fix the JS error and see if the pages work the same or not. I have a feeling it's something weird like that, because as soon as I hit the inspect button in Firebug on your "non-Ext" page to look at the CSS the font changes sizes for me. The bottom line is that the style in question is "table.spelregels caption" and it's declared exactly the same in both pages (font-size:1.4em, which will make the font bigger than everything else).

mystix
20 Oct 2007, 8:06 AM
i tried the non-Ext page and the text in question starts small but gets blown up when i click on the "inspect" button in Firebug and mouse over the text in question.

looks like a layout problem to me, not a js one.
as brian points out, the text should also (correctly) be 1.4 times the size of surrounding text.

DelTorro
20 Oct 2007, 2:52 PM
I might be stupid but I still don't understand your logical:


This is causing a JS error, which could be affecting something else in your page. Fix the JS error and see if the pages work the same or not.
Of course it causes an error because of the missing ext-all.js-file. On the "Ext-version", which does have this file included, there is no error so I've already "fixed" the error, haven't I? Or am I doing something wrong in my way of thinking here?

Another try from my side:
I've now excluded the functies.js-file so there are no own-written functions at both pages anymore, I am just loading Ext and doing nothing with it (so no js-errors).
At page1 (http://test.webtrash.nl/spelregels/#puntentelling), both ext-base.js and ext-all-debug.js are included (bigger-fontsize-problem occures). At page2 (http://test.webtrash.nl/spelregels/?ext=noinclude#puntentelling), only ext-base.js is included (so Ext is not correctly loaded, bigger-fontsize-problem does not occure). At page3 (http://test.webtrash.nl/spelregels/?ext=noincludeboth#puntentelling), none of these 2 files are included (bigger-fontsize-problem does not occure).

To me it's clear:
If I load Ext (http://test.webtrash.nl/spelregels/#puntentelling) (with no errors on page), the problem occures. *
If I don't load Ext (http://test.webtrash.nl/spelregels/?ext=noincludeboth#puntentelling) or disable JS, the problem does not occure.So why do you doubt if I state Ext is causing the font-size-problem here?

* I can be even more specific: as soon as the ext-all.js-file is included, the problem occures.

mystix
21 Oct 2007, 1:01 AM
@DelTorro, this is neither an Ext bug, nor a javascript problem.
it's an issue with the way FireFox renders <caption> tags.

both IE & FF handle <caption>s differently. FF follows the W3C specs, while IE does not (see [References] section below for more info).
[list]
in IE, <caption> text is displayed at the same size as content.
in FF however, <caption> text is always displayed at the browser's default size.
a reflow (or repaint, or both) of the <caption> element then causes the text within the caption to be displayed at the correct size.

line 654 of your CSS file found @ http://test.webtrash.nl/media/stijl/cupmanager.css contains the following line


table.spelregels { font-size: .7em; }

which somehow prevents FF from reflowing (or repainting, or both) the <caption> when the following rule is processed later on line 656 of cupmanager.css


table.spelregels caption { font-size: 1.4em; }

removing that line allows <caption> text to render the same in both IE and FF.

____________________

[investigation methodology]
i managed to narrow down the issue to the following code taken from your site
(note 1: you should be the one doing this, not me... /:))
(note 2: notice there are no links to any CSS file / Javascript file / image -- it just plain old HTML + CSS)
(note 3: i've also removed unnecessary nested <div>s which did not contribute to the issue)


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="nl">
<head>
<title>Cupmanager 2008 &raquo; De spelregels</title>
<style>
/*
#####################
# TABELLEN #
#####################
*/
table.spelregels { font-size: .7em; }/** THIS RULE LEADS TO THE ISSUE YOU REPORTED **/
table.spelregels caption { font-size: 1.4em; }
</style>
</head>
<body>
<div class="container">
<div id="kolom-links">
<div class="content">
<table class="spelregels" id="spelregels-wedstrijd" cellspacing="0" cellpadding="0" summary="Overzicht van spelregels">
<caption>Tabel 1: Puntentelling met betrekking tot teamstatistieken</caption>
<col width="48">
<col width="48">
<col width="48">
<col width="54">
<col width="54">
<col width="54">
<col width="54">
<col width="48">
<col width="48">
<tr>
<th scope="col" title="Doelpunt team">Dlp team</th>
<th scope="col">Gelijk poule</th>
<th scope="col">Winst poule</th>
<th scope="col">Winst<br> 1/4 fin</th>
<th scope="col">Verlies<br> 1/4 fin</th>
<th scope="col">Winst<br> 1/2 fin</th>
<th scope="col">Verlies<br> 1/2 fin</th>
<th scope="col">Winst finale</th>
<th scope="col">Verlies finale</th>
</tr>
<tr class="rij">
<td class="midden groen">1</td>
<td class="midden groen">1</td>
<td class="midden groen">3</td>
<td class="midden groen">4</td>
<td class="midden groen">2</td>
<td class="midden groen">6</td>
<td class="midden groen">3</td>
<td class="midden groen">10</td>
<td class="midden groen">5</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>


which can be further simplified to the following test case


<html>
<head>
<title>&lt;caption&gt; test</title>
<style>
table.myclass { font-size:0.7em; }/** THIS RULE CAUSES THE ISSUE YOU REPORTED. WHEN REMOVED, CAPTION TEXT DISPLAYS THE SAME IN FF AND IE **/
table.myclass caption { font-size: 1.4em; }
.onepointfourtimes { font-size: 1.4em; }
</style>
<!-- uncomment this chunk to see how the reflow affects
<script src="../fms2/js/ext/adapter/ext/ext-base.js"></script>
<script src="../fms2/js/ext/ext-all-debug.js"></script>
-->
</head>
<body>
<span>This text is displayed at my browser's default font size.</span> <span class="onepointfourtimes">This text is 1.4 times larger than my browser's default font size.</span>
<br/><br/>
<table class="myclass" border="1"><!-- added border for clarity -->
<caption>My Table Caption</caption>
<tr>
<td>My Column 1</td>
<td>My Column 2</td>
</tr>
</table>
</body>
</html>


____________________



I can be even more specific: as soon as the ext-all.js-file is included, the problem occures.

including ext-all.js causes a document reflow (or repaint, or both) when the following code
(line 1782 of ext-all-debug.js in the official Ext 2.0-beta1a download) is executed on document ready


Ext.onReady(function(){
var bd = Ext.getBody();
if(!bd){ return; }

var cls = [
Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : 'ext-ie7')
: Ext.isGecko ? "ext-gecko"
: Ext.isOpera ? "ext-opera"
: Ext.isSafari ? "ext-safari" : ""
];

if(Ext.isMac){
cls.push("ext-mac");
}
if(Ext.isLinux){
cls.push("ext-linux");
}
if(Ext.isBorderBox){
cls.push('ext-border-box');
}
if(Ext.isStrict){
var p = bd.dom.parentNode;
if(p){
p.className += ' ext-strict';
}
}
bd.addClass(cls.join(' ')); // gives the <body> tag a class of ext-gecko/ext-opera/ext-safari, causing a reflow / repaint / both
});

it is this reflow (or repaint, or both) which causes FF to render the text within the <caption> tag at FF's correct size --
in our case, this will be 1.4 times larger than the browser's default font size, which is not the same as the default font-size you've specified
for <table class="spelregels">. IE, on the other hand, (for once) renders [b]<caption>s[b] the way we expect it to.

to fix this browser inconsistency, either specify an absolute font-size for your <caption> text like so


table.spelregels caption { font-size: 20px; }/* SAME RESULT IN BOTH IE / FF */

or remove that CSS rule on line 656 of cupmanager.css


table.spelregels { font-size: .7em; }

and target specific <tr>s / <td>s instead.

____________________

[references]
http://www.thescripts.com/forum/thread557393.html
http://blackwidows.co.uk/blog/?p=124
https://bugzilla.mozilla.org/show_bug.cgi?id=114734%20#comment_text_10
http://www.w3.org/TR/REC-CSS2/tables.html#q5

Animal
21 Oct 2007, 1:23 AM
It's weird because if you set a breakpoint at 1783 in ext-all-debug.js and step through Ext's document initialization, and carry on stepping through and out of it and step until execution disappears back into the browser, the caption sizes don't change.

It's only when you allow it to run unhindered!

mystix
21 Oct 2007, 1:26 AM
It's weird because if you set a breakpoint at 1783 in ext-all-debug.js and step through Ext's document initialization, and carry on stepping through and out of it and step until execution disappears back into the browser, the caption sizes don't change.

It's only when you allow it to run unhindered!



even weirder: exclude ext-base.js & ext-all.js, make sure the following 2 CSS rules are present


table.myclass { font-size:0.7em; }
table.myclass caption { font-size: 1.4em; }

then load the page -- the caption size doesn't change.

next, start Firebug and try to inspect the <caption> tag -- the caption instantly explodes.
that's how i narrowed it down to a repaint / reflow issue.

JeffHowden
21 Oct 2007, 1:35 AM
The problem occurs on all three pages, there's just some sort of delay in the CSS being applied to the caption. The size difference is caused by the 1.4em CSS already mentioned by Brian and Mystix. Check it out for yourself. Open firebug and watch as you inspect the caption. It'll jump in size. It does it on all three pages *except* the Ext one. On the Ext one, it's already the larger size automatically (probably because Ext is cause some sort of reflow to happen which triggers that text to change to 1.4em).

Again, however, the problem is not Ext, but your CSS.

DelTorro
21 Oct 2007, 5:40 AM
mystix long post Ah, now I get it: the problem occures because of the repaint and the 1.4 font-size setting. Thank you very much for taking the time to give me such a long explanation. Now I understand why it's not Ext causing it. I will fix it with editing the CSS. Many thanks again!