[Webkit-unassigned] [Bug 71886] New: Defer applying style recalculation when stylesheet is loaded to improve page load performance
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Nov 9 03:51:24 PST 2011
https://bugs.webkit.org/show_bug.cgi?id=71886
Summary: Defer applying style recalculation when stylesheet is
loaded to improve page load performance
Product: WebKit
Version: 528+ (Nightly build)
Platform: Unspecified
OS/Version: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: Page Loading
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: jnd at chromium.org
CC: hyatt at apple.com, ap at webkit.org, koivisto at iki.fi,
dglazkov at chromium.org, tonyg at chromium.org,
satish at chromium.org
Currently Webkit immediately does a force style recalculation after stylesheet is loaded, the style recalculation routine checks almost all nodes in the document at that time and may change/re-create render objects for all affected nodes.
If there are several continuous style elements coming when there are already many nodes in the document, it can cost webkit much time to do several style recalculation cycles. Please check the attached test case.
Comparing with WebKit, seems like other mainstream browsers (IE, Firefox, opera) all defer style recalculation.
When running the attached test case on my machine. (Intel Xeon E5620 2.4G*2 processors, 12G memory), IE, firefox and Opera all use around 1 second, but Chrome and Safari use around 6 seconds.
After looking Firefox source code, it shows firefox asynchronously apply style rules, please refer to the resource links in the end of this comment.
Don't know how IE and opera did, but their loading speed does not look like doing immediate style recalc for each style element.
I have a initial patch to change immediate style-recalc to scheduled style-recalc. I am still resolving the broken layout tests. (most of them should be rebaselined)
Bug 70868 was created to handle part of this issue.
Resource for firefox style load path (Last I checked)
nsCSSStyleSheet::StyleSheetLoaded (http://mxr.mozilla.org/mozilla-central/source/layout/style/nsCSSStyleSheet.cpp#2046)
mozAutoDocUpdate (http://mxr.mozilla.org/mozilla-central/source/content/base/src/mozAutoDocUpdate.h#51)
nsDocument::BeginUpdate/EndUpdate (http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsDocument.cpp#3970)
nsDocument::StyleRuleAdded (http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsDocument.cpp#4275)
PresShell::BeginUpdate/EndUpdate (http://mxr.mozilla.org/mozilla-central/source/layout/base/nsPresShell.cpp#2635)
PresShell::StyleRuleAdded (http://mxr.mozilla.org/mozilla-central/source/layout/base/nsPresShell.cpp#4433)
nsIPresShell::ReconstructStyleDataInternal() (http://mxr.mozilla.org/mozilla-central/source/layout/base/nsPresShell.cpp#4353)
nsCSSFrameConstructor::PostRestyleEventCommon (http://mxr.mozilla.org/mozilla-central/source/layout/base/nsCSSFrameConstructor.cpp#11647)
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list