Bug 97504

Summary: Don't use StyleSheetList internally
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: cmarcelo, kling, macpherson, menard, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
none
updated patch rniwa: review+

Antti Koivisto
Reported 2012-09-24 17:38:29 PDT
StyleSheetList is a DOM type and should not be used internally. Use plain Vector instead and construct StyleSheetList on DOM access only.
Attachments
patch (12.61 KB, patch)
2012-09-24 18:24 PDT, Antti Koivisto
no flags
updated patch (13.14 KB, patch)
2012-09-24 20:58 PDT, Antti Koivisto
rniwa: review+
Antti Koivisto
Comment 1 2012-09-24 18:24:35 PDT
Ryosuke Niwa
Comment 2 2012-09-24 20:23:39 PDT
Comment on attachment 165484 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=165484&action=review > Source/WebCore/ChangeLog:10 > + Also hot rid of the StyleSheetVector typedef as Vector<RefPtr<StyleSheet> > is less opaque and not much longer. Typo: hot rid of > Source/WebCore/dom/Document.cpp:3201 > + if (!m_authorStyleSheetList) > + m_authorStyleSheetList = StyleSheetList::create(this); > + return m_authorStyleSheetList.get(); So now we wouldn't create StyleSheetList until it's used by scripts? I think that should be explained in the change log. Doesn't this imply that if the author did document.styleSheets.foo = 'bar'; gc(); // Force GC here. alert(document.styleSheets.foo); // would give us "undefined"? > Source/WebCore/dom/Document.h:1322 > OwnPtr<DocumentStyleSheetCollection> m_styleSheetCollection; > + RefPtr<StyleSheetList> m_authorStyleSheetList; This change of ownership of m_authorStyleSheetList should be explained in the change log. > Source/WebCore/dom/DocumentStyleSheetCollection.cpp:461 > - m_authorStyleSheets->swap(newStylesheets); > + m_authorStyleSheets = newStylesheets; Why do we not want to swap?
Ryosuke Niwa
Comment 3 2012-09-24 20:28:43 PDT
Comment on attachment 165484 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=165484&action=review >> Source/WebCore/dom/Document.cpp:3201 >> + return m_authorStyleSheetList.get(); > > So now we wouldn't create StyleSheetList until it's used by scripts? I think that should be explained in the change log. > Doesn't this imply that if the author did > document.styleSheets.foo = 'bar'; > gc(); // Force GC here. > alert(document.styleSheets.foo); // would give us "undefined"? Ugh... nvm. Document has a RefPtr to StyleSheetList.
Antti Koivisto
Comment 4 2012-09-24 20:50:39 PDT
(In reply to comment #2) > So now we wouldn't create StyleSheetList until it's used by scripts? I think that should be explained in the change log. > Doesn't this imply that if the author did > document.styleSheets.foo = 'bar'; > gc(); // Force GC here. > alert(document.styleSheets.foo); // would give us "undefined"? No since document refs the StyleSheetList and always returns the same instance after initial construction. There shouldn't be any externally observable changes. > Why do we not want to swap? Good point, I forgot Vector has swap() too.
Antti Koivisto
Comment 5 2012-09-24 20:58:53 PDT
Created attachment 165508 [details] updated patch Updates based on comments
Antti Koivisto
Comment 6 2012-09-24 21:25:31 PDT
Note You need to log in before you can comment on or make changes to this bug.