CachedResourceRequest constructor should be made more efficient
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Oct 2016 06:42:53 +0000 (06:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Oct 2016 06:42:53 +0000 (06:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163210

Patch by Youenn Fablet <youenn@apple.com> on 2016-10-10
Reviewed by Alex Christensen.

No change of behavior.

Refactoring to use one CachedResourceRequest constructor that will move its request and charset to improve efficiency.

* css/StyleRuleImport.cpp:
(WebCore::StyleRuleImport::requestStyleSheet):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::checkStyleSheet):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* html/parser/HTMLResourcePreloader.cpp:
(WebCore::PreloadRequest::resourceRequest):
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::CachedResourceRequest):
* loader/cache/CachedResourceRequest.h:

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

Source/WebCore/ChangeLog
Source/WebCore/css/StyleRuleImport.cpp
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/parser/HTMLResourcePreloader.cpp
Source/WebCore/loader/cache/CachedResourceRequest.cpp
Source/WebCore/loader/cache/CachedResourceRequest.h

index 9e115e1..d50f8c5 100644 (file)
@@ -1,3 +1,26 @@
+2016-10-10  Youenn Fablet  <youenn@apple.com>
+
+        CachedResourceRequest constructor should be made more efficient
+        https://bugs.webkit.org/show_bug.cgi?id=163210
+
+        Reviewed by Alex Christensen.
+
+        No change of behavior.
+
+        Refactoring to use one CachedResourceRequest constructor that will move its request and charset to improve efficiency.
+
+        * css/StyleRuleImport.cpp:
+        (WebCore::StyleRuleImport::requestStyleSheet):
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::checkStyleSheet):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::process):
+        * html/parser/HTMLResourcePreloader.cpp:
+        (WebCore::PreloadRequest::resourceRequest):
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::CachedResourceRequest):
+        * loader/cache/CachedResourceRequest.h:
+
 2016-10-10  Adam Bergkvist  <adam.bergkvist@ericsson.com> and Alejandro G. Castro <alex@igalia.com>
 
         WebRTC: Make MediaEndpointPeerConnection handle remotely assigned mids correctly
index 012edf1..ff7bc35 100644 (file)
@@ -115,7 +115,7 @@ void StyleRuleImport::requestStyleSheet()
 
     // FIXME: Skip Content Security Policy check when stylesheet is in a user agent shadow tree.
     // See <https://bugs.webkit.org/show_bug.cgi?id=146663>.
-    CachedResourceRequest request(ResourceRequest(absURL), m_parentStyleSheet->charset());
+    CachedResourceRequest request(absURL, CachedResourceLoader::defaultCachedResourceOptions(), Nullopt, String(m_parentStyleSheet->charset()));
     request.setInitiator(cachedResourceRequestInitiators().css);
     if (m_cachedSheet)
         m_cachedSheet->removeClient(m_styleSheetClient);
index 9673dd2..617935f 100644 (file)
@@ -145,11 +145,8 @@ void ProcessingInstruction::checkStyleSheet()
             } else
 #endif
             {
-                CachedResourceRequest request(ResourceRequest(document().completeURL(href)));
                 String charset = attrs.get("charset");
-                if (charset.isEmpty())
-                    charset = document().charset();
-                request.setCharset(charset);
+                CachedResourceRequest request(document().completeURL(href), CachedResourceLoader::defaultCachedResourceOptions(), Nullopt, charset.isEmpty() ? document().charset() : WTFMove(charset));
 
                 m_cachedSheet = document().cachedResourceLoader().requestCSSStyleSheet(WTFMove(request));
             }
index 3f41d6a..2911c4c 100644 (file)
@@ -228,7 +228,7 @@ void HTMLLinkElement::process()
         || (document().settings() && document().settings()->treatsAnyTextCSSLinkAsStylesheet() && m_type.containsIgnoringASCIICase("text/css"));
 
     if (m_disabledState != Disabled && treatAsStyleSheet && document().frame() && url.isValid()) {
-        AtomicString charset = attributeWithoutSynchronization(charsetAttr);
+        String charset = attributeWithoutSynchronization(charsetAttr);
         if (charset.isEmpty() && document().frame())
             charset = document().charset();
 
@@ -261,7 +261,7 @@ void HTMLLinkElement::process()
         Optional<ResourceLoadPriority> priority;
         if (!isActive)
             priority = ResourceLoadPriority::VeryLow;
-        CachedResourceRequest request(url, charset, priority);
+        CachedResourceRequest request(url, CachedResourceLoader::defaultCachedResourceOptions(), priority, WTFMove(charset));
         request.setInitiator(this);
 
         if (document().contentSecurityPolicy()->allowStyleWithNonce(attributeWithoutSynchronization(HTMLNames::nonceAttr))) {
index 5bbd37b..95e645f 100644 (file)
@@ -43,7 +43,7 @@ URL PreloadRequest::completeURL(Document& document)
 CachedResourceRequest PreloadRequest::resourceRequest(Document& document)
 {
     ASSERT(isMainThread());
-    CachedResourceRequest request(ResourceRequest(completeURL(document)));
+    CachedResourceRequest request(completeURL(document), CachedResourceLoader::defaultCachedResourceOptions());
     request.setInitiator(m_initiator);
     request.setAsPotentiallyCrossOrigin(m_crossOriginMode, document);
     return request;
index 916412c..257e4d5 100644 (file)
 
 namespace WebCore {
 
-CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequest, const String& charset, Optional<ResourceLoadPriority> priority)
-    : m_resourceRequest(resourceRequest)
-    , m_charset(charset)
-    , m_options(CachedResourceLoader::defaultCachedResourceOptions())
-    , m_priority(priority)
-{
-}
-
-CachedResourceRequest::CachedResourceRequest(ResourceRequest&& resourceRequest, const ResourceLoaderOptions& options, Optional<ResourceLoadPriority> priority)
+CachedResourceRequest::CachedResourceRequest(ResourceRequest&& resourceRequest, const ResourceLoaderOptions& options, Optional<ResourceLoadPriority> priority, String&& charset)
     : m_resourceRequest(WTFMove(resourceRequest))
+    , m_charset(WTFMove(charset))
     , m_options(options)
     , m_priority(priority)
 {
index b457476..2829410 100644 (file)
@@ -40,8 +40,7 @@ class Document;
 
 class CachedResourceRequest {
 public:
-    explicit CachedResourceRequest(const ResourceRequest&, const String& charset = String(), Optional<ResourceLoadPriority> = Nullopt);
-    CachedResourceRequest(ResourceRequest&&, const ResourceLoaderOptions&, Optional<ResourceLoadPriority> = Nullopt);
+    CachedResourceRequest(ResourceRequest&&, const ResourceLoaderOptions&, Optional<ResourceLoadPriority> = Nullopt, String&& charset = String());
 
     ResourceRequest& mutableResourceRequest() { return m_resourceRequest; }
     const ResourceRequest& resourceRequest() const { return m_resourceRequest; }