Avoid doing unnecessary work in Document::shouldEnforceContentDispositionAttachmentSa...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 May 2018 01:58:33 +0000 (01:58 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 May 2018 01:58:33 +0000 (01:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185964

Reviewed by Geoffrey Garen.

* dom/Document.cpp:
(WebCore::Document::shouldEnforceContentDispositionAttachmentSandbox const):

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

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp

index 67d9de1..8df2112 100644 (file)
@@ -1,5 +1,15 @@
 2018-05-24  Chris Dumez  <cdumez@apple.com>
 
+        Avoid doing unnecessary work in Document::shouldEnforceContentDispositionAttachmentSandbox() when setting is disabled
+        https://bugs.webkit.org/show_bug.cgi?id=185964
+
+        Reviewed by Geoffrey Garen.
+
+        * dom/Document.cpp:
+        (WebCore::Document::shouldEnforceContentDispositionAttachmentSandbox const):
+
+2018-05-24  Chris Dumez  <cdumez@apple.com>
+
         [iOS] Avoid dlopening QuickLooks in the common case where the main resource is HTML or plain text
         https://bugs.webkit.org/show_bug.cgi?id=185966
 
index 6af21a3..3315358 100644 (file)
@@ -7304,15 +7304,15 @@ void Document::applyQuickLookSandbox()
 
 bool Document::shouldEnforceContentDispositionAttachmentSandbox() const
 {
-    if (m_isSynthesized)
+    if (!settings().contentDispositionAttachmentSandboxEnabled())
         return false;
 
-    bool contentDispositionAttachmentSandboxEnabled = settings().contentDispositionAttachmentSandboxEnabled();
-    bool responseIsAttachment = false;
-    if (DocumentLoader* documentLoader = m_frame ? m_frame->loader().activeDocumentLoader() : nullptr)
-        responseIsAttachment = documentLoader->response().isAttachment();
+    if (m_isSynthesized)
+        return false;
 
-    return contentDispositionAttachmentSandboxEnabled && responseIsAttachment;
+    if (auto* documentLoader = m_frame ? m_frame->loader().activeDocumentLoader() : nullptr)
+        return documentLoader->response().isAttachment();
+    return false;
 }
 
 void Document::applyContentDispositionAttachmentSandbox()