Diff
Modified: trunk/Source/WTF/ChangeLog (287231 => 287232)
--- trunk/Source/WTF/ChangeLog 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WTF/ChangeLog 2021-12-18 23:57:08 UTC (rev 287232)
@@ -1,3 +1,16 @@
+2021-12-18 Darin Adler <[email protected]>
+
+ Hash tables, read/write, and heap memory are used unnecessarily, which may hurt performance
+ https://bugs.webkit.org/show_bug.cgi?id=234438
+
+ Reviewed by Anders Carlsson.
+
+ * wtf/SortedArrayMap.h:
+ (WTF::SortedArrayMap<ArrayType>::contains const): Added. More elegant than calling tryGet and
+ treating the pointer as a boolean.
+ (WTF::makeOptionalFromPointer): Moved here so it can be reused. Might rename later, since it's
+ only used in a few places.
+
2021-12-17 Simon Fraser <[email protected]>
Read the default value of the ScrollAnimatorEnabled setting from NSUserDefaults
Modified: trunk/Source/WTF/wtf/SortedArrayMap.h (287231 => 287232)
--- trunk/Source/WTF/wtf/SortedArrayMap.h 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WTF/wtf/SortedArrayMap.h 2021-12-18 23:57:08 UTC (rev 287232)
@@ -51,6 +51,7 @@
using ValueType = typename ElementType::second_type;
constexpr SortedArrayMap(const ArrayType&);
+ template<typename KeyArgument> bool contains(const KeyArgument&) const;
// FIXME: To match HashMap interface better, would be nice to get the default value from traits.
template<typename KeyArgument> ValueType get(const KeyArgument&, const ValueType& defaultValue = { }) const;
@@ -77,7 +78,7 @@
// NoUppercaseLettersOptimized means no characters with the 0x20 bit set.
// That means the strings can't include control characters, uppercase letters, or any of @[\]_.
-enum class ASCIISubset { All, NoUppercaseLetters, NoUppercaseLettersOptimized };
+enum class ASCIISubset : uint8_t { All, NoUppercaseLetters, NoUppercaseLettersOptimized };
template<ASCIISubset> struct ComparableASCIISubsetLiteral {
ASCIILiteral literal;
@@ -189,6 +190,11 @@
return result ? *result : defaultValue;
}
+template<typename ArrayType> template<typename KeyArgument> inline bool SortedArrayMap<ArrayType>::contains(const KeyArgument& key) const
+{
+ return tryGet(key);
+}
+
template<typename ArrayType> constexpr SortedArraySet<ArrayType>::SortedArraySet(const ArrayType& array)
: m_array { array }
{
@@ -365,8 +371,15 @@
return a.value() < b.value();
}
+template<typename ValueType> constexpr std::optional<ValueType> makeOptionalFromPointer(const ValueType* pointer)
+{
+ if (!pointer)
+ return std::nullopt;
+ return *pointer;
}
+}
+
// FIXME: Rename the Comparable and Packed types for clarity and to align them better with each other.
using WTF::ASCIISubset;
using WTF::ComparableASCIILiteral;
@@ -376,3 +389,4 @@
using WTF::PackedASCIILowerCodes;
using WTF::SortedArrayMap;
using WTF::SortedArraySet;
+using WTF::makeOptionalFromPointer;
Modified: trunk/Source/WebCore/ChangeLog (287231 => 287232)
--- trunk/Source/WebCore/ChangeLog 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/ChangeLog 2021-12-18 23:57:08 UTC (rev 287232)
@@ -1,3 +1,116 @@
+2021-12-18 Darin Adler <[email protected]>
+
+ Hash tables, read/write, and heap memory are used unnecessarily, which may hurt performance
+ https://bugs.webkit.org/show_bug.cgi?id=234438
+
+ Reviewed by Anders Carlsson.
+
+ * Modules/mediacapabilities/MediaCapabilities.cpp:
+ (WebCore::bucketMIMETypes): Deleted.
+ (WebCore::isValidMediaMIMEType): Moved the code from bucketMIMETypes in here.
+ Use a SortedArraySet for bucketMIMETypes, which should be similar in performance
+ and uses no heap or read/write memory.
+
+ * accessibility/AccessibilityObject.cpp:
+ (WebCore::AccessibilityObject::popupValue const): Use a loop to check the 5 valid
+ values here instead of making a HashSet. Should be similar in performance and
+ use no heap or read/write memory. Also removes call to convertToASCIILowercase,
+ which will also help performance and memory use a tiny bit in some cases.
+
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::AccessibilityRenderObject::inheritsPresentationalRole const): Use
+ decltype to make this declaration simpler and shorter.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateForEachEventHandlerContentAttribute): Use decltype and references
+ instead of pointers to make the function a little cleaner.
+
+ * dom/Element.cpp:
+ (WebCore::canAttachAuthorShadowRoot): Use constexpr so the tag list here does
+ not use any read/write memory.
+
+ * dom/make_names.pl:
+ (printFactoryCppFile): Removed the unnecessary constructors for the MapEntry
+ structs. Use decltype so we can make the tables constexpr so they do not use
+ any read/write memory.
+ (printWrapperFactoryCppFile): Ditto.
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::isProhibitedParagraphChild): Added a reserveInitialCapacity, which
+ could make the hash table here use a little less memory.
+
+ * html/Autofill.cpp:
+ (WebCore::fieldNameMap): Deleted. Replaced with a SortedArrayMap, which is
+ entirely made out of constexpr objcts so does not use heap or read/write memory.
+ (WebCore::toAutofillFieldName): Updated to use SortedArrayMap functions.
+ (WebCore::AutofillData::createFromHTMLFormControlElement): Ditto.
+
+ * html/HTMLDocument.cpp:
+ (WebCore::HTMLDocument::isCaseSensitiveAttribute): Added a reserveInitialCapacity,
+ which could make the hash table here use a little less memory.
+ * html/HTMLObjectElement.cpp:
+ (WebCore::preventsParentObjectFromExposure): Ditto.
+
+ * page/DebugPageOverlays.cpp:
+ (WebCore::touchEventRegionColors): Deleted.
+ (WebCore::NonFastScrollableRegionOverlay::drawRect): Use SortedArrayMap and
+ some lambdas to make this code tighter and easier to read.
+
+ * page/PerformanceUserTiming.cpp:
+ (WebCore::restrictedMarkNamesToNavigationTimingFunctionMap): Deleted. Use
+ a SortedArrayMap instead, which should be similar in performance and uses no heap
+ or read/write memory.
+ (WebCore::restrictedMarkFunction): Deleted.
+ (WebCore::isRestrictedMarkNameNonMainThread): Deleted. This is now safe to do on
+ any thread.
+ (WebCore::PerformanceUserTiming::isRestrictedMarkName): Use the SortedArrayMap,
+ which has the benefit of relaxing the thread restrictions; this is now safe to
+ call on any thread.
+ (WebCore::PerformanceUserTiming::convertMarkToTimestamp const): Updated to use
+ the SortedArrayMap. There may be some additional simplification possible now
+ that the mark functions map can be used in any thread, but I wasn't sure.
+
+ * platform/cocoa/RemoteCommandListenerCocoa.mm:
+ (WebCore::mediaRemoteCommandForPlatformCommand): Use makeOptionalFromPointer.
+
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::hasValidAverageCharWidth const): Use a SortedArraySet,
+ which should be similar in performance and uses no heap or read/write memory
+
+ * platform/graphics/FontPlatformData.cpp:
+ (WebCore::makeOptionalFromPointer): Deleted. Moved to SortedArrayMap.h.
+ * platform/graphics/HEVCUtilities.cpp:
+ (WebCore::makeOptionalFromPointer): Deleted. Moved to SortedArrayMap.h.
+
+ * platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm:
+ (WebCore::AVAssetMIMETypeCache::initializeCache): Updated for function name change.
+
+ * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+ Tweaked use of UNUSED_PARAM a bit across the file, relying on omitted names instead.
+
+ * platform/graphics/cg/UTIRegistry.cpp:
+ (WebCore::defaultSupportedImageTypes): Use a constexpr array rather than HashSet,
+ on something just iterating this, not using it as a set.
+
+ * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
+ (WebCore::SourceBufferParserWebM::supportedMIMETypes): Renamed from webmMIMETypes,
+ changed to return a Span so we don't have to allocate a HashSet, since callers
+ simply iterate this, and don't do set operations.
+ (WebCore::SourceBufferParserWebM::isSupportedVideoCodec): Replaced the
+ supportedVideoCodecs with this. We don't need a HashSet to check for two values,
+ and this should be faster and use less memory.
+ (WebCore::SourceBufferParserWebM::isSupportedAudioCodec): Ditto.
+ * platform/graphics/cocoa/SourceBufferParserWebM.h: Updated for the changes above.
+
+ * rendering/svg/SVGResources.cpp:
+ (WebCore::tagSet): Added this helper to make the code in the functions below less
+ repetitive.
+ (WebCore::clipperFilterMaskerTags): Use a constexpr array instead of many separate
+ calls to HashSet::add to construct the set.
+ (WebCore::markerTags): Ditto.
+ (WebCore::fillAndStrokeTags): Ditto.
+ (WebCore::chainableResourceTags): Ditto.
+
2021-12-18 Alex Christensen <[email protected]>
Use smart pointers for WebCoreNSURLSessionDataTask ObjC members
Modified: trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp (287231 => 287232)
--- trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -43,36 +43,33 @@
#include "Page.h"
#include "Settings.h"
#include <wtf/Logger.h>
-#include <wtf/RobinHoodHashSet.h>
+#include <wtf/SortedArrayMap.h>
namespace WebCore {
-static const MemoryCompactLookupOnlyRobinHoodHashSet<String>& bucketMIMETypes()
+static bool isValidMediaMIMEType(const ContentType& contentType)
{
// A "bucket" MIME types is one whose container type does not uniquely specify a codec.
// See: https://tools.ietf.org/html/rfc6381
- static NeverDestroyed<MemoryCompactLookupOnlyRobinHoodHashSet<String>> bucketMIMETypes(std::initializer_list<String> {
- "audio/3gpp"_s,
- "video/3gpp"_s,
- "audio/3gpp2"_s,
- "video/3gpp2"_s,
- "audio/mp4"_s,
- "video/mp4"_s,
- "application/mp4"_s,
- "video/quicktime"_s,
- "application/mp21"_s,
- "audio/vnd.apple.mpegurl"_s,
- "video/vnd.apple.mpegurl"_s,
- "audio/ogg"_s,
- "video/ogg"_s,
- "video/webm"_s,
- "audio/webm"_s,
- });
- return bucketMIMETypes;
-}
+ static constexpr ComparableASCIILiteral bucketMIMETypeArray[] = {
+ "application/mp21",
+ "application/mp4",
+ "audio/3gpp",
+ "audio/3gpp2",
+ "audio/mp4",
+ "audio/ogg",
+ "audio/vnd.apple.mpegurl",
+ "audio/webm",
+ "video/3gpp",
+ "video/3gpp2",
+ "video/mp4",
+ "video/ogg",
+ "video/quicktime",
+ "video/vnd.apple.mpegurl",
+ "video/webm",
+ };
+ static constexpr SortedArraySet bucketMIMETypes { bucketMIMETypeArray };
-static bool isValidMediaMIMEType(const ContentType& contentType)
-{
// 2.1.4. MIME types
// https://wicg.github.io/media-capabilities/#valid-media-mime-type
// A valid media MIME type is a string that is a valid MIME type per [mimesniff]. If the MIME type does
@@ -84,7 +81,7 @@
auto codecs = contentType.codecs();
// FIXME: The spec requires that the "codecs" parameter is the only parameter present.
- if (bucketMIMETypes().contains(contentType.containerType()))
+ if (bucketMIMETypes.contains(contentType.containerType()))
return codecs.size() == 1;
return !codecs.size();
}
Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (287231 => 287232)
--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -87,7 +87,6 @@
#include "VisibleUnits.h"
#include <pal/SessionID.h>
#include <wtf/NeverDestroyed.h>
-#include <wtf/RobinHoodHashSet.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringView.h>
@@ -2842,29 +2841,28 @@
String AccessibilityObject::popupValue() const
{
- static const NeverDestroyed<MemoryCompactLookupOnlyRobinHoodHashSet<String>> allowedPopupValues(std::initializer_list<String> {
- "menu"_s, "listbox"_s, "tree"_s, "grid"_s, "dialog"_s,
- });
-
- auto hasPopup = getAttribute(aria_haspopupAttr).convertToASCIILowercase();
- if (hasPopup.isNull() || hasPopup.isEmpty()) {
+ auto& hasPopup = getAttribute(aria_haspopupAttr);
+ if (hasPopup.isEmpty()) {
// In ARIA 1.1, the implicit value for combobox became "listbox."
if (isComboBox() || hasDatalist())
- return "listbox";
- return "false";
+ return "listbox"_s;
+ return "false"_s;
}
- if (allowedPopupValues->contains(hasPopup))
- return hasPopup;
+ for (auto& value : { "menu"_s, "listbox"_s, "tree"_s, "grid"_s, "dialog"_s }) {
+ // FIXME: Should fix ambiguity so we don't have to write "characters", but also don't create/destroy a String when passing an ASCIILiteral to equalIgnoringASCIICase.
+ if (equalIgnoringASCIICase(hasPopup, value.characters()))
+ return value;
+ }
// aria-haspopup specification states that true must be treated as menu.
- if (hasPopup == "true")
- return "menu";
+ if (equalLettersIgnoringASCIICase(hasPopup, "true"))
+ return "menu"_s;
// The spec states that "User agents must treat any value of aria-haspopup that is not
// included in the list of allowed values, including an empty string, as if the value
// false had been provided."
- return "false";
+ return "false"_s;
}
bool AccessibilityObject::hasDatalist() const
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (287231 => 287232)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -3214,7 +3214,7 @@
// those child elements are also presentational. For example, <li> becomes presentational from <ul>.
// http://www.w3.org/WAI/PF/aria/complete#presentation
- Span<LazyNeverDestroyed<const HTMLQualifiedName>* const> parentTags;
+ Span<decltype(aTag)* const> parentTags;
switch (roleValue()) {
case AccessibilityRole::ListItem:
case AccessibilityRole::ListMarker: {
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (287231 => 287232)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2021-12-18 23:57:08 UTC (rev 287232)
@@ -5210,18 +5210,18 @@
AddToImplIncludes("HTMLNames.h");
push(@$outputArray, "void ${className}::${functionName}(const Function<void(const AtomString& attributeName, const AtomString& eventName)>& function)\n");
push(@$outputArray, "{\n");
- push(@$outputArray, " static constexpr std::pair<LazyNeverDestroyed<const QualifiedName>*, const AtomString EventNames::*> table[] = {\n");
+ push(@$outputArray, " static constexpr std::pair<decltype(HTMLNames::altAttr)&, const AtomString EventNames::*> table[] = {\n");
foreach my $attribute (@{$interface->attributes}) {
if ($attribute->type->name eq "EventHandler" && (!defined $eventHandlerExtendedAttributeName || $attribute->extendedAttributes->{$eventHandlerExtendedAttributeName})) {
my $attributeName = $attribute->name;
my $eventName = EventHandlerAttributeShortEventName($attribute);
- push(@$outputArray, " { &HTMLNames::${attributeName}Attr, &EventNames::${eventName} },\n");
+ push(@$outputArray, " { HTMLNames::${attributeName}Attr, &EventNames::${eventName} },\n");
}
}
push(@$outputArray, " };\n");
push(@$outputArray, " auto& eventNames = WebCore::eventNames();\n");
push(@$outputArray, " for (auto& names : table)\n");
- push(@$outputArray, " function(names.first->get().localName(), eventNames.*names.second);\n");
+ push(@$outputArray, " function(names.first.get().localName(), eventNames.*names.second);\n");
push(@$outputArray, "}\n\n");
}
Modified: trunk/Source/WebCore/dom/Element.cpp (287231 => 287232)
--- trunk/Source/WebCore/dom/Element.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/dom/Element.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -2485,31 +2485,31 @@
static bool canAttachAuthorShadowRoot(const Element& element)
{
- static NeverDestroyed<MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>> tagNames = [] {
- static const HTMLQualifiedName* const tagList[] = {
- &articleTag.get(),
- &asideTag.get(),
- &blockquoteTag.get(),
- &bodyTag.get(),
- &divTag.get(),
- &footerTag.get(),
- &h1Tag.get(),
- &h2Tag.get(),
- &h3Tag.get(),
- &h4Tag.get(),
- &h5Tag.get(),
- &h6Tag.get(),
- &headerTag.get(),
- &mainTag.get(),
- &navTag.get(),
- &pTag.get(),
- §ionTag.get(),
- &spanTag.get()
+ static NeverDestroyed tagNames = [] {
+ static constexpr std::array tagList {
+ &articleTag,
+ &asideTag,
+ &blockquoteTag,
+ &bodyTag,
+ &divTag,
+ &footerTag,
+ &h1Tag,
+ &h2Tag,
+ &h3Tag,
+ &h4Tag,
+ &h5Tag,
+ &h6Tag,
+ &headerTag,
+ &mainTag,
+ &navTag,
+ &pTag,
+ §ionTag,
+ &spanTag
};
MemoryCompactLookupOnlyRobinHoodHashSet<AtomString> set;
set.reserveInitialCapacity(sizeof(tagList));
for (auto& name : tagList)
- set.add(name->localName());
+ set.add(name->get().localName());
return set;
}();
Modified: trunk/Source/WebCore/dom/make_names.pl (287231 => 287232)
--- trunk/Source/WebCore/dom/make_names.pl 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/dom/make_names.pl 2021-12-18 23:57:08 UTC (rev 287232)
@@ -994,31 +994,27 @@
printConstructors($F, \%tagConstructorMap);
+ my $firstTag;
+ for my $tag (sort keys %tagConstructorMap) {
+ $firstTag = $tag;
+ last;
+ }
+
print F <<END
struct $parameters{namespace}ConstructorFunctionMapEntry {
- $parameters{namespace}ConstructorFunctionMapEntry($parameters{namespace}ConstructorFunction function, const QualifiedName& name)
- : function(function)
- , qualifiedName(&name)
- { }
-
- $parameters{namespace}ConstructorFunctionMapEntry()
- : function(nullptr)
- , qualifiedName(nullptr)
- { }
-
- $parameters{namespace}ConstructorFunction function;
- const QualifiedName* qualifiedName; // Use pointer instead of reference so that emptyValue() in HashMap is cheap to create.
+ $parameters{namespace}ConstructorFunction function { nullptr };
+ const QualifiedName* qualifiedName { nullptr }; // Use pointer instead of reference so that emptyValue() in HashMap is cheap to create.
};
static NEVER_INLINE MemoryCompactLookupOnlyRobinHoodHashMap<AtomString, $parameters{namespace}ConstructorFunctionMapEntry> create$parameters{namespace}FactoryMap()
{
struct TableEntry {
- const QualifiedName& name;
+ decltype($parameters{namespace}Names::${firstTag}Tag)& name;
$parameters{namespace}ConstructorFunction function;
};
- static const TableEntry table[] = {
+ static constexpr TableEntry table[] = {
END
;
@@ -1029,7 +1025,7 @@
MemoryCompactLookupOnlyRobinHoodHashMap<AtomString, $parameters{namespace}ConstructorFunctionMapEntry> map;
for (auto& entry : table)
- map.add(entry.name.localName(), $parameters{namespace}ConstructorFunctionMapEntry(entry.function, entry.name));
+ map.add(entry.name.get().localName(), $parameters{namespace}ConstructorFunctionMapEntry { entry.function, &entry.name.get() });
return map;
}
@@ -1261,16 +1257,22 @@
printWrapperFunctions($F);
+ my $firstTag;
+ for my $tag (sort keys %allTags) {
+ $firstTag = $tag;
+ last;
+ }
+
print F <<END
static NEVER_INLINE MemoryCompactLookupOnlyRobinHoodHashMap<AtomString, Create$parameters{namespace}ElementWrapperFunction> create$parameters{namespace}WrapperMap()
{
struct TableEntry {
- const QualifiedName& name;
+ decltype($parameters{namespace}Names::${firstTag}Tag)& name;
Create$parameters{namespace}ElementWrapperFunction function;
};
- static const TableEntry table[] = {
+ static constexpr TableEntry table[] = {
END
;
@@ -1303,7 +1305,7 @@
MemoryCompactLookupOnlyRobinHoodHashMap<AtomString, Create$parameters{namespace}ElementWrapperFunction> map;
for (auto& entry : table)
- map.add(entry.name.localName(), entry.function);
+ map.add(entry.name.get().localName(), entry.function);
return map;
}
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (287231 => 287232)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -778,6 +778,7 @@
&xmpTag,
};
MemoryCompactLookupOnlyRobinHoodHashSet<AtomString> set;
+ set.reserveInitialCapacity(std::size(tags));
for (auto& tag : tags)
set.add(tag->get().localName());
return set;
Modified: trunk/Source/WebCore/html/Autofill.cpp (287231 => 287232)
--- trunk/Source/WebCore/html/Autofill.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/html/Autofill.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -30,106 +30,79 @@
#include "HTMLFormControlElement.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
-#include <wtf/HashMap.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/RobinHoodHashMap.h>
-#include <wtf/text/AtomString.h>
-#include <wtf/text/AtomStringHash.h>
+#include <wtf/SortedArrayMap.h>
namespace WebCore {
-enum class AutofillCategory {
- Off,
- Automatic,
- Normal,
- Contact,
-};
+enum class AutofillCategory : uint8_t { Off, Automatic, Normal, Contact };
-struct AutofillInfo {
- AutofillFieldName fieldName;
+struct AutofillFieldNameMapping {
+ AutofillFieldName name;
AutofillCategory category;
};
-static const MemoryCompactLookupOnlyRobinHoodHashMap<AtomString, AutofillInfo>& fieldNameMap()
-{
- static NeverDestroyed map = [] {
- struct MapEntry {
- ASCIILiteral name;
- AutofillInfo value;
- };
- static constexpr MapEntry entries[] = {
- { "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 } },
+static constexpr std::pair<ComparableLettersLiteral, AutofillFieldNameMapping> fieldNameMappings[] = {
+ { "additional-name", { AutofillFieldName::AdditionalName, AutofillCategory::Normal } },
+ { "address-level1", { AutofillFieldName::AddressLevel1, AutofillCategory::Normal } },
+ { "address-level2", { AutofillFieldName::AddressLevel2, AutofillCategory::Normal } },
+ { "address-level3", { AutofillFieldName::AddressLevel3, AutofillCategory::Normal } },
+ { "address-level4", { AutofillFieldName::AddressLevel4, AutofillCategory::Normal } },
+ { "address-line1", { AutofillFieldName::AddressLine1, AutofillCategory::Normal } },
+ { "address-line2", { AutofillFieldName::AddressLine2, AutofillCategory::Normal } },
+ { "address-line3", { AutofillFieldName::AddressLine3, AutofillCategory::Normal } },
+ { "bday", { AutofillFieldName::Bday, AutofillCategory::Normal } },
+ { "bday-day", { AutofillFieldName::BdayDay, AutofillCategory::Normal } },
+ { "bday-month", { AutofillFieldName::BdayMonth, AutofillCategory::Normal } },
+ { "bday-year", { AutofillFieldName::BdayYear, AutofillCategory::Normal } },
+ { "cc-additional-name", { AutofillFieldName::CcAdditionalName, AutofillCategory::Normal } },
+ { "cc-csc", { AutofillFieldName::CcCsc, AutofillCategory::Normal } },
+ { "cc-exp", { AutofillFieldName::CcExp, AutofillCategory::Normal } },
+ { "cc-exp-month", { AutofillFieldName::CcExpMonth, AutofillCategory::Normal } },
+ { "cc-exp-year", { AutofillFieldName::CcExpYear, AutofillCategory::Normal } },
+ { "cc-family-name", { AutofillFieldName::CcFamilyName, AutofillCategory::Normal } },
+ { "cc-given-name", { AutofillFieldName::CcGivenName, AutofillCategory::Normal } },
+ { "cc-name", { AutofillFieldName::CcName, AutofillCategory::Normal } },
+ { "cc-number", { AutofillFieldName::CcNumber, AutofillCategory::Normal } },
+ { "cc-type", { AutofillFieldName::CcType, AutofillCategory::Normal } },
+ { "country", { AutofillFieldName::Country, AutofillCategory::Normal } },
+ { "country-name", { AutofillFieldName::CountryName, AutofillCategory::Normal } },
+ { "current-password", { AutofillFieldName::CurrentPassword, AutofillCategory::Normal } },
+ { "email", { AutofillFieldName::Email, AutofillCategory::Contact } },
+ { "family-name", { AutofillFieldName::FamilyName, AutofillCategory::Normal } },
+ { "given-name", { AutofillFieldName::GivenName, AutofillCategory::Normal } },
+ { "honorific-prefix", { AutofillFieldName::HonorificPrefix, AutofillCategory::Normal } },
+ { "honorific-suffix", { AutofillFieldName::HonorificSuffix, AutofillCategory::Normal } },
+ { "impp", { AutofillFieldName::Impp, AutofillCategory::Contact } },
+ { "language", { AutofillFieldName::Language, AutofillCategory::Normal } },
+ { "name", { AutofillFieldName::Name, AutofillCategory::Normal } },
+ { "new-password", { AutofillFieldName::NewPassword, AutofillCategory::Normal } },
+ { "nickname", { AutofillFieldName::Nickname, AutofillCategory::Normal } },
+ { "off", { AutofillFieldName::None, AutofillCategory::Off } },
+ { "on", { AutofillFieldName::None, AutofillCategory::Automatic } },
+ { "organization", { AutofillFieldName::Organization, AutofillCategory::Normal } },
+ { "organization-title", { AutofillFieldName::OrganizationTitle, AutofillCategory::Normal } },
+ { "photo", { AutofillFieldName::Photo, AutofillCategory::Normal } },
+ { "postal-code", { AutofillFieldName::PostalCode, AutofillCategory::Normal } },
+ { "sex", { AutofillFieldName::Sex, AutofillCategory::Normal } },
+ { "street-address", { AutofillFieldName::StreetAddress, AutofillCategory::Normal } },
+ { "tel", { AutofillFieldName::Tel, AutofillCategory::Contact } },
+ { "tel-area-code", { AutofillFieldName::TelAreaCode, AutofillCategory::Contact } },
+ { "tel-country-code", { AutofillFieldName::TelCountryCode, AutofillCategory::Contact } },
+ { "tel-extension", { AutofillFieldName::TelExtension, AutofillCategory::Contact } },
+ { "tel-local", { AutofillFieldName::TelLocal, AutofillCategory::Contact } },
+ { "tel-local-prefix", { AutofillFieldName::TelLocalPrefix, AutofillCategory::Contact } },
+ { "tel-local-suffix", { AutofillFieldName::TelLocalSuffix, AutofillCategory::Contact } },
+ { "tel-national", { AutofillFieldName::TelNational, AutofillCategory::Contact } },
+ { "transaction-amount", { AutofillFieldName::TransactionAmount, AutofillCategory::Normal } },
+ { "transaction-currency", { AutofillFieldName::TransactionCurrency, AutofillCategory::Normal } },
+ { "url", { AutofillFieldName::URL, AutofillCategory::Normal } },
+ { "username", { AutofillFieldName::Username, AutofillCategory::Normal } },
+};
+static constexpr SortedArrayMap fieldNameMap { fieldNameMappings };
- { "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 } },
- };
- MemoryCompactLookupOnlyRobinHoodHashMap<AtomString, AutofillInfo> map;
- for (auto& entry : entries)
- map.add(entry.name, entry.value);
- return map;
- }();
- return map;
-}
-
AutofillFieldName toAutofillFieldName(const AtomString& value)
{
- auto map = fieldNameMap();
- auto it = map.find(value);
- if (it == map.end())
- return AutofillFieldName::None;
- return it->value.fieldName;
+ return fieldNameMap.get(value).name;
}
static inline bool isContactToken(const AtomString& token)
@@ -204,13 +177,12 @@
// 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())
+ auto mapEntry = fieldNameMap.tryGet(tokens[index]);
+ if (!mapEntry)
return defaultLabel();
- auto category = it->value.category;
+ auto category = mapEntry->category;
if (tokens.size() > maxTokensForAutofillFieldCategory(category))
return defaultLabel();
Modified: trunk/Source/WebCore/html/HTMLDocument.cpp (287231 => 287232)
--- trunk/Source/WebCore/html/HTMLDocument.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/html/HTMLDocument.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -227,6 +227,7 @@
&vlinkAttr,
};
MemoryCompactLookupOnlyRobinHoodHashSet<AtomString> set;
+ set.reserveInitialCapacity(std::size(names));
for (auto* name : names)
set.add(name->get().localName());
return set;
Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (287231 => 287232)
--- trunk/Source/WebCore/html/HTMLObjectElement.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -359,6 +359,7 @@
static NeverDestroyed mostKnownTags = [] {
MemoryCompactLookupOnlyRobinHoodHashSet<QualifiedName> set;
auto* tags = HTMLNames::getHTMLTags();
+ set.reserveInitialCapacity(HTMLNames::HTMLTagsCount);
for (size_t i = 0; i < HTMLNames::HTMLTagsCount; i++) {
auto& tag = *tags[i];
// Only the param element was explicitly mentioned in the HTML specification rule
Modified: trunk/Source/WebCore/page/DebugPageOverlays.cpp (287231 => 287232)
--- trunk/Source/WebCore/page/DebugPageOverlays.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/page/DebugPageOverlays.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,7 +36,7 @@
#include "Region.h"
#include "ScrollingCoordinator.h"
#include "Settings.h"
-#include <wtf/RobinHoodHashMap.h>
+#include <wtf/SortedArrayMap.h>
namespace WebCore {
@@ -150,21 +150,6 @@
return regionChanged;
}
-static const MemoryCompactLookupOnlyRobinHoodHashMap<String, SRGBA<uint8_t>>& touchEventRegionColors()
-{
- static NeverDestroyed regionColors { MemoryCompactLookupOnlyRobinHoodHashMap<String, SRGBA<uint8_t>> { {
- { "touchstart"_s, { 191, 191, 63, 50 } },
- { "touchmove"_s, { 80, 204, 245, 50 } },
- { "touchend"_s, { 191, 63, 127, 50 } },
- { "touchforcechange"_s, { 63, 63, 191, 50 } },
- { "wheel"_s, { 255, 128, 0, 50 } },
- { "mousedown"_s, { 80, 245, 80, 50 } },
- { "mousemove"_s, { 245, 245, 80, 50 } },
- { "mouseup"_s, { 80, 245, 176, 50 } },
- } } };
- return regionColors;
-}
-
static void drawRightAlignedText(const String& text, GraphicsContext& context, const FontCascade& font, const FloatPoint& boxLocation)
{
float textGap = 10;
@@ -178,6 +163,19 @@
void NonFastScrollableRegionOverlay::drawRect(PageOverlay& pageOverlay, GraphicsContext& context, const IntRect&)
{
+ static constexpr std::pair<ComparableASCIILiteral, SRGBA<uint8_t>> colorMappings[] = {
+ { "mousedown", { 80, 245, 80, 50 } },
+ { "mousemove", { 245, 245, 80, 50 } },
+ { "mouseup", { 80, 245, 176, 50 } },
+ { "touchend", { 191, 63, 127, 50 } },
+ { "touchforcechange", { 63, 63, 191, 50 } },
+ { "touchmove", { 80, 204, 245, 50 } },
+ { "touchstart", { 191, 191, 63, 50 } },
+ { "wheel", { 255, 128, 0, 50 } },
+ };
+ constexpr SortedArrayMap colors { colorMappings };
+ constexpr auto defaultColor = Color::black.colorWithAlphaByte(64);
+
IntRect bounds = pageOverlay.bounds();
context.clearRect(bounds);
@@ -192,60 +190,32 @@
FontCascade font(WTFMove(fontDescription), 0, 0);
font.update(nullptr);
+ auto drawLegend = [&] (const Color& color, ASCIILiteral text) {
+ context.setFillColor(color);
+ context.fillRect(legendRect);
+ drawRightAlignedText(text, context, font, legendRect.location());
+ legendRect.move(0, 30);
+ };
+
#if ENABLE(TOUCH_EVENTS)
- context.setFillColor(touchEventRegionColors().get("touchstart"_s));
- context.fillRect(legendRect);
- drawRightAlignedText("touchstart"_s, context, font, legendRect.location());
-
- legendRect.move(0, 30);
- context.setFillColor(touchEventRegionColors().get("touchmove"_s));
- context.fillRect(legendRect);
- drawRightAlignedText("touchmove"_s, context, font, legendRect.location());
-
- legendRect.move(0, 30);
- context.setFillColor(touchEventRegionColors().get("touchend"_s));
- context.fillRect(legendRect);
- drawRightAlignedText("touchend"_s, context, font, legendRect.location());
-
- legendRect.move(0, 30);
- context.setFillColor(touchEventRegionColors().get("touchforcechange"_s));
- context.fillRect(legendRect);
- drawRightAlignedText("touchforcechange"_s, context, font, legendRect.location());
-
- legendRect.move(0, 30);
- context.setFillColor(m_color);
- context.fillRect(legendRect);
- drawRightAlignedText("passive listeners"_s, context, font, legendRect.location());
-
- legendRect.move(0, 30);
- context.setFillColor(touchEventRegionColors().get("mousedown"_s));
- context.fillRect(legendRect);
- drawRightAlignedText("mousedown"_s, context, font, legendRect.location());
-
- legendRect.move(0, 30);
- context.setFillColor(touchEventRegionColors().get("mousemove"_s));
- context.fillRect(legendRect);
- drawRightAlignedText("mousemove"_s, context, font, legendRect.location());
-
- legendRect.move(0, 30);
- context.setFillColor(touchEventRegionColors().get("mouseup"_s));
- context.fillRect(legendRect);
- drawRightAlignedText("mouseup"_s, context, font, legendRect.location());
+ auto drawEventLegend = [&] (ASCIILiteral color) {
+ drawLegend(colors.get(StringView { color }), color);
+ };
+ drawEventLegend("touchstart"_s);
+ drawEventLegend("touchmove"_s);
+ drawEventLegend("touchend"_s);
+ drawEventLegend("touchforcechange"_s);
+ drawLegend(m_color, "passive listeners"_s);
+ drawEventLegend("mousedown"_s);
+ drawEventLegend("mousemove"_s);
+ drawEventLegend("mouseup"_s);
#else
// On desktop platforms, the "wheel" region includes the non-fast scrollable region.
- context.setFillColor(touchEventRegionColors().get("wheel"_s));
- context.fillRect(legendRect);
- drawRightAlignedText("non-fast region"_s, context, font, legendRect.location());
+ drawLegend(colors.get("wheel"), "non-fast region"_s);
#endif
- for (const auto& synchronousEventRegion : m_eventTrackingRegions.eventSpecificSynchronousDispatchRegions) {
- auto regionColor = Color::black.colorWithAlphaByte(64);
- auto it = touchEventRegionColors().find(synchronousEventRegion.key);
- if (it != touchEventRegionColors().end())
- regionColor = it->value;
- drawRegion(context, synchronousEventRegion.value, regionColor, bounds);
- }
-
+ for (auto& region : m_eventTrackingRegions.eventSpecificSynchronousDispatchRegions)
+ drawRegion(context, region.value, colors.get(region.key, defaultColor), bounds);
drawRegion(context, m_eventTrackingRegions.asynchronousDispatchRegion, m_color, bounds);
}
Modified: trunk/Source/WebCore/page/PerformanceUserTiming.cpp (287231 => 287232)
--- trunk/Source/WebCore/page/PerformanceUserTiming.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/page/PerformanceUserTiming.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -34,62 +34,40 @@
#include "PerformanceTiming.h"
#include "SerializedScriptValue.h"
#include <_javascript_Core/JSCJSValueInlines.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/RobinHoodHashMap.h>
+#include <wtf/SortedArrayMap.h>
namespace WebCore {
using NavigationTimingFunction = unsigned long long (PerformanceTiming::*)() const;
-static const MemoryCompactLookupOnlyRobinHoodHashMap<String, NavigationTimingFunction>& restrictedMarkNamesToNavigationTimingFunctionMap()
-{
- ASSERT(isMainThread());
- static NeverDestroyed map = MemoryCompactLookupOnlyRobinHoodHashMap<String, NavigationTimingFunction> {
- { "connectEnd"_s, &PerformanceTiming::connectEnd },
- { "connectStart"_s, &PerformanceTiming::connectStart },
- { "domComplete"_s, &PerformanceTiming::domComplete },
- { "domContentLoadedEventEnd"_s, &PerformanceTiming::domContentLoadedEventEnd },
- { "domContentLoadedEventStart"_s, &PerformanceTiming::domContentLoadedEventStart },
- { "domInteractive"_s, &PerformanceTiming::domInteractive },
- { "domLoading"_s, &PerformanceTiming::domLoading },
- { "domainLookupEnd"_s, &PerformanceTiming::domainLookupEnd },
- { "domainLookupStart"_s, &PerformanceTiming::domainLookupStart },
- { "fetchStart"_s, &PerformanceTiming::fetchStart },
- { "loadEventEnd"_s, &PerformanceTiming::loadEventEnd },
- { "loadEventStart"_s, &PerformanceTiming::loadEventStart },
- { "navigationStart"_s, &PerformanceTiming::navigationStart },
- { "redirectEnd"_s, &PerformanceTiming::redirectEnd },
- { "redirectStart"_s, &PerformanceTiming::redirectStart },
- { "requestStart"_s, &PerformanceTiming::requestStart },
- { "responseEnd"_s, &PerformanceTiming::responseEnd },
- { "responseStart"_s, &PerformanceTiming::responseStart },
- { "secureConnectionStart"_s, &PerformanceTiming::secureConnectionStart },
- { "unloadEventEnd"_s, &PerformanceTiming::unloadEventEnd },
- { "unloadEventStart"_s, &PerformanceTiming::unloadEventStart },
- };
- return map;
-}
-static NavigationTimingFunction restrictedMarkFunction(const String& markName)
-{
- ASSERT(isMainThread());
- return restrictedMarkNamesToNavigationTimingFunctionMap().get(markName);
-}
+static constexpr std::pair<ComparableASCIILiteral, NavigationTimingFunction> restrictedMarkMappings[] = {
+ { "connectEnd", &PerformanceTiming::connectEnd },
+ { "connectStart", &PerformanceTiming::connectStart },
+ { "domComplete", &PerformanceTiming::domComplete },
+ { "domContentLoadedEventEnd", &PerformanceTiming::domContentLoadedEventEnd },
+ { "domContentLoadedEventStart", &PerformanceTiming::domContentLoadedEventStart },
+ { "domInteractive", &PerformanceTiming::domInteractive },
+ { "domLoading", &PerformanceTiming::domLoading },
+ { "domainLookupEnd", &PerformanceTiming::domainLookupEnd },
+ { "domainLookupStart", &PerformanceTiming::domainLookupStart },
+ { "fetchStart", &PerformanceTiming::fetchStart },
+ { "loadEventEnd", &PerformanceTiming::loadEventEnd },
+ { "loadEventStart", &PerformanceTiming::loadEventStart },
+ { "navigationStart", &PerformanceTiming::navigationStart },
+ { "redirectEnd", &PerformanceTiming::redirectEnd },
+ { "redirectStart", &PerformanceTiming::redirectStart },
+ { "requestStart", &PerformanceTiming::requestStart },
+ { "responseEnd", &PerformanceTiming::responseEnd },
+ { "responseStart", &PerformanceTiming::responseStart },
+ { "secureConnectionStart", &PerformanceTiming::secureConnectionStart },
+ { "unloadEventEnd", &PerformanceTiming::unloadEventEnd },
+ { "unloadEventStart", &PerformanceTiming::unloadEventStart },
+};
+static constexpr SortedArrayMap restrictedMarkFunctions { restrictedMarkMappings };
-static bool isRestrictedMarkNameNonMainThread(const String& markName)
-{
- ASSERT(!isMainThread());
-
- bool isRestricted;
- callOnMainThreadAndWait([&isRestricted, markName = markName.isolatedCopy()] {
- isRestricted = restrictedMarkNamesToNavigationTimingFunctionMap().contains(markName);
- });
- return isRestricted;
-}
-
bool PerformanceUserTiming::isRestrictedMarkName(const String& markName)
{
- ASSERT(isMainThread());
- return restrictedMarkNamesToNavigationTimingFunctionMap().contains(markName);
+ return restrictedMarkFunctions.contains(markName);
}
PerformanceUserTiming::PerformanceUserTiming(Performance& performance)
@@ -136,11 +114,11 @@
ExceptionOr<double> PerformanceUserTiming::convertMarkToTimestamp(const String& mark) const
{
if (!isMainThread()) {
- if (isRestrictedMarkNameNonMainThread(mark))
+ if (restrictedMarkFunctions.contains(mark))
return Exception { TypeError };
} else {
- if (auto function = restrictedMarkFunction(mark)) {
- if (function == &PerformanceTiming::navigationStart)
+ if (auto function = restrictedMarkFunctions.tryGet(mark)) {
+ if (*function == &PerformanceTiming::navigationStart)
return 0.0;
// PerformanceTiming should always be non-null for the Document ScriptExecutionContext.
@@ -147,7 +125,7 @@
ASSERT(m_performance.timing());
auto timing = m_performance.timing();
auto startTime = timing->navigationStart();
- auto endTime = ((*timing).*(function))();
+ auto endTime = ((*timing).*(*function))();
if (!endTime)
return Exception { InvalidAccessError };
return endTime - startTime;
Modified: trunk/Source/WebCore/platform/cocoa/RemoteCommandListenerCocoa.mm (287231 => 287232)
--- trunk/Source/WebCore/platform/cocoa/RemoteCommandListenerCocoa.mm 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/platform/cocoa/RemoteCommandListenerCocoa.mm 2021-12-18 23:57:08 UTC (rev 287232)
@@ -55,9 +55,7 @@
{ PlatformMediaSession::PreviousTrackCommand, MRMediaRemoteCommandPreviousTrack },
};
static constexpr SortedArrayMap map { mappings };
- if (auto* value = map.tryGet(command))
- return *value;
- return std::nullopt;
+ return makeOptionalFromPointer(map.tryGet(command));
}
std::unique_ptr<RemoteCommandListenerCocoa> RemoteCommandListenerCocoa::create(RemoteCommandListenerClient& client)
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (287231 => 287232)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -39,6 +39,7 @@
#include <wtf/MathExtras.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/RobinHoodHashSet.h>
+#include <wtf/SortedArrayMap.h>
#include <wtf/text/AtomStringHash.h>
#include <wtf/text/StringBuilder.h>
@@ -373,43 +374,44 @@
return false;
#endif
- static NeverDestroyed map = MemoryCompactLookupOnlyRobinHoodHashSet<AtomString> {
- "American Typewriter"_s,
- "Arial Hebrew"_s,
- "Chalkboard"_s,
- "Cochin"_s,
- "Corsiva Hebrew"_s,
- "Courier"_s,
- "Euphemia UCAS"_s,
- "Geneva"_s,
- "Gill Sans"_s,
- "Hei"_s,
- "Helvetica"_s,
- "Hoefler Text"_s,
- "InaiMathi"_s,
- "Kai"_s,
- "Lucida Grande"_s,
- "Marker Felt"_s,
- "Monaco"_s,
- "Mshtakan"_s,
- "New Peninim MT"_s,
- "Osaka"_s,
- "Raanana"_s,
- "STHeiti"_s,
- "Symbol"_s,
- "Times"_s,
- "Apple Braille"_s,
- "Apple LiGothic"_s,
- "Apple LiSung"_s,
- "Apple Symbols"_s,
- "AppleGothic"_s,
- "AppleMyungjo"_s,
- "#GungSeo"_s,
- "#HeadLineA"_s,
- "#PCMyungjo"_s,
- "#PilGi"_s,
+ static constexpr ComparableASCIILiteral names[] = {
+ "#GungSeo",
+ "#HeadLineA",
+ "#PCMyungjo",
+ "#PilGi",
+ "American Typewriter",
+ "Apple Braille",
+ "Apple LiGothic",
+ "Apple LiSung",
+ "Apple Symbols",
+ "AppleGothic",
+ "AppleMyungjo",
+ "Arial Hebrew",
+ "Chalkboard",
+ "Cochin",
+ "Corsiva Hebrew",
+ "Courier",
+ "Euphemia UCAS",
+ "Geneva",
+ "Gill Sans",
+ "Hei",
+ "Helvetica",
+ "Hoefler Text",
+ "InaiMathi",
+ "Kai",
+ "Lucida Grande",
+ "Marker Felt",
+ "Monaco",
+ "Mshtakan",
+ "New Peninim MT",
+ "Osaka",
+ "Raanana",
+ "STHeiti",
+ "Symbol",
+ "Times",
};
- return !map.get().contains(family);
+ static constexpr SortedArraySet set { names };
+ return !set.contains(family);
}
bool FontCascade::fastAverageCharWidthIfAvailable(float& width) const
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp (287231 => 287232)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -21,6 +21,8 @@
#include "config.h"
#include "FontPlatformData.h"
+#include <wtf/SortedArrayMap.h>
+
namespace WebCore {
FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
@@ -32,13 +34,6 @@
{
}
-template<typename ValueType> static inline std::optional<ValueType> makeOptionalFromPointer(const ValueType* pointer)
-{
- if (!pointer)
- return std::nullopt;
- return *pointer;
-}
-
FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode, const CreationData* creationData)
: m_size(size)
, m_orientation(orientation)
Modified: trunk/Source/WebCore/platform/graphics/HEVCUtilities.cpp (287231 => 287232)
--- trunk/Source/WebCore/platform/graphics/HEVCUtilities.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/platform/graphics/HEVCUtilities.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -312,13 +312,6 @@
return parameters;
}
-template<typename ValueType> static inline std::optional<ValueType> makeOptionalFromPointer(const ValueType* pointer)
-{
- if (!pointer)
- return std::nullopt;
- return *pointer;
-}
-
static std::optional<DoViParameters::Codec> parseDoViCodecType(StringView string)
{
static constexpr std::pair<PackedASCIILowerCodes<uint32_t>, DoViParameters::Codec> typesArray[] = {
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm (287231 => 287232)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm 2021-12-18 23:57:08 UTC (rev 287232)
@@ -151,8 +151,8 @@
#if ENABLE(WEBM_FORMAT_READER)
if (SourceBufferParserWebM::isWebMFormatReaderAvailable()) {
- auto webmTypes = SourceBufferParserWebM::webmMIMETypes();
- cache.add(webmTypes.begin(), webmTypes.end());
+ auto types = SourceBufferParserWebM::supportedMIMETypes();
+ cache.add(types.begin(), types.end());
}
#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (287231 => 287232)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm 2021-12-18 23:57:08 UTC (rev 287232)
@@ -145,6 +145,7 @@
if (_parent)
_parent->sessionIdentifierChanged(session.contentProtectionSessionIdentifier);
}
+
- (void)contentKeySession:(AVContentKeySession *)session contentProtectionSessionIdentifierDidChangeForKeyGroup:(nullable AVContentKeyReportGroup *)reportGroup
{
// FIXME: Remove after rdar://57430747 is fixed
@@ -298,9 +299,8 @@
if (!--m_numberOfExpectedResponses)
m_callback(WTFMove(m_responses));
}
- void addErrorResponse(AVContentKeyRequest* request, NSError* error)
+ void addErrorResponse(AVContentKeyRequest* request, NSError*)
{
- UNUSED_PARAM(error);
m_responses.set(request, nullptr);
if (!--m_numberOfExpectedResponses)
m_callback(WTFMove(m_responses));
@@ -536,9 +536,8 @@
return false;
}
-void CDMInstanceFairPlayStreamingAVFObjC::sessionIdentifierChanged(NSData *sessionIdentifier)
+void CDMInstanceFairPlayStreamingAVFObjC::sessionIdentifierChanged(NSData *)
{
- UNUSED_PARAM(sessionIdentifier);
// No-op. If we are getting this callback, there are outstanding AVContentKeyRequestGroups which are managing their own
// session identifiers.
}
@@ -917,9 +916,8 @@
m_updateLicenseCallback = WTFMove(callback);
}
-void CDMInstanceSessionFairPlayStreamingAVFObjC::loadSession(LicenseType licenseType, const String& sessionId, const String& origin, LoadSessionCallback&& callback)
+void CDMInstanceSessionFairPlayStreamingAVFObjC::loadSession(LicenseType licenseType, const String& sessionId, const String&, LoadSessionCallback&& callback)
{
- UNUSED_PARAM(origin);
if (licenseType == LicenseType::PersistentUsageRecord) {
auto* storageURL = m_instance->storageURL();
if (!m_instance->persistentStateAllowed() || !storageURL) {
@@ -1213,8 +1211,7 @@
auto keyIDs = keyIDsForRequest(request.get());
RefPtr<FragmentedSharedBuffer> keyID = WTFMove(keyIDs.first());
auto contentIdentifier = keyID->makeContiguous()->createNSData();
- [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[keyID = WTFMove(keyID), aggregator] (NSData *contentKeyRequestData, NSError *error) mutable {
- UNUSED_PARAM(error);
+ [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[keyID = WTFMove(keyID), aggregator] (NSData *contentKeyRequestData, NSError *) mutable {
callOnMainThread([keyID = WTFMove(keyID), aggregator = WTFMove(aggregator), contentKeyRequestData = retainPtr(contentKeyRequestData)] () mutable {
aggregator->requestsData.append({ WTFMove(keyID), WTFMove(contentKeyRequestData) });
});
@@ -1276,15 +1273,12 @@
}
}
-void CDMInstanceSessionFairPlayStreamingAVFObjC::didProvidePersistableRequest(AVContentKeyRequest *request)
+void CDMInstanceSessionFairPlayStreamingAVFObjC::didProvidePersistableRequest(AVContentKeyRequest *)
{
- UNUSED_PARAM(request);
}
void CDMInstanceSessionFairPlayStreamingAVFObjC::didFailToProvideRequest(AVContentKeyRequest *request, NSError *error)
{
- UNUSED_PARAM(request);
-
// Rather than reject the update() promise when the CDM indicates that
// the key requires a higher level of security than it is currently able
// to provide, signal this state by "succeeding", but set the key status
@@ -1312,7 +1306,6 @@
void CDMInstanceSessionFairPlayStreamingAVFObjC::requestDidSucceed(AVContentKeyRequest *request)
{
- UNUSED_PARAM(request);
if (m_updateResponseCollector) {
m_updateResponseCollector->addSuccessfulResponse(request, nullptr);
return;
@@ -1371,10 +1364,8 @@
return false;
}
-bool CDMInstanceSessionFairPlayStreamingAVFObjC::shouldRetryRequestForReason(AVContentKeyRequest *request, NSString *reason)
+bool CDMInstanceSessionFairPlayStreamingAVFObjC::shouldRetryRequestForReason(AVContentKeyRequest *, NSString *)
{
- UNUSED_PARAM(request);
- UNUSED_PARAM(reason);
notImplemented();
return false;
}
@@ -1393,9 +1384,8 @@
m_client->sessionIdChanged(m_sessionId);
}
-void CDMInstanceSessionFairPlayStreamingAVFObjC::groupSessionIdentifierChanged(AVContentKeyReportGroup* group, NSData *sessionIdentifier)
+void CDMInstanceSessionFairPlayStreamingAVFObjC::groupSessionIdentifierChanged(AVContentKeyReportGroup*, NSData *sessionIdentifier)
{
- UNUSED_PARAM(group);
sessionIdentifierChanged(sessionIdentifier);
}
@@ -1452,9 +1442,8 @@
m_client->updateKeyStatuses(keyStatuses());
}
-void CDMInstanceSessionFairPlayStreamingAVFObjC::externalProtectionStatusDidChangeForContentKeyRequest(AVContentKeyRequest* request)
+void CDMInstanceSessionFairPlayStreamingAVFObjC::externalProtectionStatusDidChangeForContentKeyRequest(AVContentKeyRequest*)
{
- UNUSED_PARAM(request);
if (!m_client)
return;
@@ -1461,7 +1450,7 @@
updateProtectionStatusForDisplayID(m_client->displayID());
}
-std::optional<CDMKeyStatus> CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID(AVContentKeyRequest *request, std::optional<PlatformDisplayID> displayID) const
+std::optional<CDMKeyStatus> CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID(AVContentKeyRequest *request, std::optional<PlatformDisplayID>) const
{
#if HAVE(AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS)
if ([request respondsToSelector:@selector(externalContentProtectionStatus)]) {
@@ -1478,7 +1467,6 @@
// across all displays. Replace the below with explicit APIs to query the per-display HDCP status in the UIProcess
// and to query the HDCP level required by each AVContentKeyRequest, and do the comparison between the two in the
// WebProcess.
- UNUSED_PARAM(displayID);
if ([request respondsToSelector:@selector(willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:)]) {
// willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays will always return "YES" prior to
Modified: trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp (287231 => 287232)
--- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -41,7 +41,7 @@
const MemoryCompactLookupOnlyRobinHoodHashSet<String>& defaultSupportedImageTypes()
{
static NeverDestroyed defaultSupportedImageTypes = [] {
- HashSet<String> defaultSupportedImageTypes = {
+ static constexpr std::array defaultSupportedImageTypes = {
"com.compuserve.gif"_s,
"com.microsoft.bmp"_s,
"com.microsoft.cur"_s,
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp (287231 => 287232)
--- trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -553,19 +553,21 @@
webm::TrackEntry m_track;
};
-const HashSet<String, ASCIICaseInsensitiveHash>& SourceBufferParserWebM::webmMIMETypes()
+Span<const ASCIILiteral> SourceBufferParserWebM::supportedMIMETypes()
{
- static NeverDestroyed types = [] {
- HashSet<String, ASCIICaseInsensitiveHash> types;
+#if !(ENABLE(VP9) || ENABLE(VORBIS) || ENABLE(OPUS))
+ return { };
+#else
+ static constexpr std::array types {
#if ENABLE(VP9)
- types.add("video/webm");
+ "video/webm"_s,
#endif
#if ENABLE(VORBIS) || ENABLE(OPUS)
- types.add("audio/webm");
+ "audio/webm"_s,
#endif
- return types;
- }();
+ };
return types;
+#endif
}
static bool canLoadFormatReader()
@@ -806,7 +808,6 @@
Status SourceBufferParserWebM::OnElementBegin(const ElementMetadata& metadata, Action* action)
{
- UNUSED_PARAM(metadata);
ASSERT(action);
if (!action)
return Status(Status::kNotEnoughMemory);
@@ -879,7 +880,6 @@
Status SourceBufferParserWebM::OnElementEnd(const ElementMetadata& metadata)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
auto oldState = m_state;
@@ -919,9 +919,8 @@
return Status(Status::kOkCompleted);
}
-Status SourceBufferParserWebM::OnEbml(const ElementMetadata& metadata, const Ebml& ebml)
+Status SourceBufferParserWebM::OnEbml(const ElementMetadata&, const Ebml& ebml)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
if (ebml.doc_type.is_present() && ebml.doc_type.value().compare("webm"))
@@ -939,9 +938,8 @@
return Status(Status::kOkCompleted);
}
-Status SourceBufferParserWebM::OnSegmentBegin(const ElementMetadata& metadata, Action* action)
+Status SourceBufferParserWebM::OnSegmentBegin(const ElementMetadata&, Action* action)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
if (!m_initializationSegmentEncountered) {
@@ -957,9 +955,8 @@
return Status(Status::kOkCompleted);
}
-Status SourceBufferParserWebM::OnInfo(const ElementMetadata& metadata, const Info& info)
+Status SourceBufferParserWebM::OnInfo(const ElementMetadata&, const Info& info)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
if (!m_initializationSegmentEncountered || !m_initializationSegment) {
@@ -974,9 +971,8 @@
return Status(Status::kOkCompleted);
}
-Status SourceBufferParserWebM::OnClusterBegin(const ElementMetadata& metadata, const Cluster& cluster, Action* action)
+Status SourceBufferParserWebM::OnClusterBegin(const ElementMetadata&, const Cluster& cluster, Action* action)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
ASSERT(action);
@@ -991,9 +987,8 @@
return Status(Status::kOkCompleted);
}
-Status SourceBufferParserWebM::OnTrackEntry(const ElementMetadata& metadata, const TrackEntry& trackEntry)
+Status SourceBufferParserWebM::OnTrackEntry(const ElementMetadata&, const TrackEntry& trackEntry)
{
- UNUSED_PARAM(metadata);
if (!trackEntry.track_type.is_present() || !trackEntry.codec_id.is_present())
return Status(Status::kOkCompleted);
@@ -1002,12 +997,12 @@
ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER, trackType, ", codec ", codecId);
- if (trackType == TrackType::kVideo && !supportedVideoCodecs().contains(codecId)) {
+ if (trackType == TrackType::kVideo && !isSupportedVideoCodec(codecId)) {
ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "Encountered unsupported video codec ID ", codecId);
return Status(Status::Code(ErrorCode::UnsupportedVideoCodec));
}
- if (trackType == TrackType::kAudio && !supportedAudioCodecs().contains(codecId)) {
+ if (trackType == TrackType::kAudio && !isSupportedAudioCodec(codecId)) {
ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "Encountered unsupported audio codec ID ", codecId);
return Status(Status::Code(ErrorCode::UnsupportedAudioCodec));
}
@@ -1073,9 +1068,8 @@
return Status(Status::kOkCompleted);
}
-webm::Status SourceBufferParserWebM::OnBlockBegin(const ElementMetadata& metadata, const Block& block, Action* action)
+webm::Status SourceBufferParserWebM::OnBlockBegin(const ElementMetadata&, const Block& block, Action* action)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
ASSERT(action);
@@ -1089,10 +1083,8 @@
return Status(Status::kOkCompleted);
}
-webm::Status SourceBufferParserWebM::OnBlockEnd(const ElementMetadata& metadata, const Block& block)
+webm::Status SourceBufferParserWebM::OnBlockEnd(const ElementMetadata&, const Block&)
{
- UNUSED_PARAM(metadata);
- UNUSED_PARAM(block);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
m_currentBlock = std::nullopt;
@@ -1100,9 +1092,8 @@
return Status(Status::kOkCompleted);
}
-webm::Status SourceBufferParserWebM::OnSimpleBlockBegin(const ElementMetadata& metadata, const SimpleBlock& block, Action* action)
+webm::Status SourceBufferParserWebM::OnSimpleBlockBegin(const ElementMetadata&, const SimpleBlock& block, Action* action)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
ASSERT(action);
@@ -1116,21 +1107,17 @@
return Status(Status::kOkCompleted);
}
-webm::Status SourceBufferParserWebM::OnSimpleBlockEnd(const ElementMetadata& metadata, const SimpleBlock& block)
+webm::Status SourceBufferParserWebM::OnSimpleBlockEnd(const ElementMetadata&, const SimpleBlock&)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
- UNUSED_PARAM(block);
-
m_currentBlock = std::nullopt;
return Status(Status::kOkCompleted);
}
-webm::Status SourceBufferParserWebM::OnBlockGroupBegin(const webm::ElementMetadata& metadata, webm::Action* action)
+webm::Status SourceBufferParserWebM::OnBlockGroupBegin(const webm::ElementMetadata&, webm::Action* action)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
ASSERT(action);
@@ -1141,9 +1128,8 @@
return Status(Status::kOkCompleted);
}
-webm::Status SourceBufferParserWebM::OnBlockGroupEnd(const webm::ElementMetadata& metadata, const webm::BlockGroup& blockGroup)
+webm::Status SourceBufferParserWebM::OnBlockGroupEnd(const webm::ElementMetadata&, const webm::BlockGroup& blockGroup)
{
- UNUSED_PARAM(metadata);
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER);
if (blockGroup.block.is_present() && blockGroup.discard_padding.is_present()) {
auto trackNumber = blockGroup.block.value().track_number;
@@ -1527,16 +1513,14 @@
m_minimumAudioSampleDuration = duration;
}
-const MemoryCompactLookupOnlyRobinHoodHashSet<String>& SourceBufferParserWebM::supportedVideoCodecs()
+bool SourceBufferParserWebM::isSupportedVideoCodec(StringView name)
{
- static NeverDestroyed codecs = MemoryCompactLookupOnlyRobinHoodHashSet<String> { "V_VP8"_s, "V_VP9"_s };
- return codecs;
+ return name == "V_VP8" || name == "V_VP9";
}
-const MemoryCompactLookupOnlyRobinHoodHashSet<String>& SourceBufferParserWebM::supportedAudioCodecs()
+bool SourceBufferParserWebM::isSupportedAudioCodec(StringView name)
{
- static NeverDestroyed codecs = MemoryCompactLookupOnlyRobinHoodHashSet<String> { "A_VORBIS"_s, "A_OPUS"_s };
- return codecs;
+ return name == "A_VORBIS" || name == "A_OPUS";
}
}
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h (287231 => 287232)
--- trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h 2021-12-18 23:57:08 UTC (rev 287232)
@@ -35,14 +35,8 @@
#include <webm/callback.h>
#include <webm/status.h>
#include <webm/vp9_header_parser.h>
-#include <wtf/Box.h>
-#include <wtf/Function.h>
-#include <wtf/MediaTime.h>
-#include <wtf/RobinHoodHashSet.h>
#include <wtf/UniqueRef.h>
#include <wtf/Vector.h>
-#include <wtf/text/AtomString.h>
-#include <wtf/text/WTFString.h>
typedef const struct opaqueCMFormatDescription* CMFormatDescriptionRef;
typedef struct OpaqueCMBlockBuffer *CMBlockBufferRef;
@@ -53,8 +47,6 @@
namespace WebCore {
-class MediaSampleAVFObjC;
-
class SourceBufferParserWebM : public SourceBufferParser, private webm::Callback {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -62,7 +54,7 @@
static bool isWebMFormatReaderAvailable();
static MediaPlayerEnums::SupportsType isContentTypeSupported(const ContentType&);
- static const HashSet<String, ASCIICaseInsensitiveHash>& webmMIMETypes();
+ static Span<const ASCIILiteral> supportedMIMETypes();
WEBCORE_EXPORT static RefPtr<SourceBufferParserWebM> create(const ContentType&);
SourceBufferParserWebM();
@@ -256,8 +248,8 @@
TrackData* trackDataForTrackNumber(uint64_t);
- static const MemoryCompactLookupOnlyRobinHoodHashSet<String>& supportedVideoCodecs();
- static const MemoryCompactLookupOnlyRobinHoodHashSet<String>& supportedAudioCodecs();
+ static bool isSupportedVideoCodec(StringView);
+ static bool isSupportedAudioCodec(StringView);
// webm::Callback
webm::Status OnElementBegin(const webm::ElementMetadata&, webm::Action*) final;
Modified: trunk/Source/WebCore/rendering/svg/SVGResources.cpp (287231 => 287232)
--- trunk/Source/WebCore/rendering/svg/SVGResources.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebCore/rendering/svg/SVGResources.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -48,100 +48,105 @@
{
}
+static MemoryCompactLookupOnlyRobinHoodHashSet<AtomString> tagSet(Span<decltype(SVGNames::aTag)* const> tags)
+{
+ MemoryCompactLookupOnlyRobinHoodHashSet<AtomString> set;
+ set.reserveInitialCapacity(tags.size());
+ for (auto& tag : tags)
+ set.add(tag->get().localName());
+ return set;
+}
+
static const MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>& clipperFilterMaskerTags()
{
- static NeverDestroyed<MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>> s_tagList;
- if (s_tagList.get().isEmpty()) {
+ static constexpr std::array tags {
// "container elements": http://www.w3.org/TR/SVG11/intro.html#TermContainerElement
// "graphics elements" : http://www.w3.org/TR/SVG11/intro.html#TermGraphicsElement
- s_tagList.get().add(SVGNames::aTag->localName());
- s_tagList.get().add(SVGNames::circleTag->localName());
- s_tagList.get().add(SVGNames::ellipseTag->localName());
- s_tagList.get().add(SVGNames::glyphTag->localName());
- s_tagList.get().add(SVGNames::gTag->localName());
- s_tagList.get().add(SVGNames::imageTag->localName());
- s_tagList.get().add(SVGNames::lineTag->localName());
- s_tagList.get().add(SVGNames::markerTag->localName());
- s_tagList.get().add(SVGNames::maskTag->localName());
- s_tagList.get().add(SVGNames::missing_glyphTag->localName());
- s_tagList.get().add(SVGNames::pathTag->localName());
- s_tagList.get().add(SVGNames::polygonTag->localName());
- s_tagList.get().add(SVGNames::polylineTag->localName());
- s_tagList.get().add(SVGNames::rectTag->localName());
- s_tagList.get().add(SVGNames::svgTag->localName());
- s_tagList.get().add(SVGNames::textTag->localName());
- s_tagList.get().add(SVGNames::useTag->localName());
+ &SVGNames::aTag,
+ &SVGNames::circleTag,
+ &SVGNames::ellipseTag,
+ &SVGNames::glyphTag,
+ &SVGNames::gTag,
+ &SVGNames::imageTag,
+ &SVGNames::lineTag,
+ &SVGNames::markerTag,
+ &SVGNames::maskTag,
+ &SVGNames::missing_glyphTag,
+ &SVGNames::pathTag,
+ &SVGNames::polygonTag,
+ &SVGNames::polylineTag,
+ &SVGNames::rectTag,
+ &SVGNames::svgTag,
+ &SVGNames::textTag,
+ &SVGNames::useTag,
// Not listed in the definitions is the clipPath element, the SVG spec says though:
// The "clipPath" element or any of its children can specify property "clip-path".
// So we have to add clipPathTag here, otherwhise clip-path on clipPath will fail.
// (Already mailed SVG WG, waiting for a solution)
- s_tagList.get().add(SVGNames::clipPathTag->localName());
+ &SVGNames::clipPathTag,
// Not listed in the definitions are the text content elements, though filter/clipper/masker on tspan/text/.. is allowed.
// (Already mailed SVG WG, waiting for a solution)
- s_tagList.get().add(SVGNames::altGlyphTag->localName());
- s_tagList.get().add(SVGNames::textPathTag->localName());
- s_tagList.get().add(SVGNames::trefTag->localName());
- s_tagList.get().add(SVGNames::tspanTag->localName());
+ &SVGNames::altGlyphTag,
+ &SVGNames::textPathTag,
+ &SVGNames::trefTag,
+ &SVGNames::tspanTag,
// Not listed in the definitions is the foreignObject element, but clip-path
// is a supported attribute.
- s_tagList.get().add(SVGNames::foreignObjectTag->localName());
+ &SVGNames::foreignObjectTag,
// Elements that we ignore, as it doesn't make any sense.
// defs, pattern, switch (FIXME: Mail SVG WG about these)
// symbol (is converted to a svg element, when referenced by use, we can safely ignore it.)
- }
-
- return s_tagList;
+ };
+ static NeverDestroyed set = tagSet(tags);
+ return set;
}
static const MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>& markerTags()
{
- static NeverDestroyed<MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>> s_tagList;
- if (s_tagList.get().isEmpty()) {
- s_tagList.get().add(SVGNames::lineTag->localName());
- s_tagList.get().add(SVGNames::pathTag->localName());
- s_tagList.get().add(SVGNames::polygonTag->localName());
- s_tagList.get().add(SVGNames::polylineTag->localName());
- }
-
- return s_tagList;
+ static constexpr std::array tags {
+ &SVGNames::lineTag,
+ &SVGNames::pathTag,
+ &SVGNames::polygonTag,
+ &SVGNames::polylineTag,
+ };
+ static NeverDestroyed set = tagSet(tags);
+ return set;
}
static const MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>& fillAndStrokeTags()
{
- static NeverDestroyed<MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>> s_tagList;
- if (s_tagList.get().isEmpty()) {
- s_tagList.get().add(SVGNames::altGlyphTag->localName());
- s_tagList.get().add(SVGNames::circleTag->localName());
- s_tagList.get().add(SVGNames::ellipseTag->localName());
- s_tagList.get().add(SVGNames::lineTag->localName());
- s_tagList.get().add(SVGNames::pathTag->localName());
- s_tagList.get().add(SVGNames::polygonTag->localName());
- s_tagList.get().add(SVGNames::polylineTag->localName());
- s_tagList.get().add(SVGNames::rectTag->localName());
- s_tagList.get().add(SVGNames::textTag->localName());
- s_tagList.get().add(SVGNames::textPathTag->localName());
- s_tagList.get().add(SVGNames::trefTag->localName());
- s_tagList.get().add(SVGNames::tspanTag->localName());
- }
-
- return s_tagList;
+ static constexpr std::array tags {
+ &SVGNames::altGlyphTag,
+ &SVGNames::circleTag,
+ &SVGNames::ellipseTag,
+ &SVGNames::lineTag,
+ &SVGNames::pathTag,
+ &SVGNames::polygonTag,
+ &SVGNames::polylineTag,
+ &SVGNames::rectTag,
+ &SVGNames::textTag,
+ &SVGNames::textPathTag,
+ &SVGNames::trefTag,
+ &SVGNames::tspanTag,
+ };
+ static NeverDestroyed set = tagSet(tags);
+ return set;
}
static const MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>& chainableResourceTags()
{
- static NeverDestroyed<MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>> s_tagList;
- if (s_tagList.get().isEmpty()) {
- s_tagList.get().add(SVGNames::linearGradientTag->localName());
- s_tagList.get().add(SVGNames::filterTag->localName());
- s_tagList.get().add(SVGNames::patternTag->localName());
- s_tagList.get().add(SVGNames::radialGradientTag->localName());
- }
-
- return s_tagList;
+ static constexpr std::array tags {
+ &SVGNames::linearGradientTag,
+ &SVGNames::filterTag,
+ &SVGNames::patternTag,
+ &SVGNames::radialGradientTag,
+ };
+ static NeverDestroyed set = tagSet(tags);
+ return set;
}
static inline String targetReferenceFromResource(SVGElement& element)
Modified: trunk/Source/WebKit/ChangeLog (287231 => 287232)
--- trunk/Source/WebKit/ChangeLog 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebKit/ChangeLog 2021-12-18 23:57:08 UTC (rev 287232)
@@ -1,3 +1,26 @@
+2021-12-18 Darin Adler <[email protected]>
+
+ Hash tables, read/write, and heap memory are used unnecessarily, which may hurt performance
+ https://bugs.webkit.org/show_bug.cgi?id=234438
+
+ Reviewed by Anders Carlsson.
+
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+ (WebKit::ResourceLoadStatisticsDatabaseStore::sortedTables): Simplify unnecessarily complicated
+ _expression_ to initialize the Span.
+
+ * Shared/Cocoa/DefaultWebBrowserChecks.h: Return a Span instead of an optional Vector.
+ * Shared/Cocoa/DefaultWebBrowserChecks.mm:
+ (WebKit::appBoundDomainsForTesting): Renamed from getAppBoundDomainsTesting to fit WebKit
+ coding style a bit better, and be a little more grammatical. Removed an un-needed HashMap
+ that had only a single entry, used a NeverDestroyed std::array rather than a Vector so we
+ don't use any heap or read/write memory.
+
+ * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+ (WebKit::WebsiteDataStore::addTestDomains const): Rewrite to use the function above.
+ Fewer special cases needed since we are just using an empty Span, which efficiently
+ does nothing, so no need to have a distinct null value.
+
2021-12-18 Chris Dumez <[email protected]>
Move CacheStorage engines from NetworkProcess to NetworkSession
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (287231 => 287232)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2021-12-18 23:57:08 UTC (rev 287232)
@@ -288,7 +288,7 @@
"OperatingDates"_s
};
- return { sortedTables.data(), sortedTables.size() };
+ return sortedTables;
}
template <typename ContainerType>
Modified: trunk/Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.h (287231 => 287232)
--- trunk/Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.h 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.h 2021-12-18 23:57:08 UTC (rev 287232)
@@ -38,7 +38,7 @@
bool hasRequestedCrossWebsiteTrackingPermission();
bool hasProhibitedUsageStrings();
-std::optional<Vector<WebCore::RegistrableDomain>> getAppBoundDomainsTesting(const String&);
+Span<const WebCore::RegistrableDomain> appBoundDomainsForTesting(const String&);
bool isRunningTest(const String& bundleID);
void determineITPState();
bool doesAppHaveITPEnabled();
Modified: trunk/Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.mm (287231 => 287232)
--- trunk/Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.mm 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.mm 2021-12-18 23:57:08 UTC (rev 287232)
@@ -35,7 +35,6 @@
#import <WebCore/VersionChecks.h>
#import <wtf/HashMap.h>
#import <wtf/NeverDestroyed.h>
-#import <wtf/RobinHoodHashMap.h>
#import <wtf/RunLoop.h>
#import <wtf/WorkQueue.h>
#import <wtf/cocoa/Entitlements.h>
@@ -50,20 +49,15 @@
return bundleID == "com.apple.WebKit.TestWebKitAPI"_s || bundleID == "com.apple.WebKit.WebKitTestRunner"_s || bundleID == "org.webkit.WebKitTestRunnerApp"_s;
}
-std::optional<Vector<WebCore::RegistrableDomain>> getAppBoundDomainsTesting(const String& bundleID)
+Span<const WebCore::RegistrableDomain> appBoundDomainsForTesting(const String& bundleID)
{
- if (bundleID.isNull())
- return std::nullopt;
-
- static NeverDestroyed appBoundDomainList = MemoryCompactLookupOnlyRobinHoodHashMap<String, Vector<WebCore::RegistrableDomain>> {
- {"inAppBrowserPrivacyTestIdentifier"_s, Vector<WebCore::RegistrableDomain> { WebCore::RegistrableDomain::uncheckedCreateFromRegistrableDomainString("127.0.0.1") }},
- };
-
- auto appBoundDomainIter = appBoundDomainList->find(bundleID);
- if (appBoundDomainIter != appBoundDomainList->end())
- return appBoundDomainIter->value;
-
- return std::nullopt;
+ if (bundleID == "inAppBrowserPrivacyTestIdentifier") {
+ static NeverDestroyed domains = std::array {
+ WebCore::RegistrableDomain::uncheckedCreateFromRegistrableDomainString("127.0.0.1"_s),
+ };
+ return domains.get();
+ }
+ return { };
}
#if ASSERT_ENABLED
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (287231 => 287232)
--- trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2021-12-18 22:50:04 UTC (rev 287231)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2021-12-18 23:57:08 UTC (rev 287232)
@@ -519,12 +519,8 @@
void WebsiteDataStore::addTestDomains() const
{
if (appBoundDomains().isEmpty()) {
- auto bundleID = WebCore::applicationBundleIdentifier();
- auto appBoundDomainsTesting = getAppBoundDomainsTesting(bundleID);
- if (appBoundDomainsTesting) {
- for (auto& domain : *appBoundDomainsTesting)
- appBoundDomains().add(domain);
- }
+ for (auto& domain : appBoundDomainsForTesting(WebCore::applicationBundleIdentifier()))
+ appBoundDomains().add(domain);
}
}