Fix post-landing nits after r206561.
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2016 21:28:45 +0000 (21:28 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2016 21:28:45 +0000 (21:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162659

Reviewed by Alex Christensen.

Uses more StringViews and constness.

* dom/SecurityContext.cpp:
(WebCore::SecurityContext::isSupportedSandboxPolicy):
* dom/SecurityContext.h:
* html/DOMTokenList.cpp:
(WebCore::DOMTokenList::DOMTokenList):
(WebCore::DOMTokenList::supports):
* html/DOMTokenList.h:
(WebCore::DOMTokenList::DOMTokenList):
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::relList):
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::sandbox):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::relList):
* html/LinkRelAttribute.cpp:
(WebCore::LinkRelAttribute::isSupported):
* html/LinkRelAttribute.h:

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

Source/WebCore/ChangeLog
Source/WebCore/dom/SecurityContext.cpp
Source/WebCore/dom/SecurityContext.h
Source/WebCore/html/DOMTokenList.cpp
Source/WebCore/html/DOMTokenList.h
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/html/HTMLIFrameElement.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/LinkRelAttribute.cpp
Source/WebCore/html/LinkRelAttribute.h

index 4c47aaa..08cca35 100644 (file)
@@ -1,3 +1,30 @@
+2016-09-29  Chris Dumez  <cdumez@apple.com>
+
+        Fix post-landing nits after r206561.
+        https://bugs.webkit.org/show_bug.cgi?id=162659
+
+        Reviewed by Alex Christensen.
+
+        Uses more StringViews and constness.
+
+        * dom/SecurityContext.cpp:
+        (WebCore::SecurityContext::isSupportedSandboxPolicy):
+        * dom/SecurityContext.h:
+        * html/DOMTokenList.cpp:
+        (WebCore::DOMTokenList::DOMTokenList):
+        (WebCore::DOMTokenList::supports):
+        * html/DOMTokenList.h:
+        (WebCore::DOMTokenList::DOMTokenList):
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::relList):
+        * html/HTMLIFrameElement.cpp:
+        (WebCore::HTMLIFrameElement::sandbox):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::relList):
+        * html/LinkRelAttribute.cpp:
+        (WebCore::LinkRelAttribute::isSupported):
+        * html/LinkRelAttribute.h:
+
 2016-09-29  Alex Christensen  <achristensen@webkit.org>
 
         URLParser should correctly parse ports with leading 0's
index 15ffe7e..23420a0 100644 (file)
@@ -85,9 +85,9 @@ void SecurityContext::enforceSandboxFlags(SandboxFlags mask)
         setSecurityOriginPolicy(SecurityOriginPolicy::create(SecurityOrigin::createUnique()));
 }
 
-bool SecurityContext::isSupportedSandboxPolicy(const String& policy)
+bool SecurityContext::isSupportedSandboxPolicy(StringView policy)
 {
-    static const char* supportedPolicies[] = {
+    static const char* const supportedPolicies[] = {
         "allow-forms", "allow-same-origin", "allow-scripts", "allow-top-navigation", "allow-pointer-lock", "allow-popups"
     };
 
index 069d31b..3cc20fe 100644 (file)
@@ -75,7 +75,7 @@ public:
     WEBCORE_EXPORT SecurityOrigin* securityOrigin() const;
 
     static SandboxFlags parseSandboxPolicy(const String& policy, String& invalidTokensErrorMessage);
-    static bool isSupportedSandboxPolicy(const String&);
+    static bool isSupportedSandboxPolicy(StringView);
 
     bool foundMixedContent() const { return m_foundMixedContent; }
     void setFoundMixedContent() { m_foundMixedContent = true; }
index ed373a0..a2ad083 100644 (file)
@@ -36,7 +36,7 @@
 
 namespace WebCore {
 
-DOMTokenList::DOMTokenList(Element& element, const QualifiedName& attributeName, WTF::Function<bool(const String&)>&& isSupportedToken)
+DOMTokenList::DOMTokenList(Element& element, const QualifiedName& attributeName, WTF::Function<bool(StringView)>&& isSupportedToken)
     : m_element(element)
     , m_attributeName(attributeName)
     , m_isSupportedToken(WTFMove(isSupportedToken))
@@ -179,7 +179,7 @@ void DOMTokenList::replace(const AtomicString& token, const AtomicString& newTok
 }
 
 // https://dom.spec.whatwg.org/#concept-domtokenlist-validation
-bool DOMTokenList::supports(const String& token, ExceptionCode& ec)
+bool DOMTokenList::supports(StringView token, ExceptionCode& ec)
 {
     if (!m_isSupportedToken) {
         ec = TypeError;
index c8318a3..8595803 100644 (file)
@@ -32,7 +32,7 @@ namespace WebCore {
 class DOMTokenList {
     WTF_MAKE_NONCOPYABLE(DOMTokenList); WTF_MAKE_FAST_ALLOCATED;
 public:
-    DOMTokenList(Element&, const QualifiedName& attributeName, WTF::Function<bool(const String&)>&& isSupportedToken = { });
+    DOMTokenList(Element&, const QualifiedName& attributeName, WTF::Function<bool(StringView)>&& isSupportedToken = { });
 
     void associatedAttributeValueChanged(const AtomicString&);
 
@@ -49,7 +49,7 @@ public:
     void remove(const AtomicString&, ExceptionCode&);
     WEBCORE_EXPORT bool toggle(const AtomicString&, Optional<bool> force, ExceptionCode&);
     void replace(const AtomicString& token, const AtomicString& newToken, ExceptionCode&);
-    bool supports(const String& token, ExceptionCode&);
+    bool supports(StringView token, ExceptionCode&);
 
     Element& element() const { return m_element; }
 
@@ -73,7 +73,7 @@ private:
     bool m_inUpdateAssociatedAttributeFromTokens { false };
     bool m_tokensNeedUpdating { true };
     Vector<AtomicString> m_tokens;
-    WTF::Function<bool(const String&)> m_isSupportedToken;
+    WTF::Function<bool(StringView)> m_isSupportedToken;
 };
 
 inline unsigned DOMTokenList::length() const
index 5a9c2e4..4329e16 100644 (file)
@@ -303,7 +303,7 @@ bool HTMLAnchorElement::hasRel(uint32_t relation) const
 DOMTokenList& HTMLAnchorElement::relList()
 {
     if (!m_relList) 
-        m_relList = std::make_unique<DOMTokenList>(*this, HTMLNames::relAttr, [](const String& token) {
+        m_relList = std::make_unique<DOMTokenList>(*this, HTMLNames::relAttr, [](StringView token) {
             return equalIgnoringASCIICase(token, "noreferrer");
         });
     return *m_relList;
index 4aa0151..d30322d 100644 (file)
@@ -51,7 +51,7 @@ Ref<HTMLIFrameElement> HTMLIFrameElement::create(const QualifiedName& tagName, D
 DOMTokenList& HTMLIFrameElement::sandbox()
 {
     if (!m_sandbox)
-        m_sandbox = std::make_unique<DOMTokenList>(*this, sandboxAttr, [](const String& token) {
+        m_sandbox = std::make_unique<DOMTokenList>(*this, sandboxAttr, [](StringView token) {
             return SecurityContext::isSupportedSandboxPolicy(token);
         });
     return *m_sandbox;
index 449cd47..b89176d 100644 (file)
@@ -444,7 +444,7 @@ void HTMLLinkElement::dispatchPendingEvent(LinkEventSender* eventSender)
 DOMTokenList& HTMLLinkElement::relList()
 {
     if (!m_relList) 
-        m_relList = std::make_unique<DOMTokenList>(*this, HTMLNames::relAttr, [](const String& token) {
+        m_relList = std::make_unique<DOMTokenList>(*this, HTMLNames::relAttr, [](StringView token) {
             return LinkRelAttribute::isSupported(token);
         });
     return *m_relList;
index a7d4775..b76955c 100644 (file)
@@ -88,9 +88,9 @@ LinkRelAttribute::LinkRelAttribute(const String& rel)
 }
 
 // https://html.spec.whatwg.org/#linkTypes
-bool LinkRelAttribute::isSupported(const String& attribute)
+bool LinkRelAttribute::isSupported(StringView attribute)
 {
-    static const char* supportedAttributes[] = {
+    static const char* const supportedAttributes[] = {
         "alternate", "dns-prefetch", "icon", "stylesheet", "apple-touch-icon", "apple-touch-icon-precomposed",
 #if ENABLE(LINK_PREFETCH)
         "prefetch", "subresource",
index fc28a99..6b009a2 100644 (file)
@@ -53,7 +53,7 @@ struct LinkRelAttribute {
     LinkRelAttribute();
     explicit LinkRelAttribute(const String&);
 
-    static bool isSupported(const String&);
+    static bool isSupported(StringView);
 };
 
 }