Diff
Modified: trunk/Source/WebCore/ChangeLog (206602 => 206603)
--- trunk/Source/WebCore/ChangeLog 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/ChangeLog 2016-09-29 19:36:39 UTC (rev 206603)
@@ -1,3 +1,52 @@
+2016-09-29 Antti Koivisto <an...@apple.com>
+
+ Remove addSubresourceStyleURLs functions
+ https://bugs.webkit.org/show_bug.cgi?id=162731
+
+ Reviewed by Ryosuke Niwa.
+
+ Use the generic std::function taking traverseSubresources instead. This prevents bugs caused by the code paths
+ not being in sync.
+
+ These functions are only used by the legacy webarchive code to gather URLs to locate CachedResources from the memory cache.
+ This can be improved further by returning the cached resources themselves instead of the URLs.
+
+ * css/CSSFontFaceSrcValue.cpp:
+ (WebCore::CSSFontFaceSrcValue::addSubresourceStyleURLs): Deleted.
+ * css/CSSFontFaceSrcValue.h:
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::CSSPrimitiveValue::addSubresourceStyleURLs): Deleted.
+ * css/CSSPrimitiveValue.h:
+ * css/CSSReflectValue.cpp:
+ (WebCore::CSSReflectValue::addSubresourceStyleURLs): Deleted.
+ * css/CSSReflectValue.h:
+ * css/CSSValue.cpp:
+ (WebCore::CSSValue::addSubresourceStyleURLs): Deleted.
+ * css/CSSValue.h:
+ * css/CSSValueList.cpp:
+ (WebCore::CSSValueList::addSubresourceStyleURLs): Deleted.
+ * css/CSSValueList.h:
+ * css/StyleProperties.cpp:
+ (WebCore::StyleProperties::addSubresourceStyleURLs): Deleted.
+ * css/StyleProperties.h:
+ * css/StyleRuleImport.h:
+ * css/StyleSheetContents.cpp:
+ (WebCore::StyleSheetContents::traverseSubresources):
+
+ Fix a bug where this would miss @import rules in @imported stylesheets.
+ Include the CachedResource for the imported stylesheet itself.
+
+ Tested by the test cases under LayoutTests/webarchive
+
+ (WebCore::StyleSheetContents::addSubresourceStyleURLs): Deleted.
+ * css/StyleSheetContents.h:
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::addSubresourceAttributeURLs):
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::addSubresourceAttributeURLs):
+ * html/HTMLStyleElement.cpp:
+ (WebCore::HTMLStyleElement::addSubresourceAttributeURLs):
+
2016-09-29 Brent Fulgham <bfulg...@apple.com>
[Win][Direct2D] Add D2D Font handling code
Modified: trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp (206602 => 206603)
--- trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -85,12 +85,6 @@
return result.toString();
}
-void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const
-{
- if (!isLocal())
- addSubresourceURL(urls, styleSheet->completeURL(m_resource));
-}
-
bool CSSFontFaceSrcValue::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const
{
if (!m_cachedFont)
Modified: trunk/Source/WebCore/css/CSSFontFaceSrcValue.h (206602 => 206603)
--- trunk/Source/WebCore/css/CSSFontFaceSrcValue.h 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSFontFaceSrcValue.h 2016-09-29 19:36:39 UTC (rev 206603)
@@ -65,8 +65,6 @@
String customCSSText() const;
- void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;
-
bool traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const;
CachedFont* cachedFont(Document*, bool isSVG, bool isInitiatingElementInUserAgentShadowTree);
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (206602 => 206603)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -1264,12 +1264,6 @@
return text;
}
-void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const
-{
- if (m_primitiveUnitType == CSS_URI)
- addSubresourceURL(urls, styleSheet->completeURL(m_value.string));
-}
-
Ref<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const
{
RefPtr<CSSPrimitiveValue> result;
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (206602 => 206603)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.h 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h 2016-09-29 19:36:39 UTC (rev 206603)
@@ -381,8 +381,6 @@
// FIXME-NEWPARSER: Can ditch the boolean and just use the unit type once old parser is gone.
bool isQuirkValue() const { return m_isQuirkValue || primitiveType() == CSS_QUIRKY_EMS; }
- void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;
-
Ref<CSSPrimitiveValue> cloneForCSSOM() const;
void setCSSOMSafe() { m_isCSSOMSafe = true; }
Modified: trunk/Source/WebCore/css/CSSReflectValue.cpp (206602 => 206603)
--- trunk/Source/WebCore/css/CSSReflectValue.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSReflectValue.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -38,12 +38,6 @@
return m_direction->cssText() + ' ' + m_offset->cssText();
}
-void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const
-{
- if (m_mask)
- m_mask->addSubresourceStyleURLs(urls, styleSheet);
-}
-
bool CSSReflectValue::equals(const CSSReflectValue& other) const
{
return m_direction.ptr() == other.m_direction.ptr()
Modified: trunk/Source/WebCore/css/CSSReflectValue.h (206602 => 206603)
--- trunk/Source/WebCore/css/CSSReflectValue.h 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSReflectValue.h 2016-09-29 19:36:39 UTC (rev 206603)
@@ -48,8 +48,6 @@
String customCSSText() const;
- void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;
-
bool equals(const CSSReflectValue&) const;
private:
Modified: trunk/Source/WebCore/css/CSSValue.cpp (206602 => 206603)
--- trunk/Source/WebCore/css/CSSValue.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSValue.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -123,21 +123,6 @@
return CSS_CUSTOM;
}
-void CSSValue::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const
-{
- // This should get called for internal instances only.
- ASSERT(!isCSSOMSafe());
-
- if (is<CSSPrimitiveValue>(*this))
- downcast<CSSPrimitiveValue>(*this).addSubresourceStyleURLs(urls, styleSheet);
- else if (is<CSSValueList>(*this))
- downcast<CSSValueList>(*this).addSubresourceStyleURLs(urls, styleSheet);
- else if (is<CSSFontFaceSrcValue>(*this))
- downcast<CSSFontFaceSrcValue>(*this).addSubresourceStyleURLs(urls, styleSheet);
- else if (is<CSSReflectValue>(*this))
- downcast<CSSReflectValue>(*this).addSubresourceStyleURLs(urls, styleSheet);
-}
-
bool CSSValue::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const
{
// This should get called for internal instances only.
Modified: trunk/Source/WebCore/css/CSSValue.h (206602 => 206603)
--- trunk/Source/WebCore/css/CSSValue.h 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSValue.h 2016-09-29 19:36:39 UTC (rev 206603)
@@ -137,8 +137,6 @@
RefPtr<CSSValue> cloneForCSSOM() const;
- void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;
-
bool traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const;
bool equals(const CSSValue&) const;
Modified: trunk/Source/WebCore/css/CSSValueList.cpp (206602 => 206603)
--- trunk/Source/WebCore/css/CSSValueList.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSValueList.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -155,12 +155,6 @@
return m_values[0].get().equals(other);
}
-void CSSValueList::addSubresourceStyleURLs(ListHashSet<URL>& urls, const StyleSheetContents* styleSheet) const
-{
- for (unsigned i = 0, size = m_values.size(); i < size; ++i)
- m_values[i].get().addSubresourceStyleURLs(urls, styleSheet);
-}
-
bool CSSValueList::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const
{
for (unsigned i = 0; i < m_values.size(); ++i) {
Modified: trunk/Source/WebCore/css/CSSValueList.h (206602 => 206603)
--- trunk/Source/WebCore/css/CSSValueList.h 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/CSSValueList.h 2016-09-29 19:36:39 UTC (rev 206603)
@@ -72,8 +72,6 @@
bool equals(const CSSValueList&) const;
bool equals(const CSSValue&) const;
- void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;
-
bool traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const;
Ref<CSSValueList> cloneForCSSOM() const;
Modified: trunk/Source/WebCore/css/StyleProperties.cpp (206602 => 206603)
--- trunk/Source/WebCore/css/StyleProperties.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/StyleProperties.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -1113,13 +1113,6 @@
addParsedProperty(other.propertyAt(i).toCSSProperty());
}
-void StyleProperties::addSubresourceStyleURLs(ListHashSet<URL>& urls, StyleSheetContents* contextStyleSheet) const
-{
- unsigned size = propertyCount();
- for (unsigned i = 0; i < size; ++i)
- propertyAt(i).value()->addSubresourceStyleURLs(urls, contextStyleSheet);
-}
-
bool StyleProperties::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const
{
unsigned size = propertyCount();
Modified: trunk/Source/WebCore/css/StyleProperties.h (206602 => 206603)
--- trunk/Source/WebCore/css/StyleProperties.h 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/StyleProperties.h 2016-09-29 19:36:39 UTC (rev 206603)
@@ -96,8 +96,6 @@
CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
- void addSubresourceStyleURLs(ListHashSet<URL>&, StyleSheetContents* contextStyleSheet) const;
-
WEBCORE_EXPORT Ref<MutableStyleProperties> mutableCopy() const;
Ref<ImmutableStyleProperties> immutableCopyIfNeeded() const;
Modified: trunk/Source/WebCore/css/StyleRuleImport.h (206602 => 206603)
--- trunk/Source/WebCore/css/StyleRuleImport.h 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/StyleRuleImport.h 2016-09-29 19:36:39 UTC (rev 206603)
@@ -51,6 +51,7 @@
MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
void requestStyleSheet();
+ const CachedCSSStyleSheet* cachedCSSStyleSheet() const { return m_cachedSheet.get(); }
private:
// NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it
Modified: trunk/Source/WebCore/css/StyleSheetContents.cpp (206602 => 206603)
--- trunk/Source/WebCore/css/StyleSheetContents.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/StyleSheetContents.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -410,29 +410,6 @@
return CSSParser::completeURL(m_parserContext, url);
}
-void StyleSheetContents::addSubresourceStyleURLs(ListHashSet<URL>& urls)
-{
- Deque<StyleSheetContents*> styleSheetQueue;
- styleSheetQueue.append(this);
-
- while (!styleSheetQueue.isEmpty()) {
- StyleSheetContents* styleSheet = styleSheetQueue.takeFirst();
-
- for (auto& importRule : styleSheet->m_importRules) {
- if (importRule->styleSheet()) {
- styleSheetQueue.append(importRule->styleSheet());
- addSubresourceURL(urls, importRule->styleSheet()->baseURL());
- }
- }
- for (auto& rule : styleSheet->m_childRules) {
- if (is<StyleRule>(*rule))
- downcast<StyleRule>(*rule).properties().addSubresourceStyleURLs(urls, this);
- else if (is<StyleRuleFontFace>(*rule))
- downcast<StyleRuleFontFace>(*rule).properties().addSubresourceStyleURLs(urls, this);
- }
- }
-}
-
static bool traverseSubresourcesInRules(const Vector<RefPtr<StyleRuleBase>>& rules, const std::function<bool (const CachedResource&)>& handler)
{
for (auto& rule : rules) {
@@ -477,9 +454,12 @@
bool StyleSheetContents::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const
{
for (auto& importRule : m_importRules) {
- if (!importRule->styleSheet())
- continue;
- if (traverseSubresourcesInRules(importRule->styleSheet()->m_childRules, handler))
+ if (auto* cachedResource = importRule->cachedCSSStyleSheet()) {
+ if (handler(*cachedResource))
+ return true;
+ }
+ auto* importedStyleSheet = importRule->styleSheet();
+ if (importedStyleSheet && importedStyleSheet->traverseSubresources(handler))
return true;
}
return traverseSubresourcesInRules(m_childRules, handler);
Modified: trunk/Source/WebCore/css/StyleSheetContents.h (206602 => 206603)
--- trunk/Source/WebCore/css/StyleSheetContents.h 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/css/StyleSheetContents.h 2016-09-29 19:36:39 UTC (rev 206603)
@@ -86,7 +86,6 @@
bool loadCompleted() const { return m_loadCompleted; }
URL completeURL(const String& url) const;
- void addSubresourceStyleURLs(ListHashSet<URL>&);
bool traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const;
void setIsUserStyleSheet(bool b) { m_isUserStyleSheet = b; }
Modified: trunk/Source/WebCore/dom/StyledElement.cpp (206602 => 206603)
--- trunk/Source/WebCore/dom/StyledElement.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/dom/StyledElement.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -28,6 +28,7 @@
#include "CSSParser.h"
#include "CSSStyleSheet.h"
#include "CSSValuePool.h"
+#include "CachedResource.h"
#include "ContentSecurityPolicy.h"
#include "DOMTokenList.h"
#include "HTMLElement.h"
@@ -266,8 +267,13 @@
void StyledElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const
{
- if (const StyleProperties* inlineStyle = elementData() ? elementData()->inlineStyle() : nullptr)
- inlineStyle->addSubresourceStyleURLs(urls, &document().elementSheet().contents());
+ auto* inlineStyle = this->inlineStyle();
+ if (!inlineStyle)
+ return;
+ inlineStyle->traverseSubresources([&] (auto& resource) {
+ urls.add(resource.url());
+ return false;
+ });
}
static inline bool attributeNameSort(const std::pair<AtomicStringImpl*, AtomicString>& p1, const std::pair<AtomicStringImpl*, AtomicString>& p2)
Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (206602 => 206603)
--- trunk/Source/WebCore/html/HTMLLinkElement.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -530,10 +530,13 @@
// Append the URL of this link element.
addSubresourceURL(urls, href());
-
- // Walk the URLs linked by the linked-to stylesheet.
- if (CSSStyleSheet* styleSheet = const_cast<HTMLLinkElement*>(this)->sheet())
- styleSheet->contents().addSubresourceStyleURLs(urls);
+
+ if (auto* styleSheet = this->sheet()) {
+ styleSheet->contents().traverseSubresources([&] (auto& resource) {
+ urls.add(resource.url());
+ return false;
+ });
+ }
}
void HTMLLinkElement::addPendingSheet(PendingSheetType type)
Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (206602 => 206603)
--- trunk/Source/WebCore/html/HTMLStyleElement.cpp 2016-09-29 19:22:56 UTC (rev 206602)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp 2016-09-29 19:36:39 UTC (rev 206603)
@@ -25,6 +25,7 @@
#include "HTMLStyleElement.h"
#include "AuthorStyleSheets.h"
+#include "CachedResource.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
@@ -142,8 +143,12 @@
{
HTMLElement::addSubresourceAttributeURLs(urls);
- if (CSSStyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet())
- styleSheet->contents().addSubresourceStyleURLs(urls);
+ if (auto* styleSheet = this->sheet()) {
+ styleSheet->contents().traverseSubresources([&] (auto& resource) {
+ urls.add(resource.url());
+ return false;
+ });
+ }
}
bool HTMLStyleElement::disabled() const