Changeset 38787 in webkit
- Timestamp:
- Nov 26, 2008 11:44:05 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r38785 r38787 1 2008-11-26 David Kilzer <ddkilzer@apple.com> 2 3 Make CSSStyleSheet::addSubresourceURLStrings() iterative 4 5 Part of the fix for Bug 11850: Webarchive fails to save images referenced in CSS 6 <https://bugs.webkit.org/show_bug.cgi?id=11850> 7 8 Reviewed by Brady Eidson. 9 10 * css/CSSStyleSheet.cpp: 11 (WebCore::CSSStyleSheet::addSubresourceURLStrings): Switch algorithm 12 from recursive to iterative for gathering the list of all CSS 13 stylesheets referenced in @import statements. 14 1 15 2008-11-26 Dirk Schulze <krit@webkit.org> 2 16 -
trunk/WebCore/css/CSSStyleSheet.cpp
r38617 r38787 200 200 201 201 void CSSStyleSheet::addSubresourceURLStrings(HashSet<String>& urls, const String& base) const 202 { 203 RefPtr<CSSRuleList> ruleList = const_cast<CSSStyleSheet*>(this)->cssRules(); 204 205 // Add the URLs for each child import rule, and recurse for the stylesheet belonging to each of those rules. 206 for (unsigned i = 0; i < ruleList->length(); ++i) { 207 CSSRule* rule = ruleList->item(i); 208 if (rule->type() != CSSRule::IMPORT_RULE) 209 continue; 210 211 CSSImportRule* importRule = static_cast<CSSImportRule*>(rule); 212 CSSStyleSheet* ruleSheet = importRule->styleSheet(); 213 if (!ruleSheet) 214 continue; 215 216 KURL fullURL(KURL(base), importRule->href()); 217 urls.add(fullURL.string()); 218 ruleSheet->addSubresourceURLStrings(urls, fullURL.string()); 219 } 220 } 221 222 } 202 { 203 typedef HashMap<RefPtr<CSSStyleSheet>, KURL> CSSStyleSheetMap; 204 CSSStyleSheetMap styleSheetMap; 205 styleSheetMap.add(const_cast<CSSStyleSheet*>(this), KURL(base)); 206 207 while(styleSheetMap.size() > 0) { 208 CSSStyleSheetMap::iterator it = styleSheetMap.begin(); 209 RefPtr<CSSStyleSheet> styleSheet = it->first; 210 const KURL baseURL = it->second; 211 styleSheetMap.remove(it); 212 213 RefPtr<CSSRuleList> ruleList = styleSheet->cssRules(); 214 215 // Add the URLs for each child import rule to styleSheetMap for processing 216 for (unsigned i = 0; i < ruleList->length(); ++i) { 217 CSSRule* rule = ruleList->item(i); 218 if (rule->type() != CSSRule::IMPORT_RULE) 219 continue; 220 221 CSSImportRule* importRule = static_cast<CSSImportRule*>(rule); 222 RefPtr<CSSStyleSheet> ruleSheet = importRule->styleSheet(); 223 if (!ruleSheet) 224 continue; 225 226 const KURL fullURL(baseURL, importRule->href()); 227 if (!urls.contains(fullURL.string())) { 228 urls.add(fullURL.string()); 229 styleSheetMap.add(ruleSheet, fullURL); 230 } 231 } 232 } 233 } 234 235 }
Note: See TracChangeset
for help on using the changeset viewer.