stylesheet loading

David Hyatt hyatt at apple.com
Wed Jun 4 18:23:16 CEST 2003


There are two ways of interpreting the .disabled property on <link> 
elements.  You can follow the Opera 7 and WinIE way, or you can follow 
the Mozilla way.

In Mozilla, the alternate stylesheet mechanism is built on top of 
.disabled.  In other words, when you first load a Web page with a main 
sheet A, and two alternates B and C, A will be considered enabled, but 
B and C will be considered disabled and have their disabled properties 
set.

In WinIE and Opera (and the code I wrote in Safari) all three sheets 
are enabled.  In other words, .disabled is a separate mechanism that is 
independent of whether or not a sheet happens to be an alternate or not.

This creates an unusual side effect in that you have to distinguish 
between the case of a default alternate, which is *enabled* in the 
sense that it has no disabled property set, but is *disabled* from the 
point of view of the active stylesheets.  However, once you enable the 
sheet via script, the sheet is now still *enabled* in the sense that it 
has no disabled property, but is now also *enabled* from the point of 
view of the active stylesheets list.

This means you have to distinguish between the unset enabled case, and 
the enabled via script case.  Safari's behavior matches WinIE and Opera 
7 in this regard, and it's how I thought Mozilla worked also.  However, 
having discovered now that Mozilla just uses the .disabled mechanism 
for alternates, it seems like this is clearly a simpler solution and 
more internally consistent.

Safari not updating the .disabled state in your test case is an easily 
fixed bug even with this complicated mechanism, but I believe it would 
be better to move to a model where everything is just built on top of 
the disabled state of the stylesheets themselves, even though it 
deviates from the WinIE and Opera behavior.

Dave
(hyatt at apple.com)

On Wednesday, June 4, 2003, at 03:46 PM, Dirk Mueller wrote:

> Sure, but a boolean is enough for that. The part I didn't get is the 
> 3rd
> state "isEnabledViaScript". You can't really check if its enabled by
> JavaScript this way, and it shouldn't matter in any case.
>
> I think you were trying to work around the problem that changes in the 
> link
> sheets have to recalculate the chain which determines which titled
> stylesheet to render by default. I don't see any other use for this 
> code,
> but maybe I'm wrong.
>
>> Can you give me an example of a site that's broken?
>
> Any site that provides alternative stylesheets and the user has 
> actually
> selected them. Furthermore dynamic updates were broken, see testcase at
>
> http://khtml.homeip.net/DOMlink.html
>
> See the bit lengthy patch I just committed. It is itself not yet 
> optimal as
> it causes more style selector recalculations than necessary, but thats 
> not
> unintrusive to fix.
>
>
> -- 
> Dirk
> _______________________________________________
> Khtml-devel at mail.kde.org
> http://mail.kde.org/mailman/listinfo/khtml-devel



More information about the Khtml-devel mailing list