}
/**
*/
private static void addStyleSheet(Element node, List result) {
IDOMElement element = (IDOMElement) node;
String tagName = element.getTagName();
if (tagName == null) {
return;
}
boolean isContainer = false;
if (element.isCommentTag()) {
Node parent = element.getParentNode();
if (parent == element.getOwnerDocument()) {
// This condition is too severe, actually do not work for JSF
// template.
// But above (! globalTag() && isContainer()) cover JSF template
// + tpl template
isContainer = true;
} else if (parent.getNodeType() == Node.ELEMENT_NODE) {
tagName = ((Element) parent).getTagName();
if (tagName != null
&& tagName
.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD)) {
isContainer = true;
}
}
} else {
INodeNotifier notifier = element;
// (lium) Increase performance: since this method is called tooooo
// many times,
// and getAdapterFor() is slow, so add a check on the tagName to
// filter
// those stylesheet stuff first.
if (IHTMLConstants.TAG_LINK.equalsIgnoreCase(tagName)
|| IHTMLConstants.TAG_STYLE.equalsIgnoreCase(tagName)) {
INodeAdapter adapter = notifier
.getAdapterFor(IStyleSheetAdapter.class);
if (adapter instanceof IStyleSheetAdapter) {
StyleSheet sheet = ((IStyleSheetAdapter) adapter).getSheet();
if (sheet != null)
{
result.add(sheet);
}
}
}
isContainer = true;
}
if (isContainer) {
for (Node child = element.getFirstChild(); child != null; child = child
.getNextSibling()) {
if (child.getNodeType() != Node.ELEMENT_NODE)
continue;
addStyleSheet((Element) child, result);
}