haikuwebkit/PerformanceTests/CSS/StyleSheetInsert.html

35 lines
911 B
HTML
Raw Permalink Normal View History

Optimize stylesheet insertions https://bugs.webkit.org/show_bug.cgi?id=97627 Reviewed by Andreas Kling. PerformanceTests: Add synthetic performance test for avoiding style recalcs on stylesheet inserts. * CSS/StyleSheetInsert.html: Added. Source/WebCore: We currently do scope analysis for stylesheets that are added to the end of the active stylesheet list to avoid unnecessary style recalcs and StyleResolver rebuilding. However it is somewhat common to insert <style> elements dynamically to positions other than last. In this case we currently simply force full style recalc. We should do scope analysis and partial style recalcs also in these cases. PerformanceTests/CSS/StyleSheetInsert.html microbenchmark shows ~20x progression from the patch. * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): (WebCore::StyleResolver::resetAuthorStyle): Add a way to reset author RuleSet without deleting the whole StyleResolver. (WebCore): * css/StyleResolver.h: (StyleResolver): * dom/DocumentStyleSheetCollection.cpp: (WebCore::DocumentStyleSheetCollection::analyzeStyleSheetChange): Check if there have been insertions to the stylesheet list. If so we need to reset the StyleResolver (to handle rule position changes) but don't need to force full style recalc. Do scope analysis for inserted stylesheets as well. (WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets): * dom/DocumentStyleSheetCollection.h: Canonical link: https://commits.webkit.org/115660@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129644 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-09-26 14:52:19 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../resources/runner.js"></script>
</head>
<body>
<iframe></iframe>
</body>
<script>
function setup() {
var frame = document.getElementsByTagName("iframe")[0];
var testDoc = frame.contentDocument;
var docText = "";
docText += "<body><style>.foo {color:red}</style>";
docText += "<div class='bar'>Foo</div>";
for (var i = 0; i < 10000; ++i)
docText += "<div class='foo'>Foo</div>";
testDoc.body.innerHTML = docText;
return testDoc;
}
Optimize stylesheet insertions https://bugs.webkit.org/show_bug.cgi?id=97627 Reviewed by Andreas Kling. PerformanceTests: Add synthetic performance test for avoiding style recalcs on stylesheet inserts. * CSS/StyleSheetInsert.html: Added. Source/WebCore: We currently do scope analysis for stylesheets that are added to the end of the active stylesheet list to avoid unnecessary style recalcs and StyleResolver rebuilding. However it is somewhat common to insert <style> elements dynamically to positions other than last. In this case we currently simply force full style recalc. We should do scope analysis and partial style recalcs also in these cases. PerformanceTests/CSS/StyleSheetInsert.html microbenchmark shows ~20x progression from the patch. * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): (WebCore::StyleResolver::resetAuthorStyle): Add a way to reset author RuleSet without deleting the whole StyleResolver. (WebCore): * css/StyleResolver.h: (StyleResolver): * dom/DocumentStyleSheetCollection.cpp: (WebCore::DocumentStyleSheetCollection::analyzeStyleSheetChange): Check if there have been insertions to the stylesheet list. If so we need to reset the StyleResolver (to handle rule position changes) but don't need to force full style recalc. Do scope analysis for inserted stylesheets as well. (WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets): * dom/DocumentStyleSheetCollection.h: Canonical link: https://commits.webkit.org/115660@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129644 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-09-26 14:52:19 +00:00
PerfTestRunner.measureTime({run:function() {
var testDoc = setup();
var start = PerfTestRunner.now();
for (var i = 0; i < 50; i++) {
var styleElem = testDoc.createElement("style");
styleElem.innerText = ".bar {color:green}";
testDoc.body.insertBefore(styleElem, testDoc.body.firstChild);
}
return PerfTestRunner.now() - start;
}});
Optimize stylesheet insertions https://bugs.webkit.org/show_bug.cgi?id=97627 Reviewed by Andreas Kling. PerformanceTests: Add synthetic performance test for avoiding style recalcs on stylesheet inserts. * CSS/StyleSheetInsert.html: Added. Source/WebCore: We currently do scope analysis for stylesheets that are added to the end of the active stylesheet list to avoid unnecessary style recalcs and StyleResolver rebuilding. However it is somewhat common to insert <style> elements dynamically to positions other than last. In this case we currently simply force full style recalc. We should do scope analysis and partial style recalcs also in these cases. PerformanceTests/CSS/StyleSheetInsert.html microbenchmark shows ~20x progression from the patch. * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): (WebCore::StyleResolver::resetAuthorStyle): Add a way to reset author RuleSet without deleting the whole StyleResolver. (WebCore): * css/StyleResolver.h: (StyleResolver): * dom/DocumentStyleSheetCollection.cpp: (WebCore::DocumentStyleSheetCollection::analyzeStyleSheetChange): Check if there have been insertions to the stylesheet list. If so we need to reset the StyleResolver (to handle rule position changes) but don't need to force full style recalc. Do scope analysis for inserted stylesheets as well. (WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets): * dom/DocumentStyleSheetCollection.h: Canonical link: https://commits.webkit.org/115660@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129644 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-09-26 14:52:19 +00:00
</script>
</html>