Title: [216102] trunk/Source
Revision
216102
Author
[email protected]
Date
2017-05-02 15:51:40 -0700 (Tue, 02 May 2017)

Log Message

Using StringView.split() instead of String.split() in some places
https://bugs.webkit.org/show_bug.cgi?id=170925

Reviewed by Darin Adler.

Source/WebCore:

Replace some uses of String.split() with StringView.split() (added in r211087) as the latter
avoids the need to allocate an intermediary Vector of substrings. Instead StringView.split()
returns an iterator for traversing the substrings.

No functionality changed. So, no new tests.

* accessibility/AccessibilityObject.cpp: Convert some typedefs to modern C++ using declarations.
(WebCore::ASCIICaseInsensitiveStringViewHashTranslator::hash): Added.
(WebCore::ASCIICaseInsensitiveStringViewHashTranslator::equal): Added.
(WebCore::AccessibilityObject::ariaRoleToWebCoreRole): Modified code to use StringView.split().
(WebCore::AccessibilityObject::elementsFromAttribute): Ditto.
* dom/TreeScope.cpp:
(WebCore::TreeScope::getElementById): Added.
* dom/TreeScope.h:
* html/LinkRelAttribute.cpp:
(WebCore::LinkRelAttribute::LinkRelAttribute): Modified code to use StringView.split().
* html/parser/XSSAuditor.cpp:
(WebCore::semicolonSeparatedValueContainsJavaScriptURL): Ditto.
* platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
(WebCore::CDMPrivateMediaSourceAVFObjC::createSession): Ditto.
* platform/network/CacheValidation.cpp:
(WebCore::collectVaryingRequestHeaders): Simplify code by using the String.split(UChar, Vector<String>&) overload.
* svg/SVGAnimationElement.cpp:
(WebCore::parseKeyTimes): Modified code to use StringView.split().
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter): Ditto.
* testing/Internals.cpp:
(WebCore::Internals::setMediaSessionRestrictions): Ditto.
(WebCore::Internals::setMediaElementRestrictions): Ditto.
(WebCore::Internals::setAudioContextRestrictions): Ditto.
(WebCore::Internals::setPageMuted): Ditto.
* testing/Internals.h:

Source/WTF:

Add HashMap::get() overload that takes a HashTranslator.

* wtf/HashMap.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (216101 => 216102)


--- trunk/Source/WTF/ChangeLog	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WTF/ChangeLog	2017-05-02 22:51:40 UTC (rev 216102)
@@ -1,3 +1,14 @@
+2017-05-02  Daniel Bates  <[email protected]>
+
+        Using StringView.split() instead of String.split() in some places
+        https://bugs.webkit.org/show_bug.cgi?id=170925
+
+        Reviewed by Darin Adler.
+
+        Add HashMap::get() overload that takes a HashTranslator.
+
+        * wtf/HashMap.h:
+
 2017-05-01  Dan Bernstein  <[email protected]>
 
         [Xcode] It’s easy to accidentally install a WTF header outside /usr/local/include/wtf

Modified: trunk/Source/WTF/wtf/HashMap.h (216101 => 216102)


--- trunk/Source/WTF/wtf/HashMap.h	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WTF/wtf/HashMap.h	2017-05-02 22:51:40 UTC (rev 216102)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2008, 2011, 2013, 2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -65,6 +65,8 @@
     class HashMapKeysProxy;
     class HashMapValuesProxy;
 
+    using IdentityTranslatorType = typename HashTableType::IdentityTranslatorType;
+
 public:
     typedef HashTableIteratorAdapter<HashTableType, KeyValuePairType> iterator;
     typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePairType> const_iterator;
@@ -142,6 +144,7 @@
     template<typename HashTranslator, typename T> iterator find(const T&);
     template<typename HashTranslator, typename T> const_iterator find(const T&) const;
     template<typename HashTranslator, typename T> bool contains(const T&) const;
+    template<typename HashTranslator, typename T> MappedPeekType get(const T&) const;
 
     // An alternate version of add() that finds the object by hashing and comparing
     // with some other type, to avoid the cost of type conversion if the object is already
@@ -294,6 +297,16 @@
 
 template<typename T, typename U, typename V, typename W, typename X>
 template<typename HashTranslator, typename TYPE>
+auto HashMap<T, U, V, W, X>::get(const TYPE& value) const -> MappedPeekType
+{
+    auto* entry = const_cast<HashTableType&>(m_impl).template lookup<HashMapTranslatorAdapter<KeyValuePairTraits, HashTranslator>>(value);
+    if (!entry)
+        return MappedTraits::peek(MappedTraits::emptyValue());
+    return MappedTraits::peek(entry->value);
+}
+
+template<typename T, typename U, typename V, typename W, typename X>
+template<typename HashTranslator, typename TYPE>
 inline bool HashMap<T, U, V, W, X>::contains(const TYPE& value) const
 {
     return m_impl.template contains<HashMapTranslatorAdapter<KeyValuePairTraits, HashTranslator>>(value);
@@ -389,18 +402,15 @@
 }
     
 template<typename T, typename U, typename V, typename W, typename MappedTraits>
-auto HashMap<T, U, V, W, MappedTraits>::get(const KeyType& key) const -> MappedPeekType
+inline auto HashMap<T, U, V, W, MappedTraits>::get(const KeyType& key) const -> MappedPeekType
 {
-    KeyValuePairType* entry = const_cast<HashTableType&>(m_impl).lookup(key);
-    if (!entry)
-        return MappedTraits::peek(MappedTraits::emptyValue());
-    return MappedTraits::peek(entry->value);
+    return get<IdentityTranslatorType>(key);
 }
 
 template<typename T, typename U, typename V, typename W, typename MappedTraits>
 ALWAYS_INLINE auto HashMap<T, U, V, W, MappedTraits>::fastGet(const KeyType& key) const -> MappedPeekType
 {
-    KeyValuePairType* entry = const_cast<HashTableType&>(m_impl).template inlineLookup<typename HashTableType::IdentityTranslatorType>(key);
+    KeyValuePairType* entry = const_cast<HashTableType&>(m_impl).template inlineLookup<IdentityTranslatorType>(key);
     if (!entry)
         return MappedTraits::peek(MappedTraits::emptyValue());
     return MappedTraits::peek(entry->value);

Modified: trunk/Source/WTF/wtf/text/StringHash.h (216101 => 216102)


--- trunk/Source/WTF/wtf/text/StringHash.h	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WTF/wtf/text/StringHash.h	2017-05-02 22:51:40 UTC (rev 216102)
@@ -175,6 +175,22 @@
         }
     };
 
+    // FIXME: Find a way to incorporate this functionality into ASCIICaseInsensitiveHash and allow
+    // a HashMap whose keys are type String to perform operations when given a key of type StringView.
+    struct ASCIICaseInsensitiveStringViewHashTranslator {
+    static unsigned hash(StringView key)
+    {
+        if (key.is8Bit())
+            return ASCIICaseInsensitiveHash::hash(key.characters8(), key.length());
+        return ASCIICaseInsensitiveHash::hash(key.characters16(), key.length());
+    }
+
+    static bool equal(const String& a, StringView b)
+    {
+        return equalIgnoringASCIICaseCommon(a, b);
+    }
+    };
+
 }
 
 using WTF::ASCIICaseInsensitiveHash;

Modified: trunk/Source/WebCore/ChangeLog (216101 => 216102)


--- trunk/Source/WebCore/ChangeLog	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/ChangeLog	2017-05-02 22:51:40 UTC (rev 216102)
@@ -1,3 +1,43 @@
+2017-05-02  Daniel Bates  <[email protected]>
+
+        Using StringView.split() instead of String.split() in some places
+        https://bugs.webkit.org/show_bug.cgi?id=170925
+
+        Reviewed by Darin Adler.
+
+        Replace some uses of String.split() with StringView.split() (added in r211087) as the latter
+        avoids the need to allocate an intermediary Vector of substrings. Instead StringView.split()
+        returns an iterator for traversing the substrings.
+
+        No functionality changed. So, no new tests.
+
+        * accessibility/AccessibilityObject.cpp: Convert some typedefs to modern C++ using declarations.
+        (WebCore::ASCIICaseInsensitiveStringViewHashTranslator::hash): Added.
+        (WebCore::ASCIICaseInsensitiveStringViewHashTranslator::equal): Added.
+        (WebCore::AccessibilityObject::ariaRoleToWebCoreRole): Modified code to use StringView.split().
+        (WebCore::AccessibilityObject::elementsFromAttribute): Ditto.
+        * dom/TreeScope.cpp:
+        (WebCore::TreeScope::getElementById): Added.
+        * dom/TreeScope.h:
+        * html/LinkRelAttribute.cpp:
+        (WebCore::LinkRelAttribute::LinkRelAttribute): Modified code to use StringView.split().
+        * html/parser/XSSAuditor.cpp:
+        (WebCore::semicolonSeparatedValueContainsJavaScriptURL): Ditto.
+        * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
+        (WebCore::CDMPrivateMediaSourceAVFObjC::createSession): Ditto.
+        * platform/network/CacheValidation.cpp:
+        (WebCore::collectVaryingRequestHeaders): Simplify code by using the String.split(UChar, Vector<String>&) overload.
+        * svg/SVGAnimationElement.cpp:
+        (WebCore::parseKeyTimes): Modified code to use StringView.split().
+        * svg/SVGToOTFFontConversion.cpp:
+        (WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter): Ditto.
+        * testing/Internals.cpp:
+        (WebCore::Internals::setMediaSessionRestrictions): Ditto.
+        (WebCore::Internals::setMediaElementRestrictions): Ditto.
+        (WebCore::Internals::setAudioContextRestrictions): Ditto.
+        (WebCore::Internals::setPageMuted): Ditto.
+        * testing/Internals.h:
+
 2017-05-02  Gwang Yoon Hwang  <[email protected]>
 
         [GTK] Drop coordinated surfaces from the compositing thread as soon as possible

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (216101 => 216102)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2017-05-02 22:51:40 UTC (rev 216102)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2009, 2011, 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -74,6 +74,7 @@
 #include <wtf/NeverDestroyed.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/StringBuilder.h>
+#include <wtf/text/StringView.h>
 #include <wtf/text/WTFString.h>
 #include <wtf/unicode/CharacterNames.h>
 
@@ -2132,8 +2133,8 @@
     return nullptr;
 }
 
-typedef HashMap<String, AccessibilityRole, ASCIICaseInsensitiveHash> ARIARoleMap;
-typedef HashMap<AccessibilityRole, String, DefaultHash<int>::Hash, WTF::UnsignedWithZeroKeyHashTraits<int>> ARIAReverseRoleMap;
+using ARIARoleMap = HashMap<String, AccessibilityRole, ASCIICaseInsensitiveHash>;
+using ARIAReverseRoleMap = HashMap<AccessibilityRole, String, DefaultHash<int>::Hash, WTF::UnsignedWithZeroKeyHashTraits<int>>;
 
 static ARIARoleMap* gAriaRoleMap = nullptr;
 static ARIAReverseRoleMap* gAriaReverseRoleMap = nullptr;
@@ -2287,17 +2288,11 @@
 AccessibilityRole AccessibilityObject::ariaRoleToWebCoreRole(const String& value)
 {
     ASSERT(!value.isEmpty());
-    
-    Vector<String> roleVector;
-    value.split(' ', roleVector);
-    AccessibilityRole role = UnknownRole;
-    for (const auto& roleName : roleVector) {
-        role = ariaRoleMap().get(roleName);
-        if (role)
+    for (auto roleName : StringView(value).split(' ')) {
+        if (AccessibilityRole role = ariaRoleMap().get<ASCIICaseInsensitiveStringViewHashTranslator>(roleName))
             return role;
     }
-    
-    return role;
+    return UnknownRole;
 }
 
 String AccessibilityObject::computedRoleString() const
@@ -3176,11 +3171,8 @@
         return;
 
     idList.replace('\n', ' ');
-    Vector<String> idVector;
-    idList.split(' ', idVector);
-
-    for (const auto& idName : idVector) {
-        if (Element* idElement = treeScope.getElementById(idName))
+    for (auto idName : StringView(idList).split(' ')) {
+        if (auto* idElement = treeScope.getElementById(idName))
             elements.append(idElement);
     }
 }

Modified: trunk/Source/WebCore/dom/TreeScope.cpp (216101 => 216102)


--- trunk/Source/WebCore/dom/TreeScope.cpp	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/dom/TreeScope.cpp	2017-05-02 22:51:40 UTC (rev 216102)
@@ -114,6 +114,17 @@
     return nullptr;
 }
 
+Element* TreeScope::getElementById(StringView elementId) const
+{
+    if (!m_elementsById)
+        return nullptr;
+
+    if (auto atomicElementId = elementId.toExistingAtomicString())
+        return m_elementsById->getElementById(*atomicElementId, *this);
+
+    return nullptr;
+}
+
 const Vector<Element*>* TreeScope::getAllElementsById(const AtomicString& elementId) const
 {
     if (elementId.isEmpty())

Modified: trunk/Source/WebCore/dom/TreeScope.h (216101 => 216102)


--- trunk/Source/WebCore/dom/TreeScope.h	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/dom/TreeScope.h	2017-05-02 22:51:40 UTC (rev 216102)
@@ -56,6 +56,7 @@
 
     WEBCORE_EXPORT Element* getElementById(const AtomicString&) const;
     WEBCORE_EXPORT Element* getElementById(const String&) const;
+    Element* getElementById(StringView) const;
     const Vector<Element*>* getAllElementsById(const AtomicString&) const;
     bool hasElementWithId(const AtomicStringImpl&) const;
     bool containsMultipleElementsWithId(const AtomicString& id) const;

Modified: trunk/Source/WebCore/html/LinkRelAttribute.cpp (216101 => 216102)


--- trunk/Source/WebCore/html/LinkRelAttribute.cpp	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/html/LinkRelAttribute.cpp	2017-05-02 22:51:40 UTC (rev 216102)
@@ -34,6 +34,7 @@
 
 #include "LinkIconType.h"
 #include "RuntimeEnabledFeatures.h"
+#include <wtf/text/StringView.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -64,9 +65,7 @@
         // Tokenize the rel attribute and set bits based on specific keywords that we find.
         String relCopy = rel;
         relCopy.replace('\n', ' ');
-        Vector<String> list;
-        relCopy.split(' ', list);
-        for (auto& word : list) {
+        for (auto word : StringView(relCopy).split(' ')) {
             if (equalLettersIgnoringASCIICase(word, "stylesheet"))
                 isStyleSheet = true;
             else if (equalLettersIgnoringASCIICase(word, "alternate"))

Modified: trunk/Source/WebCore/html/parser/XSSAuditor.cpp (216101 => 216102)


--- trunk/Source/WebCore/html/parser/XSSAuditor.cpp	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/html/parser/XSSAuditor.cpp	2017-05-02 22:51:40 UTC (rev 216102)
@@ -43,6 +43,7 @@
 #include <wtf/ASCIICType.h>
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -238,11 +239,9 @@
     return threadSafeMatch(attribute.name, SVGNames::valuesAttr);
 }
 
-static bool semicolonSeparatedValueContainsJavaScriptURL(const String& value)
+static bool semicolonSeparatedValueContainsJavaScriptURL(StringView semicolonSeparatedValue)
 {
-    Vector<String> valueList;
-    value.split(';', valueList);
-    for (auto& value : valueList) {
+    for (auto value : semicolonSeparatedValue.split(';')) {
         if (protocolIsJavaScript(value))
             return true;
     }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm (216101 => 216102)


--- trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm	2017-05-02 22:51:40 UTC (rev 216102)
@@ -35,6 +35,7 @@
 #import "MediaPlayerPrivateMediaSourceAVFObjC.h"
 #import "WebCoreSystemInterface.h"
 #import <wtf/NeverDestroyed.h>
+#import <wtf/text/StringView.h>
 #import <yarr/RegularExpression.h>
 
 using JSC::Yarr::RegularExpression;
@@ -101,18 +102,16 @@
 
 std::unique_ptr<CDMSession> CDMPrivateMediaSourceAVFObjC::createSession(CDMSessionClient* client)
 {
-    String keySystem = m_cdm->keySystem();
+    String keySystem = m_cdm->keySystem(); // Local copy for StringView usage
+    StringView keySystemStringView { keySystem };
     ASSERT(validKeySystemRE().match(keySystem) >= 0);
 
-    Vector<String> protocolVersionsStrings;
-    keySystem.substring(16).split(',', false, protocolVersionsStrings);
-
     Vector<int> protocolVersions;
-    for (auto& protocolVersionString : protocolVersionsStrings)
+    for (StringView protocolVersionString : keySystemStringView.substring(16).split(','))
         protocolVersions.append(protocolVersionString.toInt());
 
     std::unique_ptr<CDMSessionMediaSourceAVFObjC> session;
-    if (keySystem.substring(14, 1).toInt() == 3 && CDMSessionAVContentKeySession::isAvailable())
+    if (keySystemStringView.substring(14, 1).toInt() == 3 && CDMSessionAVContentKeySession::isAvailable())
         session = std::make_unique<CDMSessionAVContentKeySession>(protocolVersions, *this, client);
     else
         session = std::make_unique<CDMSessionAVStreamSession>(protocolVersions, *this, client);

Modified: trunk/Source/WebCore/platform/network/CacheValidation.cpp (216101 => 216102)


--- trunk/Source/WebCore/platform/network/CacheValidation.cpp	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/platform/network/CacheValidation.cpp	2017-05-02 22:51:40 UTC (rev 216102)
@@ -356,7 +356,7 @@
     if (varyValue.isEmpty())
         return { };
     Vector<String> varyingHeaderNames;
-    varyValue.split(',', /*allowEmptyEntries*/ false, varyingHeaderNames);
+    varyValue.split(',', varyingHeaderNames);
     Vector<std::pair<String, String>> varyingRequestHeaders;
     varyingRequestHeaders.reserveCapacity(varyingHeaderNames.size());
     for (auto& varyHeaderName : varyingHeaderNames) {

Modified: trunk/Source/WebCore/svg/SVGAnimationElement.cpp (216101 => 216102)


--- trunk/Source/WebCore/svg/SVGAnimationElement.cpp	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/svg/SVGAnimationElement.cpp	2017-05-02 22:51:40 UTC (rev 216102)
@@ -2,7 +2,7 @@
  * Copyright (C) 2004, 2005 Nikolas Zimmermann <[email protected]>
  * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <[email protected]>
  * Copyright (C) 2007 Eric Seidel <[email protected]>
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2017 Apple Inc. All rights reserved.
  * Copyright (C) 2009 Cameron McCormack <[email protected]>
  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
  * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
@@ -61,18 +61,17 @@
 static void parseKeyTimes(const String& parse, Vector<float>& result, bool verifyOrder)
 {
     result.clear();
-    Vector<String> parseList;
-    parse.split(';', parseList);
-    for (unsigned n = 0; n < parseList.size(); ++n) {
-        String timeString = parseList[n];
+    bool isFirst = true;
+    for (StringView timeString : StringView(parse).split(';')) {
         bool ok;
-        float time = timeString.toFloat(&ok);
+        float time = timeString.toFloat(ok);
         if (!ok || time < 0 || time > 1)
             goto fail;
         if (verifyOrder) {
-            if (!n) {
+            if (isFirst) {
                 if (time)
                     goto fail;
+                isFirst = false;
             } else if (time < result.last())
                 goto fail;
         }

Modified: trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp (216101 => 216102)


--- trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp	2017-05-02 22:51:40 UTC (rev 216102)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,6 +39,7 @@
 #include "SVGPathParser.h"
 #include "SVGPathStringSource.h"
 #include "SVGVKernElement.h"
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -1471,22 +1472,21 @@
 
     // FIXME: Handle commas.
     if (m_fontFaceElement) {
-        Vector<String> segments;
-        m_fontFaceElement->attributeWithoutSynchronization(SVGNames::font_weightAttr).string().split(' ', segments);
-        for (auto& segment : segments) {
+        auto& fontWeightAttribute = m_fontFaceElement->attributeWithoutSynchronization(SVGNames::font_weightAttr);
+        for (auto segment : StringView(fontWeightAttribute).split(' ')) {
             if (equalLettersIgnoringASCIICase(segment, "bold")) {
                 m_weight = 7;
                 break;
             }
             bool ok;
-            int value = segment.toInt(&ok);
+            int value = segment.toInt(ok);
             if (ok && value >= 0 && value < 1000) {
                 m_weight = (value + 50) / 100;
                 break;
             }
         }
-        m_fontFaceElement->attributeWithoutSynchronization(SVGNames::font_styleAttr).string().split(' ', segments);
-        for (auto& segment : segments) {
+        auto& fontStyleAttribute = m_fontFaceElement->attributeWithoutSynchronization(SVGNames::font_styleAttr);
+        for (auto segment : StringView(fontStyleAttribute).split(' ')) {
             if (equalLettersIgnoringASCIICase(segment, "italic") || equalLettersIgnoringASCIICase(segment, "oblique")) {
                 m_italic = true;
                 break;

Modified: trunk/Source/WebCore/testing/Internals.cpp (216101 => 216102)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-05-02 22:51:40 UTC (rev 216102)
@@ -152,9 +152,9 @@
 #include <runtime/JSCJSValue.h>
 #include <wtf/MemoryPressureHandler.h>
 #include <wtf/MonotonicTime.h>
-#include <wtf/text/CString.h>
 #include <wtf/text/StringBuffer.h>
 #include <wtf/text/StringBuilder.h>
+#include <wtf/text/StringView.h>
 
 #if ENABLE(INPUT_TYPE_COLOR)
 #include "ColorChooser.h"
@@ -3242,7 +3242,7 @@
     return PlatformMediaSession::None;
 }
 
-ExceptionOr<void> Internals::setMediaSessionRestrictions(const String& mediaTypeString, const String& restrictionsString)
+ExceptionOr<void> Internals::setMediaSessionRestrictions(const String& mediaTypeString, StringView restrictionsString)
 {
     PlatformMediaSession::MediaType mediaType = mediaTypeFromString(mediaTypeString);
     if (mediaType == PlatformMediaSession::None)
@@ -3253,9 +3253,7 @@
 
     restrictions = PlatformMediaSessionManager::NoRestrictions;
 
-    Vector<String> restrictionsArray;
-    restrictionsString.split(',', false, restrictionsArray);
-    for (auto& restrictionString : restrictionsArray) {
+    for (StringView restrictionString : restrictionsString.split(',')) {
         if (equalLettersIgnoringASCIICase(restrictionString, "concurrentplaybacknotpermitted"))
             restrictions |= PlatformMediaSessionManager::ConcurrentPlaybackNotPermitted;
         if (equalLettersIgnoringASCIICase(restrictionString, "backgroundprocessplaybackrestricted"))
@@ -3300,7 +3298,7 @@
     return builder.toString();
 }
 
-void Internals::setMediaElementRestrictions(HTMLMediaElement& element, const String& restrictionsString)
+void Internals::setMediaElementRestrictions(HTMLMediaElement& element, StringView restrictionsString)
 {
     MediaElementSession::BehaviorRestrictions restrictions = element.mediaSession().behaviorRestrictions();
     element.mediaSession().removeBehaviorRestriction(restrictions);
@@ -3307,9 +3305,7 @@
 
     restrictions = MediaElementSession::NoRestrictions;
 
-    Vector<String> restrictionsArray;
-    restrictionsString.split(',', false, restrictionsArray);
-    for (auto& restrictionString : restrictionsArray) {
+    for (StringView restrictionString : restrictionsString.split(',')) {
         if (equalLettersIgnoringASCIICase(restrictionString, "norestrictions"))
             restrictions |= MediaElementSession::NoRestrictions;
         if (equalLettersIgnoringASCIICase(restrictionString, "requireusergestureforload"))
@@ -3429,7 +3425,7 @@
 
 #if ENABLE(WEB_AUDIO)
 
-void Internals::setAudioContextRestrictions(AudioContext& context, const String& restrictionsString)
+void Internals::setAudioContextRestrictions(AudioContext& context, StringView restrictionsString)
 {
     AudioContext::BehaviorRestrictions restrictions = context.behaviorRestrictions();
     context.removeBehaviorRestriction(restrictions);
@@ -3436,9 +3432,7 @@
 
     restrictions = AudioContext::NoRestrictions;
 
-    Vector<String> restrictionsArray;
-    restrictionsString.split(',', false, restrictionsArray);
-    for (auto& restrictionString : restrictionsArray) {
+    for (StringView restrictionString : restrictionsString.split(',')) {
         if (equalLettersIgnoringASCIICase(restrictionString, "norestrictions"))
             restrictions |= AudioContext::NoRestrictions;
         if (equalLettersIgnoringASCIICase(restrictionString, "requireusergestureforaudiostart"))
@@ -3517,7 +3511,7 @@
     return MockPageOverlayClient::singleton().layerTreeAsText(document->frame()->mainFrame(), toLayerTreeFlags(flags));
 }
 
-void Internals::setPageMuted(const String& states)
+void Internals::setPageMuted(StringView statesString)
 {
     Document* document = contextDocument();
     if (!document)
@@ -3524,12 +3518,10 @@
         return;
 
     WebCore::MediaProducer::MutedStateFlags state = MediaProducer::NoneMuted;
-    Vector<String> stateString;
-    states.split(',', false, stateString);
-    for (auto& muteString : stateString) {
-        if (equalLettersIgnoringASCIICase(muteString, "audio"))
+    for (StringView stateString : statesString.split(',')) {
+        if (equalLettersIgnoringASCIICase(stateString, "audio"))
             state |= MediaProducer::AudioIsMuted;
-        if (equalLettersIgnoringASCIICase(muteString, "capturedevices"))
+        if (equalLettersIgnoringASCIICase(stateString, "capturedevices"))
             state |= MediaProducer::CaptureDevicesAreMuted;
     }
 

Modified: trunk/Source/WebCore/testing/Internals.h (216101 => 216102)


--- trunk/Source/WebCore/testing/Internals.h	2017-05-02 22:50:46 UTC (rev 216101)
+++ trunk/Source/WebCore/testing/Internals.h	2017-05-02 22:51:40 UTC (rev 216102)
@@ -469,9 +469,9 @@
     void endMediaSessionInterruption(const String&);
     void applicationDidEnterForeground() const;
     void applicationWillEnterBackground() const;
-    ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, const String& restrictions);
+    ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString);
     ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const;
-    void setMediaElementRestrictions(HTMLMediaElement&, const String& restrictions);
+    void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString);
     ExceptionOr<void> postRemoteControlCommand(const String&, float argument);
     bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const;
 #endif
@@ -491,7 +491,7 @@
 #endif
 
 #if ENABLE(WEB_AUDIO)
-    void setAudioContextRestrictions(AudioContext&, const String& restrictions);
+    void setAudioContextRestrictions(AudioContext&, StringView restrictionsString);
 #endif
 
     void simulateSystemSleep() const;
@@ -501,7 +501,7 @@
     ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
     ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const;
 
-    void setPageMuted(const String&);
+    void setPageMuted(StringView);
     String pageMediaState();
 
     void setPageDefersLoading(bool);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to