Title: [169978] trunk/Source/WebCore
Revision
169978
Author
[email protected]
Date
2014-06-14 13:33:49 -0700 (Sat, 14 Jun 2014)

Log Message

Simplify Document::processHttpEquiv
https://bugs.webkit.org/show_bug.cgi?id=133910

Reviewed by Andreas Kling.

* dom/Document.cpp:
(WebCore::Document::processHttpEquiv):
* platform/network/HTTPHeaderNames.in:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (169977 => 169978)


--- trunk/Source/WebCore/ChangeLog	2014-06-14 19:39:19 UTC (rev 169977)
+++ trunk/Source/WebCore/ChangeLog	2014-06-14 20:33:49 UTC (rev 169978)
@@ -1,3 +1,14 @@
+2014-06-14  Anders Carlsson  <[email protected]>
+
+        Simplify Document::processHttpEquiv
+        https://bugs.webkit.org/show_bug.cgi?id=133910
+
+        Reviewed by Andreas Kling.
+
+        * dom/Document.cpp:
+        (WebCore::Document::processHttpEquiv):
+        * platform/network/HTTPHeaderNames.in:
+
 2014-06-14  Andreas Kling  <[email protected]>
 
         GCController should return FastMalloc memory to the system.

Modified: trunk/Source/WebCore/dom/Document.cpp (169977 => 169978)


--- trunk/Source/WebCore/dom/Document.cpp	2014-06-14 19:39:19 UTC (rev 169977)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-06-14 20:33:49 UTC (rev 169978)
@@ -83,6 +83,7 @@
 #include "HTMLScriptElement.h"
 #include "HTMLStyleElement.h"
 #include "HTMLTitleElement.h"
+#include "HTTPHeaderNames.h"
 #include "HTTPParsers.h"
 #include "HashChangeEvent.h"
 #include "History.h"
@@ -2787,17 +2788,24 @@
 
     Frame* frame = this->frame();
 
-    if (equalIgnoringCase(equiv, "default-style")) {
-        // The preferred style set has been overridden as per section 
+    HTTPHeaderName headerName;
+    if (!findHTTPHeaderName(equiv, headerName))
+        return;
+
+    switch (headerName) {
+    case HTTPHeaderName::DefaultStyle:
+        // The preferred style set has been overridden as per section
         // 14.3.2 of the HTML4.0 specification.  We need to update the
-        // sheet used variable and then update our style selector. 
+        // sheet used variable and then update our style selector.
         // For more info, see the test at:
         // http://www.hixie.ch/tests/evil/css/import/main/preferred.html
         // -dwh
         m_styleSheetCollection.setSelectedStylesheetSetName(content);
         m_styleSheetCollection.setPreferredStylesheetSetName(content);
         styleResolverChanged(DeferRecalcStyle);
-    } else if (equalIgnoringCase(equiv, "refresh")) {
+        break;
+
+    case HTTPHeaderName::Refresh: {
         double delay;
         String urlString;
         if (frame && parseHTTPRefresh(content, true, delay, urlString)) {
@@ -2813,17 +2821,27 @@
                 addConsoleMessage(MessageSource::Security, MessageLevel::Error, message);
             }
         }
-    } else if (equalIgnoringCase(equiv, "set-cookie")) {
+
+        break;
+    }
+
+    case HTTPHeaderName::SetCookie:
         // FIXME: make setCookie work on XML documents too; e.g. in case of <html:meta .....>
         if (isHTMLDocument()) {
             // Exception (for sandboxed documents) ignored.
             toHTMLDocument(this)->setCookie(content, IGNORE_EXCEPTION);
         }
-    } else if (equalIgnoringCase(equiv, "content-language"))
+        break;
+
+    case HTTPHeaderName::ContentLanguage:
         setContentLanguage(content);
-    else if (equalIgnoringCase(equiv, "x-dns-prefetch-control"))
+        break;
+
+    case HTTPHeaderName::XDNSPrefetchControl:
         parseDNSPrefetchControlHeader(content);
-    else if (equalIgnoringCase(equiv, "x-frame-options")) {
+        break;
+
+    case HTTPHeaderName::XFrameOptions:
         if (frame) {
             FrameLoader& frameLoader = frame->loader();
             unsigned long requestIdentifier = 0;
@@ -2839,14 +2857,27 @@
                 addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, requestIdentifier);
             }
         }
-    } else if (equalIgnoringCase(equiv, "content-security-policy"))
+        break;
+
+    case HTTPHeaderName::ContentSecurityPolicy:
         contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy::Enforce);
-    else if (equalIgnoringCase(equiv, "content-security-policy-report-only"))
+        break;
+
+    case HTTPHeaderName::ContentSecurityPolicyReportOnly:
         contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy::Report);
-    else if (equalIgnoringCase(equiv, "x-webkit-csp"))
+        break;
+
+    case HTTPHeaderName::XWebKitCSP:
         contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy::PrefixedEnforce);
-    else if (equalIgnoringCase(equiv, "x-webkit-csp-report-only"))
+        break;
+
+    case HTTPHeaderName::XWebKitCSPReportOnly:
         contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy::PrefixedReport);
+        break;
+
+    default:
+        break;
+    }
 }
 
 // Though isspace() considers \t and \v to be whitespace, Win IE doesn't.

Modified: trunk/Source/WebCore/platform/network/HTTPHeaderNames.in (169977 => 169978)


--- trunk/Source/WebCore/platform/network/HTTPHeaderNames.in	2014-06-14 19:39:19 UTC (rev 169977)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderNames.in	2014-06-14 20:33:49 UTC (rev 169978)
@@ -29,9 +29,13 @@
 Authorization
 Cache-Control
 Connection
+Content-Language
 Content-Length
+Content-Security-Policy
+Content-Security-Policy-Report-Only
 Content-Type
 Cookie
+Default-Style
 Host
 If-Match
 If-Modified-Since
@@ -47,6 +51,7 @@
 Pragma
 Range
 Referer
+Refresh
 Sec-WebSocket-Accept
 Sec-WebSocket-Extensions
 Sec-WebSocket-Key
@@ -56,7 +61,10 @@
 Set-Cookie2
 Upgrade
 User-Agent
+X-DNS-Prefetch-Control
 X-Frame-Options
+X-WebKit-CSP
+X-WebKit-CSP-Report-Only
 
 // These headers are specific to GStreamer.
 Icy-Metadata
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to