use of org.w3c.dom.stylesheets.LinkStyle in project webtools.sourceediting by eclipse.
the class StyleAdapterPerfTest method testPerformance.
public void testPerformance() {
try {
String filename = "testfiles/html/example04.html";
IStructuredModel model = StructuredModelManager.getModelManager().getModelForEdit(filename, getClass().getResourceAsStream(filename), null);
if (model instanceof IDOMModel) {
IDOMDocument doc = ((IDOMModel) model).getDocument();
NodeList nodes = doc.getElementsByTagName(HTML40Namespace.ElementName.STYLE);
if (nodes != null && nodes.getLength() > 0) {
Node node = nodes.item(0);
if (node instanceof LinkStyle) {
long start = System.currentTimeMillis();
((LinkStyle) node).getSheet();
// System.out.println("elapsed time = " + (System.currentTimeMillis() - start));
// TODO: we should probably use something likse o.e.core.runtime.PerformanceStats
// I picked the following fail criteria simple since before fix, the printlin reports about 7000
// on my computer, but with fix, reported about 1000.
// The appropriate time may vary greatly depending on the build/test machine.
// This is just to catch some large change in behavior
long elapsedTime = System.currentTimeMillis() - start;
if (elapsedTime > MAX_EXPECTED_TIME) {
fail("getSheet took longer than expected the expected " + MAX_EXPECTED_TIME + "ms");
}
}
}
}
if (model != null)
model.releaseFromRead();
} catch (Exception e) {
}
}
use of org.w3c.dom.stylesheets.LinkStyle in project webtools.sourceediting by eclipse.
the class StyleTest method testModel.
public void testModel() {
// new HTMLModelImpl();
IDOMModel model = createHTMLModel();
Document document = model.getDocument();
Element style = document.createElement("STYLE");
Text text = document.createTextNode("BODY { color : red; } P { color : green; } B { color : blue; }");
style.appendChild(text);
document.appendChild(style);
printSource(model);
printTree(model);
DocumentStyle ds = (DocumentStyle) document;
StyleSheetList ssl = ds.getStyleSheets();
if (ssl.getLength() > 0) {
CSSStyleSheet ss = (CSSStyleSheet) ssl.item(0);
ss.deleteRule(1);
}
printSource(model);
printTree(model);
LinkStyle ls = (LinkStyle) style;
CSSStyleSheet ss2 = (CSSStyleSheet) ls.getSheet();
if (ss2 != null) {
ss2.deleteRule(0);
}
printSource(model);
printTree(model);
saveAndCompareTestResults();
}
Aggregations