Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Overview:
The compressed styleclass map stored in FileSystemStyleCache gets created once based on the current StyleContext.
If the StyleContext changes, it's possible that the css will get corrupted.
You'll see something like
. .AFFoo
instead of
.x10 .AFFoo
This can lead to really strange skinning errors, and it has been hard to track down in the past, but now I know what is going on.
Steps to Reproduce:
1. Set skin-family in trinidad-config.xml to purple
2. In demo's purpleSkin.css add
@agent ie
{
af|panelLabelAndMessage .Foo
af|panelLabelAndMessage af|inputText::content
{ background-color: yellow; }}
af|panelLabelAndMessage {}
3. Run in gecko
4. Then run in IE
5. In IE, view the generated css file
6. At the end you will see something like:
. .AFFoo
7. You should see a compressed style instead of a blank '.'
.xd0 .AFFoo
Details:
All this happens in FileSystemStyleCache:
1. We get the styleSheetDocument - ALL selectors in the skinning file
2. We get the shortenedStyleMap using the styleSheetDocument pared down for
the specific StyleContext (gecko, for example)
3. There is an optimization to use "" as the shortened key if the style
selector has no properties
e.g., af|bar{} as opposed to af|bar
4. Now when we switch to another context (internet explorer from gecko, or a different locale), we are using the original shortenedStyleMap
which had "" for af|barsince for gecko there was no styling
5. BUT for the new context, af|bar has styling.
6. We do not render af|bar on the dom element (bug)
7. We render '.' in the css, so you see something like . .AFFoo
(bug)
Fix:
The fix is to simply create the compressed styleclass map using all styles, not just the styles that match the StyleContext. Then even if we switch the context, the styleclass will be in the map.
This is a one line fix.
In _getShortStyleClassMap change
document.getStyleSheets(context); to
document.getStyleSheets()