2016-03-06 02:17:29 +00:00
/*
* Copyright ( C ) 2016 Apple Inc . All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
* 1. Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
* 2. Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC . AND ITS CONTRIBUTORS ` ` AS IS ' '
* AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO ,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL APPLE INC . OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR
* CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS
* INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN
* CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE )
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE .
*/
# include "config.h"
# include "Autofill.h"
# include "HTMLFormControlElement.h"
# include "HTMLFormElement.h"
# include "HTMLNames.h"
# include <wtf/HashMap.h>
# include <wtf/NeverDestroyed.h>
[WTF] Introduce RobinHoodHashTable
https://bugs.webkit.org/show_bug.cgi?id=223895
Reviewed by Fil Pizlo.
Source/JavaScriptCore:
* builtins/BuiltinNames.cpp:
(JSC::lookUpPrivateNameImpl):
(JSC::lookUpWellKnownSymbolImpl):
* builtins/BuiltinNames.h:
* bytecode/BytecodeIntrinsicRegistry.h:
* runtime/Identifier.h:
* runtime/IntlCollator.cpp:
(JSC::IntlCollator::initializeCollator):
(JSC::IntlCollator::checkICULocaleInvariants):
* runtime/IntlCollator.h:
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
* runtime/IntlDateTimeFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlDisplayNames.cpp:
(JSC::IntlDisplayNames::initializeDisplayNames):
* runtime/IntlDisplayNamesConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlListFormat.cpp:
(JSC::IntlListFormat::initializeListFormat):
* runtime/IntlListFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat):
* runtime/IntlNumberFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlObject.cpp:
(JSC::addScriptlessLocaleIfNeeded):
(JSC::intlAvailableLocales):
(JSC::intlCollatorAvailableLocales):
(JSC::intlSegmenterAvailableLocales):
(JSC::bestAvailableLocale):
(JSC::lookupMatcher):
(JSC::bestFitMatcher):
(JSC::resolveLocale):
(JSC::lookupSupportedLocales):
(JSC::bestFitSupportedLocales):
(JSC::supportedLocales):
* runtime/IntlObject.h:
(JSC::intlDateTimeFormatAvailableLocales):
(JSC::intlDisplayNamesAvailableLocales):
(JSC::intlNumberFormatAvailableLocales):
(JSC::intlPluralRulesAvailableLocales):
(JSC::intlRelativeTimeFormatAvailableLocales):
(JSC::intlListFormatAvailableLocales):
* runtime/IntlPluralRules.cpp:
(JSC::IntlPluralRules::initializePluralRules):
* runtime/IntlPluralRulesConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlRelativeTimeFormat.cpp:
(JSC::IntlRelativeTimeFormat::initializeRelativeTimeFormat):
* runtime/IntlRelativeTimeFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlSegmenter.cpp:
(JSC::IntlSegmenter::initializeSegmenter):
* runtime/IntlSegmenterConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/RegExpCache.h:
* runtime/RegExpKey.h:
Source/WebCore:
* Modules/mediacapabilities/MediaCapabilities.cpp:
(WebCore::bucketMIMETypes):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::popupValue const):
* dom/Element.cpp:
(WebCore::canAttachAuthorShadowRoot):
* dom/QualifiedName.h:
* dom/make_names.pl:
(printNamesHeaderFile):
(printFactoryCppFile):
(printWrapperFactoryCppFile):
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock):
* editing/RemoveFormatCommand.cpp:
(WebCore::isElementForRemoveFormatCommand):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::isProhibitedParagraphChild):
* html/Autofill.cpp:
(WebCore::fieldNameMap):
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::isCaseSensitiveAttribute):
* html/HTMLObjectElement.cpp:
(WebCore::preventsParentObjectFromExposure):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::createCaseMap):
(WebCore::adjustSVGTagNameCase):
(WebCore::adjustAttributes):
(WebCore::createForeignAttributesMap):
(WebCore::adjustForeignAttributes):
(WebCore::addNamesWithPrefix): Deleted.
* page/DebugPageOverlays.cpp:
(WebCore::touchEventRegionColors):
(WebCore::NonFastScrollableRegionOverlay::drawRect):
* page/PerformanceUserTiming.cpp:
(WebCore::restrictedMarkNamesToNavigationTimingFunctionMap):
* platform/cocoa/MIMETypeRegistryCocoa.mm:
(WebCore::extensionsForMIMETypeMap):
* platform/graphics/FontCascade.cpp:
(WebCore::useBackslashAsYenSignForFamily):
(WebCore::FontCascade::hasValidAverageCharWidth const):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::validInitDataTypes):
* platform/graphics/cg/UTIRegistry.cpp:
(WebCore::defaultSupportedImageTypes):
* platform/graphics/cg/UTIRegistry.h:
* platform/graphics/cocoa/HEVCUtilitiesCocoa.mm:
(WebCore::codecTypeForDoViCodecString):
* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::supportedVideoCodecs):
(WebCore::SourceBufferParserWebM::supportedAudioCodecs):
* platform/graphics/cocoa/SourceBufferParserWebM.h:
* rendering/svg/SVGResources.cpp:
(WebCore::clipperFilterMaskerTags):
(WebCore::markerTags):
(WebCore::fillAndStrokeTags):
(WebCore::chainableResourceTags):
* style/StyleAdjuster.cpp:
(WebCore::Style::hasEffectiveDisplayNoneForDisplayContents):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::isSupportedAttribute):
* svg/SVGElement.cpp:
(WebCore::createAttributeNameToCSSPropertyIDMap):
(WebCore::SVGElement::animatableAttributeForName):
(WebCore::SVGElement::cssPropertyIdForSVGAttributeName):
* svg/SVGTests.cpp:
(WebCore::SVGTests::addSupportedAttributes):
* svg/SVGTests.h:
* svg/SVGUseElement.cpp:
(WebCore::createAllowedElementSet):
(WebCore::isDisallowedElement):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSupportedAttribute):
* xml/XPathFunctions.cpp:
(WebCore::XPath::createFunctionMap):
* xml/XPathParser.cpp:
(WebCore::XPath::createAxisNamesMap):
Source/WebKit:
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ObservedDomainsTableSchemaV1Alternate):
(WebKit::expectedUnattributedColumns):
(WebKit::expectedAttributedColumns):
(WebKit::createTableQueries):
* Platform/IPC/ArgumentCoders.h:
* Shared/Cocoa/DefaultWebBrowserChecks.mm:
(WebKit::getAppBoundDomainsTesting):
* Shared/WebPreferencesStore.cpp:
(WebKit::WebPreferencesStore::decode):
* Shared/WebPreferencesStore.h:
* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::platformPathsWithAssumedReadAccess):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::platformPathsWithAssumedReadAccess):
* UIProcess/WebProcessProxy.h:
Source/WTF:
This patch implements RobinHoodHashTable[1]. We don't use it as a default hashtable since it has different performance v.s. memory-saving characteristics,
and this patch's goal is not tackling on making this default. Rather, the goal of this patch is introducing it to non-performance sensitive area quickly
so that we can save memory. RobinHoodHashTable more frequently computes hash value compared to HashTable, so this is not drop-in replacement for the existing
one. But still, this is useful since we know that "while there are many small HashTables and they holds much memory, there are super large HashTables and
they holds almost same amount of memory while they are a few.". This patch's goal is applying this RobinHoodHashTable to these "large, but a few" singleton tables.
RobinHoodHashTable maintains distance-from-initial-bucket (DIB) small by adjusting existing entries when inserting. When inserting, if we found that the
existing entry has less DIB than the current inserting entry's DIB, then we swap entries, and insert the existing entry to the other place. This is giving
some good DIB from rich entry to poor entry (that's why it is called RobinHood Hashing), and making average DIB lower. And this algorithm adds good invariant
that, when looking up an entry, and we found that existing entry has smaller DIB, then we can stop searching in the middle of the chain since we know that
we should swap entries when this happened when inserting. These two tricks maintain HashTable performance even under significantly high load factor: 90% load-factor
just works. 95% load-factor regress adding performance, but still it does not become catastrophic compared to normal open-addressing HashTable.
We introduce RobinHoodHashTable, and adding several kinds of tables based on load-factors.
1. MemoryCompactLookupOnlyRobinHoodHashSet / HashMap
This has 95% load-factor. This is suitable for sets and maps which is mostly-constant: constructing once, and looking up repeatedly. In WebKit, there are so
many this kind of tables e.g. singleton HashMap for various kinds of things. We can use this super high load-factor table so that we can save memory even while
we are maintains fast HashTable lookup.
2. MemoryCompactRobinHoodHashSet / HashMap
This has 90% load-factor. It just works, and we can try using it if sets and maps are significantly performance intensive.
3. FastRobinHoodHashSet / HashMap
This has 75% load-factor. This is still good compared to HashSet and HashMap since they are using 50% load-factor for large sized tables. This has very slightly performance regressed
compared to 50% load-factor large HashSet and HashMap, but if that is not performance intensive (e.g. AtomStringTable is one of the most performance intensive table), this is good.
In this patch, we replace many singleton HashSet / HashMap with RobinHoodHashTable.
[1]: https://www.sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Forward.h:
* wtf/HashMap.h:
(WTF::Y>::swap):
(WTF::Y>::size const):
(WTF::Y>::capacity const):
(WTF::Y>::isEmpty const):
(WTF::Y>::begin):
(WTF::Y>::end):
(WTF::Y>::begin const):
(WTF::Y>::end const):
(WTF::Y>::find):
(WTF::Y>::find const):
(WTF::Y>::contains const):
(WTF::Y>::get const):
(WTF::Y>::inlineGet const):
(WTF::TableTraitsArg>::inlineSet):
(WTF::TableTraitsArg>::inlineAdd):
(WTF::TableTraitsArg>::inlineEnsure):
(WTF::TableTraitsArg>::set):
(WTF::TableTraitsArg>::add):
(WTF::TableTraitsArg>::fastAdd):
(WTF::TableTraitsArg>::ensure):
(WTF::Y>::remove):
(WTF::Y>::removeIf):
(WTF::Y>::clear):
(WTF::Y>::take):
(WTF::Y>::checkConsistency const):
(WTF::Y>::isValidKey):
(WTF::operator==):
(WTF::operator!=):
(WTF::X>::swap): Deleted.
(WTF::X>::size const): Deleted.
(WTF::X>::capacity const): Deleted.
(WTF::X>::isEmpty const): Deleted.
(WTF::X>::begin): Deleted.
(WTF::X>::end): Deleted.
(WTF::X>::begin const): Deleted.
(WTF::X>::end const): Deleted.
(WTF::X>::find): Deleted.
(WTF::X>::find const): Deleted.
(WTF::X>::contains const): Deleted.
(WTF::X>::get const): Deleted.
(WTF::X>::inlineGet const): Deleted.
(WTF::MappedTraitsArg>::inlineSet): Deleted.
(WTF::MappedTraitsArg>::inlineAdd): Deleted.
(WTF::MappedTraitsArg>::inlineEnsure): Deleted.
(WTF::MappedTraitsArg>::set): Deleted.
(WTF::MappedTraitsArg>::add): Deleted.
(WTF::MappedTraitsArg>::fastAdd): Deleted.
(WTF::MappedTraitsArg>::ensure): Deleted.
(WTF::MappedTraits>::get const): Deleted.
(WTF::MappedTraits>::inlineGet const): Deleted.
(WTF::X>::remove): Deleted.
(WTF::X>::removeIf): Deleted.
(WTF::X>::clear): Deleted.
(WTF::MappedTraits>::take): Deleted.
(WTF::X>::take): Deleted.
(WTF::X>::checkConsistency const): Deleted.
(WTF::X>::isValidKey): Deleted.
* wtf/HashSet.h:
(WTF::W>::swap):
(WTF::W>::size const):
(WTF::W>::capacity const):
(WTF::W>::isEmpty const):
(WTF::W>::begin const):
(WTF::W>::end const):
(WTF::W>::find const):
(WTF::W>::contains const):
(WTF::TableTraits>::find const):
(WTF::TableTraits>::contains const):
(WTF::TableTraits>::ensure):
(WTF::W>::add):
(WTF::W>::addVoid):
(WTF::TableTraits>::add):
(WTF::W>::remove):
(WTF::W>::removeIf):
(WTF::W>::clear):
(WTF::W>::take):
(WTF::W>::takeAny):
(WTF::TableTraits>::remove):
(WTF::TableTraits>::take):
(WTF::W>::isValidValue):
(WTF::= const):
(WTF::W>::checkConsistency const):
(WTF::V>::swap): Deleted.
(WTF::V>::size const): Deleted.
(WTF::V>::capacity const): Deleted.
(WTF::V>::isEmpty const): Deleted.
(WTF::V>::begin const): Deleted.
(WTF::V>::end const): Deleted.
(WTF::V>::find const): Deleted.
(WTF::V>::contains const): Deleted.
(WTF::Traits>::find const): Deleted.
(WTF::Traits>::contains const): Deleted.
(WTF::Traits>::ensure): Deleted.
(WTF::V>::add): Deleted.
(WTF::V>::addVoid): Deleted.
(WTF::Traits>::add): Deleted.
(WTF::V>::remove): Deleted.
(WTF::V>::removeIf): Deleted.
(WTF::V>::clear): Deleted.
(WTF::V>::take): Deleted.
(WTF::V>::takeAny): Deleted.
(WTF::Traits>::remove): Deleted.
(WTF::Traits>::take): Deleted.
(WTF::V>::isValidValue): Deleted.
(WTF::V>::checkConsistency const): Deleted.
* wtf/HashTable.h:
(WTF::addIterator):
(WTF::removeIterator):
(WTF::invalidateIterators):
(WTF::HashTable::~HashTable):
(WTF::HashTable::random):
(WTF::KeyTraits>::inlineLookup):
(WTF::KeyTraits>::lookupForWriting):
(WTF::KeyTraits>::fullLookupForWriting):
(WTF::KeyTraits>::addUniqueForInitialization):
(WTF::KeyTraits>::add):
(WTF::KeyTraits>::addPassingHashCode):
(WTF::KeyTraits>::removeAndInvalidateWithoutEntryConsistencyCheck):
(WTF::KeyTraits>::removeAndInvalidate):
(WTF::KeyTraits>::clear):
(WTF::KeyTraits>::swap):
(WTF::KeyTraits>::HashTable):
(WTF::HashTable::invalidateIterators): Deleted.
(WTF::KeyTraits>::invalidateIterators): Deleted.
* wtf/RobinHoodHashMap.h: Added.
* wtf/RobinHoodHashSet.h: Added.
* wtf/RobinHoodHashTable.h: Added.
(WTF::RobinHoodHashTable::~RobinHoodHashTable):
(WTF::RobinHoodHashTable::begin):
(WTF::RobinHoodHashTable::end):
(WTF::RobinHoodHashTable::begin const):
(WTF::RobinHoodHashTable::end const):
(WTF::RobinHoodHashTable::random):
(WTF::RobinHoodHashTable::random const):
(WTF::RobinHoodHashTable::size const):
(WTF::RobinHoodHashTable::capacity const):
(WTF::RobinHoodHashTable::isEmpty const):
(WTF::RobinHoodHashTable::reserveInitialCapacity):
(WTF::RobinHoodHashTable::add):
(WTF::RobinHoodHashTable::find):
(WTF::RobinHoodHashTable::find const):
(WTF::RobinHoodHashTable::contains const):
(WTF::RobinHoodHashTable::isEmptyBucket):
(WTF::RobinHoodHashTable::isEmptyOrDeletedBucket):
(WTF::RobinHoodHashTable::lookup):
(WTF::RobinHoodHashTable::checkTableConsistency):
(WTF::RobinHoodHashTable::internalCheckTableConsistency const):
(WTF::RobinHoodHashTable::internalCheckTableConsistencyExceptSize const):
(WTF::RobinHoodHashTable::internalCheckTableConsistencyExceptSize):
(WTF::RobinHoodHashTable::internalCheckTableConsistency):
(WTF::RobinHoodHashTable::shouldExpand):
(WTF::RobinHoodHashTable::computeTableHash):
(WTF::RobinHoodHashTable::shouldExpand const):
(WTF::RobinHoodHashTable::shouldShrink const):
(WTF::RobinHoodHashTable::shrink):
(WTF::RobinHoodHashTable::deleteBucket):
(WTF::RobinHoodHashTable::desiredIndex):
(WTF::RobinHoodHashTable::probeDistance):
(WTF::RobinHoodHashTable::makeIterator):
(WTF::RobinHoodHashTable::makeConstIterator const):
(WTF::RobinHoodHashTable::makeKnownGoodIterator):
(WTF::RobinHoodHashTable::makeKnownGoodConstIterator const):
(WTF::RobinHoodHashTable::checkTableConsistencyExceptSize):
(WTF::RobinHoodHashTable::tableSize const):
(WTF::RobinHoodHashTable::tableSizeMask const):
(WTF::RobinHoodHashTable::keyCount const):
(WTF::RobinHoodHashTable::tableHash const):
(WTF::SizePolicy>::checkKey):
(WTF::SizePolicy>::lookup):
(WTF::SizePolicy>::inlineLookup):
(WTF::SizePolicy>::initializeBucket):
(WTF::SizePolicy>::add):
(WTF::SizePolicy>::maintainProbeDistanceForAdd):
(WTF::SizePolicy>::addPassingHashCode):
(WTF::SizePolicy>::reinsert):
(WTF::SizePolicy>::find):
(WTF::SizePolicy>::find const):
(WTF::SizePolicy>::contains const):
(WTF::SizePolicy>::removeAndInvalidateWithoutEntryConsistencyCheck):
(WTF::SizePolicy>::removeAndInvalidate):
(WTF::SizePolicy>::remove):
(WTF::SizePolicy>::removeWithoutEntryConsistencyCheck):
(WTF::SizePolicy>::allocateTable):
(WTF::SizePolicy>::deallocateTable):
(WTF::SizePolicy>::expand):
(WTF::SizePolicy>::computeBestTableSize):
(WTF::SizePolicy>::shrinkToBestSize):
(WTF::SizePolicy>::rehash):
(WTF::SizePolicy>::clear):
(WTF::SizePolicy>::RobinHoodHashTable):
(WTF::SizePolicy>::swap):
(WTF::=):
(WTF::SizePolicy>::checkTableConsistency const):
(WTF::SizePolicy>::checkTableConsistencyExceptSize const):
* wtf/text/AtomStringHash.h:
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringTable.cpp:
(WTF::AtomStringTable::~AtomStringTable):
* wtf/text/AtomStringTable.h:
(WTF::AtomStringTable::table):
* wtf/text/StringHash.h:
Tools:
* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/DeletedAddressOfOperator.h:
* TestWebKitAPI/Tests/WTF/HashMap.cpp:
(TestWebKitAPI::testMovingUsingEnsure):
(TestWebKitAPI::testMovingUsingAdd):
* TestWebKitAPI/Tests/WTF/HashSet.cpp:
(TestWebKitAPI::generateTestCapacityUpToSize<0>):
(TestWebKitAPI::generateTestCapacityUpToSize):
* TestWebKitAPI/Tests/WTF/MoveOnly.h:
* TestWebKitAPI/Tests/WTF/RobinHoodHashMap.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp.
(TestWebKitAPI::TEST):
(TestWebKitAPI::bucketForKey):
(TestWebKitAPI::ZeroHash::hash):
(TestWebKitAPI::ObjectWithRefLogger::ObjectWithRefLogger):
(TestWebKitAPI::testMovingUsingEnsure):
(TestWebKitAPI::testMovingUsingAdd):
(TestWebKitAPI::DerefObserver::ref):
(TestWebKitAPI::DerefObserver::deref):
(TestWebKitAPI::TestObjectWithCustomDestructor::TestObjectWithCustomDestructor):
(TestWebKitAPI::TestObjectWithCustomDestructor::~TestObjectWithCustomDestructor):
* TestWebKitAPI/Tests/WTF/RobinHoodHashSet.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/HashSet.cpp.
(TestWebKitAPI::capacityForSize):
(TestWebKitAPI::testInitialCapacity):
(TestWebKitAPI::generateTestCapacityUpToSize<0>):
(TestWebKitAPI::generateTestCapacityUpToSize):
(TestWebKitAPI::TEST):
(TestWebKitAPI::DerefObserver::ref):
(TestWebKitAPI::DerefObserver::deref):
Canonical link: https://commits.webkit.org/236073@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-02 08:33:32 +00:00
# include <wtf/RobinHoodHashMap.h>
2019-06-17 01:48:13 +00:00
# include <wtf/text/AtomString.h>
# include <wtf/text/AtomStringHash.h>
2016-03-06 02:17:29 +00:00
namespace WebCore {
enum class AutofillCategory {
Off ,
Automatic ,
Normal ,
Contact ,
} ;
struct AutofillInfo {
AutofillFieldName fieldName ;
AutofillCategory category ;
} ;
[WTF] Introduce RobinHoodHashTable
https://bugs.webkit.org/show_bug.cgi?id=223895
Reviewed by Fil Pizlo.
Source/JavaScriptCore:
* builtins/BuiltinNames.cpp:
(JSC::lookUpPrivateNameImpl):
(JSC::lookUpWellKnownSymbolImpl):
* builtins/BuiltinNames.h:
* bytecode/BytecodeIntrinsicRegistry.h:
* runtime/Identifier.h:
* runtime/IntlCollator.cpp:
(JSC::IntlCollator::initializeCollator):
(JSC::IntlCollator::checkICULocaleInvariants):
* runtime/IntlCollator.h:
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
* runtime/IntlDateTimeFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlDisplayNames.cpp:
(JSC::IntlDisplayNames::initializeDisplayNames):
* runtime/IntlDisplayNamesConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlListFormat.cpp:
(JSC::IntlListFormat::initializeListFormat):
* runtime/IntlListFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat):
* runtime/IntlNumberFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlObject.cpp:
(JSC::addScriptlessLocaleIfNeeded):
(JSC::intlAvailableLocales):
(JSC::intlCollatorAvailableLocales):
(JSC::intlSegmenterAvailableLocales):
(JSC::bestAvailableLocale):
(JSC::lookupMatcher):
(JSC::bestFitMatcher):
(JSC::resolveLocale):
(JSC::lookupSupportedLocales):
(JSC::bestFitSupportedLocales):
(JSC::supportedLocales):
* runtime/IntlObject.h:
(JSC::intlDateTimeFormatAvailableLocales):
(JSC::intlDisplayNamesAvailableLocales):
(JSC::intlNumberFormatAvailableLocales):
(JSC::intlPluralRulesAvailableLocales):
(JSC::intlRelativeTimeFormatAvailableLocales):
(JSC::intlListFormatAvailableLocales):
* runtime/IntlPluralRules.cpp:
(JSC::IntlPluralRules::initializePluralRules):
* runtime/IntlPluralRulesConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlRelativeTimeFormat.cpp:
(JSC::IntlRelativeTimeFormat::initializeRelativeTimeFormat):
* runtime/IntlRelativeTimeFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlSegmenter.cpp:
(JSC::IntlSegmenter::initializeSegmenter):
* runtime/IntlSegmenterConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/RegExpCache.h:
* runtime/RegExpKey.h:
Source/WebCore:
* Modules/mediacapabilities/MediaCapabilities.cpp:
(WebCore::bucketMIMETypes):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::popupValue const):
* dom/Element.cpp:
(WebCore::canAttachAuthorShadowRoot):
* dom/QualifiedName.h:
* dom/make_names.pl:
(printNamesHeaderFile):
(printFactoryCppFile):
(printWrapperFactoryCppFile):
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock):
* editing/RemoveFormatCommand.cpp:
(WebCore::isElementForRemoveFormatCommand):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::isProhibitedParagraphChild):
* html/Autofill.cpp:
(WebCore::fieldNameMap):
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::isCaseSensitiveAttribute):
* html/HTMLObjectElement.cpp:
(WebCore::preventsParentObjectFromExposure):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::createCaseMap):
(WebCore::adjustSVGTagNameCase):
(WebCore::adjustAttributes):
(WebCore::createForeignAttributesMap):
(WebCore::adjustForeignAttributes):
(WebCore::addNamesWithPrefix): Deleted.
* page/DebugPageOverlays.cpp:
(WebCore::touchEventRegionColors):
(WebCore::NonFastScrollableRegionOverlay::drawRect):
* page/PerformanceUserTiming.cpp:
(WebCore::restrictedMarkNamesToNavigationTimingFunctionMap):
* platform/cocoa/MIMETypeRegistryCocoa.mm:
(WebCore::extensionsForMIMETypeMap):
* platform/graphics/FontCascade.cpp:
(WebCore::useBackslashAsYenSignForFamily):
(WebCore::FontCascade::hasValidAverageCharWidth const):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::validInitDataTypes):
* platform/graphics/cg/UTIRegistry.cpp:
(WebCore::defaultSupportedImageTypes):
* platform/graphics/cg/UTIRegistry.h:
* platform/graphics/cocoa/HEVCUtilitiesCocoa.mm:
(WebCore::codecTypeForDoViCodecString):
* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::supportedVideoCodecs):
(WebCore::SourceBufferParserWebM::supportedAudioCodecs):
* platform/graphics/cocoa/SourceBufferParserWebM.h:
* rendering/svg/SVGResources.cpp:
(WebCore::clipperFilterMaskerTags):
(WebCore::markerTags):
(WebCore::fillAndStrokeTags):
(WebCore::chainableResourceTags):
* style/StyleAdjuster.cpp:
(WebCore::Style::hasEffectiveDisplayNoneForDisplayContents):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::isSupportedAttribute):
* svg/SVGElement.cpp:
(WebCore::createAttributeNameToCSSPropertyIDMap):
(WebCore::SVGElement::animatableAttributeForName):
(WebCore::SVGElement::cssPropertyIdForSVGAttributeName):
* svg/SVGTests.cpp:
(WebCore::SVGTests::addSupportedAttributes):
* svg/SVGTests.h:
* svg/SVGUseElement.cpp:
(WebCore::createAllowedElementSet):
(WebCore::isDisallowedElement):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSupportedAttribute):
* xml/XPathFunctions.cpp:
(WebCore::XPath::createFunctionMap):
* xml/XPathParser.cpp:
(WebCore::XPath::createAxisNamesMap):
Source/WebKit:
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ObservedDomainsTableSchemaV1Alternate):
(WebKit::expectedUnattributedColumns):
(WebKit::expectedAttributedColumns):
(WebKit::createTableQueries):
* Platform/IPC/ArgumentCoders.h:
* Shared/Cocoa/DefaultWebBrowserChecks.mm:
(WebKit::getAppBoundDomainsTesting):
* Shared/WebPreferencesStore.cpp:
(WebKit::WebPreferencesStore::decode):
* Shared/WebPreferencesStore.h:
* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::platformPathsWithAssumedReadAccess):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::platformPathsWithAssumedReadAccess):
* UIProcess/WebProcessProxy.h:
Source/WTF:
This patch implements RobinHoodHashTable[1]. We don't use it as a default hashtable since it has different performance v.s. memory-saving characteristics,
and this patch's goal is not tackling on making this default. Rather, the goal of this patch is introducing it to non-performance sensitive area quickly
so that we can save memory. RobinHoodHashTable more frequently computes hash value compared to HashTable, so this is not drop-in replacement for the existing
one. But still, this is useful since we know that "while there are many small HashTables and they holds much memory, there are super large HashTables and
they holds almost same amount of memory while they are a few.". This patch's goal is applying this RobinHoodHashTable to these "large, but a few" singleton tables.
RobinHoodHashTable maintains distance-from-initial-bucket (DIB) small by adjusting existing entries when inserting. When inserting, if we found that the
existing entry has less DIB than the current inserting entry's DIB, then we swap entries, and insert the existing entry to the other place. This is giving
some good DIB from rich entry to poor entry (that's why it is called RobinHood Hashing), and making average DIB lower. And this algorithm adds good invariant
that, when looking up an entry, and we found that existing entry has smaller DIB, then we can stop searching in the middle of the chain since we know that
we should swap entries when this happened when inserting. These two tricks maintain HashTable performance even under significantly high load factor: 90% load-factor
just works. 95% load-factor regress adding performance, but still it does not become catastrophic compared to normal open-addressing HashTable.
We introduce RobinHoodHashTable, and adding several kinds of tables based on load-factors.
1. MemoryCompactLookupOnlyRobinHoodHashSet / HashMap
This has 95% load-factor. This is suitable for sets and maps which is mostly-constant: constructing once, and looking up repeatedly. In WebKit, there are so
many this kind of tables e.g. singleton HashMap for various kinds of things. We can use this super high load-factor table so that we can save memory even while
we are maintains fast HashTable lookup.
2. MemoryCompactRobinHoodHashSet / HashMap
This has 90% load-factor. It just works, and we can try using it if sets and maps are significantly performance intensive.
3. FastRobinHoodHashSet / HashMap
This has 75% load-factor. This is still good compared to HashSet and HashMap since they are using 50% load-factor for large sized tables. This has very slightly performance regressed
compared to 50% load-factor large HashSet and HashMap, but if that is not performance intensive (e.g. AtomStringTable is one of the most performance intensive table), this is good.
In this patch, we replace many singleton HashSet / HashMap with RobinHoodHashTable.
[1]: https://www.sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Forward.h:
* wtf/HashMap.h:
(WTF::Y>::swap):
(WTF::Y>::size const):
(WTF::Y>::capacity const):
(WTF::Y>::isEmpty const):
(WTF::Y>::begin):
(WTF::Y>::end):
(WTF::Y>::begin const):
(WTF::Y>::end const):
(WTF::Y>::find):
(WTF::Y>::find const):
(WTF::Y>::contains const):
(WTF::Y>::get const):
(WTF::Y>::inlineGet const):
(WTF::TableTraitsArg>::inlineSet):
(WTF::TableTraitsArg>::inlineAdd):
(WTF::TableTraitsArg>::inlineEnsure):
(WTF::TableTraitsArg>::set):
(WTF::TableTraitsArg>::add):
(WTF::TableTraitsArg>::fastAdd):
(WTF::TableTraitsArg>::ensure):
(WTF::Y>::remove):
(WTF::Y>::removeIf):
(WTF::Y>::clear):
(WTF::Y>::take):
(WTF::Y>::checkConsistency const):
(WTF::Y>::isValidKey):
(WTF::operator==):
(WTF::operator!=):
(WTF::X>::swap): Deleted.
(WTF::X>::size const): Deleted.
(WTF::X>::capacity const): Deleted.
(WTF::X>::isEmpty const): Deleted.
(WTF::X>::begin): Deleted.
(WTF::X>::end): Deleted.
(WTF::X>::begin const): Deleted.
(WTF::X>::end const): Deleted.
(WTF::X>::find): Deleted.
(WTF::X>::find const): Deleted.
(WTF::X>::contains const): Deleted.
(WTF::X>::get const): Deleted.
(WTF::X>::inlineGet const): Deleted.
(WTF::MappedTraitsArg>::inlineSet): Deleted.
(WTF::MappedTraitsArg>::inlineAdd): Deleted.
(WTF::MappedTraitsArg>::inlineEnsure): Deleted.
(WTF::MappedTraitsArg>::set): Deleted.
(WTF::MappedTraitsArg>::add): Deleted.
(WTF::MappedTraitsArg>::fastAdd): Deleted.
(WTF::MappedTraitsArg>::ensure): Deleted.
(WTF::MappedTraits>::get const): Deleted.
(WTF::MappedTraits>::inlineGet const): Deleted.
(WTF::X>::remove): Deleted.
(WTF::X>::removeIf): Deleted.
(WTF::X>::clear): Deleted.
(WTF::MappedTraits>::take): Deleted.
(WTF::X>::take): Deleted.
(WTF::X>::checkConsistency const): Deleted.
(WTF::X>::isValidKey): Deleted.
* wtf/HashSet.h:
(WTF::W>::swap):
(WTF::W>::size const):
(WTF::W>::capacity const):
(WTF::W>::isEmpty const):
(WTF::W>::begin const):
(WTF::W>::end const):
(WTF::W>::find const):
(WTF::W>::contains const):
(WTF::TableTraits>::find const):
(WTF::TableTraits>::contains const):
(WTF::TableTraits>::ensure):
(WTF::W>::add):
(WTF::W>::addVoid):
(WTF::TableTraits>::add):
(WTF::W>::remove):
(WTF::W>::removeIf):
(WTF::W>::clear):
(WTF::W>::take):
(WTF::W>::takeAny):
(WTF::TableTraits>::remove):
(WTF::TableTraits>::take):
(WTF::W>::isValidValue):
(WTF::= const):
(WTF::W>::checkConsistency const):
(WTF::V>::swap): Deleted.
(WTF::V>::size const): Deleted.
(WTF::V>::capacity const): Deleted.
(WTF::V>::isEmpty const): Deleted.
(WTF::V>::begin const): Deleted.
(WTF::V>::end const): Deleted.
(WTF::V>::find const): Deleted.
(WTF::V>::contains const): Deleted.
(WTF::Traits>::find const): Deleted.
(WTF::Traits>::contains const): Deleted.
(WTF::Traits>::ensure): Deleted.
(WTF::V>::add): Deleted.
(WTF::V>::addVoid): Deleted.
(WTF::Traits>::add): Deleted.
(WTF::V>::remove): Deleted.
(WTF::V>::removeIf): Deleted.
(WTF::V>::clear): Deleted.
(WTF::V>::take): Deleted.
(WTF::V>::takeAny): Deleted.
(WTF::Traits>::remove): Deleted.
(WTF::Traits>::take): Deleted.
(WTF::V>::isValidValue): Deleted.
(WTF::V>::checkConsistency const): Deleted.
* wtf/HashTable.h:
(WTF::addIterator):
(WTF::removeIterator):
(WTF::invalidateIterators):
(WTF::HashTable::~HashTable):
(WTF::HashTable::random):
(WTF::KeyTraits>::inlineLookup):
(WTF::KeyTraits>::lookupForWriting):
(WTF::KeyTraits>::fullLookupForWriting):
(WTF::KeyTraits>::addUniqueForInitialization):
(WTF::KeyTraits>::add):
(WTF::KeyTraits>::addPassingHashCode):
(WTF::KeyTraits>::removeAndInvalidateWithoutEntryConsistencyCheck):
(WTF::KeyTraits>::removeAndInvalidate):
(WTF::KeyTraits>::clear):
(WTF::KeyTraits>::swap):
(WTF::KeyTraits>::HashTable):
(WTF::HashTable::invalidateIterators): Deleted.
(WTF::KeyTraits>::invalidateIterators): Deleted.
* wtf/RobinHoodHashMap.h: Added.
* wtf/RobinHoodHashSet.h: Added.
* wtf/RobinHoodHashTable.h: Added.
(WTF::RobinHoodHashTable::~RobinHoodHashTable):
(WTF::RobinHoodHashTable::begin):
(WTF::RobinHoodHashTable::end):
(WTF::RobinHoodHashTable::begin const):
(WTF::RobinHoodHashTable::end const):
(WTF::RobinHoodHashTable::random):
(WTF::RobinHoodHashTable::random const):
(WTF::RobinHoodHashTable::size const):
(WTF::RobinHoodHashTable::capacity const):
(WTF::RobinHoodHashTable::isEmpty const):
(WTF::RobinHoodHashTable::reserveInitialCapacity):
(WTF::RobinHoodHashTable::add):
(WTF::RobinHoodHashTable::find):
(WTF::RobinHoodHashTable::find const):
(WTF::RobinHoodHashTable::contains const):
(WTF::RobinHoodHashTable::isEmptyBucket):
(WTF::RobinHoodHashTable::isEmptyOrDeletedBucket):
(WTF::RobinHoodHashTable::lookup):
(WTF::RobinHoodHashTable::checkTableConsistency):
(WTF::RobinHoodHashTable::internalCheckTableConsistency const):
(WTF::RobinHoodHashTable::internalCheckTableConsistencyExceptSize const):
(WTF::RobinHoodHashTable::internalCheckTableConsistencyExceptSize):
(WTF::RobinHoodHashTable::internalCheckTableConsistency):
(WTF::RobinHoodHashTable::shouldExpand):
(WTF::RobinHoodHashTable::computeTableHash):
(WTF::RobinHoodHashTable::shouldExpand const):
(WTF::RobinHoodHashTable::shouldShrink const):
(WTF::RobinHoodHashTable::shrink):
(WTF::RobinHoodHashTable::deleteBucket):
(WTF::RobinHoodHashTable::desiredIndex):
(WTF::RobinHoodHashTable::probeDistance):
(WTF::RobinHoodHashTable::makeIterator):
(WTF::RobinHoodHashTable::makeConstIterator const):
(WTF::RobinHoodHashTable::makeKnownGoodIterator):
(WTF::RobinHoodHashTable::makeKnownGoodConstIterator const):
(WTF::RobinHoodHashTable::checkTableConsistencyExceptSize):
(WTF::RobinHoodHashTable::tableSize const):
(WTF::RobinHoodHashTable::tableSizeMask const):
(WTF::RobinHoodHashTable::keyCount const):
(WTF::RobinHoodHashTable::tableHash const):
(WTF::SizePolicy>::checkKey):
(WTF::SizePolicy>::lookup):
(WTF::SizePolicy>::inlineLookup):
(WTF::SizePolicy>::initializeBucket):
(WTF::SizePolicy>::add):
(WTF::SizePolicy>::maintainProbeDistanceForAdd):
(WTF::SizePolicy>::addPassingHashCode):
(WTF::SizePolicy>::reinsert):
(WTF::SizePolicy>::find):
(WTF::SizePolicy>::find const):
(WTF::SizePolicy>::contains const):
(WTF::SizePolicy>::removeAndInvalidateWithoutEntryConsistencyCheck):
(WTF::SizePolicy>::removeAndInvalidate):
(WTF::SizePolicy>::remove):
(WTF::SizePolicy>::removeWithoutEntryConsistencyCheck):
(WTF::SizePolicy>::allocateTable):
(WTF::SizePolicy>::deallocateTable):
(WTF::SizePolicy>::expand):
(WTF::SizePolicy>::computeBestTableSize):
(WTF::SizePolicy>::shrinkToBestSize):
(WTF::SizePolicy>::rehash):
(WTF::SizePolicy>::clear):
(WTF::SizePolicy>::RobinHoodHashTable):
(WTF::SizePolicy>::swap):
(WTF::=):
(WTF::SizePolicy>::checkTableConsistency const):
(WTF::SizePolicy>::checkTableConsistencyExceptSize const):
* wtf/text/AtomStringHash.h:
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringTable.cpp:
(WTF::AtomStringTable::~AtomStringTable):
* wtf/text/AtomStringTable.h:
(WTF::AtomStringTable::table):
* wtf/text/StringHash.h:
Tools:
* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/DeletedAddressOfOperator.h:
* TestWebKitAPI/Tests/WTF/HashMap.cpp:
(TestWebKitAPI::testMovingUsingEnsure):
(TestWebKitAPI::testMovingUsingAdd):
* TestWebKitAPI/Tests/WTF/HashSet.cpp:
(TestWebKitAPI::generateTestCapacityUpToSize<0>):
(TestWebKitAPI::generateTestCapacityUpToSize):
* TestWebKitAPI/Tests/WTF/MoveOnly.h:
* TestWebKitAPI/Tests/WTF/RobinHoodHashMap.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp.
(TestWebKitAPI::TEST):
(TestWebKitAPI::bucketForKey):
(TestWebKitAPI::ZeroHash::hash):
(TestWebKitAPI::ObjectWithRefLogger::ObjectWithRefLogger):
(TestWebKitAPI::testMovingUsingEnsure):
(TestWebKitAPI::testMovingUsingAdd):
(TestWebKitAPI::DerefObserver::ref):
(TestWebKitAPI::DerefObserver::deref):
(TestWebKitAPI::TestObjectWithCustomDestructor::TestObjectWithCustomDestructor):
(TestWebKitAPI::TestObjectWithCustomDestructor::~TestObjectWithCustomDestructor):
* TestWebKitAPI/Tests/WTF/RobinHoodHashSet.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/HashSet.cpp.
(TestWebKitAPI::capacityForSize):
(TestWebKitAPI::testInitialCapacity):
(TestWebKitAPI::generateTestCapacityUpToSize<0>):
(TestWebKitAPI::generateTestCapacityUpToSize):
(TestWebKitAPI::TEST):
(TestWebKitAPI::DerefObserver::ref):
(TestWebKitAPI::DerefObserver::deref):
Canonical link: https://commits.webkit.org/236073@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-02 08:33:32 +00:00
static const MemoryCompactLookupOnlyRobinHoodHashMap < AtomString , AutofillInfo > & fieldNameMap ( )
2016-03-06 02:17:29 +00:00
{
Improve use of NeverDestroyed
https://bugs.webkit.org/show_bug.cgi?id=174348
Reviewed by Sam Weinig.
Source/JavaScriptCore:
* heap/MachineStackMarker.cpp:
* wasm/WasmMemory.cpp:
Removed unneeded includes of NeverDestroyed.h in files that do not make use
of NeverDestroyed.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/encryptedmedia/legacy/LegacyCDM.cpp:
(WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather
than a separate boolean for initialization.
* Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
(WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a
RefPtr. Simple to just use leakRef instead.
* Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h.
* Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto.
* Modules/mediasession/MediaSessionManager.cpp: Moved include of
NeverDestroyed.h here ...
* Modules/mediasession/MediaSessionManager.h: ... from here.
* Modules/mediasource/MediaSourceRegistry.cpp: Moved include of
NeverDestroyed.h here ...
* Modules/mediasource/MediaSourceRegistry.h: ... from here.
* Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/plugins/QuickTimePluginReplacement.h: Initialize
m_scriptObject in the class definition.
* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::QuickTimePluginReplacement::supportsMimeType): Use
makeNeverDestroyed and the HashSet constructor instead of a loop.
(WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto.
(WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a
slight cleanup of the initializers.
(WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added
a FIXME; unclear why there is code here at all.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use
makeNeverDestroyed and the Vector constructor instead of using empty
vector checks and Vector::add. Use std::any_of rather than Vector::contains
since we now are matching against pointers.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateEnumerationImplementationContent): Use const NeverDestroyed.
* bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp:
* bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp:
Regenerated.
* css/CSSProperty.cpp:
(WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed
for a global object that has a trivial destructor.
* css/ElementRuleCollector.cpp:
(WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a
Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit
isEmpty check each time this is called.
(WebCore::rightToLeftDeclaration): Ditto.
* css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the
uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand
is no less efficient than copying a global empty one was.
* dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h.
* dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h.
* dom/InputEvent.cpp: Ditto.
* dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ...
* dom/Microtasks.h: ... from here.
* dom/MutationObserver.cpp: Added an include of NeverDestroyed.h.
* dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ...
* dom/ScopedEventQueue.h: ... from here. Added Forward.h.
* dom/ScriptElement.cpp:
(WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed
and the HashSet constructor rather than an isEmpty check and a lot of
add function calls. Also removed comments that don't have value any more,
with dubious no longer relevant claims about the behavior of old web browsers.
The function that calls this one already has sufficient comments about why we
hope some day this function can be eliminated.
* dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h.
* dom/make_names.pl:
(printFactoryCppFile): Instead of using a "populate" function, use a function
that creates as HashMap. Then use const auto and makeNeverDestroyed.
(printWrapperFactoryCppFile): Ditto.
* editing/AlternativeTextController.cpp:
(WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed
and the Vector constructor rather than an isEmpty check and a lot of
append function calls.
(WebCore::markerTypesForReplacement): Ditto.
(WebCore::markerTypesForAppliedDictationAlternative): Ditto.
* editing/EditingStyle.cpp:
(WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed,
the Vector constructor, and new rather than make_unique. Changed return
type to use const pointers rather than unique_ptr with non-const type.
(WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated
for the above change to htmlElementEquivalents.
(WebCore::htmlAttributeEquivalents): Same approach as above.
(WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto.
(WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take
references instead of pointers.
(WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated
for the above.
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed,
and the HashSet constructor rather than isEmpty and a lot of calls to add.
* editing/RemoveFormatCommand.cpp:
(WebCore::isElementForRemoveFormatCommand): Ditto.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed,
and a lambda, rather than isEmpty and a lot of calls to add.
* html/Autofill.cpp:
(WebCore::fieldNameMap): Changed return type to be const. Use const auto,
makeNeverDestroyed, a lambda, and an array of values rather than isEmpty
and a lot of calls to add. Stopped doing the ConstructFromLiteral
optimization here. (Easy to add it back if that is a mistake.)
* html/HTMLObjectElement.cpp:
(WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and
a lambda rather than isEmpty.
* html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h.
* html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h.
* html/InputType.cpp:
(WebCore::createInputTypeFactoryMap): Replaced the populate function
with this create function.
(WebCore::InputType::create): Use const auto and makeNeverDestroyed
istead of isEmpty. Also put the map right where it is used so it's
not initialized in code path where not needed.
* html/parser/HTMLParserIdioms.cpp: Removed uneeded include of
NeverDestroyed.h.
* inspector/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::networkStateChanged):
Merged into a single line.
* loader/ContentFilter.cpp:
(WebCore::blockedPageURL): Use const auto and makeNeverDestroyed
rather than std::call_once. Since this is a URL and has a non-thread-safe
reference count, this was not thread safe before, so no need to use the
more roundabout and less efficient idiom for its thread safety.
* loader/CrossOriginAccessControl.cpp:
(WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted.
* loader/CrossOriginAccessControl.h: Deleted unused function
isOnAccessControlResponseHeaderWhitelist.
* loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>.
* loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of
NeverDestroyed.h.
* page/CaptionUserPreferences.cpp: Ditto.
* page/DebugPageOverlays.cpp:
(WebCore::touchEventRegionColors): Changed the return type to const, since
the callers do not modify the map. Use const auto, makeNeverDestroyed, and
a lambda rather than isEmpty and repeated calls to add.
* page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h.
* page/MemoryRelease.cpp:
(WebCore::releaseMemory): Use a function directly instead of calling it
inside a lambda.
* page/NavigatorBase.cpp:
(WebCore::NavigatorBase::onLine): Updated to call
NetworkStateNotifier::singleton.
* page/Page.cpp:
(WebCore::allPages): Made this a function instead of a global to use the
normal idiom for such globals.
(WebCore::Page::forEachPage): Updated for change to allPages.
(WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary
churn by using const AtomicString& instead of AtomicString.
(WebCore::Page::Page): Moved initialization of most data members to the
class definition. Removed initialiation of allPages. Updated the use of
NetworkStateNotifier for its new slightly changed interface.
(WebCore::Page::~Page): Updated for change to allPages.
(WebCore::Page::clearPreviousItemFromAllPages): Ditto.
(WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto.
(WebCore::Page::refreshPlugins): Ditto.
* page/Page.h: Moved initialization of most data members here.
* page/PerformanceUserTiming.cpp: Removed many unneded includes.
(WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and
a lambda instead of isEmpty. Also use an array rather than std::array and
got rid fo the unneeded use of anonymous namespace since this is fine in
the top level WebCore namespace.
(WebCore::clearPerformanceEntries): Tweaked coding style.
(WebCore::UserTiming::mark): Ditto.
(WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash
table lookup by using find instead of using contains followed by get.
removed unneeded explicit cast to double. Tweaked coding style.
(WebCore::convertToEntrySequence): Tweaked coding style.
(WebCore::getEntrySequenceByName): Deleted.
(WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName.
(WebCore::UserTiming::getMeasures): Ditto.
* page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ...
* page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h.
* platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h.
* platform/MIMETypeRegistry.cpp:
(WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global
constant array.
(WebCore::initializeSupportedJavaScriptMIMETypes): Ditto.
(WebCore::initializeSupportedNonImageMimeTypes): Ditto.
(WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function
with this one. Moved the common media types array here since it's only used here.
Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check.
Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the
double hashing that the old code was doing. And moved the code to find an entry
in the map in here from the client functions.
(WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the
typesForCommonExtension, and changed logic to use this first, and only call
getMIMETypeForExtension for extensions not in the map. This gives the same
result but should be slightly more efficient.
(WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the
typesForCommonExtension function. Comment about strategy is now in there.
(WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global
constant array. Also started using ASCIILiteral.
* platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ...
* platform/MainThreadSharedTimer.h: ... from here. Added Forward.h.
* platform/SchemeRegistry.cpp:
(WebCore::add): Added helper functions to keep code below simpler.
(WebCore::makeNeverDestroyedSchemeSet): Ditto.
(WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda,
and the helper functions above, rather than isEmpty.
(WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and
the HashSet constructor instead of isEmpty and add calls. Also changed the
return type to be const.
(WebCore::localURLSchemes): Copy the map using assignment instead of an
isEmpty function and a loop with calls to add.
(WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and
the Vector constructor rather than isEmpty, repeated calls to append,
and shrinkToFit.
(WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather
than isEmpty and repeated calls to add.
(WebCore::builtinSchemesWithUniqueOrigins): More of the same.
(WebCore::schemesWithUniqueOrigins): Ditto.
(WebCore::builtinEmptyDocumentSchemes): Ditto.
(WebCore::emptyDocumentSchemes): Ditto.
(WebCore::schemesForbiddenFromDomainRelaxation): Ditto.
(WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto.
(WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto.
(WebCore::builtinCORSEnabledSchemes): Ditto.
(WebCore::CORSEnabledSchemes): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for
empty string with check for null string, since that's slightly more efficient
for non-null, non-empty strings, and the hash table can handle empty strings
just fine.
(WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto.
(WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto.
(WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto.
(WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto.
(WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto.
(WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto.
(WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto.
(WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto.
(WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit.
(WebCore::SchemeRegistry::isBuiltinScheme): Added null check.
* platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto,
makeNeverDestroyed, and the Vector constructor rather than a call to size
and then append eacn time this funciton is called.
* platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of
NeverDestroyed.h from here ...
* platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here.
* platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of
NeverDestroyed.h here ...
* platform/gamepad/mac/HIDGamepadProvider.h: ... from here.
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::hasValidAverageCharWidth): Use const auto,
makeNeverDestroyed, and the HashSet constructor.
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of
NeverDestroyed<Vector<int>> here, instead using const std::array.
* platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take
const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole
pointer of the argument is that it's a table to map bytes onto other bytes.
* platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of
NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function,
and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead.
Made most functions in this class pure virtual instead of having default
implementations.
* platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include
of MediaPlaybackTargetContext.h now that it was removed above.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto,
makeNeverDestroyed, and the HashSet constructor.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense
of the boolean logic here to make this simpler and easier to read.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed
the implementation here, which empties out the passed in hash set, to use
the clear function rather than assignment from a global empty hash set. Added
a FIXME because it seems peculiar that this would be considered OK.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make
this a little more terse; I think it's clearer.
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to
argument type.
* platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of
NeverDestroyed.h.
(WebCore::appendImageSourceOption): Streamlined code using auto with
adoptCF; there is no need to write out the type of the RetainPtr.
(WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use
const auto and leakRef.
(WebCore::imageSourceAsyncOptions): Ditto.
* platform/graphics/gtk/GdkCairoUtilities.cpp:
(WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed
on a pointer, just use a global pointer. There is no need to use any kind
of NeverDestroyed on a type with a trivial destructor such as a pointer.
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::platformFontWithFamilySpecialCase): Instead of using
NeverDestroyed<RetainPtr> just use a raw pointer global.
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformFontWithFamilySpecialCase): Ditto.
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::createFileTypesSet): Return the HashSet instead of adding to it.
Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although
it seems the C++ syntax was working fine.
(WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the
HashMap every time this function is called. Use const auto and makeNeverDestroyed
instead of using a boolean to do one time initialization.
(WebCore::mimeModernTypesCache): Ditto.
(WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a
constant array const.
* platform/ios/Device.cpp:
(WebCore::deviceClass): Use a lambda to initialize a variable here instead
of using std::call_once. This function does not need to be thread safe.
(WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed
and std::call_once. This function does not need to be thread safe.
* platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a
constant instead of a variable.
(WebCore::cascadeForSystemFont): Added helper function.
(WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed
instead of LazyNeverDestroyed and dispatch_once. This code does not need
to be thread safe since its arguments include, for example, a DOM element.
* platform/ios/LegacyTileLayerPool.h: Removed unneeded include of
NeverDestroyed.h.
* platform/ios/QuickLook.mm:
(WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer
instead of NeverDestroyed<RetainPtr<NSSet>>.
(WebCore::createQLPreviewProtocol): Deleted.
(WebCore::QLPreviewProtocol): Use a global raw pointer instead of
a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead
of appending to an array, and less wasteful of memory too.
* platform/ios/WebCoreMotionManager.mm: Removed unneeded include of
NeverDestroyed.h.
* platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto.
* platform/mac/DragImageMac.mm: Ditto.
* platform/mediastream/CaptureDeviceManager.cpp: Ditto.
* platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto.
* platform/mock/MockRealtimeMediaSource.cpp:
(WebCore::MockRealtimeMediaSource::audioDevices): Use auto,
makeNeverDestroyed, and a lambda instead of checking size each time.
(WebCore::MockRealtimeMediaSource::videoDevices): Ditto.
* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the
HashSet constructor instead of an explicit boolean to initialize.
* platform/network/BlobRegistryImpl.cpp:
(WebCore::blobUtilityQueue): Use a global with a raw reference instead
of a NeverDestroyed<Ref>.
* platform/network/NetworkStateNotifier.cpp:
(WebCore::NetworkStateNotifier::singleton): Renamed this from
networkStateNotifier. We must have missed this when we changed to use the
singleton idiom consistently. Also changed to use normal NeverDestroyed
rather than using LazyNeverDestroyed and call_once, because this is not
used from multiple threads and has no special thread safety requirements.
(WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor
here and construct the timer. Before the timer was used only on the Mac
platform but now it is there for all platforms.
(WebCore::NetworkStateNotifier::onLine): Moved function here from the header.
It's a littlel less trivial than before because it now triggers a call to
updateState as needed.
(WebCore::NetworkStateNotifier::addListener): Renamed from
addNetworkStateChangeListener since there is only one kind of listener and
the old name was too wordy. Changed to call the new startObserving function,
and guaranteed to call it onlh once. The platform-specific logic for iOS is
now inside the iOS version of that function instead of here.
(WebCore::NetworkStateNotifier::updateState): Moved here now that it is the
same for all platforms. The actual state updating is done in a function named
updateStateWithoutNotifying, which is implemented for each platform.
(WebCore::NetworkStateNotifier::updateStateSoon): New function which takes
advantage of the timer to coalesce network state updates.
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub
version of this function.
(WebCore::NetworkStateNotifier::startObserving): Ditto.
(WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from
this has moved into updateState.
* platform/network/NetworkStateNotifier.h: Greatly cut down what part of this
class is platform-specific.
* platform/network/ios/NetworkStateNotifierIOS.mm:
(-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it
takes a block, rather than using a pointer to the C++ notifier and doing
WebThreadRun.
(-[WebNetworkStateObserver dealloc]): Ditto.
(-[WebNetworkStateObserver networkStateChanged:]): Ditto.
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying):
This now calls isNetworkReachable.
(WebCore::NetworkStateNotifier::startObserving): Check the
Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK
to observe, then create the observer. This code now takes care of the
WebThreadRun and calls updateStateSoon.
(WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The
constructor is now platform independent.
(WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This
object is never destroyed so we should not write a destructor for it.
(WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted.
Replaced by startObserving.
(WebCore::NetworkStateNotifier::onLine): Deleted. This function is now
platform-independent.
(WebCore::setOnLine): Deleted. The logic from this is now in
updateState and updateStateWithoutNotifying.
* platform/network/mac/NetworkStateNotifierMac.cpp:
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed
this from updateState and tightened up the code a bit. Also changed
to not assume anything. If there is an error, we leave m_isOnLine alone.
Default behavior is now in the platform-independent code, and the default
is to treat things as on-line if updateStateWithoutNotifying was called
and it was never able to update the state even once.
(WebCore::NetworkStateNotifier::startObserving): Moved most of the code
from the constructor into this function.
(WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is
now a lambda inside startObserving.
(WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted.
This function is now platform-independent and is named updateState.
* platform/network/win/NetworkStateNotifierWin.cpp:
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed
from updateState and tightened the code up a bit. Also changed
to not assume anything. If there is an error, we leave m_isOnLine alone.
Default behavior is now in the platform-independent code, and the default
is to treat things as on-line if updateStateWithoutNotifying was called
and it was never able to update the state even once.
(WebCore::NetworkStateNotifier::addressChanged): Deleted.
This function is now platform-independent and is named updateState.
(WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from
addrChangeCallback. Simplified by using the singleton function instead
of relying on the context pointer.
(WebCore::NetworkStateNotifier::startObserving): Moved most of the code
from the constructor here.
* platform/text/LocaleToScriptMappingDefault.cpp:
(WebCore::scriptNameToCode): Use makeNeverDestroyed.
(WebCore::localeToScriptCodeForFontSelection): Ditto.
* platform/text/ios/LocalizedDateCache.h: Moved include of
NeverDestroyed.h from here ...
* platform/text/ios/LocalizedDateCache.mm: ... to here.
* platform/wpe/RenderThemeWPE.cpp:
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/RenderTheme.h: Made RenderTheme no longer reference counted.
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/RenderThemeIOS.h: Ditto.
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
Also marked a lot of functions final rather than override and initialized
data members in the class deifnition.
* rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the
file. They should really go into SPI headers.
(-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument
here because the theme is a singleton and we don't need a pointer to it.
Add the observer here instead of doing it in the caller.
(-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call
platformColorsDidChange through the singleton rather than using a pointer.
(-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]):
Tightened up the code a bit by using CFAutorelease instead of using a
combination of NSMakeCollectable, autorelease, and a typecast to accomplish
the same thing.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
(WebCore::RenderThemeMac::create): Deleted.
(WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the
class definition and observing into the WebCoreRenderThemeNotificationObserver
init function.
(WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since
the object will never be destroyed.
(WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType):
Removed an unnecessary conversion from C string literal to WTF::String and
then to NSString. Instead, just use an NSString literal.
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/svg/RenderSVGResource.cpp:
(WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into
the code where it is used.
* svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h.
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGClipPathElement.cpp:
(WebCore::SVGClipPathElement::isSupportedAttribute): Ditto.
* svg/SVGComponentTransferFunctionElement.cpp:
(WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto.
* svg/SVGCursorElement.cpp:
(WebCore::SVGCursorElement::isSupportedAttribute): Ditto.
* svg/SVGElement.cpp:
(WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate
function with this create function.
(WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto.
(WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to
const reference. Use const auto and makeNeverDestroyed instead of using
isEmpty and a populate function.
(WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap):
More of the same.
(WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto.
(WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of
a HashSet since we are checking against only 3 or 4 values.
(WebCore::addQualifiedName): Deleted.
(WebCore::SVGElement::animatableAttributeForName): Use const auto,
makeNeverDestroyed, and a lambda to efficiently build the map in this function.
(WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and
makeNeverDestroyed instead of using isEmpty and a populate function.
* svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGFilterPrimitiveStandardAttributes.cpp:
(WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto.
* svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto.
* svg/SVGGElement.cpp:
(WebCore::SVGGElement::isSupportedAttribute): Ditto.
* svg/SVGGradientElement.cpp:
(WebCore::SVGGradientElement::isSupportedAttribute): Ditto.
* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto.
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::isSupportedAttribute): Ditto.
* svg/SVGLangSpace.cpp:
(WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead
of making our own NeverDestroyed local xmlPrefix.
(WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper.
* svg/SVGLineElement.cpp:
(WebCore::SVGLineElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGLinearGradientElement.cpp:
(WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto.
* svg/SVGMarkerElement.cpp:
(WebCore::SVGMarkerElement::isSupportedAttribute): Ditto.
* svg/SVGMaskElement.cpp:
(WebCore::SVGMaskElement::isSupportedAttribute): Ditto.
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::isSupportedAttribute): Ditto.
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::isSupportedAttribute): Ditto.
* svg/SVGRadialGradientElement.cpp:
(WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto.
* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::isSupportedAttribute): Ditto.
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::isSupportedAttribute): Ditto.
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSupportedAttribute): Ditto.
* testing/MockContentFilterSettings.h: Removed unneeded include of
NeverDestroyed.h.
* testing/MockGamepadProvider.cpp: Moved include of
NeverDestroyed.h here ...
* testing/MockGamepadProvider.h: ... from here.
* testing/MockPreviewLoaderClient.h: Removed unneeded include of
NeverDestroyed.h.
* workers/Worker.cpp:
(WebCore::allWorkers): Changed this from a global to a function.
(WebCore::Worker::networkStateChanged): Updated for above change and
made this a member function.
(WebCore::Worker::Worker): Updated for above change and
change to NetworkStateNotifier.
(WebCore::Worker::~Worker): Ditto.
* workers/Worker.h: Made networkStateChanged a static member instead of
a friend since that is a cleaner way to give it access to private member
functions.
* xml/XPathFunctions.cpp:
(WebCore::XPath::createFunctionMap): Use create instead of populate style.
(WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed
instead of an isEmpty check.
* xml/XPathParser.cpp:
(WebCore::XPath::createAxisNamesMap): Use create instead of populate style.
(WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed
instead of an isEmpty check.
Source/WebKit:
* DatabaseProcess/DatabaseProcess.h: Removed unneeded include of
NeverDestroyed.h.
* NetworkProcess/cache/NetworkCacheKey.cpp: Ditto.
* NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of
NeverDestroyed.h here ...
* NetworkProcess/capture/NetworkCaptureManager.h: ... from here.
* PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h
here ...
* PluginProcess/PluginProcess.h: ... from here.
* Shared/API/Cocoa/_WKRemoteObjectInterface.mm:
(isContainerClass): Removed trivial inefficient use of
LazyNeverDestroyed<HashSet> to check against two classes.
Instead wrote out the boolean expression.
* Shared/mac/SecItemShim.cpp: Removed unneeded include of
NeverDestroyed.h.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitialize): Call
installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton.
* UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include
of NeverDestroyed.h.
* UIProcess/Plugins/PluginProcessManager.cpp: Moved include of
NeverDestroyed.h here ...
* UIProcess/Plugins/PluginProcessManager.h: ... from here.
* UIProcess/WebInspectorProxy.cpp: Removed unneeded include
of NeverDestroyed.h.
* UIProcess/WebPageProxy.h: Added now-needed include of
MediaPlaybackTargetContext.h.
* UIProcess/WebPasteboardProxy.cpp: Moved include of
NeverDestroyed.h here ...
* UIProcess/WebPasteboardProxy.h: ... from here.
* UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the
WebMemoryPressureHandler class from this header. Callers don't need to
know if there is a class. They simply indicate when it's time to install
the handler. Another way to put it is that this class had no functions
other than the singleton function.
* UIProcess/ios/WebMemoryPressureHandlerIOS.mm:
(WebKit::installMemoryPressureHandler): Replaced the class with this function.
It creates a dispatch source and then resumes it. To avoid having the source
look like a leak, we keep it in a global variable.
* WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of
NeverDestroyed.h.
* WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of
NeverDestroyed.h here ...
* WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded
include of NeverDestroyed.h.
Source/WebKitLegacy:
* Storage/StorageThread.cpp:
(WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads):
Simplify code by using a modern for loop and passing a function without wrapping
it in a lambda.
Source/WebKitLegacy/mac:
* Misc/WebStringTruncator.mm:
(+[WebStringTruncator centerTruncateString:toWidth:]): Replace
NeverDestroyed<RetainPtr> with just an NSFont * global.
* Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of
NeverDestroyed.h.
* Storage/WebDatabaseManager.mm: Ditto.
* WebCoreSupport/WebFrameNetworkingContext.mm: Ditto.
* WebCoreSupport/WebPlatformStrategies.mm: Ditto.
* WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h.
(aeDescFromJSValue): Removed double hashing by using the return value from
add rather than calling contains before calling add.
Source/WTF:
* wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of
const references. This is handy to add a bunch of values all at once. Later we can
consider optimizing to grow the hash table only once instead of deciding whether to
grow repeatedly as we add each value.
(WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here.
* wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ...
* wtf/MemoryPressureHandler.h: ... not here.
* wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed.
Added a makeNeverDestroyed function that deduces the type from the argument.
With auto, this can be used to avoid writing out a long type twice.
* wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h.
* wtf/text/AtomicString.cpp: Ditto.
Canonical link: https://commits.webkit.org/191408@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
static const auto map = makeNeverDestroyed ( [ ] {
struct MapEntry {
2021-04-06 00:09:31 +00:00
ASCIILiteral name ;
Improve use of NeverDestroyed
https://bugs.webkit.org/show_bug.cgi?id=174348
Reviewed by Sam Weinig.
Source/JavaScriptCore:
* heap/MachineStackMarker.cpp:
* wasm/WasmMemory.cpp:
Removed unneeded includes of NeverDestroyed.h in files that do not make use
of NeverDestroyed.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/encryptedmedia/legacy/LegacyCDM.cpp:
(WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather
than a separate boolean for initialization.
* Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
(WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a
RefPtr. Simple to just use leakRef instead.
* Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h.
* Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto.
* Modules/mediasession/MediaSessionManager.cpp: Moved include of
NeverDestroyed.h here ...
* Modules/mediasession/MediaSessionManager.h: ... from here.
* Modules/mediasource/MediaSourceRegistry.cpp: Moved include of
NeverDestroyed.h here ...
* Modules/mediasource/MediaSourceRegistry.h: ... from here.
* Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/plugins/QuickTimePluginReplacement.h: Initialize
m_scriptObject in the class definition.
* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::QuickTimePluginReplacement::supportsMimeType): Use
makeNeverDestroyed and the HashSet constructor instead of a loop.
(WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto.
(WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a
slight cleanup of the initializers.
(WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added
a FIXME; unclear why there is code here at all.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use
makeNeverDestroyed and the Vector constructor instead of using empty
vector checks and Vector::add. Use std::any_of rather than Vector::contains
since we now are matching against pointers.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateEnumerationImplementationContent): Use const NeverDestroyed.
* bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp:
* bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp:
Regenerated.
* css/CSSProperty.cpp:
(WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed
for a global object that has a trivial destructor.
* css/ElementRuleCollector.cpp:
(WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a
Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit
isEmpty check each time this is called.
(WebCore::rightToLeftDeclaration): Ditto.
* css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the
uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand
is no less efficient than copying a global empty one was.
* dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h.
* dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h.
* dom/InputEvent.cpp: Ditto.
* dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ...
* dom/Microtasks.h: ... from here.
* dom/MutationObserver.cpp: Added an include of NeverDestroyed.h.
* dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ...
* dom/ScopedEventQueue.h: ... from here. Added Forward.h.
* dom/ScriptElement.cpp:
(WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed
and the HashSet constructor rather than an isEmpty check and a lot of
add function calls. Also removed comments that don't have value any more,
with dubious no longer relevant claims about the behavior of old web browsers.
The function that calls this one already has sufficient comments about why we
hope some day this function can be eliminated.
* dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h.
* dom/make_names.pl:
(printFactoryCppFile): Instead of using a "populate" function, use a function
that creates as HashMap. Then use const auto and makeNeverDestroyed.
(printWrapperFactoryCppFile): Ditto.
* editing/AlternativeTextController.cpp:
(WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed
and the Vector constructor rather than an isEmpty check and a lot of
append function calls.
(WebCore::markerTypesForReplacement): Ditto.
(WebCore::markerTypesForAppliedDictationAlternative): Ditto.
* editing/EditingStyle.cpp:
(WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed,
the Vector constructor, and new rather than make_unique. Changed return
type to use const pointers rather than unique_ptr with non-const type.
(WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated
for the above change to htmlElementEquivalents.
(WebCore::htmlAttributeEquivalents): Same approach as above.
(WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto.
(WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take
references instead of pointers.
(WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated
for the above.
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed,
and the HashSet constructor rather than isEmpty and a lot of calls to add.
* editing/RemoveFormatCommand.cpp:
(WebCore::isElementForRemoveFormatCommand): Ditto.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed,
and a lambda, rather than isEmpty and a lot of calls to add.
* html/Autofill.cpp:
(WebCore::fieldNameMap): Changed return type to be const. Use const auto,
makeNeverDestroyed, a lambda, and an array of values rather than isEmpty
and a lot of calls to add. Stopped doing the ConstructFromLiteral
optimization here. (Easy to add it back if that is a mistake.)
* html/HTMLObjectElement.cpp:
(WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and
a lambda rather than isEmpty.
* html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h.
* html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h.
* html/InputType.cpp:
(WebCore::createInputTypeFactoryMap): Replaced the populate function
with this create function.
(WebCore::InputType::create): Use const auto and makeNeverDestroyed
istead of isEmpty. Also put the map right where it is used so it's
not initialized in code path where not needed.
* html/parser/HTMLParserIdioms.cpp: Removed uneeded include of
NeverDestroyed.h.
* inspector/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::networkStateChanged):
Merged into a single line.
* loader/ContentFilter.cpp:
(WebCore::blockedPageURL): Use const auto and makeNeverDestroyed
rather than std::call_once. Since this is a URL and has a non-thread-safe
reference count, this was not thread safe before, so no need to use the
more roundabout and less efficient idiom for its thread safety.
* loader/CrossOriginAccessControl.cpp:
(WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted.
* loader/CrossOriginAccessControl.h: Deleted unused function
isOnAccessControlResponseHeaderWhitelist.
* loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>.
* loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of
NeverDestroyed.h.
* page/CaptionUserPreferences.cpp: Ditto.
* page/DebugPageOverlays.cpp:
(WebCore::touchEventRegionColors): Changed the return type to const, since
the callers do not modify the map. Use const auto, makeNeverDestroyed, and
a lambda rather than isEmpty and repeated calls to add.
* page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h.
* page/MemoryRelease.cpp:
(WebCore::releaseMemory): Use a function directly instead of calling it
inside a lambda.
* page/NavigatorBase.cpp:
(WebCore::NavigatorBase::onLine): Updated to call
NetworkStateNotifier::singleton.
* page/Page.cpp:
(WebCore::allPages): Made this a function instead of a global to use the
normal idiom for such globals.
(WebCore::Page::forEachPage): Updated for change to allPages.
(WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary
churn by using const AtomicString& instead of AtomicString.
(WebCore::Page::Page): Moved initialization of most data members to the
class definition. Removed initialiation of allPages. Updated the use of
NetworkStateNotifier for its new slightly changed interface.
(WebCore::Page::~Page): Updated for change to allPages.
(WebCore::Page::clearPreviousItemFromAllPages): Ditto.
(WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto.
(WebCore::Page::refreshPlugins): Ditto.
* page/Page.h: Moved initialization of most data members here.
* page/PerformanceUserTiming.cpp: Removed many unneded includes.
(WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and
a lambda instead of isEmpty. Also use an array rather than std::array and
got rid fo the unneeded use of anonymous namespace since this is fine in
the top level WebCore namespace.
(WebCore::clearPerformanceEntries): Tweaked coding style.
(WebCore::UserTiming::mark): Ditto.
(WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash
table lookup by using find instead of using contains followed by get.
removed unneeded explicit cast to double. Tweaked coding style.
(WebCore::convertToEntrySequence): Tweaked coding style.
(WebCore::getEntrySequenceByName): Deleted.
(WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName.
(WebCore::UserTiming::getMeasures): Ditto.
* page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ...
* page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h.
* platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h.
* platform/MIMETypeRegistry.cpp:
(WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global
constant array.
(WebCore::initializeSupportedJavaScriptMIMETypes): Ditto.
(WebCore::initializeSupportedNonImageMimeTypes): Ditto.
(WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function
with this one. Moved the common media types array here since it's only used here.
Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check.
Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the
double hashing that the old code was doing. And moved the code to find an entry
in the map in here from the client functions.
(WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the
typesForCommonExtension, and changed logic to use this first, and only call
getMIMETypeForExtension for extensions not in the map. This gives the same
result but should be slightly more efficient.
(WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the
typesForCommonExtension function. Comment about strategy is now in there.
(WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global
constant array. Also started using ASCIILiteral.
* platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ...
* platform/MainThreadSharedTimer.h: ... from here. Added Forward.h.
* platform/SchemeRegistry.cpp:
(WebCore::add): Added helper functions to keep code below simpler.
(WebCore::makeNeverDestroyedSchemeSet): Ditto.
(WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda,
and the helper functions above, rather than isEmpty.
(WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and
the HashSet constructor instead of isEmpty and add calls. Also changed the
return type to be const.
(WebCore::localURLSchemes): Copy the map using assignment instead of an
isEmpty function and a loop with calls to add.
(WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and
the Vector constructor rather than isEmpty, repeated calls to append,
and shrinkToFit.
(WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather
than isEmpty and repeated calls to add.
(WebCore::builtinSchemesWithUniqueOrigins): More of the same.
(WebCore::schemesWithUniqueOrigins): Ditto.
(WebCore::builtinEmptyDocumentSchemes): Ditto.
(WebCore::emptyDocumentSchemes): Ditto.
(WebCore::schemesForbiddenFromDomainRelaxation): Ditto.
(WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto.
(WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto.
(WebCore::builtinCORSEnabledSchemes): Ditto.
(WebCore::CORSEnabledSchemes): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for
empty string with check for null string, since that's slightly more efficient
for non-null, non-empty strings, and the hash table can handle empty strings
just fine.
(WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto.
(WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto.
(WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto.
(WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto.
(WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto.
(WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto.
(WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto.
(WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto.
(WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit.
(WebCore::SchemeRegistry::isBuiltinScheme): Added null check.
* platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto,
makeNeverDestroyed, and the Vector constructor rather than a call to size
and then append eacn time this funciton is called.
* platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of
NeverDestroyed.h from here ...
* platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here.
* platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of
NeverDestroyed.h here ...
* platform/gamepad/mac/HIDGamepadProvider.h: ... from here.
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::hasValidAverageCharWidth): Use const auto,
makeNeverDestroyed, and the HashSet constructor.
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of
NeverDestroyed<Vector<int>> here, instead using const std::array.
* platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take
const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole
pointer of the argument is that it's a table to map bytes onto other bytes.
* platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of
NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function,
and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead.
Made most functions in this class pure virtual instead of having default
implementations.
* platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include
of MediaPlaybackTargetContext.h now that it was removed above.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto,
makeNeverDestroyed, and the HashSet constructor.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense
of the boolean logic here to make this simpler and easier to read.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed
the implementation here, which empties out the passed in hash set, to use
the clear function rather than assignment from a global empty hash set. Added
a FIXME because it seems peculiar that this would be considered OK.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make
this a little more terse; I think it's clearer.
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to
argument type.
* platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of
NeverDestroyed.h.
(WebCore::appendImageSourceOption): Streamlined code using auto with
adoptCF; there is no need to write out the type of the RetainPtr.
(WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use
const auto and leakRef.
(WebCore::imageSourceAsyncOptions): Ditto.
* platform/graphics/gtk/GdkCairoUtilities.cpp:
(WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed
on a pointer, just use a global pointer. There is no need to use any kind
of NeverDestroyed on a type with a trivial destructor such as a pointer.
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::platformFontWithFamilySpecialCase): Instead of using
NeverDestroyed<RetainPtr> just use a raw pointer global.
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformFontWithFamilySpecialCase): Ditto.
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::createFileTypesSet): Return the HashSet instead of adding to it.
Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although
it seems the C++ syntax was working fine.
(WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the
HashMap every time this function is called. Use const auto and makeNeverDestroyed
instead of using a boolean to do one time initialization.
(WebCore::mimeModernTypesCache): Ditto.
(WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a
constant array const.
* platform/ios/Device.cpp:
(WebCore::deviceClass): Use a lambda to initialize a variable here instead
of using std::call_once. This function does not need to be thread safe.
(WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed
and std::call_once. This function does not need to be thread safe.
* platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a
constant instead of a variable.
(WebCore::cascadeForSystemFont): Added helper function.
(WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed
instead of LazyNeverDestroyed and dispatch_once. This code does not need
to be thread safe since its arguments include, for example, a DOM element.
* platform/ios/LegacyTileLayerPool.h: Removed unneeded include of
NeverDestroyed.h.
* platform/ios/QuickLook.mm:
(WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer
instead of NeverDestroyed<RetainPtr<NSSet>>.
(WebCore::createQLPreviewProtocol): Deleted.
(WebCore::QLPreviewProtocol): Use a global raw pointer instead of
a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead
of appending to an array, and less wasteful of memory too.
* platform/ios/WebCoreMotionManager.mm: Removed unneeded include of
NeverDestroyed.h.
* platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto.
* platform/mac/DragImageMac.mm: Ditto.
* platform/mediastream/CaptureDeviceManager.cpp: Ditto.
* platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto.
* platform/mock/MockRealtimeMediaSource.cpp:
(WebCore::MockRealtimeMediaSource::audioDevices): Use auto,
makeNeverDestroyed, and a lambda instead of checking size each time.
(WebCore::MockRealtimeMediaSource::videoDevices): Ditto.
* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the
HashSet constructor instead of an explicit boolean to initialize.
* platform/network/BlobRegistryImpl.cpp:
(WebCore::blobUtilityQueue): Use a global with a raw reference instead
of a NeverDestroyed<Ref>.
* platform/network/NetworkStateNotifier.cpp:
(WebCore::NetworkStateNotifier::singleton): Renamed this from
networkStateNotifier. We must have missed this when we changed to use the
singleton idiom consistently. Also changed to use normal NeverDestroyed
rather than using LazyNeverDestroyed and call_once, because this is not
used from multiple threads and has no special thread safety requirements.
(WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor
here and construct the timer. Before the timer was used only on the Mac
platform but now it is there for all platforms.
(WebCore::NetworkStateNotifier::onLine): Moved function here from the header.
It's a littlel less trivial than before because it now triggers a call to
updateState as needed.
(WebCore::NetworkStateNotifier::addListener): Renamed from
addNetworkStateChangeListener since there is only one kind of listener and
the old name was too wordy. Changed to call the new startObserving function,
and guaranteed to call it onlh once. The platform-specific logic for iOS is
now inside the iOS version of that function instead of here.
(WebCore::NetworkStateNotifier::updateState): Moved here now that it is the
same for all platforms. The actual state updating is done in a function named
updateStateWithoutNotifying, which is implemented for each platform.
(WebCore::NetworkStateNotifier::updateStateSoon): New function which takes
advantage of the timer to coalesce network state updates.
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub
version of this function.
(WebCore::NetworkStateNotifier::startObserving): Ditto.
(WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from
this has moved into updateState.
* platform/network/NetworkStateNotifier.h: Greatly cut down what part of this
class is platform-specific.
* platform/network/ios/NetworkStateNotifierIOS.mm:
(-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it
takes a block, rather than using a pointer to the C++ notifier and doing
WebThreadRun.
(-[WebNetworkStateObserver dealloc]): Ditto.
(-[WebNetworkStateObserver networkStateChanged:]): Ditto.
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying):
This now calls isNetworkReachable.
(WebCore::NetworkStateNotifier::startObserving): Check the
Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK
to observe, then create the observer. This code now takes care of the
WebThreadRun and calls updateStateSoon.
(WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The
constructor is now platform independent.
(WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This
object is never destroyed so we should not write a destructor for it.
(WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted.
Replaced by startObserving.
(WebCore::NetworkStateNotifier::onLine): Deleted. This function is now
platform-independent.
(WebCore::setOnLine): Deleted. The logic from this is now in
updateState and updateStateWithoutNotifying.
* platform/network/mac/NetworkStateNotifierMac.cpp:
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed
this from updateState and tightened up the code a bit. Also changed
to not assume anything. If there is an error, we leave m_isOnLine alone.
Default behavior is now in the platform-independent code, and the default
is to treat things as on-line if updateStateWithoutNotifying was called
and it was never able to update the state even once.
(WebCore::NetworkStateNotifier::startObserving): Moved most of the code
from the constructor into this function.
(WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is
now a lambda inside startObserving.
(WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted.
This function is now platform-independent and is named updateState.
* platform/network/win/NetworkStateNotifierWin.cpp:
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed
from updateState and tightened the code up a bit. Also changed
to not assume anything. If there is an error, we leave m_isOnLine alone.
Default behavior is now in the platform-independent code, and the default
is to treat things as on-line if updateStateWithoutNotifying was called
and it was never able to update the state even once.
(WebCore::NetworkStateNotifier::addressChanged): Deleted.
This function is now platform-independent and is named updateState.
(WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from
addrChangeCallback. Simplified by using the singleton function instead
of relying on the context pointer.
(WebCore::NetworkStateNotifier::startObserving): Moved most of the code
from the constructor here.
* platform/text/LocaleToScriptMappingDefault.cpp:
(WebCore::scriptNameToCode): Use makeNeverDestroyed.
(WebCore::localeToScriptCodeForFontSelection): Ditto.
* platform/text/ios/LocalizedDateCache.h: Moved include of
NeverDestroyed.h from here ...
* platform/text/ios/LocalizedDateCache.mm: ... to here.
* platform/wpe/RenderThemeWPE.cpp:
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/RenderTheme.h: Made RenderTheme no longer reference counted.
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/RenderThemeIOS.h: Ditto.
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
Also marked a lot of functions final rather than override and initialized
data members in the class deifnition.
* rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the
file. They should really go into SPI headers.
(-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument
here because the theme is a singleton and we don't need a pointer to it.
Add the observer here instead of doing it in the caller.
(-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call
platformColorsDidChange through the singleton rather than using a pointer.
(-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]):
Tightened up the code a bit by using CFAutorelease instead of using a
combination of NSMakeCollectable, autorelease, and a typecast to accomplish
the same thing.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
(WebCore::RenderThemeMac::create): Deleted.
(WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the
class definition and observing into the WebCoreRenderThemeNotificationObserver
init function.
(WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since
the object will never be destroyed.
(WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType):
Removed an unnecessary conversion from C string literal to WTF::String and
then to NSString. Instead, just use an NSString literal.
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/svg/RenderSVGResource.cpp:
(WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into
the code where it is used.
* svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h.
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGClipPathElement.cpp:
(WebCore::SVGClipPathElement::isSupportedAttribute): Ditto.
* svg/SVGComponentTransferFunctionElement.cpp:
(WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto.
* svg/SVGCursorElement.cpp:
(WebCore::SVGCursorElement::isSupportedAttribute): Ditto.
* svg/SVGElement.cpp:
(WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate
function with this create function.
(WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto.
(WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to
const reference. Use const auto and makeNeverDestroyed instead of using
isEmpty and a populate function.
(WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap):
More of the same.
(WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto.
(WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of
a HashSet since we are checking against only 3 or 4 values.
(WebCore::addQualifiedName): Deleted.
(WebCore::SVGElement::animatableAttributeForName): Use const auto,
makeNeverDestroyed, and a lambda to efficiently build the map in this function.
(WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and
makeNeverDestroyed instead of using isEmpty and a populate function.
* svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGFilterPrimitiveStandardAttributes.cpp:
(WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto.
* svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto.
* svg/SVGGElement.cpp:
(WebCore::SVGGElement::isSupportedAttribute): Ditto.
* svg/SVGGradientElement.cpp:
(WebCore::SVGGradientElement::isSupportedAttribute): Ditto.
* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto.
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::isSupportedAttribute): Ditto.
* svg/SVGLangSpace.cpp:
(WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead
of making our own NeverDestroyed local xmlPrefix.
(WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper.
* svg/SVGLineElement.cpp:
(WebCore::SVGLineElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGLinearGradientElement.cpp:
(WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto.
* svg/SVGMarkerElement.cpp:
(WebCore::SVGMarkerElement::isSupportedAttribute): Ditto.
* svg/SVGMaskElement.cpp:
(WebCore::SVGMaskElement::isSupportedAttribute): Ditto.
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::isSupportedAttribute): Ditto.
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::isSupportedAttribute): Ditto.
* svg/SVGRadialGradientElement.cpp:
(WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto.
* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::isSupportedAttribute): Ditto.
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::isSupportedAttribute): Ditto.
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSupportedAttribute): Ditto.
* testing/MockContentFilterSettings.h: Removed unneeded include of
NeverDestroyed.h.
* testing/MockGamepadProvider.cpp: Moved include of
NeverDestroyed.h here ...
* testing/MockGamepadProvider.h: ... from here.
* testing/MockPreviewLoaderClient.h: Removed unneeded include of
NeverDestroyed.h.
* workers/Worker.cpp:
(WebCore::allWorkers): Changed this from a global to a function.
(WebCore::Worker::networkStateChanged): Updated for above change and
made this a member function.
(WebCore::Worker::Worker): Updated for above change and
change to NetworkStateNotifier.
(WebCore::Worker::~Worker): Ditto.
* workers/Worker.h: Made networkStateChanged a static member instead of
a friend since that is a cleaner way to give it access to private member
functions.
* xml/XPathFunctions.cpp:
(WebCore::XPath::createFunctionMap): Use create instead of populate style.
(WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed
instead of an isEmpty check.
* xml/XPathParser.cpp:
(WebCore::XPath::createAxisNamesMap): Use create instead of populate style.
(WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed
instead of an isEmpty check.
Source/WebKit:
* DatabaseProcess/DatabaseProcess.h: Removed unneeded include of
NeverDestroyed.h.
* NetworkProcess/cache/NetworkCacheKey.cpp: Ditto.
* NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of
NeverDestroyed.h here ...
* NetworkProcess/capture/NetworkCaptureManager.h: ... from here.
* PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h
here ...
* PluginProcess/PluginProcess.h: ... from here.
* Shared/API/Cocoa/_WKRemoteObjectInterface.mm:
(isContainerClass): Removed trivial inefficient use of
LazyNeverDestroyed<HashSet> to check against two classes.
Instead wrote out the boolean expression.
* Shared/mac/SecItemShim.cpp: Removed unneeded include of
NeverDestroyed.h.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitialize): Call
installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton.
* UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include
of NeverDestroyed.h.
* UIProcess/Plugins/PluginProcessManager.cpp: Moved include of
NeverDestroyed.h here ...
* UIProcess/Plugins/PluginProcessManager.h: ... from here.
* UIProcess/WebInspectorProxy.cpp: Removed unneeded include
of NeverDestroyed.h.
* UIProcess/WebPageProxy.h: Added now-needed include of
MediaPlaybackTargetContext.h.
* UIProcess/WebPasteboardProxy.cpp: Moved include of
NeverDestroyed.h here ...
* UIProcess/WebPasteboardProxy.h: ... from here.
* UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the
WebMemoryPressureHandler class from this header. Callers don't need to
know if there is a class. They simply indicate when it's time to install
the handler. Another way to put it is that this class had no functions
other than the singleton function.
* UIProcess/ios/WebMemoryPressureHandlerIOS.mm:
(WebKit::installMemoryPressureHandler): Replaced the class with this function.
It creates a dispatch source and then resumes it. To avoid having the source
look like a leak, we keep it in a global variable.
* WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of
NeverDestroyed.h.
* WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of
NeverDestroyed.h here ...
* WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded
include of NeverDestroyed.h.
Source/WebKitLegacy:
* Storage/StorageThread.cpp:
(WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads):
Simplify code by using a modern for loop and passing a function without wrapping
it in a lambda.
Source/WebKitLegacy/mac:
* Misc/WebStringTruncator.mm:
(+[WebStringTruncator centerTruncateString:toWidth:]): Replace
NeverDestroyed<RetainPtr> with just an NSFont * global.
* Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of
NeverDestroyed.h.
* Storage/WebDatabaseManager.mm: Ditto.
* WebCoreSupport/WebFrameNetworkingContext.mm: Ditto.
* WebCoreSupport/WebPlatformStrategies.mm: Ditto.
* WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h.
(aeDescFromJSValue): Removed double hashing by using the return value from
add rather than calling contains before calling add.
Source/WTF:
* wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of
const references. This is handy to add a bunch of values all at once. Later we can
consider optimizing to grow the hash table only once instead of deciding whether to
grow repeatedly as we add each value.
(WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here.
* wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ...
* wtf/MemoryPressureHandler.h: ... not here.
* wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed.
Added a makeNeverDestroyed function that deduces the type from the argument.
With auto, this can be used to avoid writing out a long type twice.
* wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h.
* wtf/text/AtomicString.cpp: Ditto.
Canonical link: https://commits.webkit.org/191408@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
AutofillInfo value ;
} ;
static const MapEntry entries [ ] = {
2021-04-06 00:09:31 +00:00
{ " off " _s , { AutofillFieldName : : None , AutofillCategory : : Off } } ,
{ " on " _s , { AutofillFieldName : : None , AutofillCategory : : Automatic } } ,
{ " name " _s , { AutofillFieldName : : Name , AutofillCategory : : Normal } } ,
{ " honorific-prefix " _s , { AutofillFieldName : : HonorificPrefix , AutofillCategory : : Normal } } ,
{ " given-name " _s , { AutofillFieldName : : GivenName , AutofillCategory : : Normal } } ,
{ " additional-name " _s , { AutofillFieldName : : AdditionalName , AutofillCategory : : Normal } } ,
{ " family-name " _s , { AutofillFieldName : : FamilyName , AutofillCategory : : Normal } } ,
{ " honorific-suffix " _s , { AutofillFieldName : : HonorificSuffix , AutofillCategory : : Normal } } ,
{ " nickname " _s , { AutofillFieldName : : Nickname , AutofillCategory : : Normal } } ,
{ " username " _s , { AutofillFieldName : : Username , AutofillCategory : : Normal } } ,
{ " new-password " _s , { AutofillFieldName : : NewPassword , AutofillCategory : : Normal } } ,
{ " current-password " _s , { AutofillFieldName : : CurrentPassword , AutofillCategory : : Normal } } ,
{ " organization-title " _s , { AutofillFieldName : : OrganizationTitle , AutofillCategory : : Normal } } ,
{ " organization " _s , { AutofillFieldName : : Organization , AutofillCategory : : Normal } } ,
{ " street-address " _s , { AutofillFieldName : : StreetAddress , AutofillCategory : : Normal } } ,
{ " address-line1 " _s , { AutofillFieldName : : AddressLine1 , AutofillCategory : : Normal } } ,
{ " address-line2 " _s , { AutofillFieldName : : AddressLine2 , AutofillCategory : : Normal } } ,
{ " address-line3 " _s , { AutofillFieldName : : AddressLine3 , AutofillCategory : : Normal } } ,
{ " address-level4 " _s , { AutofillFieldName : : AddressLevel4 , AutofillCategory : : Normal } } ,
{ " address-level3 " _s , { AutofillFieldName : : AddressLevel3 , AutofillCategory : : Normal } } ,
{ " address-level2 " _s , { AutofillFieldName : : AddressLevel2 , AutofillCategory : : Normal } } ,
{ " address-level1 " _s , { AutofillFieldName : : AddressLevel1 , AutofillCategory : : Normal } } ,
{ " country " _s , { AutofillFieldName : : Country , AutofillCategory : : Normal } } ,
{ " country-name " _s , { AutofillFieldName : : CountryName , AutofillCategory : : Normal } } ,
{ " postal-code " _s , { AutofillFieldName : : PostalCode , AutofillCategory : : Normal } } ,
{ " cc-name " _s , { AutofillFieldName : : CcName , AutofillCategory : : Normal } } ,
{ " cc-given-name " _s , { AutofillFieldName : : CcGivenName , AutofillCategory : : Normal } } ,
{ " cc-additional-name " _s , { AutofillFieldName : : CcAdditionalName , AutofillCategory : : Normal } } ,
{ " cc-family-name " _s , { AutofillFieldName : : CcFamilyName , AutofillCategory : : Normal } } ,
{ " cc-number " _s , { AutofillFieldName : : CcNumber , AutofillCategory : : Normal } } ,
{ " cc-exp " _s , { AutofillFieldName : : CcExp , AutofillCategory : : Normal } } ,
{ " cc-exp-month " _s , { AutofillFieldName : : CcExpMonth , AutofillCategory : : Normal } } ,
{ " cc-exp-year " _s , { AutofillFieldName : : CcExpYear , AutofillCategory : : Normal } } ,
{ " cc-csc " _s , { AutofillFieldName : : CcCsc , AutofillCategory : : Normal } } ,
{ " cc-type " _s , { AutofillFieldName : : CcType , AutofillCategory : : Normal } } ,
{ " transaction-currency " _s , { AutofillFieldName : : TransactionCurrency , AutofillCategory : : Normal } } ,
{ " transaction-amount " _s , { AutofillFieldName : : TransactionAmount , AutofillCategory : : Normal } } ,
{ " language " _s , { AutofillFieldName : : Language , AutofillCategory : : Normal } } ,
{ " bday " _s , { AutofillFieldName : : Bday , AutofillCategory : : Normal } } ,
{ " bday-day " _s , { AutofillFieldName : : BdayDay , AutofillCategory : : Normal } } ,
{ " bday-month " _s , { AutofillFieldName : : BdayMonth , AutofillCategory : : Normal } } ,
{ " bday-year " _s , { AutofillFieldName : : BdayYear , AutofillCategory : : Normal } } ,
{ " sex " _s , { AutofillFieldName : : Sex , AutofillCategory : : Normal } } ,
{ " url " _s , { AutofillFieldName : : URL , AutofillCategory : : Normal } } ,
{ " photo " _s , { AutofillFieldName : : Photo , AutofillCategory : : Normal } } ,
2016-03-06 02:17:29 +00:00
2021-04-06 00:09:31 +00:00
{ " tel " _s , { AutofillFieldName : : Tel , AutofillCategory : : Contact } } ,
{ " tel-country-code " _s , { AutofillFieldName : : TelCountryCode , AutofillCategory : : Contact } } ,
{ " tel-national " _s , { AutofillFieldName : : TelNational , AutofillCategory : : Contact } } ,
{ " tel-area-code " _s , { AutofillFieldName : : TelAreaCode , AutofillCategory : : Contact } } ,
{ " tel-local " _s , { AutofillFieldName : : TelLocal , AutofillCategory : : Contact } } ,
{ " tel-local-prefix " _s , { AutofillFieldName : : TelLocalPrefix , AutofillCategory : : Contact } } ,
{ " tel-local-suffix " _s , { AutofillFieldName : : TelLocalSuffix , AutofillCategory : : Contact } } ,
{ " tel-extension " _s , { AutofillFieldName : : TelExtension , AutofillCategory : : Contact } } ,
{ " email " _s , { AutofillFieldName : : Email , AutofillCategory : : Contact } } ,
{ " impp " _s , { AutofillFieldName : : Impp , AutofillCategory : : Contact } } ,
Improve use of NeverDestroyed
https://bugs.webkit.org/show_bug.cgi?id=174348
Reviewed by Sam Weinig.
Source/JavaScriptCore:
* heap/MachineStackMarker.cpp:
* wasm/WasmMemory.cpp:
Removed unneeded includes of NeverDestroyed.h in files that do not make use
of NeverDestroyed.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/encryptedmedia/legacy/LegacyCDM.cpp:
(WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather
than a separate boolean for initialization.
* Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
(WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a
RefPtr. Simple to just use leakRef instead.
* Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h.
* Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto.
* Modules/mediasession/MediaSessionManager.cpp: Moved include of
NeverDestroyed.h here ...
* Modules/mediasession/MediaSessionManager.h: ... from here.
* Modules/mediasource/MediaSourceRegistry.cpp: Moved include of
NeverDestroyed.h here ...
* Modules/mediasource/MediaSourceRegistry.h: ... from here.
* Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/plugins/QuickTimePluginReplacement.h: Initialize
m_scriptObject in the class definition.
* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::QuickTimePluginReplacement::supportsMimeType): Use
makeNeverDestroyed and the HashSet constructor instead of a loop.
(WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto.
(WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a
slight cleanup of the initializers.
(WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added
a FIXME; unclear why there is code here at all.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use
makeNeverDestroyed and the Vector constructor instead of using empty
vector checks and Vector::add. Use std::any_of rather than Vector::contains
since we now are matching against pointers.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateEnumerationImplementationContent): Use const NeverDestroyed.
* bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp:
* bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp:
Regenerated.
* css/CSSProperty.cpp:
(WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed
for a global object that has a trivial destructor.
* css/ElementRuleCollector.cpp:
(WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a
Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit
isEmpty check each time this is called.
(WebCore::rightToLeftDeclaration): Ditto.
* css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the
uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand
is no less efficient than copying a global empty one was.
* dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h.
* dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h.
* dom/InputEvent.cpp: Ditto.
* dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ...
* dom/Microtasks.h: ... from here.
* dom/MutationObserver.cpp: Added an include of NeverDestroyed.h.
* dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ...
* dom/ScopedEventQueue.h: ... from here. Added Forward.h.
* dom/ScriptElement.cpp:
(WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed
and the HashSet constructor rather than an isEmpty check and a lot of
add function calls. Also removed comments that don't have value any more,
with dubious no longer relevant claims about the behavior of old web browsers.
The function that calls this one already has sufficient comments about why we
hope some day this function can be eliminated.
* dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h.
* dom/make_names.pl:
(printFactoryCppFile): Instead of using a "populate" function, use a function
that creates as HashMap. Then use const auto and makeNeverDestroyed.
(printWrapperFactoryCppFile): Ditto.
* editing/AlternativeTextController.cpp:
(WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed
and the Vector constructor rather than an isEmpty check and a lot of
append function calls.
(WebCore::markerTypesForReplacement): Ditto.
(WebCore::markerTypesForAppliedDictationAlternative): Ditto.
* editing/EditingStyle.cpp:
(WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed,
the Vector constructor, and new rather than make_unique. Changed return
type to use const pointers rather than unique_ptr with non-const type.
(WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated
for the above change to htmlElementEquivalents.
(WebCore::htmlAttributeEquivalents): Same approach as above.
(WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto.
(WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take
references instead of pointers.
(WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated
for the above.
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed,
and the HashSet constructor rather than isEmpty and a lot of calls to add.
* editing/RemoveFormatCommand.cpp:
(WebCore::isElementForRemoveFormatCommand): Ditto.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed,
and a lambda, rather than isEmpty and a lot of calls to add.
* html/Autofill.cpp:
(WebCore::fieldNameMap): Changed return type to be const. Use const auto,
makeNeverDestroyed, a lambda, and an array of values rather than isEmpty
and a lot of calls to add. Stopped doing the ConstructFromLiteral
optimization here. (Easy to add it back if that is a mistake.)
* html/HTMLObjectElement.cpp:
(WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and
a lambda rather than isEmpty.
* html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h.
* html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h.
* html/InputType.cpp:
(WebCore::createInputTypeFactoryMap): Replaced the populate function
with this create function.
(WebCore::InputType::create): Use const auto and makeNeverDestroyed
istead of isEmpty. Also put the map right where it is used so it's
not initialized in code path where not needed.
* html/parser/HTMLParserIdioms.cpp: Removed uneeded include of
NeverDestroyed.h.
* inspector/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::networkStateChanged):
Merged into a single line.
* loader/ContentFilter.cpp:
(WebCore::blockedPageURL): Use const auto and makeNeverDestroyed
rather than std::call_once. Since this is a URL and has a non-thread-safe
reference count, this was not thread safe before, so no need to use the
more roundabout and less efficient idiom for its thread safety.
* loader/CrossOriginAccessControl.cpp:
(WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted.
* loader/CrossOriginAccessControl.h: Deleted unused function
isOnAccessControlResponseHeaderWhitelist.
* loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>.
* loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of
NeverDestroyed.h.
* page/CaptionUserPreferences.cpp: Ditto.
* page/DebugPageOverlays.cpp:
(WebCore::touchEventRegionColors): Changed the return type to const, since
the callers do not modify the map. Use const auto, makeNeverDestroyed, and
a lambda rather than isEmpty and repeated calls to add.
* page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h.
* page/MemoryRelease.cpp:
(WebCore::releaseMemory): Use a function directly instead of calling it
inside a lambda.
* page/NavigatorBase.cpp:
(WebCore::NavigatorBase::onLine): Updated to call
NetworkStateNotifier::singleton.
* page/Page.cpp:
(WebCore::allPages): Made this a function instead of a global to use the
normal idiom for such globals.
(WebCore::Page::forEachPage): Updated for change to allPages.
(WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary
churn by using const AtomicString& instead of AtomicString.
(WebCore::Page::Page): Moved initialization of most data members to the
class definition. Removed initialiation of allPages. Updated the use of
NetworkStateNotifier for its new slightly changed interface.
(WebCore::Page::~Page): Updated for change to allPages.
(WebCore::Page::clearPreviousItemFromAllPages): Ditto.
(WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto.
(WebCore::Page::refreshPlugins): Ditto.
* page/Page.h: Moved initialization of most data members here.
* page/PerformanceUserTiming.cpp: Removed many unneded includes.
(WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and
a lambda instead of isEmpty. Also use an array rather than std::array and
got rid fo the unneeded use of anonymous namespace since this is fine in
the top level WebCore namespace.
(WebCore::clearPerformanceEntries): Tweaked coding style.
(WebCore::UserTiming::mark): Ditto.
(WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash
table lookup by using find instead of using contains followed by get.
removed unneeded explicit cast to double. Tweaked coding style.
(WebCore::convertToEntrySequence): Tweaked coding style.
(WebCore::getEntrySequenceByName): Deleted.
(WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName.
(WebCore::UserTiming::getMeasures): Ditto.
* page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ...
* page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h.
* platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h.
* platform/MIMETypeRegistry.cpp:
(WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global
constant array.
(WebCore::initializeSupportedJavaScriptMIMETypes): Ditto.
(WebCore::initializeSupportedNonImageMimeTypes): Ditto.
(WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function
with this one. Moved the common media types array here since it's only used here.
Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check.
Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the
double hashing that the old code was doing. And moved the code to find an entry
in the map in here from the client functions.
(WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the
typesForCommonExtension, and changed logic to use this first, and only call
getMIMETypeForExtension for extensions not in the map. This gives the same
result but should be slightly more efficient.
(WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the
typesForCommonExtension function. Comment about strategy is now in there.
(WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global
constant array. Also started using ASCIILiteral.
* platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ...
* platform/MainThreadSharedTimer.h: ... from here. Added Forward.h.
* platform/SchemeRegistry.cpp:
(WebCore::add): Added helper functions to keep code below simpler.
(WebCore::makeNeverDestroyedSchemeSet): Ditto.
(WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda,
and the helper functions above, rather than isEmpty.
(WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and
the HashSet constructor instead of isEmpty and add calls. Also changed the
return type to be const.
(WebCore::localURLSchemes): Copy the map using assignment instead of an
isEmpty function and a loop with calls to add.
(WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and
the Vector constructor rather than isEmpty, repeated calls to append,
and shrinkToFit.
(WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather
than isEmpty and repeated calls to add.
(WebCore::builtinSchemesWithUniqueOrigins): More of the same.
(WebCore::schemesWithUniqueOrigins): Ditto.
(WebCore::builtinEmptyDocumentSchemes): Ditto.
(WebCore::emptyDocumentSchemes): Ditto.
(WebCore::schemesForbiddenFromDomainRelaxation): Ditto.
(WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto.
(WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto.
(WebCore::builtinCORSEnabledSchemes): Ditto.
(WebCore::CORSEnabledSchemes): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for
empty string with check for null string, since that's slightly more efficient
for non-null, non-empty strings, and the hash table can handle empty strings
just fine.
(WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto.
(WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto.
(WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto.
(WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto.
(WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto.
(WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto.
(WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto.
(WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto.
(WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit.
(WebCore::SchemeRegistry::isBuiltinScheme): Added null check.
* platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto,
makeNeverDestroyed, and the Vector constructor rather than a call to size
and then append eacn time this funciton is called.
* platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of
NeverDestroyed.h from here ...
* platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here.
* platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of
NeverDestroyed.h here ...
* platform/gamepad/mac/HIDGamepadProvider.h: ... from here.
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::hasValidAverageCharWidth): Use const auto,
makeNeverDestroyed, and the HashSet constructor.
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of
NeverDestroyed<Vector<int>> here, instead using const std::array.
* platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take
const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole
pointer of the argument is that it's a table to map bytes onto other bytes.
* platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of
NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function,
and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead.
Made most functions in this class pure virtual instead of having default
implementations.
* platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include
of MediaPlaybackTargetContext.h now that it was removed above.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto,
makeNeverDestroyed, and the HashSet constructor.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense
of the boolean logic here to make this simpler and easier to read.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed
the implementation here, which empties out the passed in hash set, to use
the clear function rather than assignment from a global empty hash set. Added
a FIXME because it seems peculiar that this would be considered OK.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make
this a little more terse; I think it's clearer.
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to
argument type.
* platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of
NeverDestroyed.h.
(WebCore::appendImageSourceOption): Streamlined code using auto with
adoptCF; there is no need to write out the type of the RetainPtr.
(WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use
const auto and leakRef.
(WebCore::imageSourceAsyncOptions): Ditto.
* platform/graphics/gtk/GdkCairoUtilities.cpp:
(WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed
on a pointer, just use a global pointer. There is no need to use any kind
of NeverDestroyed on a type with a trivial destructor such as a pointer.
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::platformFontWithFamilySpecialCase): Instead of using
NeverDestroyed<RetainPtr> just use a raw pointer global.
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformFontWithFamilySpecialCase): Ditto.
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::createFileTypesSet): Return the HashSet instead of adding to it.
Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although
it seems the C++ syntax was working fine.
(WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the
HashMap every time this function is called. Use const auto and makeNeverDestroyed
instead of using a boolean to do one time initialization.
(WebCore::mimeModernTypesCache): Ditto.
(WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a
constant array const.
* platform/ios/Device.cpp:
(WebCore::deviceClass): Use a lambda to initialize a variable here instead
of using std::call_once. This function does not need to be thread safe.
(WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed
and std::call_once. This function does not need to be thread safe.
* platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a
constant instead of a variable.
(WebCore::cascadeForSystemFont): Added helper function.
(WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed
instead of LazyNeverDestroyed and dispatch_once. This code does not need
to be thread safe since its arguments include, for example, a DOM element.
* platform/ios/LegacyTileLayerPool.h: Removed unneeded include of
NeverDestroyed.h.
* platform/ios/QuickLook.mm:
(WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer
instead of NeverDestroyed<RetainPtr<NSSet>>.
(WebCore::createQLPreviewProtocol): Deleted.
(WebCore::QLPreviewProtocol): Use a global raw pointer instead of
a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead
of appending to an array, and less wasteful of memory too.
* platform/ios/WebCoreMotionManager.mm: Removed unneeded include of
NeverDestroyed.h.
* platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto.
* platform/mac/DragImageMac.mm: Ditto.
* platform/mediastream/CaptureDeviceManager.cpp: Ditto.
* platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto.
* platform/mock/MockRealtimeMediaSource.cpp:
(WebCore::MockRealtimeMediaSource::audioDevices): Use auto,
makeNeverDestroyed, and a lambda instead of checking size each time.
(WebCore::MockRealtimeMediaSource::videoDevices): Ditto.
* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the
HashSet constructor instead of an explicit boolean to initialize.
* platform/network/BlobRegistryImpl.cpp:
(WebCore::blobUtilityQueue): Use a global with a raw reference instead
of a NeverDestroyed<Ref>.
* platform/network/NetworkStateNotifier.cpp:
(WebCore::NetworkStateNotifier::singleton): Renamed this from
networkStateNotifier. We must have missed this when we changed to use the
singleton idiom consistently. Also changed to use normal NeverDestroyed
rather than using LazyNeverDestroyed and call_once, because this is not
used from multiple threads and has no special thread safety requirements.
(WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor
here and construct the timer. Before the timer was used only on the Mac
platform but now it is there for all platforms.
(WebCore::NetworkStateNotifier::onLine): Moved function here from the header.
It's a littlel less trivial than before because it now triggers a call to
updateState as needed.
(WebCore::NetworkStateNotifier::addListener): Renamed from
addNetworkStateChangeListener since there is only one kind of listener and
the old name was too wordy. Changed to call the new startObserving function,
and guaranteed to call it onlh once. The platform-specific logic for iOS is
now inside the iOS version of that function instead of here.
(WebCore::NetworkStateNotifier::updateState): Moved here now that it is the
same for all platforms. The actual state updating is done in a function named
updateStateWithoutNotifying, which is implemented for each platform.
(WebCore::NetworkStateNotifier::updateStateSoon): New function which takes
advantage of the timer to coalesce network state updates.
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub
version of this function.
(WebCore::NetworkStateNotifier::startObserving): Ditto.
(WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from
this has moved into updateState.
* platform/network/NetworkStateNotifier.h: Greatly cut down what part of this
class is platform-specific.
* platform/network/ios/NetworkStateNotifierIOS.mm:
(-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it
takes a block, rather than using a pointer to the C++ notifier and doing
WebThreadRun.
(-[WebNetworkStateObserver dealloc]): Ditto.
(-[WebNetworkStateObserver networkStateChanged:]): Ditto.
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying):
This now calls isNetworkReachable.
(WebCore::NetworkStateNotifier::startObserving): Check the
Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK
to observe, then create the observer. This code now takes care of the
WebThreadRun and calls updateStateSoon.
(WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The
constructor is now platform independent.
(WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This
object is never destroyed so we should not write a destructor for it.
(WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted.
Replaced by startObserving.
(WebCore::NetworkStateNotifier::onLine): Deleted. This function is now
platform-independent.
(WebCore::setOnLine): Deleted. The logic from this is now in
updateState and updateStateWithoutNotifying.
* platform/network/mac/NetworkStateNotifierMac.cpp:
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed
this from updateState and tightened up the code a bit. Also changed
to not assume anything. If there is an error, we leave m_isOnLine alone.
Default behavior is now in the platform-independent code, and the default
is to treat things as on-line if updateStateWithoutNotifying was called
and it was never able to update the state even once.
(WebCore::NetworkStateNotifier::startObserving): Moved most of the code
from the constructor into this function.
(WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is
now a lambda inside startObserving.
(WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted.
This function is now platform-independent and is named updateState.
* platform/network/win/NetworkStateNotifierWin.cpp:
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed
from updateState and tightened the code up a bit. Also changed
to not assume anything. If there is an error, we leave m_isOnLine alone.
Default behavior is now in the platform-independent code, and the default
is to treat things as on-line if updateStateWithoutNotifying was called
and it was never able to update the state even once.
(WebCore::NetworkStateNotifier::addressChanged): Deleted.
This function is now platform-independent and is named updateState.
(WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from
addrChangeCallback. Simplified by using the singleton function instead
of relying on the context pointer.
(WebCore::NetworkStateNotifier::startObserving): Moved most of the code
from the constructor here.
* platform/text/LocaleToScriptMappingDefault.cpp:
(WebCore::scriptNameToCode): Use makeNeverDestroyed.
(WebCore::localeToScriptCodeForFontSelection): Ditto.
* platform/text/ios/LocalizedDateCache.h: Moved include of
NeverDestroyed.h from here ...
* platform/text/ios/LocalizedDateCache.mm: ... to here.
* platform/wpe/RenderThemeWPE.cpp:
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/RenderTheme.h: Made RenderTheme no longer reference counted.
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/RenderThemeIOS.h: Ditto.
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
Also marked a lot of functions final rather than override and initialized
data members in the class deifnition.
* rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the
file. They should really go into SPI headers.
(-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument
here because the theme is a singleton and we don't need a pointer to it.
Add the observer here instead of doing it in the caller.
(-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call
platformColorsDidChange through the singleton rather than using a pointer.
(-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]):
Tightened up the code a bit by using CFAutorelease instead of using a
combination of NSMakeCollectable, autorelease, and a typecast to accomplish
the same thing.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
(WebCore::RenderThemeMac::create): Deleted.
(WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the
class definition and observing into the WebCoreRenderThemeNotificationObserver
init function.
(WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since
the object will never be destroyed.
(WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType):
Removed an unnecessary conversion from C string literal to WTF::String and
then to NSString. Instead, just use an NSString literal.
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/svg/RenderSVGResource.cpp:
(WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into
the code where it is used.
* svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h.
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGClipPathElement.cpp:
(WebCore::SVGClipPathElement::isSupportedAttribute): Ditto.
* svg/SVGComponentTransferFunctionElement.cpp:
(WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto.
* svg/SVGCursorElement.cpp:
(WebCore::SVGCursorElement::isSupportedAttribute): Ditto.
* svg/SVGElement.cpp:
(WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate
function with this create function.
(WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto.
(WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to
const reference. Use const auto and makeNeverDestroyed instead of using
isEmpty and a populate function.
(WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap):
More of the same.
(WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto.
(WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of
a HashSet since we are checking against only 3 or 4 values.
(WebCore::addQualifiedName): Deleted.
(WebCore::SVGElement::animatableAttributeForName): Use const auto,
makeNeverDestroyed, and a lambda to efficiently build the map in this function.
(WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and
makeNeverDestroyed instead of using isEmpty and a populate function.
* svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGFilterPrimitiveStandardAttributes.cpp:
(WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto.
* svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto.
* svg/SVGGElement.cpp:
(WebCore::SVGGElement::isSupportedAttribute): Ditto.
* svg/SVGGradientElement.cpp:
(WebCore::SVGGradientElement::isSupportedAttribute): Ditto.
* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto.
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::isSupportedAttribute): Ditto.
* svg/SVGLangSpace.cpp:
(WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead
of making our own NeverDestroyed local xmlPrefix.
(WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper.
* svg/SVGLineElement.cpp:
(WebCore::SVGLineElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGLinearGradientElement.cpp:
(WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto.
* svg/SVGMarkerElement.cpp:
(WebCore::SVGMarkerElement::isSupportedAttribute): Ditto.
* svg/SVGMaskElement.cpp:
(WebCore::SVGMaskElement::isSupportedAttribute): Ditto.
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::isSupportedAttribute): Ditto.
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::isSupportedAttribute): Ditto.
* svg/SVGRadialGradientElement.cpp:
(WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto.
* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::isSupportedAttribute): Ditto.
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::isSupportedAttribute): Ditto.
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSupportedAttribute): Ditto.
* testing/MockContentFilterSettings.h: Removed unneeded include of
NeverDestroyed.h.
* testing/MockGamepadProvider.cpp: Moved include of
NeverDestroyed.h here ...
* testing/MockGamepadProvider.h: ... from here.
* testing/MockPreviewLoaderClient.h: Removed unneeded include of
NeverDestroyed.h.
* workers/Worker.cpp:
(WebCore::allWorkers): Changed this from a global to a function.
(WebCore::Worker::networkStateChanged): Updated for above change and
made this a member function.
(WebCore::Worker::Worker): Updated for above change and
change to NetworkStateNotifier.
(WebCore::Worker::~Worker): Ditto.
* workers/Worker.h: Made networkStateChanged a static member instead of
a friend since that is a cleaner way to give it access to private member
functions.
* xml/XPathFunctions.cpp:
(WebCore::XPath::createFunctionMap): Use create instead of populate style.
(WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed
instead of an isEmpty check.
* xml/XPathParser.cpp:
(WebCore::XPath::createAxisNamesMap): Use create instead of populate style.
(WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed
instead of an isEmpty check.
Source/WebKit:
* DatabaseProcess/DatabaseProcess.h: Removed unneeded include of
NeverDestroyed.h.
* NetworkProcess/cache/NetworkCacheKey.cpp: Ditto.
* NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of
NeverDestroyed.h here ...
* NetworkProcess/capture/NetworkCaptureManager.h: ... from here.
* PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h
here ...
* PluginProcess/PluginProcess.h: ... from here.
* Shared/API/Cocoa/_WKRemoteObjectInterface.mm:
(isContainerClass): Removed trivial inefficient use of
LazyNeverDestroyed<HashSet> to check against two classes.
Instead wrote out the boolean expression.
* Shared/mac/SecItemShim.cpp: Removed unneeded include of
NeverDestroyed.h.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitialize): Call
installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton.
* UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include
of NeverDestroyed.h.
* UIProcess/Plugins/PluginProcessManager.cpp: Moved include of
NeverDestroyed.h here ...
* UIProcess/Plugins/PluginProcessManager.h: ... from here.
* UIProcess/WebInspectorProxy.cpp: Removed unneeded include
of NeverDestroyed.h.
* UIProcess/WebPageProxy.h: Added now-needed include of
MediaPlaybackTargetContext.h.
* UIProcess/WebPasteboardProxy.cpp: Moved include of
NeverDestroyed.h here ...
* UIProcess/WebPasteboardProxy.h: ... from here.
* UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the
WebMemoryPressureHandler class from this header. Callers don't need to
know if there is a class. They simply indicate when it's time to install
the handler. Another way to put it is that this class had no functions
other than the singleton function.
* UIProcess/ios/WebMemoryPressureHandlerIOS.mm:
(WebKit::installMemoryPressureHandler): Replaced the class with this function.
It creates a dispatch source and then resumes it. To avoid having the source
look like a leak, we keep it in a global variable.
* WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of
NeverDestroyed.h.
* WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of
NeverDestroyed.h here ...
* WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded
include of NeverDestroyed.h.
Source/WebKitLegacy:
* Storage/StorageThread.cpp:
(WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads):
Simplify code by using a modern for loop and passing a function without wrapping
it in a lambda.
Source/WebKitLegacy/mac:
* Misc/WebStringTruncator.mm:
(+[WebStringTruncator centerTruncateString:toWidth:]): Replace
NeverDestroyed<RetainPtr> with just an NSFont * global.
* Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of
NeverDestroyed.h.
* Storage/WebDatabaseManager.mm: Ditto.
* WebCoreSupport/WebFrameNetworkingContext.mm: Ditto.
* WebCoreSupport/WebPlatformStrategies.mm: Ditto.
* WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h.
(aeDescFromJSValue): Removed double hashing by using the return value from
add rather than calling contains before calling add.
Source/WTF:
* wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of
const references. This is handy to add a bunch of values all at once. Later we can
consider optimizing to grow the hash table only once instead of deciding whether to
grow repeatedly as we add each value.
(WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here.
* wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ...
* wtf/MemoryPressureHandler.h: ... not here.
* wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed.
Added a makeNeverDestroyed function that deduces the type from the argument.
With auto, this can be used to avoid writing out a long type twice.
* wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h.
* wtf/text/AtomicString.cpp: Ditto.
Canonical link: https://commits.webkit.org/191408@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
} ;
[WTF] Introduce RobinHoodHashTable
https://bugs.webkit.org/show_bug.cgi?id=223895
Reviewed by Fil Pizlo.
Source/JavaScriptCore:
* builtins/BuiltinNames.cpp:
(JSC::lookUpPrivateNameImpl):
(JSC::lookUpWellKnownSymbolImpl):
* builtins/BuiltinNames.h:
* bytecode/BytecodeIntrinsicRegistry.h:
* runtime/Identifier.h:
* runtime/IntlCollator.cpp:
(JSC::IntlCollator::initializeCollator):
(JSC::IntlCollator::checkICULocaleInvariants):
* runtime/IntlCollator.h:
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
* runtime/IntlDateTimeFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlDisplayNames.cpp:
(JSC::IntlDisplayNames::initializeDisplayNames):
* runtime/IntlDisplayNamesConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlListFormat.cpp:
(JSC::IntlListFormat::initializeListFormat):
* runtime/IntlListFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat):
* runtime/IntlNumberFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlObject.cpp:
(JSC::addScriptlessLocaleIfNeeded):
(JSC::intlAvailableLocales):
(JSC::intlCollatorAvailableLocales):
(JSC::intlSegmenterAvailableLocales):
(JSC::bestAvailableLocale):
(JSC::lookupMatcher):
(JSC::bestFitMatcher):
(JSC::resolveLocale):
(JSC::lookupSupportedLocales):
(JSC::bestFitSupportedLocales):
(JSC::supportedLocales):
* runtime/IntlObject.h:
(JSC::intlDateTimeFormatAvailableLocales):
(JSC::intlDisplayNamesAvailableLocales):
(JSC::intlNumberFormatAvailableLocales):
(JSC::intlPluralRulesAvailableLocales):
(JSC::intlRelativeTimeFormatAvailableLocales):
(JSC::intlListFormatAvailableLocales):
* runtime/IntlPluralRules.cpp:
(JSC::IntlPluralRules::initializePluralRules):
* runtime/IntlPluralRulesConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlRelativeTimeFormat.cpp:
(JSC::IntlRelativeTimeFormat::initializeRelativeTimeFormat):
* runtime/IntlRelativeTimeFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlSegmenter.cpp:
(JSC::IntlSegmenter::initializeSegmenter):
* runtime/IntlSegmenterConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/RegExpCache.h:
* runtime/RegExpKey.h:
Source/WebCore:
* Modules/mediacapabilities/MediaCapabilities.cpp:
(WebCore::bucketMIMETypes):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::popupValue const):
* dom/Element.cpp:
(WebCore::canAttachAuthorShadowRoot):
* dom/QualifiedName.h:
* dom/make_names.pl:
(printNamesHeaderFile):
(printFactoryCppFile):
(printWrapperFactoryCppFile):
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock):
* editing/RemoveFormatCommand.cpp:
(WebCore::isElementForRemoveFormatCommand):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::isProhibitedParagraphChild):
* html/Autofill.cpp:
(WebCore::fieldNameMap):
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::isCaseSensitiveAttribute):
* html/HTMLObjectElement.cpp:
(WebCore::preventsParentObjectFromExposure):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::createCaseMap):
(WebCore::adjustSVGTagNameCase):
(WebCore::adjustAttributes):
(WebCore::createForeignAttributesMap):
(WebCore::adjustForeignAttributes):
(WebCore::addNamesWithPrefix): Deleted.
* page/DebugPageOverlays.cpp:
(WebCore::touchEventRegionColors):
(WebCore::NonFastScrollableRegionOverlay::drawRect):
* page/PerformanceUserTiming.cpp:
(WebCore::restrictedMarkNamesToNavigationTimingFunctionMap):
* platform/cocoa/MIMETypeRegistryCocoa.mm:
(WebCore::extensionsForMIMETypeMap):
* platform/graphics/FontCascade.cpp:
(WebCore::useBackslashAsYenSignForFamily):
(WebCore::FontCascade::hasValidAverageCharWidth const):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::validInitDataTypes):
* platform/graphics/cg/UTIRegistry.cpp:
(WebCore::defaultSupportedImageTypes):
* platform/graphics/cg/UTIRegistry.h:
* platform/graphics/cocoa/HEVCUtilitiesCocoa.mm:
(WebCore::codecTypeForDoViCodecString):
* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::supportedVideoCodecs):
(WebCore::SourceBufferParserWebM::supportedAudioCodecs):
* platform/graphics/cocoa/SourceBufferParserWebM.h:
* rendering/svg/SVGResources.cpp:
(WebCore::clipperFilterMaskerTags):
(WebCore::markerTags):
(WebCore::fillAndStrokeTags):
(WebCore::chainableResourceTags):
* style/StyleAdjuster.cpp:
(WebCore::Style::hasEffectiveDisplayNoneForDisplayContents):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::isSupportedAttribute):
* svg/SVGElement.cpp:
(WebCore::createAttributeNameToCSSPropertyIDMap):
(WebCore::SVGElement::animatableAttributeForName):
(WebCore::SVGElement::cssPropertyIdForSVGAttributeName):
* svg/SVGTests.cpp:
(WebCore::SVGTests::addSupportedAttributes):
* svg/SVGTests.h:
* svg/SVGUseElement.cpp:
(WebCore::createAllowedElementSet):
(WebCore::isDisallowedElement):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSupportedAttribute):
* xml/XPathFunctions.cpp:
(WebCore::XPath::createFunctionMap):
* xml/XPathParser.cpp:
(WebCore::XPath::createAxisNamesMap):
Source/WebKit:
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ObservedDomainsTableSchemaV1Alternate):
(WebKit::expectedUnattributedColumns):
(WebKit::expectedAttributedColumns):
(WebKit::createTableQueries):
* Platform/IPC/ArgumentCoders.h:
* Shared/Cocoa/DefaultWebBrowserChecks.mm:
(WebKit::getAppBoundDomainsTesting):
* Shared/WebPreferencesStore.cpp:
(WebKit::WebPreferencesStore::decode):
* Shared/WebPreferencesStore.h:
* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::platformPathsWithAssumedReadAccess):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::platformPathsWithAssumedReadAccess):
* UIProcess/WebProcessProxy.h:
Source/WTF:
This patch implements RobinHoodHashTable[1]. We don't use it as a default hashtable since it has different performance v.s. memory-saving characteristics,
and this patch's goal is not tackling on making this default. Rather, the goal of this patch is introducing it to non-performance sensitive area quickly
so that we can save memory. RobinHoodHashTable more frequently computes hash value compared to HashTable, so this is not drop-in replacement for the existing
one. But still, this is useful since we know that "while there are many small HashTables and they holds much memory, there are super large HashTables and
they holds almost same amount of memory while they are a few.". This patch's goal is applying this RobinHoodHashTable to these "large, but a few" singleton tables.
RobinHoodHashTable maintains distance-from-initial-bucket (DIB) small by adjusting existing entries when inserting. When inserting, if we found that the
existing entry has less DIB than the current inserting entry's DIB, then we swap entries, and insert the existing entry to the other place. This is giving
some good DIB from rich entry to poor entry (that's why it is called RobinHood Hashing), and making average DIB lower. And this algorithm adds good invariant
that, when looking up an entry, and we found that existing entry has smaller DIB, then we can stop searching in the middle of the chain since we know that
we should swap entries when this happened when inserting. These two tricks maintain HashTable performance even under significantly high load factor: 90% load-factor
just works. 95% load-factor regress adding performance, but still it does not become catastrophic compared to normal open-addressing HashTable.
We introduce RobinHoodHashTable, and adding several kinds of tables based on load-factors.
1. MemoryCompactLookupOnlyRobinHoodHashSet / HashMap
This has 95% load-factor. This is suitable for sets and maps which is mostly-constant: constructing once, and looking up repeatedly. In WebKit, there are so
many this kind of tables e.g. singleton HashMap for various kinds of things. We can use this super high load-factor table so that we can save memory even while
we are maintains fast HashTable lookup.
2. MemoryCompactRobinHoodHashSet / HashMap
This has 90% load-factor. It just works, and we can try using it if sets and maps are significantly performance intensive.
3. FastRobinHoodHashSet / HashMap
This has 75% load-factor. This is still good compared to HashSet and HashMap since they are using 50% load-factor for large sized tables. This has very slightly performance regressed
compared to 50% load-factor large HashSet and HashMap, but if that is not performance intensive (e.g. AtomStringTable is one of the most performance intensive table), this is good.
In this patch, we replace many singleton HashSet / HashMap with RobinHoodHashTable.
[1]: https://www.sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Forward.h:
* wtf/HashMap.h:
(WTF::Y>::swap):
(WTF::Y>::size const):
(WTF::Y>::capacity const):
(WTF::Y>::isEmpty const):
(WTF::Y>::begin):
(WTF::Y>::end):
(WTF::Y>::begin const):
(WTF::Y>::end const):
(WTF::Y>::find):
(WTF::Y>::find const):
(WTF::Y>::contains const):
(WTF::Y>::get const):
(WTF::Y>::inlineGet const):
(WTF::TableTraitsArg>::inlineSet):
(WTF::TableTraitsArg>::inlineAdd):
(WTF::TableTraitsArg>::inlineEnsure):
(WTF::TableTraitsArg>::set):
(WTF::TableTraitsArg>::add):
(WTF::TableTraitsArg>::fastAdd):
(WTF::TableTraitsArg>::ensure):
(WTF::Y>::remove):
(WTF::Y>::removeIf):
(WTF::Y>::clear):
(WTF::Y>::take):
(WTF::Y>::checkConsistency const):
(WTF::Y>::isValidKey):
(WTF::operator==):
(WTF::operator!=):
(WTF::X>::swap): Deleted.
(WTF::X>::size const): Deleted.
(WTF::X>::capacity const): Deleted.
(WTF::X>::isEmpty const): Deleted.
(WTF::X>::begin): Deleted.
(WTF::X>::end): Deleted.
(WTF::X>::begin const): Deleted.
(WTF::X>::end const): Deleted.
(WTF::X>::find): Deleted.
(WTF::X>::find const): Deleted.
(WTF::X>::contains const): Deleted.
(WTF::X>::get const): Deleted.
(WTF::X>::inlineGet const): Deleted.
(WTF::MappedTraitsArg>::inlineSet): Deleted.
(WTF::MappedTraitsArg>::inlineAdd): Deleted.
(WTF::MappedTraitsArg>::inlineEnsure): Deleted.
(WTF::MappedTraitsArg>::set): Deleted.
(WTF::MappedTraitsArg>::add): Deleted.
(WTF::MappedTraitsArg>::fastAdd): Deleted.
(WTF::MappedTraitsArg>::ensure): Deleted.
(WTF::MappedTraits>::get const): Deleted.
(WTF::MappedTraits>::inlineGet const): Deleted.
(WTF::X>::remove): Deleted.
(WTF::X>::removeIf): Deleted.
(WTF::X>::clear): Deleted.
(WTF::MappedTraits>::take): Deleted.
(WTF::X>::take): Deleted.
(WTF::X>::checkConsistency const): Deleted.
(WTF::X>::isValidKey): Deleted.
* wtf/HashSet.h:
(WTF::W>::swap):
(WTF::W>::size const):
(WTF::W>::capacity const):
(WTF::W>::isEmpty const):
(WTF::W>::begin const):
(WTF::W>::end const):
(WTF::W>::find const):
(WTF::W>::contains const):
(WTF::TableTraits>::find const):
(WTF::TableTraits>::contains const):
(WTF::TableTraits>::ensure):
(WTF::W>::add):
(WTF::W>::addVoid):
(WTF::TableTraits>::add):
(WTF::W>::remove):
(WTF::W>::removeIf):
(WTF::W>::clear):
(WTF::W>::take):
(WTF::W>::takeAny):
(WTF::TableTraits>::remove):
(WTF::TableTraits>::take):
(WTF::W>::isValidValue):
(WTF::= const):
(WTF::W>::checkConsistency const):
(WTF::V>::swap): Deleted.
(WTF::V>::size const): Deleted.
(WTF::V>::capacity const): Deleted.
(WTF::V>::isEmpty const): Deleted.
(WTF::V>::begin const): Deleted.
(WTF::V>::end const): Deleted.
(WTF::V>::find const): Deleted.
(WTF::V>::contains const): Deleted.
(WTF::Traits>::find const): Deleted.
(WTF::Traits>::contains const): Deleted.
(WTF::Traits>::ensure): Deleted.
(WTF::V>::add): Deleted.
(WTF::V>::addVoid): Deleted.
(WTF::Traits>::add): Deleted.
(WTF::V>::remove): Deleted.
(WTF::V>::removeIf): Deleted.
(WTF::V>::clear): Deleted.
(WTF::V>::take): Deleted.
(WTF::V>::takeAny): Deleted.
(WTF::Traits>::remove): Deleted.
(WTF::Traits>::take): Deleted.
(WTF::V>::isValidValue): Deleted.
(WTF::V>::checkConsistency const): Deleted.
* wtf/HashTable.h:
(WTF::addIterator):
(WTF::removeIterator):
(WTF::invalidateIterators):
(WTF::HashTable::~HashTable):
(WTF::HashTable::random):
(WTF::KeyTraits>::inlineLookup):
(WTF::KeyTraits>::lookupForWriting):
(WTF::KeyTraits>::fullLookupForWriting):
(WTF::KeyTraits>::addUniqueForInitialization):
(WTF::KeyTraits>::add):
(WTF::KeyTraits>::addPassingHashCode):
(WTF::KeyTraits>::removeAndInvalidateWithoutEntryConsistencyCheck):
(WTF::KeyTraits>::removeAndInvalidate):
(WTF::KeyTraits>::clear):
(WTF::KeyTraits>::swap):
(WTF::KeyTraits>::HashTable):
(WTF::HashTable::invalidateIterators): Deleted.
(WTF::KeyTraits>::invalidateIterators): Deleted.
* wtf/RobinHoodHashMap.h: Added.
* wtf/RobinHoodHashSet.h: Added.
* wtf/RobinHoodHashTable.h: Added.
(WTF::RobinHoodHashTable::~RobinHoodHashTable):
(WTF::RobinHoodHashTable::begin):
(WTF::RobinHoodHashTable::end):
(WTF::RobinHoodHashTable::begin const):
(WTF::RobinHoodHashTable::end const):
(WTF::RobinHoodHashTable::random):
(WTF::RobinHoodHashTable::random const):
(WTF::RobinHoodHashTable::size const):
(WTF::RobinHoodHashTable::capacity const):
(WTF::RobinHoodHashTable::isEmpty const):
(WTF::RobinHoodHashTable::reserveInitialCapacity):
(WTF::RobinHoodHashTable::add):
(WTF::RobinHoodHashTable::find):
(WTF::RobinHoodHashTable::find const):
(WTF::RobinHoodHashTable::contains const):
(WTF::RobinHoodHashTable::isEmptyBucket):
(WTF::RobinHoodHashTable::isEmptyOrDeletedBucket):
(WTF::RobinHoodHashTable::lookup):
(WTF::RobinHoodHashTable::checkTableConsistency):
(WTF::RobinHoodHashTable::internalCheckTableConsistency const):
(WTF::RobinHoodHashTable::internalCheckTableConsistencyExceptSize const):
(WTF::RobinHoodHashTable::internalCheckTableConsistencyExceptSize):
(WTF::RobinHoodHashTable::internalCheckTableConsistency):
(WTF::RobinHoodHashTable::shouldExpand):
(WTF::RobinHoodHashTable::computeTableHash):
(WTF::RobinHoodHashTable::shouldExpand const):
(WTF::RobinHoodHashTable::shouldShrink const):
(WTF::RobinHoodHashTable::shrink):
(WTF::RobinHoodHashTable::deleteBucket):
(WTF::RobinHoodHashTable::desiredIndex):
(WTF::RobinHoodHashTable::probeDistance):
(WTF::RobinHoodHashTable::makeIterator):
(WTF::RobinHoodHashTable::makeConstIterator const):
(WTF::RobinHoodHashTable::makeKnownGoodIterator):
(WTF::RobinHoodHashTable::makeKnownGoodConstIterator const):
(WTF::RobinHoodHashTable::checkTableConsistencyExceptSize):
(WTF::RobinHoodHashTable::tableSize const):
(WTF::RobinHoodHashTable::tableSizeMask const):
(WTF::RobinHoodHashTable::keyCount const):
(WTF::RobinHoodHashTable::tableHash const):
(WTF::SizePolicy>::checkKey):
(WTF::SizePolicy>::lookup):
(WTF::SizePolicy>::inlineLookup):
(WTF::SizePolicy>::initializeBucket):
(WTF::SizePolicy>::add):
(WTF::SizePolicy>::maintainProbeDistanceForAdd):
(WTF::SizePolicy>::addPassingHashCode):
(WTF::SizePolicy>::reinsert):
(WTF::SizePolicy>::find):
(WTF::SizePolicy>::find const):
(WTF::SizePolicy>::contains const):
(WTF::SizePolicy>::removeAndInvalidateWithoutEntryConsistencyCheck):
(WTF::SizePolicy>::removeAndInvalidate):
(WTF::SizePolicy>::remove):
(WTF::SizePolicy>::removeWithoutEntryConsistencyCheck):
(WTF::SizePolicy>::allocateTable):
(WTF::SizePolicy>::deallocateTable):
(WTF::SizePolicy>::expand):
(WTF::SizePolicy>::computeBestTableSize):
(WTF::SizePolicy>::shrinkToBestSize):
(WTF::SizePolicy>::rehash):
(WTF::SizePolicy>::clear):
(WTF::SizePolicy>::RobinHoodHashTable):
(WTF::SizePolicy>::swap):
(WTF::=):
(WTF::SizePolicy>::checkTableConsistency const):
(WTF::SizePolicy>::checkTableConsistencyExceptSize const):
* wtf/text/AtomStringHash.h:
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringTable.cpp:
(WTF::AtomStringTable::~AtomStringTable):
* wtf/text/AtomStringTable.h:
(WTF::AtomStringTable::table):
* wtf/text/StringHash.h:
Tools:
* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/DeletedAddressOfOperator.h:
* TestWebKitAPI/Tests/WTF/HashMap.cpp:
(TestWebKitAPI::testMovingUsingEnsure):
(TestWebKitAPI::testMovingUsingAdd):
* TestWebKitAPI/Tests/WTF/HashSet.cpp:
(TestWebKitAPI::generateTestCapacityUpToSize<0>):
(TestWebKitAPI::generateTestCapacityUpToSize):
* TestWebKitAPI/Tests/WTF/MoveOnly.h:
* TestWebKitAPI/Tests/WTF/RobinHoodHashMap.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp.
(TestWebKitAPI::TEST):
(TestWebKitAPI::bucketForKey):
(TestWebKitAPI::ZeroHash::hash):
(TestWebKitAPI::ObjectWithRefLogger::ObjectWithRefLogger):
(TestWebKitAPI::testMovingUsingEnsure):
(TestWebKitAPI::testMovingUsingAdd):
(TestWebKitAPI::DerefObserver::ref):
(TestWebKitAPI::DerefObserver::deref):
(TestWebKitAPI::TestObjectWithCustomDestructor::TestObjectWithCustomDestructor):
(TestWebKitAPI::TestObjectWithCustomDestructor::~TestObjectWithCustomDestructor):
* TestWebKitAPI/Tests/WTF/RobinHoodHashSet.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/HashSet.cpp.
(TestWebKitAPI::capacityForSize):
(TestWebKitAPI::testInitialCapacity):
(TestWebKitAPI::generateTestCapacityUpToSize<0>):
(TestWebKitAPI::generateTestCapacityUpToSize):
(TestWebKitAPI::TEST):
(TestWebKitAPI::DerefObserver::ref):
(TestWebKitAPI::DerefObserver::deref):
Canonical link: https://commits.webkit.org/236073@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-02 08:33:32 +00:00
MemoryCompactLookupOnlyRobinHoodHashMap < AtomString , AutofillInfo > map ;
Improve use of NeverDestroyed
https://bugs.webkit.org/show_bug.cgi?id=174348
Reviewed by Sam Weinig.
Source/JavaScriptCore:
* heap/MachineStackMarker.cpp:
* wasm/WasmMemory.cpp:
Removed unneeded includes of NeverDestroyed.h in files that do not make use
of NeverDestroyed.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/encryptedmedia/legacy/LegacyCDM.cpp:
(WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather
than a separate boolean for initialization.
* Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
(WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a
RefPtr. Simple to just use leakRef instead.
* Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h.
* Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto.
* Modules/mediasession/MediaSessionManager.cpp: Moved include of
NeverDestroyed.h here ...
* Modules/mediasession/MediaSessionManager.h: ... from here.
* Modules/mediasource/MediaSourceRegistry.cpp: Moved include of
NeverDestroyed.h here ...
* Modules/mediasource/MediaSourceRegistry.h: ... from here.
* Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of
NeverDestroyed.h.
* Modules/plugins/QuickTimePluginReplacement.h: Initialize
m_scriptObject in the class definition.
* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::QuickTimePluginReplacement::supportsMimeType): Use
makeNeverDestroyed and the HashSet constructor instead of a loop.
(WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto.
(WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a
slight cleanup of the initializers.
(WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added
a FIXME; unclear why there is code here at all.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use
makeNeverDestroyed and the Vector constructor instead of using empty
vector checks and Vector::add. Use std::any_of rather than Vector::contains
since we now are matching against pointers.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateEnumerationImplementationContent): Use const NeverDestroyed.
* bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp:
* bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp:
Regenerated.
* css/CSSProperty.cpp:
(WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed
for a global object that has a trivial destructor.
* css/ElementRuleCollector.cpp:
(WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a
Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit
isEmpty check each time this is called.
(WebCore::rightToLeftDeclaration): Ditto.
* css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the
uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand
is no less efficient than copying a global empty one was.
* dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h.
* dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h.
* dom/InputEvent.cpp: Ditto.
* dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ...
* dom/Microtasks.h: ... from here.
* dom/MutationObserver.cpp: Added an include of NeverDestroyed.h.
* dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ...
* dom/ScopedEventQueue.h: ... from here. Added Forward.h.
* dom/ScriptElement.cpp:
(WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed
and the HashSet constructor rather than an isEmpty check and a lot of
add function calls. Also removed comments that don't have value any more,
with dubious no longer relevant claims about the behavior of old web browsers.
The function that calls this one already has sufficient comments about why we
hope some day this function can be eliminated.
* dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h.
* dom/make_names.pl:
(printFactoryCppFile): Instead of using a "populate" function, use a function
that creates as HashMap. Then use const auto and makeNeverDestroyed.
(printWrapperFactoryCppFile): Ditto.
* editing/AlternativeTextController.cpp:
(WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed
and the Vector constructor rather than an isEmpty check and a lot of
append function calls.
(WebCore::markerTypesForReplacement): Ditto.
(WebCore::markerTypesForAppliedDictationAlternative): Ditto.
* editing/EditingStyle.cpp:
(WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed,
the Vector constructor, and new rather than make_unique. Changed return
type to use const pointers rather than unique_ptr with non-const type.
(WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated
for the above change to htmlElementEquivalents.
(WebCore::htmlAttributeEquivalents): Same approach as above.
(WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto.
(WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take
references instead of pointers.
(WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated
for the above.
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed,
and the HashSet constructor rather than isEmpty and a lot of calls to add.
* editing/RemoveFormatCommand.cpp:
(WebCore::isElementForRemoveFormatCommand): Ditto.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed,
and a lambda, rather than isEmpty and a lot of calls to add.
* html/Autofill.cpp:
(WebCore::fieldNameMap): Changed return type to be const. Use const auto,
makeNeverDestroyed, a lambda, and an array of values rather than isEmpty
and a lot of calls to add. Stopped doing the ConstructFromLiteral
optimization here. (Easy to add it back if that is a mistake.)
* html/HTMLObjectElement.cpp:
(WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and
a lambda rather than isEmpty.
* html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h.
* html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h.
* html/InputType.cpp:
(WebCore::createInputTypeFactoryMap): Replaced the populate function
with this create function.
(WebCore::InputType::create): Use const auto and makeNeverDestroyed
istead of isEmpty. Also put the map right where it is used so it's
not initialized in code path where not needed.
* html/parser/HTMLParserIdioms.cpp: Removed uneeded include of
NeverDestroyed.h.
* inspector/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::networkStateChanged):
Merged into a single line.
* loader/ContentFilter.cpp:
(WebCore::blockedPageURL): Use const auto and makeNeverDestroyed
rather than std::call_once. Since this is a URL and has a non-thread-safe
reference count, this was not thread safe before, so no need to use the
more roundabout and less efficient idiom for its thread safety.
* loader/CrossOriginAccessControl.cpp:
(WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted.
* loader/CrossOriginAccessControl.h: Deleted unused function
isOnAccessControlResponseHeaderWhitelist.
* loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>.
* loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of
NeverDestroyed.h.
* page/CaptionUserPreferences.cpp: Ditto.
* page/DebugPageOverlays.cpp:
(WebCore::touchEventRegionColors): Changed the return type to const, since
the callers do not modify the map. Use const auto, makeNeverDestroyed, and
a lambda rather than isEmpty and repeated calls to add.
* page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h.
* page/MemoryRelease.cpp:
(WebCore::releaseMemory): Use a function directly instead of calling it
inside a lambda.
* page/NavigatorBase.cpp:
(WebCore::NavigatorBase::onLine): Updated to call
NetworkStateNotifier::singleton.
* page/Page.cpp:
(WebCore::allPages): Made this a function instead of a global to use the
normal idiom for such globals.
(WebCore::Page::forEachPage): Updated for change to allPages.
(WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary
churn by using const AtomicString& instead of AtomicString.
(WebCore::Page::Page): Moved initialization of most data members to the
class definition. Removed initialiation of allPages. Updated the use of
NetworkStateNotifier for its new slightly changed interface.
(WebCore::Page::~Page): Updated for change to allPages.
(WebCore::Page::clearPreviousItemFromAllPages): Ditto.
(WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto.
(WebCore::Page::refreshPlugins): Ditto.
* page/Page.h: Moved initialization of most data members here.
* page/PerformanceUserTiming.cpp: Removed many unneded includes.
(WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and
a lambda instead of isEmpty. Also use an array rather than std::array and
got rid fo the unneeded use of anonymous namespace since this is fine in
the top level WebCore namespace.
(WebCore::clearPerformanceEntries): Tweaked coding style.
(WebCore::UserTiming::mark): Ditto.
(WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash
table lookup by using find instead of using contains followed by get.
removed unneeded explicit cast to double. Tweaked coding style.
(WebCore::convertToEntrySequence): Tweaked coding style.
(WebCore::getEntrySequenceByName): Deleted.
(WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName.
(WebCore::UserTiming::getMeasures): Ditto.
* page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ...
* page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h.
* platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h.
* platform/MIMETypeRegistry.cpp:
(WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global
constant array.
(WebCore::initializeSupportedJavaScriptMIMETypes): Ditto.
(WebCore::initializeSupportedNonImageMimeTypes): Ditto.
(WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function
with this one. Moved the common media types array here since it's only used here.
Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check.
Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the
double hashing that the old code was doing. And moved the code to find an entry
in the map in here from the client functions.
(WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the
typesForCommonExtension, and changed logic to use this first, and only call
getMIMETypeForExtension for extensions not in the map. This gives the same
result but should be slightly more efficient.
(WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the
typesForCommonExtension function. Comment about strategy is now in there.
(WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global
constant array. Also started using ASCIILiteral.
* platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ...
* platform/MainThreadSharedTimer.h: ... from here. Added Forward.h.
* platform/SchemeRegistry.cpp:
(WebCore::add): Added helper functions to keep code below simpler.
(WebCore::makeNeverDestroyedSchemeSet): Ditto.
(WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda,
and the helper functions above, rather than isEmpty.
(WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and
the HashSet constructor instead of isEmpty and add calls. Also changed the
return type to be const.
(WebCore::localURLSchemes): Copy the map using assignment instead of an
isEmpty function and a loop with calls to add.
(WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and
the Vector constructor rather than isEmpty, repeated calls to append,
and shrinkToFit.
(WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather
than isEmpty and repeated calls to add.
(WebCore::builtinSchemesWithUniqueOrigins): More of the same.
(WebCore::schemesWithUniqueOrigins): Ditto.
(WebCore::builtinEmptyDocumentSchemes): Ditto.
(WebCore::emptyDocumentSchemes): Ditto.
(WebCore::schemesForbiddenFromDomainRelaxation): Ditto.
(WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto.
(WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto.
(WebCore::builtinCORSEnabledSchemes): Ditto.
(WebCore::CORSEnabledSchemes): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for
empty string with check for null string, since that's slightly more efficient
for non-null, non-empty strings, and the hash table can handle empty strings
just fine.
(WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto.
(WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto.
(WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto.
(WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto.
(WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto.
(WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto.
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto.
(WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto.
(WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto.
(WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto.
(WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit.
(WebCore::SchemeRegistry::isBuiltinScheme): Added null check.
* platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto,
makeNeverDestroyed, and the Vector constructor rather than a call to size
and then append eacn time this funciton is called.
* platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of
NeverDestroyed.h from here ...
* platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here.
* platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of
NeverDestroyed.h here ...
* platform/gamepad/mac/HIDGamepadProvider.h: ... from here.
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::hasValidAverageCharWidth): Use const auto,
makeNeverDestroyed, and the HashSet constructor.
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of
NeverDestroyed<Vector<int>> here, instead using const std::array.
* platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take
const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole
pointer of the argument is that it's a table to map bytes onto other bytes.
* platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of
NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function,
and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead.
Made most functions in this class pure virtual instead of having default
implementations.
* platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include
of MediaPlaybackTargetContext.h now that it was removed above.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto,
makeNeverDestroyed, and the HashSet constructor.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense
of the boolean logic here to make this simpler and easier to read.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed
the implementation here, which empties out the passed in hash set, to use
the clear function rather than assignment from a global empty hash set. Added
a FIXME because it seems peculiar that this would be considered OK.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make
this a little more terse; I think it's clearer.
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to
argument type.
* platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of
NeverDestroyed.h.
(WebCore::appendImageSourceOption): Streamlined code using auto with
adoptCF; there is no need to write out the type of the RetainPtr.
(WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use
const auto and leakRef.
(WebCore::imageSourceAsyncOptions): Ditto.
* platform/graphics/gtk/GdkCairoUtilities.cpp:
(WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed
on a pointer, just use a global pointer. There is no need to use any kind
of NeverDestroyed on a type with a trivial destructor such as a pointer.
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::platformFontWithFamilySpecialCase): Instead of using
NeverDestroyed<RetainPtr> just use a raw pointer global.
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformFontWithFamilySpecialCase): Ditto.
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::createFileTypesSet): Return the HashSet instead of adding to it.
Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although
it seems the C++ syntax was working fine.
(WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the
HashMap every time this function is called. Use const auto and makeNeverDestroyed
instead of using a boolean to do one time initialization.
(WebCore::mimeModernTypesCache): Ditto.
(WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a
constant array const.
* platform/ios/Device.cpp:
(WebCore::deviceClass): Use a lambda to initialize a variable here instead
of using std::call_once. This function does not need to be thread safe.
(WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed
and std::call_once. This function does not need to be thread safe.
* platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a
constant instead of a variable.
(WebCore::cascadeForSystemFont): Added helper function.
(WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed
instead of LazyNeverDestroyed and dispatch_once. This code does not need
to be thread safe since its arguments include, for example, a DOM element.
* platform/ios/LegacyTileLayerPool.h: Removed unneeded include of
NeverDestroyed.h.
* platform/ios/QuickLook.mm:
(WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer
instead of NeverDestroyed<RetainPtr<NSSet>>.
(WebCore::createQLPreviewProtocol): Deleted.
(WebCore::QLPreviewProtocol): Use a global raw pointer instead of
a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead
of appending to an array, and less wasteful of memory too.
* platform/ios/WebCoreMotionManager.mm: Removed unneeded include of
NeverDestroyed.h.
* platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto.
* platform/mac/DragImageMac.mm: Ditto.
* platform/mediastream/CaptureDeviceManager.cpp: Ditto.
* platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto.
* platform/mock/MockRealtimeMediaSource.cpp:
(WebCore::MockRealtimeMediaSource::audioDevices): Use auto,
makeNeverDestroyed, and a lambda instead of checking size each time.
(WebCore::MockRealtimeMediaSource::videoDevices): Ditto.
* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the
HashSet constructor instead of an explicit boolean to initialize.
* platform/network/BlobRegistryImpl.cpp:
(WebCore::blobUtilityQueue): Use a global with a raw reference instead
of a NeverDestroyed<Ref>.
* platform/network/NetworkStateNotifier.cpp:
(WebCore::NetworkStateNotifier::singleton): Renamed this from
networkStateNotifier. We must have missed this when we changed to use the
singleton idiom consistently. Also changed to use normal NeverDestroyed
rather than using LazyNeverDestroyed and call_once, because this is not
used from multiple threads and has no special thread safety requirements.
(WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor
here and construct the timer. Before the timer was used only on the Mac
platform but now it is there for all platforms.
(WebCore::NetworkStateNotifier::onLine): Moved function here from the header.
It's a littlel less trivial than before because it now triggers a call to
updateState as needed.
(WebCore::NetworkStateNotifier::addListener): Renamed from
addNetworkStateChangeListener since there is only one kind of listener and
the old name was too wordy. Changed to call the new startObserving function,
and guaranteed to call it onlh once. The platform-specific logic for iOS is
now inside the iOS version of that function instead of here.
(WebCore::NetworkStateNotifier::updateState): Moved here now that it is the
same for all platforms. The actual state updating is done in a function named
updateStateWithoutNotifying, which is implemented for each platform.
(WebCore::NetworkStateNotifier::updateStateSoon): New function which takes
advantage of the timer to coalesce network state updates.
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub
version of this function.
(WebCore::NetworkStateNotifier::startObserving): Ditto.
(WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from
this has moved into updateState.
* platform/network/NetworkStateNotifier.h: Greatly cut down what part of this
class is platform-specific.
* platform/network/ios/NetworkStateNotifierIOS.mm:
(-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it
takes a block, rather than using a pointer to the C++ notifier and doing
WebThreadRun.
(-[WebNetworkStateObserver dealloc]): Ditto.
(-[WebNetworkStateObserver networkStateChanged:]): Ditto.
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying):
This now calls isNetworkReachable.
(WebCore::NetworkStateNotifier::startObserving): Check the
Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK
to observe, then create the observer. This code now takes care of the
WebThreadRun and calls updateStateSoon.
(WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The
constructor is now platform independent.
(WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This
object is never destroyed so we should not write a destructor for it.
(WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted.
Replaced by startObserving.
(WebCore::NetworkStateNotifier::onLine): Deleted. This function is now
platform-independent.
(WebCore::setOnLine): Deleted. The logic from this is now in
updateState and updateStateWithoutNotifying.
* platform/network/mac/NetworkStateNotifierMac.cpp:
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed
this from updateState and tightened up the code a bit. Also changed
to not assume anything. If there is an error, we leave m_isOnLine alone.
Default behavior is now in the platform-independent code, and the default
is to treat things as on-line if updateStateWithoutNotifying was called
and it was never able to update the state even once.
(WebCore::NetworkStateNotifier::startObserving): Moved most of the code
from the constructor into this function.
(WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is
now a lambda inside startObserving.
(WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted.
This function is now platform-independent and is named updateState.
* platform/network/win/NetworkStateNotifierWin.cpp:
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed
from updateState and tightened the code up a bit. Also changed
to not assume anything. If there is an error, we leave m_isOnLine alone.
Default behavior is now in the platform-independent code, and the default
is to treat things as on-line if updateStateWithoutNotifying was called
and it was never able to update the state even once.
(WebCore::NetworkStateNotifier::addressChanged): Deleted.
This function is now platform-independent and is named updateState.
(WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from
addrChangeCallback. Simplified by using the singleton function instead
of relying on the context pointer.
(WebCore::NetworkStateNotifier::startObserving): Moved most of the code
from the constructor here.
* platform/text/LocaleToScriptMappingDefault.cpp:
(WebCore::scriptNameToCode): Use makeNeverDestroyed.
(WebCore::localeToScriptCodeForFontSelection): Ditto.
* platform/text/ios/LocalizedDateCache.h: Moved include of
NeverDestroyed.h from here ...
* platform/text/ios/LocalizedDateCache.mm: ... to here.
* platform/wpe/RenderThemeWPE.cpp:
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/RenderTheme.h: Made RenderTheme no longer reference counted.
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/RenderThemeIOS.h: Ditto.
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
Also marked a lot of functions final rather than override and initialized
data members in the class deifnition.
* rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the
file. They should really go into SPI headers.
(-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument
here because the theme is a singleton and we don't need a pointer to it.
Add the observer here instead of doing it in the caller.
(-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call
platformColorsDidChange through the singleton rather than using a pointer.
(-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]):
Tightened up the code a bit by using CFAutorelease instead of using a
combination of NSMakeCollectable, autorelease, and a typecast to accomplish
the same thing.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
(WebCore::RenderThemeMac::create): Deleted.
(WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the
class definition and observing into the WebCoreRenderThemeNotificationObserver
init function.
(WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since
the object will never be destroyed.
(WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType):
Removed an unnecessary conversion from C string literal to WTF::String and
then to NSString. Instead, just use an NSString literal.
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::create): Deleted.
(WebCore::RenderTheme::singleton): Use a theme that is never destroyed
rather than Ref that is never destroyed.
* rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than
a create function since RenderTheme is no longer reference counted.
* rendering/svg/RenderSVGResource.cpp:
(WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into
the code where it is used.
* svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h.
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGClipPathElement.cpp:
(WebCore::SVGClipPathElement::isSupportedAttribute): Ditto.
* svg/SVGComponentTransferFunctionElement.cpp:
(WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto.
* svg/SVGCursorElement.cpp:
(WebCore::SVGCursorElement::isSupportedAttribute): Ditto.
* svg/SVGElement.cpp:
(WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate
function with this create function.
(WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto.
(WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to
const reference. Use const auto and makeNeverDestroyed instead of using
isEmpty and a populate function.
(WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap):
More of the same.
(WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto.
(WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of
a HashSet since we are checking against only 3 or 4 values.
(WebCore::addQualifiedName): Deleted.
(WebCore::SVGElement::animatableAttributeForName): Use const auto,
makeNeverDestroyed, and a lambda to efficiently build the map in this function.
(WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and
makeNeverDestroyed instead of using isEmpty and a populate function.
* svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGFilterPrimitiveStandardAttributes.cpp:
(WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto.
* svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto.
* svg/SVGGElement.cpp:
(WebCore::SVGGElement::isSupportedAttribute): Ditto.
* svg/SVGGradientElement.cpp:
(WebCore::SVGGradientElement::isSupportedAttribute): Ditto.
* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto.
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::isSupportedAttribute): Ditto.
* svg/SVGLangSpace.cpp:
(WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead
of making our own NeverDestroyed local xmlPrefix.
(WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper.
* svg/SVGLineElement.cpp:
(WebCore::SVGLineElement::isSupportedAttribute): Use const auto,
makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of
an isEmpty check and lots of separate add function calls.
* svg/SVGLinearGradientElement.cpp:
(WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto.
* svg/SVGMarkerElement.cpp:
(WebCore::SVGMarkerElement::isSupportedAttribute): Ditto.
* svg/SVGMaskElement.cpp:
(WebCore::SVGMaskElement::isSupportedAttribute): Ditto.
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::isSupportedAttribute): Ditto.
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::isSupportedAttribute): Ditto.
* svg/SVGRadialGradientElement.cpp:
(WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto.
* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::isSupportedAttribute): Ditto.
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::isSupportedAttribute): Ditto.
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSupportedAttribute): Ditto.
* testing/MockContentFilterSettings.h: Removed unneeded include of
NeverDestroyed.h.
* testing/MockGamepadProvider.cpp: Moved include of
NeverDestroyed.h here ...
* testing/MockGamepadProvider.h: ... from here.
* testing/MockPreviewLoaderClient.h: Removed unneeded include of
NeverDestroyed.h.
* workers/Worker.cpp:
(WebCore::allWorkers): Changed this from a global to a function.
(WebCore::Worker::networkStateChanged): Updated for above change and
made this a member function.
(WebCore::Worker::Worker): Updated for above change and
change to NetworkStateNotifier.
(WebCore::Worker::~Worker): Ditto.
* workers/Worker.h: Made networkStateChanged a static member instead of
a friend since that is a cleaner way to give it access to private member
functions.
* xml/XPathFunctions.cpp:
(WebCore::XPath::createFunctionMap): Use create instead of populate style.
(WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed
instead of an isEmpty check.
* xml/XPathParser.cpp:
(WebCore::XPath::createAxisNamesMap): Use create instead of populate style.
(WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed
instead of an isEmpty check.
Source/WebKit:
* DatabaseProcess/DatabaseProcess.h: Removed unneeded include of
NeverDestroyed.h.
* NetworkProcess/cache/NetworkCacheKey.cpp: Ditto.
* NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of
NeverDestroyed.h here ...
* NetworkProcess/capture/NetworkCaptureManager.h: ... from here.
* PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h
here ...
* PluginProcess/PluginProcess.h: ... from here.
* Shared/API/Cocoa/_WKRemoteObjectInterface.mm:
(isContainerClass): Removed trivial inefficient use of
LazyNeverDestroyed<HashSet> to check against two classes.
Instead wrote out the boolean expression.
* Shared/mac/SecItemShim.cpp: Removed unneeded include of
NeverDestroyed.h.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitialize): Call
installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton.
* UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include
of NeverDestroyed.h.
* UIProcess/Plugins/PluginProcessManager.cpp: Moved include of
NeverDestroyed.h here ...
* UIProcess/Plugins/PluginProcessManager.h: ... from here.
* UIProcess/WebInspectorProxy.cpp: Removed unneeded include
of NeverDestroyed.h.
* UIProcess/WebPageProxy.h: Added now-needed include of
MediaPlaybackTargetContext.h.
* UIProcess/WebPasteboardProxy.cpp: Moved include of
NeverDestroyed.h here ...
* UIProcess/WebPasteboardProxy.h: ... from here.
* UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the
WebMemoryPressureHandler class from this header. Callers don't need to
know if there is a class. They simply indicate when it's time to install
the handler. Another way to put it is that this class had no functions
other than the singleton function.
* UIProcess/ios/WebMemoryPressureHandlerIOS.mm:
(WebKit::installMemoryPressureHandler): Replaced the class with this function.
It creates a dispatch source and then resumes it. To avoid having the source
look like a leak, we keep it in a global variable.
* WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of
NeverDestroyed.h.
* WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of
NeverDestroyed.h here ...
* WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded
include of NeverDestroyed.h.
Source/WebKitLegacy:
* Storage/StorageThread.cpp:
(WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads):
Simplify code by using a modern for loop and passing a function without wrapping
it in a lambda.
Source/WebKitLegacy/mac:
* Misc/WebStringTruncator.mm:
(+[WebStringTruncator centerTruncateString:toWidth:]): Replace
NeverDestroyed<RetainPtr> with just an NSFont * global.
* Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of
NeverDestroyed.h.
* Storage/WebDatabaseManager.mm: Ditto.
* WebCoreSupport/WebFrameNetworkingContext.mm: Ditto.
* WebCoreSupport/WebPlatformStrategies.mm: Ditto.
* WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h.
(aeDescFromJSValue): Removed double hashing by using the return value from
add rather than calling contains before calling add.
Source/WTF:
* wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of
const references. This is handy to add a bunch of values all at once. Later we can
consider optimizing to grow the hash table only once instead of deciding whether to
grow repeatedly as we add each value.
(WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here.
* wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ...
* wtf/MemoryPressureHandler.h: ... not here.
* wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed.
Added a makeNeverDestroyed function that deduces the type from the argument.
With auto, this can be used to avoid writing out a long type twice.
* wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h.
* wtf/text/AtomicString.cpp: Ditto.
Canonical link: https://commits.webkit.org/191408@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
for ( auto & entry : entries )
map . add ( entry . name , entry . value ) ;
return map ;
} ( ) ) ;
2016-03-06 02:17:29 +00:00
return map ;
}
2019-06-17 01:48:13 +00:00
AutofillFieldName toAutofillFieldName ( const AtomString & value )
2016-03-06 02:17:29 +00:00
{
auto map = fieldNameMap ( ) ;
auto it = map . find ( value ) ;
if ( it = = map . end ( ) )
return AutofillFieldName : : None ;
return it - > value . fieldName ;
}
2019-06-17 01:48:13 +00:00
static inline bool isContactToken ( const AtomString & token )
2016-03-06 02:17:29 +00:00
{
2020-05-01 19:47:39 +00:00
static MainThreadNeverDestroyed < const AtomString > home ( " home " , AtomString : : ConstructFromLiteral ) ;
static MainThreadNeverDestroyed < const AtomString > work ( " work " , AtomString : : ConstructFromLiteral ) ;
static MainThreadNeverDestroyed < const AtomString > mobile ( " mobile " , AtomString : : ConstructFromLiteral ) ;
static MainThreadNeverDestroyed < const AtomString > fax ( " fax " , AtomString : : ConstructFromLiteral ) ;
static MainThreadNeverDestroyed < const AtomString > pager ( " pager " , AtomString : : ConstructFromLiteral ) ;
2016-03-06 02:17:29 +00:00
return token = = home | | token = = work | | token = = mobile | | token = = fax | | token = = pager ;
}
static unsigned maxTokensForAutofillFieldCategory ( AutofillCategory category )
{
switch ( category ) {
case AutofillCategory : : Automatic :
case AutofillCategory : : Off :
return 1 ;
case AutofillCategory : : Normal :
return 3 ;
case AutofillCategory : : Contact :
return 4 ;
}
ASSERT_NOT_REACHED ( ) ;
return 0 ;
}
// https://html.spec.whatwg.org/multipage/forms.html#processing-model-3
AutofillData AutofillData : : createFromHTMLFormControlElement ( const HTMLFormControlElement & element )
{
2020-05-01 19:47:39 +00:00
static MainThreadNeverDestroyed < const AtomString > on ( " on " , AtomString : : ConstructFromLiteral ) ;
static MainThreadNeverDestroyed < const AtomString > off ( " off " , AtomString : : ConstructFromLiteral ) ;
2016-03-06 02:17:29 +00:00
// Label: Default
// 26. Let the element's IDL-exposed autofill value be the empty string, and its autofill hint set and autofill scope be empty.
// 27. If the element's autocomplete attribute is wearing the autofill anchor mantle, then let the element's autofill field name be the empty string and abort these steps.
// 28. Let form be the element's form owner, if any, or null otherwise.
// 29. If form is not null and form's autocomplete attribute is in the off state, then let the element's autofill field name be "off". Otherwise, let the element's autofill field name be "on".
auto defaultLabel = [ & ] ( ) - > AutofillData {
if ( element . autofillMantle ( ) = = AutofillMantle : : Anchor )
return { emptyString ( ) , emptyString ( ) } ;
auto form = element . form ( ) ;
if ( form & & form - > autocomplete ( ) = = off )
return { off , emptyString ( ) } ;
return { on , emptyString ( ) } ;
} ;
2019-06-17 01:48:13 +00:00
const AtomString & attributeValue = element . attributeWithoutSynchronization ( HTMLNames : : autocompleteAttr ) ;
2016-03-06 02:17:29 +00:00
// 1. If the element has no autocomplete attribute, then jump to the step labeled default.
More NeverDestroyed and related cleanup
https://bugs.webkit.org/show_bug.cgi?id=174745
Reviewed by Alex Christensen.
Source/WebCore:
* bindings/js/JSCustomElementInterface.cpp:
(WebCore::JSCustomElementInterface::constructElementWithFallback):
Use isNull() rather than comparing against nullAtom() since it's
slightly more efficient.
* css/MediaQueryEvaluator.cpp:
(WebCore::prefersReducedMotionEvaluate): Use a switch statement for the
three states of forcedPrefersReducedMotionAccessibilityValue. Also update
to use Theme::singleton() instead of platformTheme().
* dom/QualifiedName.h: Removed some unneeded includes, minor style tweaks,
and use isNull() rather than comparing against nullAtom() since it's
slightly more efficient.
* html/Autofill.cpp:
(WebCore::AutofillData::createFromHTMLFormControlElement): Use isNull()
rather than comparing against nullAtom() since it's slightly more efficient.
* html/HTMLDocument.cpp:
(WebCore::addLocalNameToSet): Deleted.
(WebCore::createHtmlCaseInsensitiveAttributesSet): Deleted.
(WebCore::HTMLDocument::isCaseSensitiveAttribute): Moved the case-sensitive
attribute set in here and made it use makeNeverDestroyed.
* html/HTMLNameCollection.cpp:
(WebCore::WindowNameCollection::elementMatchesIfNameAttributeMatch):
Formatted vertically and sorted so it's easier to see what it does.
(WebCore::WindowNameCollection::elementMatches): Use boolean logic instead
of multiple return statements to make this a little more straightforward.
(WebCore::isObjectElementForDocumentNameCollection): Added. Calls the new
isExposed function. The old code called this isDocNamedItem.
(WebCore::DocumentNameCollection::elementMatchesIfIdAttributeMatch):
Use isObjectElementForDocumentNameCollection to clean up logic. Also
sorted classes.
(WebCore::DocumentNameCollection::elementMatchesIfNameAttributeMatch):
Use isObjectElementForDocumentNameCollection to clean up logic. Also
sorted classes and formatted vertically.
(WebCore::DocumentNameCollection::elementMatches): Write in terms of
above functions for clarity. Efficiency is roughly the same.
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::HTMLObjectElement): Initialize data members
in class definition instead of here.
(WebCore::HTMLObjectElement::childrenChanged): Update for name change;
function is now called updateExposedState rather than updateDocNamedItem.
Also use m_useFallbackContent directly instead of through a function.
(WebCore::HTMLObjectElement::renderFallbackContent): Ditto.
(WebCore::preventsParentObjectFromExposure): Added. Replaces the old
isRecognizedTagName function, and does almost the same thing, but the
argument type is different and the param tag is now one of the tags
exempted here. Also broke up into two overloads so we can handle the
Element, Text, and other Node cases.
(WebCore::shouldBeExposed): Added. Helper for the updateExposedState
function that handles the logic of when the element should be exposed,
separating it from what to do when the state changes.
(WebCore::HTMLObjectElement::updateExposedState): Renamed from
updateDocNamedItem.
* html/HTMLObjectElement.h: Renamed isDocNamedItem -> isExposed,
m_docNamedItem -> m_isExposed, updateDocNamedItem -> updateExposedState,
stopped using bit fields for the two boolean data members, and
initialized those data members here in the class definition.
* platform/Theme.cpp:
(WebCore::Theme::baselinePositionAdjustment): Moved here from header.
(WebCore::Theme::controlFont): Ditto.
(WebCore::Theme::controlSize): Ditto.
(WebCore::Theme::minimumControlSize): Ditto.
(WebCore::Theme::controlRequiresPreWhiteSpace): Ditto.
(WebCore::Theme::paint): Ditto.
(WebCore::Theme::inflateControlPaintRect): Ditto.
(WebCore::Theme::userPrefersReducedMotion): Ditto.
(WebCore::Theme::controlBorder): Fixed switch statement indentation.
(WebCore::Theme::controlPadding): Ditto.
* platform/Theme.h: Removed the many unnecessary includes. The one
I was really after here was FontCascade.h. Replaced the platformTheme
function with a singleton function, following our normal style. Also
changed the return type to a reference rather than a pointer.
Removed many unused function and data members.
* platform/cocoa/ThemeCocoa.h: Tightened up implementation, removing
unnecessary members and making overrides private.
* platform/cocoa/ThemeCocoa.mm: Moved include in here.
* platform/gamepad/glib/GamepadsGlib.cpp:
(WebCore::sampleGamepads): Use NeverDestroyed instead of
DEPRECATED_DEFINE_STATIC_LOCAL.
* platform/graphics/FontCascade.cpp:
(WebCore::useBackslashAsYenSignForFamily): Build the set in a cleaner
way and use a NeverDestroyed set instead of a heap-allocated one.
(WebCore::FontCascade::FontCascade): Moved initialization of data members
to the class definition.
* platform/graphics/FontCascade.h: Initialize GlyphOverflow and
FonstCascade data members in the class definition. Remove the constructor
for GlyphOverflow entirely. Added FIXME about the peculiar != operator we
defined for GlyphOverflow.
* platform/graphics/NamedImageGeneratedImage.cpp:
(WebCore::NamedImageGeneratedImage::draw): Use Theme::singleton() instead
of platformTheme().
(WebCore::NamedImageGeneratedImage::drawPattern): Ditto.
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::CMTimeRangeStartKey): Use CFSTR directly instead of using
DEPRECATED_DEFINE_STATIC_LOCAL.
(WebCore::CMTimeRangeDurationKey): Ditto.
(WebCore::CACFContextNeedsFlushNotification): Ditto.
* platform/graphics/ca/win/LayerChangesFlusher.cpp:
(WebCore::LayerChangesFlusher::singleton): Use NeverDestroyed instead of
DEPRECATED_DEFINE_STATIC_LOCAL.
* platform/graphics/ca/win/LayerChangesFlusher.h: Ditto.
* platform/graphics/cg/ImageSourceCGWin.cpp:
(WebCore::preferredExtensionForImageSourceType): Use HashMap constructor
instead of writing out a lot of add calls.
* platform/graphics/harfbuzz/HarfBuzzFace.cpp:
(WebCore::harfBuzzFaceCache): Use NeverDestroyed instead of
DEPRECATED_DEFINE_STATIC_LOCAL.
* platform/graphics/win/FontCacheWin.cpp:
(WebCore::FontCache::lastResortFallbackFont): Ditto.
* platform/ios/ThemeIOS.h: Tightened up implementation, removing
unnecessary members and making overrides private.
* platform/ios/ThemeIOS.mm:
(WebCore::Theme::singleton): Renamed from platformTheme.
* platform/mac/ThemeMac.h: Tightened up implementation, removing
unnecessary members and making overrides private. Removed unneeded
WTF_MAKE_FAST_ALLOCATED since this is never allocated on the heap.
Removed unused -[NSFont webCoreFamilyName] method.
* platform/mac/ThemeMac.mm:
(-[NSFont webCoreFamilyName]): Deleted.
(WebCore::Theme::singleton): Renamed from platformTheme.
* platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
Removed unneeded include of FontCascade.h.
* platform/mediastream/mac/MockRealtimeVideoSourceMac.h:
Ditto.
* platform/mock/MockRealtimeAudioSource.h: Ditto.
* platform/network/win/DownloadBundleWin.cpp:
(WebCore::DownloadBundle::fileExtension): Use NeverDestroyed
instead of DEPRECATED_DEFINE_STATIC_LOCAL.
* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::replaceNewlinesWithWindowsStyleNewlines): Use
appendLiteral instead of DEPRECATED_DEFINE_STATIC_LOCAL.
* platform/win/FileSystemWin.cpp:
(WebCore::bundleName): Use NeverDestroyed instead of
DEPRECATED_DEFINE_STATIC_LOCAL, and used a lambda to initialize
rather than a boolean to control one-time code.
(WebCore::storageDirectory): Removed unneeded use of
DEPRECATED_DEFINE_STATIC_LOCAL for a prefix we are appending to
a String. The + operator can handle a literal just as efficiently
without first storing it in a String.
* platform/wpe/ThemeWPE.cpp:
(WebCore::Theme::singleton): Renamed from platformTheme.
* platform/wpe/ThemeWPE.h: Tightened up implementation, removing
unnecessary members and making overrides private.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::RenderTheme): No need to initialize m_theme.
(WebCore::RenderTheme::adjustStyle): Use Theme::singleton() instead
of accessing it through m_theme.
(WebCore::RenderTheme::paint): Ditto.
(WebCore::RenderTheme::baselinePosition): Ditto.
(WebCore::RenderTheme::adjustRepaintRect): Ditto.
(WebCore::RenderTheme::setCustomFocusRingColor): Ditto.
(WebCore::RenderTheme::platformTapHighlightColor): Ditto.
* rendering/RenderTheme.h: Removed unneded m_theme and unneeded
inclusion of Theme.h.
* rendering/line/LineBreaker.h: Removed unneeded include of
FontCascade.h.
Source/WebKitLegacy/mac:
* DOM/DOMUIKitExtensions.mm: Removed a lot of unneeded "using"
for names that aren't even used in this file.
(-[DOMNode boundingBoxes]): Use @[] syntax instead of
-[NSArray arrayWithObject:].
(-[DOMNode absoluteQuads]): Ditto.
(-[DOMNode findExplodedTextNodeAtPoint:]): Use auto* instead
of writing out various types.
(-[DOMHTMLAreaElement boundingBoxesWithOwner:]): Use @[]
syntax instea of -[NSArray arrayWithObject:].
(-[DOMHTMLAreaElement absoluteQuadsWithOwner:]): Ditto.
(-[DOMHTMLImageElement dataRepresentation:]): Use auto* instead
of writing out various types.
(-[DOMHTMLImageElement mimeType]): Ditto.
Source/WebKitLegacy/win:
* Plugins/PluginDatabase.cpp:
(WebCore::persistentPluginMetadataCachePath): Use NeverDestroyed
instead of DEPRECATED_DEFINE_STATIC_LOCAL.
* Plugins/PluginMainThreadScheduler.cpp:
(WebCore::PluginMainThreadScheduler::scheduler): Ditto.
* Plugins/PluginMainThreadScheduler.h: Ditto.
* WebCoreSupport/WebPlatformStrategies.cpp:
(WebPlatformStrategies::initialize): Ditto.
* WebCoreSupport/WebPlatformStrategies.h: Ditto.
* WebHistory.cpp:
(sharedHistoryStorage): Ditto.
* WebLocalizableStrings.cpp:
(mainBundleLocStrings): Ditto.
(frameworkLocStringsMutex): Ditto.
(frameworkLocStrings): Ditto.
* WebView.cpp:
(WebView::standardUserAgentWithApplicationName): Ditto.
Also changed to keep one global string with the prefix of the user agent string
instead of keeping two globals with pieces of that prefix.
Tools:
* DumpRenderTree/JavaScriptThreading.cpp:
(javaScriptThreadsMutex): Use NeverDestroyed instead of
DEPRECATED_DEFINE_STATIC_LOCAL.
(javaScriptThreads): Ditto.
Canonical link: https://commits.webkit.org/191623@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219858 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-25 04:29:08 +00:00
if ( attributeValue . isNull ( ) )
2016-03-06 02:17:29 +00:00
return defaultLabel ( ) ;
// 2. Let tokens be the result of splitting the attribute's value on spaces.
SpaceSplitString tokens ( attributeValue , true ) ;
// 3. If tokens is empty, then jump to the step labeled default.
if ( tokens . isEmpty ( ) )
return defaultLabel ( ) ;
// 4. Let index be the index of the last token in tokens
unsigned index = tokens . size ( ) - 1 ;
// 5. If the indexth token in tokens is not an ASCII case-insensitive match for one of the
// tokens given in the first column of the following table, or if the number of tokens in
// tokens is greater than the maximum number given in the cell in the second column of that
// token's row, then jump to the step labeled default. Otherwise, let field be the string given
// in the cell of the first column of the matching row, and let category be the value of the
// cell in the third column of that same row.
auto & map = fieldNameMap ( ) ;
auto it = map . find ( tokens [ index ] ) ;
if ( it = = map . end ( ) )
return defaultLabel ( ) ;
auto category = it - > value . category ;
if ( tokens . size ( ) > maxTokensForAutofillFieldCategory ( category ) )
return defaultLabel ( ) ;
const auto & field = tokens [ index ] ;
// 6. If category is Off or Automatic but the element's autocomplete attribute is wearing the
// autofill anchor mantle, then jump to the step labeled default.
auto mantle = element . autofillMantle ( ) ;
if ( ( category = = AutofillCategory : : Off | | category = = AutofillCategory : : Automatic ) & & mantle = = AutofillMantle : : Anchor )
return defaultLabel ( ) ;
// 7. If category is Off, let the element's autofill field name be the string "off", let its
// autofill hint set be empty, and let its IDL-exposed autofill value be the string "off".
// Then, abort these steps.
if ( category = = AutofillCategory : : Off )
return { off , off . get ( ) . string ( ) } ;
// 8. If category is Automatic, let the element's autofill field name be the string "on",
// let its autofill hint set be empty, and let its IDL-exposed autofill value be the string
// "on". Then, abort these steps.
2016-03-06 04:18:54 +00:00
if ( category = = AutofillCategory : : Automatic )
2016-03-06 02:17:29 +00:00
return { on , on . get ( ) . string ( ) } ;
// 9. Let scope tokens be an empty list.
// 10. Let hint tokens be an empty set.
// NOTE: We are ignoring these steps as we don't currently make use of scope tokens or hint tokens anywhere.
// 11. Let IDL value have the same value as field.
String idlValue = field ;
// 12, If the indexth token in tokens is the first entry, then skip to the step labeled done.
if ( index = = 0 )
return { field , idlValue } ;
// 13. Decrement index by one
index - - ;
// 14. If category is Contact and the indexth token in tokens is an ASCII case-insensitive match
// for one of the strings in the following list, then run the substeps that follow:
const auto & contactToken = tokens [ index ] ;
if ( category = = AutofillCategory : : Contact & & isContactToken ( contactToken ) ) {
// 1. Let contact be the matching string from the list above.
const auto & contact = contactToken ;
// 2. Insert contact at the start of scope tokens.
// 3. Add contact to hint tokens.
// NOTE: We are ignoring these steps as we don't currently make use of scope tokens or hint tokens anywhere.
// 4. Let IDL value be the concatenation of contact, a U+0020 SPACE character, and the previous
// value of IDL value (which at this point will always be field).
idlValue = WTF : : makeString ( contact , " " , idlValue ) ;
// 5. If the indexth entry in tokens is the first entry, then skip to the step labeled done.
if ( index = = 0 )
return { field , idlValue } ;
// 6. Decrement index by one.
index - - ;
}
// 15. If the indexth token in tokens is an ASCII case-insensitive match for one of the strings
// in the following list, then run the substeps that follow:
const auto & modeToken = tokens [ index ] ;
if ( equalIgnoringASCIICase ( modeToken , " shipping " ) | | equalIgnoringASCIICase ( modeToken , " billing " ) ) {
// 1. Let mode be the matching string from the list above.
const auto & mode = modeToken ;
// 2. Insert mode at the start of scope tokens.
// 3. Add mode to hint tokens.
// NOTE: We are ignoring these steps as we don't currently make use of scope tokens or hint tokens anywhere.
// 4. Let IDL value be the concatenation of mode, a U+0020 SPACE character, and the previous
// value of IDL value (which at this point will either be field or the concatenation of contact,
// a space, and field).
idlValue = WTF : : makeString ( mode , " " , idlValue ) ;
// 5. If the indexth entry in tokens is the first entry, then skip to the step labeled done.
if ( index = = 0 )
return { field , idlValue } ;
// 6. Decrement index by one.
index - - ;
}
// 16. If the indexth entry in tokens is not the first entry, then jump to the step labeled default.
if ( index ! = 0 )
return defaultLabel ( ) ;
// 17. If the first eight characters of the indexth token in tokens are not an ASCII case-insensitive
// match for the string "section-", then jump to the step labeled default.
const auto & sectionToken = tokens [ index ] ;
2020-03-19 08:29:23 +00:00
if ( ! startsWithLettersIgnoringASCIICase ( StringView ( sectionToken ) , " section- " ) )
2016-03-06 02:17:29 +00:00
return defaultLabel ( ) ;
// 18. Let section be the indexth token in tokens, converted to ASCII lowercase.
const auto & section = sectionToken ;
// 19. Insert section at the start of scope tokens.
// NOTE: We are ignoring this step as we don't currently make use of scope tokens or hint tokens anywhere.
// 20. Let IDL value be the concatenation of section, a U+0020 SPACE character, and the previous
// value of IDL value.
idlValue = WTF : : makeString ( section , " " , idlValue ) ;
return { field , idlValue } ;
}
} // namespace WebCore