CachedXSLStylesheet does not need to be updated according Origin/Fetch mode
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Oct 2016 06:18:37 +0000 (06:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Oct 2016 06:18:37 +0000 (06:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162389

Patch by Youenn Fablet <youenn@apple.com> on 2016-10-06
Reviewed by Darin Adler.

No change of behavior.

Making clear that there is no reason to update cached XSLT resources according the origin, given that CORS is never checked and loading is always same-origin.

Renaming CachedResource::isClean to CachedResource::isCORSSameOrigin to better match spec terminology.
Updating HTMLLinkElement accordingly.

* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::initializeStyleSheet):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::isCORSSameOrigin): Ensuring that this method is not called for resource types for which CORS is not to be used.
(WebCore::CachedResource::isClean): Deleted.
* loader/cache/CachedResource.h:
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206902 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp

index c6d434a..3568802 100644 (file)
@@ -1,5 +1,28 @@
 2016-10-06  Youenn Fablet  <youenn@apple.com>
 
+        CachedXSLStylesheet does not need to be updated according Origin/Fetch mode
+        https://bugs.webkit.org/show_bug.cgi?id=162389
+
+        Reviewed by Darin Adler.
+
+        No change of behavior.
+
+        Making clear that there is no reason to update cached XSLT resources according the origin, given that CORS is never checked and loading is always same-origin.
+
+        Renaming CachedResource::isClean to CachedResource::isCORSSameOrigin to better match spec terminology.
+        Updating HTMLLinkElement accordingly.
+
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::initializeStyleSheet):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::isCORSSameOrigin): Ensuring that this method is not called for resource types for which CORS is not to be used.
+        (WebCore::CachedResource::isClean): Deleted.
+        * loader/cache/CachedResource.h:
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest):
+
+2016-10-06  Youenn Fablet  <youenn@apple.com>
+
         Add a place for common HTTP Header values
         https://bugs.webkit.org/show_bug.cgi?id=163002
 
index 1fc971c..866d866 100644 (file)
@@ -341,7 +341,7 @@ void HTMLLinkElement::initializeStyleSheet(Ref<StyleSheetContents>&& styleSheet,
     // FIXME: originClean should be turned to false except if fetch mode is CORS.
     Optional<bool> originClean;
     if (cachedStyleSheet.options().mode == FetchOptions::Mode::Cors)
-        originClean = cachedStyleSheet.isClean();
+        originClean = cachedStyleSheet.isCORSSameOrigin();
 
     m_sheet = CSSStyleSheet::create(WTFMove(styleSheet), *this, originClean);
     m_sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(m_media));
index 93105ca..c095c9d 100644 (file)
@@ -442,8 +442,13 @@ bool CachedResource::isCrossOrigin() const
     return m_responseTainting != ResourceResponse::Tainting::Basic;
 }
 
-bool CachedResource::isClean() const
+bool CachedResource::isCORSSameOrigin() const
 {
+    // Following resource types do not use CORS
+    ASSERT(type() != CachedResource::Type::FontResource);
+    ASSERT(type() != CachedResource::Type::SVGFontResource);
+    ASSERT(type() != CachedResource::XSLStyleSheet);
+
     // https://html.spec.whatwg.org/multipage/infrastructure.html#cors-same-origin
     return !loadFailedOrCanceled() && m_responseTainting != ResourceResponse::Tainting::Opaque;
 }
index 6791df8..bea9e38 100644 (file)
@@ -208,7 +208,7 @@ public:
 
     void setCrossOrigin();
     bool isCrossOrigin() const;
-    bool isClean() const;
+    bool isCORSSameOrigin() const;
     ResourceResponse::Tainting responseTainting() const { return m_responseTainting; }
 
     void loadFrom(const CachedResource&);
index 364d440..11c6476 100644 (file)
@@ -549,6 +549,12 @@ bool CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest(const Ca
         return false;
     }
 
+#if ENABLE(XSLT)
+    // Load is same-origin, we do not check for CORS.
+    if (resource.type() == CachedResource::XSLStyleSheet)
+        return false;
+#endif
+
     // FIXME: We should enable resource reuse for these resource types
     switch (resource.type()) {
     case CachedResource::SVGDocumentResource:
@@ -559,10 +565,6 @@ bool CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest(const Ca
         return false;
     case CachedResource::MainResource:
         return false;
-#if ENABLE(XSLT)
-    case CachedResource::XSLStyleSheet:
-        return false;
-#endif
 #if ENABLE(LINK_PREFETCH)
     case CachedResource::LinkPrefetch:
         return false;