Changeset 206603 in webkit
- Timestamp:
- Sep 29, 2016, 12:36:39 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 19 edited
-
ChangeLog (modified) (1 diff)
-
css/CSSFontFaceSrcValue.cpp (modified) (1 diff)
-
css/CSSFontFaceSrcValue.h (modified) (1 diff)
-
css/CSSPrimitiveValue.cpp (modified) (1 diff)
-
css/CSSPrimitiveValue.h (modified) (1 diff)
-
css/CSSReflectValue.cpp (modified) (1 diff)
-
css/CSSReflectValue.h (modified) (1 diff)
-
css/CSSValue.cpp (modified) (1 diff)
-
css/CSSValue.h (modified) (1 diff)
-
css/CSSValueList.cpp (modified) (1 diff)
-
css/CSSValueList.h (modified) (1 diff)
-
css/StyleProperties.cpp (modified) (1 diff)
-
css/StyleProperties.h (modified) (1 diff)
-
css/StyleRuleImport.h (modified) (1 diff)
-
css/StyleSheetContents.cpp (modified) (2 diffs)
-
css/StyleSheetContents.h (modified) (1 diff)
-
dom/StyledElement.cpp (modified) (2 diffs)
-
html/HTMLLinkElement.cpp (modified) (1 diff)
-
html/HTMLStyleElement.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206597 r206603 1 2016-09-29 Antti Koivisto <antti@apple.com> 2 3 Remove addSubresourceStyleURLs functions 4 https://bugs.webkit.org/show_bug.cgi?id=162731 5 6 Reviewed by Ryosuke Niwa. 7 8 Use the generic std::function taking traverseSubresources instead. This prevents bugs caused by the code paths 9 not being in sync. 10 11 These functions are only used by the legacy webarchive code to gather URLs to locate CachedResources from the memory cache. 12 This can be improved further by returning the cached resources themselves instead of the URLs. 13 14 * css/CSSFontFaceSrcValue.cpp: 15 (WebCore::CSSFontFaceSrcValue::addSubresourceStyleURLs): Deleted. 16 * css/CSSFontFaceSrcValue.h: 17 * css/CSSPrimitiveValue.cpp: 18 (WebCore::CSSPrimitiveValue::addSubresourceStyleURLs): Deleted. 19 * css/CSSPrimitiveValue.h: 20 * css/CSSReflectValue.cpp: 21 (WebCore::CSSReflectValue::addSubresourceStyleURLs): Deleted. 22 * css/CSSReflectValue.h: 23 * css/CSSValue.cpp: 24 (WebCore::CSSValue::addSubresourceStyleURLs): Deleted. 25 * css/CSSValue.h: 26 * css/CSSValueList.cpp: 27 (WebCore::CSSValueList::addSubresourceStyleURLs): Deleted. 28 * css/CSSValueList.h: 29 * css/StyleProperties.cpp: 30 (WebCore::StyleProperties::addSubresourceStyleURLs): Deleted. 31 * css/StyleProperties.h: 32 * css/StyleRuleImport.h: 33 * css/StyleSheetContents.cpp: 34 (WebCore::StyleSheetContents::traverseSubresources): 35 36 Fix a bug where this would miss @import rules in @imported stylesheets. 37 Include the CachedResource for the imported stylesheet itself. 38 39 Tested by the test cases under LayoutTests/webarchive 40 41 (WebCore::StyleSheetContents::addSubresourceStyleURLs): Deleted. 42 * css/StyleSheetContents.h: 43 * dom/StyledElement.cpp: 44 (WebCore::StyledElement::addSubresourceAttributeURLs): 45 * html/HTMLLinkElement.cpp: 46 (WebCore::HTMLLinkElement::addSubresourceAttributeURLs): 47 * html/HTMLStyleElement.cpp: 48 (WebCore::HTMLStyleElement::addSubresourceAttributeURLs): 49 1 50 2016-09-29 Brent Fulgham <bfulgham@apple.com> 2 51 -
trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp
r206016 r206603 86 86 } 87 87 88 void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const89 {90 if (!isLocal())91 addSubresourceURL(urls, styleSheet->completeURL(m_resource));92 }93 94 88 bool CSSFontFaceSrcValue::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const 95 89 { -
trunk/Source/WebCore/css/CSSFontFaceSrcValue.h
r205093 r206603 66 66 String customCSSText() const; 67 67 68 void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;69 70 68 bool traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const; 71 69 -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r206043 r206603 1265 1265 } 1266 1266 1267 void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const1268 {1269 if (m_primitiveUnitType == CSS_URI)1270 addSubresourceURL(urls, styleSheet->completeURL(m_value.string));1271 }1272 1273 1267 Ref<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const 1274 1268 { -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r206043 r206603 382 382 bool isQuirkValue() const { return m_isQuirkValue || primitiveType() == CSS_QUIRKY_EMS; } 383 383 384 void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;385 386 384 Ref<CSSPrimitiveValue> cloneForCSSOM() const; 387 385 void setCSSOMSafe() { m_isCSSOMSafe = true; } -
trunk/Source/WebCore/css/CSSReflectValue.cpp
r201290 r206603 39 39 } 40 40 41 void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const42 {43 if (m_mask)44 m_mask->addSubresourceStyleURLs(urls, styleSheet);45 }46 47 41 bool CSSReflectValue::equals(const CSSReflectValue& other) const 48 42 { -
trunk/Source/WebCore/css/CSSReflectValue.h
r205093 r206603 49 49 String customCSSText() const; 50 50 51 void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;52 53 51 bool equals(const CSSReflectValue&) const; 54 52 -
trunk/Source/WebCore/css/CSSValue.cpp
r205869 r206603 122 122 return CSS_REVERT; 123 123 return CSS_CUSTOM; 124 }125 126 void CSSValue::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const127 {128 // This should get called for internal instances only.129 ASSERT(!isCSSOMSafe());130 131 if (is<CSSPrimitiveValue>(*this))132 downcast<CSSPrimitiveValue>(*this).addSubresourceStyleURLs(urls, styleSheet);133 else if (is<CSSValueList>(*this))134 downcast<CSSValueList>(*this).addSubresourceStyleURLs(urls, styleSheet);135 else if (is<CSSFontFaceSrcValue>(*this))136 downcast<CSSFontFaceSrcValue>(*this).addSubresourceStyleURLs(urls, styleSheet);137 else if (is<CSSReflectValue>(*this))138 downcast<CSSReflectValue>(*this).addSubresourceStyleURLs(urls, styleSheet);139 124 } 140 125 -
trunk/Source/WebCore/css/CSSValue.h
r205869 r206603 138 138 RefPtr<CSSValue> cloneForCSSOM() const; 139 139 140 void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;141 142 140 bool traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const; 143 141 -
trunk/Source/WebCore/css/CSSValueList.cpp
r201690 r206603 156 156 } 157 157 158 void CSSValueList::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const159 {160 for (unsigned i = 0, size = m_values.size(); i < size; ++i)161 m_values[i].get().addSubresourceStyleURLs(urls, styleSheet);162 }163 164 158 bool CSSValueList::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const 165 159 { -
trunk/Source/WebCore/css/CSSValueList.h
r204466 r206603 73 73 bool equals(const CSSValue&) const; 74 74 75 void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;76 77 75 bool traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const; 78 76 -
trunk/Source/WebCore/css/StyleProperties.cpp
r205809 r206603 1114 1114 } 1115 1115 1116 void StyleProperties::addSubresourceStyleURLs(ListHashSet<URL>& urls, StyleSheetContents* contextStyleSheet) const1117 {1118 unsigned size = propertyCount();1119 for (unsigned i = 0; i < size; ++i)1120 propertyAt(i).value()->addSubresourceStyleURLs(urls, contextStyleSheet);1121 }1122 1123 1116 bool StyleProperties::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const 1124 1117 { -
trunk/Source/WebCore/css/StyleProperties.h
r205660 r206603 97 97 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); } 98 98 99 void addSubresourceStyleURLs(ListHashSet<URL>&, StyleSheetContents* contextStyleSheet) const;100 101 99 WEBCORE_EXPORT Ref<MutableStyleProperties> mutableCopy() const; 102 100 Ref<ImmutableStyleProperties> immutableCopyIfNeeded() const; -
trunk/Source/WebCore/css/StyleRuleImport.h
r205093 r206603 52 52 53 53 void requestStyleSheet(); 54 const CachedCSSStyleSheet* cachedCSSStyleSheet() const { return m_cachedSheet.get(); } 54 55 55 56 private: -
trunk/Source/WebCore/css/StyleSheetContents.cpp
r205790 r206603 409 409 { 410 410 return CSSParser::completeURL(m_parserContext, url); 411 }412 413 void StyleSheetContents::addSubresourceStyleURLs(ListHashSet<URL>& urls)414 {415 Deque<StyleSheetContents*> styleSheetQueue;416 styleSheetQueue.append(this);417 418 while (!styleSheetQueue.isEmpty()) {419 StyleSheetContents* styleSheet = styleSheetQueue.takeFirst();420 421 for (auto& importRule : styleSheet->m_importRules) {422 if (importRule->styleSheet()) {423 styleSheetQueue.append(importRule->styleSheet());424 addSubresourceURL(urls, importRule->styleSheet()->baseURL());425 }426 }427 for (auto& rule : styleSheet->m_childRules) {428 if (is<StyleRule>(*rule))429 downcast<StyleRule>(*rule).properties().addSubresourceStyleURLs(urls, this);430 else if (is<StyleRuleFontFace>(*rule))431 downcast<StyleRuleFontFace>(*rule).properties().addSubresourceStyleURLs(urls, this);432 }433 }434 411 } 435 412 … … 478 455 { 479 456 for (auto& importRule : m_importRules) { 480 if (!importRule->styleSheet()) 481 continue; 482 if (traverseSubresourcesInRules(importRule->styleSheet()->m_childRules, handler)) 457 if (auto* cachedResource = importRule->cachedCSSStyleSheet()) { 458 if (handler(*cachedResource)) 459 return true; 460 } 461 auto* importedStyleSheet = importRule->styleSheet(); 462 if (importedStyleSheet && importedStyleSheet->traverseSubresources(handler)) 483 463 return true; 484 464 } -
trunk/Source/WebCore/css/StyleSheetContents.h
r205660 r206603 87 87 88 88 URL completeURL(const String& url) const; 89 void addSubresourceStyleURLs(ListHashSet<URL>&);90 89 bool traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const; 91 90 -
trunk/Source/WebCore/dom/StyledElement.cpp
r205660 r206603 29 29 #include "CSSStyleSheet.h" 30 30 #include "CSSValuePool.h" 31 #include "CachedResource.h" 31 32 #include "ContentSecurityPolicy.h" 32 33 #include "DOMTokenList.h" … … 267 268 void StyledElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const 268 269 { 269 if (const StyleProperties* inlineStyle = elementData() ? elementData()->inlineStyle() : nullptr) 270 inlineStyle->addSubresourceStyleURLs(urls, &document().elementSheet().contents()); 270 auto* inlineStyle = this->inlineStyle(); 271 if (!inlineStyle) 272 return; 273 inlineStyle->traverseSubresources([&] (auto& resource) { 274 urls.add(resource.url()); 275 return false; 276 }); 271 277 } 272 278 -
trunk/Source/WebCore/html/HTMLLinkElement.cpp
r206561 r206603 531 531 // Append the URL of this link element. 532 532 addSubresourceURL(urls, href()); 533 534 // Walk the URLs linked by the linked-to stylesheet. 535 if (CSSStyleSheet* styleSheet = const_cast<HTMLLinkElement*>(this)->sheet()) 536 styleSheet->contents().addSubresourceStyleURLs(urls); 533 534 if (auto* styleSheet = this->sheet()) { 535 styleSheet->contents().traverseSubresources([&] (auto& resource) { 536 urls.add(resource.url()); 537 return false; 538 }); 539 } 537 540 } 538 541 -
trunk/Source/WebCore/html/HTMLStyleElement.cpp
r206361 r206603 26 26 27 27 #include "AuthorStyleSheets.h" 28 #include "CachedResource.h" 28 29 #include "Document.h" 29 30 #include "Event.h" … … 143 144 HTMLElement::addSubresourceAttributeURLs(urls); 144 145 145 if (CSSStyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet()) 146 styleSheet->contents().addSubresourceStyleURLs(urls); 146 if (auto* styleSheet = this->sheet()) { 147 styleSheet->contents().traverseSubresources([&] (auto& resource) { 148 urls.add(resource.url()); 149 return false; 150 }); 151 } 147 152 } 148 153
Note:
See TracChangeset
for help on using the changeset viewer.