Closed Bug 47734 Opened 25 years ago Closed 22 years ago

DOM StyleSheets collection inaccurate if retrieved during page load [AltSS]

Categories

(Core :: DOM: CSS Object Model, defect, P3)

defect

Tracking

()

RESOLVED FIXED
Future

People

(Reporter: tim, Assigned: jst)

References

()

Details

(Keywords: dom2, Whiteboard: relnote-user)

(this requires the latest build with author stylesheet support, or the patch in bug 6782) 1. Go to http://www.fas.harvard.edu/~dbaron/css/ssui/ 2. While the page is loading, select the View > Use Stylesheet item to show a list of alternate stylesheets for the page. Only some of the stylesheets will be shown. 3. Then wait for the entire page to load. Go to View > Use Stylesheet again to view the list. Actual Results: - Not all of the alternate stylesheets for the page are shown, even though the page is now fully loaded. (If you wait for the page to completely load before accessing the menu, all stylesheets ARE shown correctly) Expected Results: - All alternate stylesheets should be shown. The "Use Stylesheet" menu generates the list of alternate stylesheets using the document.styleSheets property each time the menu pops up. But once you access the document.styleSheets collection for the first time (i.e. during page load), it seems to keep the same list in memory until the page is reloaded.
Confirming bug because someone else had the same problem... and to test my newfound Bugzilla permissions!
Status: UNCONFIRMED → NEW
Ever confirmed: true
This bug has been marked "future" because the original netscape engineer working on this is over-burdened. If you feel this is an error, that you or another known resource will be working on this bug,or if it blocks your work in some way -- please attach your concern to the bug for reconsideration.
Status: NEW → ASSIGNED
Target Milestone: --- → Future
Taking QA since this is a DOM2 Style bug and I'm supposed to be getting into DOM2 Style...
Keywords: correctness
QA Contact: vidur → ian
Blocks: 6782
Whiteboard: relnote-user
(marking alternate style sheet bugs for easy tracking...)
Summary: DOM StyleSheets collection inaccurate if retrieved during page load → DOM StyleSheets collection inaccurate if retrieved during page load [ASS]
Summary: DOM StyleSheets collection inaccurate if retrieved during page load [ASS] → DOM StyleSheets collection inaccurate if retrieved during page load [AltSS]
Keywords: dom2
Component: DOM Level 2 → DOM Style
Taking QA Contact on all open or unverified DOM Style bugs...
WORKSFORME on Linux build 2001052621 Please verify...
I still see this problem.
*** Bug 111765 has been marked as a duplicate of this bug. ***
*** Bug 107118 has been marked as a duplicate of this bug. ***
My comments from bug 111765: The problem is the following: 1) We defer alternate sheet loads. So when we create the nsDOMStyleSheetList and it calls GetNumberOfStyleSheets the first time it gets 0. 2) The stylesheet list caches the 0 and only updates it if the StyleSheetAdded callback is called. This callback is never called if all the pending sheets are alternate sheets. Worse, yet, if the remaining sheets are not all alternates there will be only _one_ call to StyleSheetAdded, since the CSS loader will only set notification to true on the last pending sheet. See http://lxr.mozilla.org/seamonkey/source/content/html/style/src/nsCSSLoader.cpp#798 There is no real explanation for why we do it that way and I'm not sure what the performance (or correctness) impact would be of notifying on all sheets here. ccing pierre. The two solutions I see would be the following: 1) Have the CSS loader_always_ file a notification on pending sheets (even if they are all alternates) and have the nsDOMStyleSheetList set mLength to -1 instead of incrementing it when StyleSheetAdded is called 2) Have the CSS loader notify on all stylesheet insertions Pierre? Thoughts?
The problem is that we have two kinds of observers but only one kind of notification. The HTMLContentSink needs to be notified when a doc sheet is inserted in the document in order to rebuild everything. The nsDOMStyleSheetList needs to be notified when a sheet is linked to the document (which does not mean that it will later be inserted in the cascade) in order to update its count. As Boris pointed out, the current notifications only cover the first case. A solution could be for the document to be notified when a sheet is loaded (see the StyleSheetLoaded notification in nsICSSLoaderObserver) and forward this notification to its |nsIDocumentObserver|s. It would allow nsDOMStyleSheetList to set mLength to -1. The other observers could just ignore the notification. We don't want to send the StyleSheetAdded notification on all stylesheets. It is incorrect for alternate sheets to do that and it would hurt the performance quite a bit.
Depends on: 107567
Fixed for 1.3a by checkin for bug 107567
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.