WebKit Bugzilla
Attachment 343437 Details for
Bug 186969
: Remove static initializers more
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186969-20180624011611.patch (text/plain), 31.98 KB, created by
Yusuke Suzuki
on 2018-06-23 09:16:12 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-06-23 09:16:12 PDT
Size:
31.98 KB
patch
obsolete
>Subversion Revision: 233123 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 80a4223ffbff6997c5743d34794274ef4f19c5f7..e9f2b18eee0004c33b042e906ef9edef6b92c4ce 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,41 @@ >+2018-06-23 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ Remove static initializers more >+ https://bugs.webkit.org/show_bug.cgi?id=186969 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch removes static initializers more. They typically exists in GTK port. >+ >+ No behavior change. >+ >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * page/ResourceUsageData.cpp: Removed. >+ * page/ResourceUsageData.h: >+ Remove ResourceUsageData constructors since default constructors are enough. >+ >+ (WebCore::MemoryCategoryInfo::MemoryCategoryInfo): >+ * platform/gtk/PasteboardHelper.cpp: >+ (WebCore::markupPrefix): >+ (WebCore::removeMarkupPrefix): >+ (WebCore::PasteboardHelper::fillSelectionData): >+ Use NeverDestroyed<> and static functions. >+ >+ * platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp: >+ (WebCore::defaultVolumeCapability): >+ (WebCore::GStreamerAudioCaptureSource::capabilities const): >+ CapabilityValueOrRange's constructor is not constexpr. >+ >+ * platform/network/soup/SoupNetworkSession.cpp: >+ (WebCore::initialAcceptLanguages): >+ (WebCore::proxySettings): >+ (WebCore::SoupNetworkSession::SoupNetworkSession): >+ (WebCore::SoupNetworkSession::setupProxy): >+ (WebCore::SoupNetworkSession::setProxySettings): >+ (WebCore::SoupNetworkSession::setInitialAcceptLanguages): >+ Use NeverDestroyed<> and static functions. >+ > 2018-06-23 Yusuke Suzuki <utatane.tea@gmail.com> > > [WTF] Add user-defined literal for ASCIILiteral >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 958df37b77ad6e6bf30fda265bdee9f034d396ab..e30d517a6831d00002137964ca2876cf79c034ee 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -1408,7 +1408,6 @@ page/PointerLockController.cpp > page/PrintContext.cpp > page/RemoteDOMWindow.cpp > page/RemoteFrame.cpp >-page/ResourceUsageData.cpp > page/ResourceUsageOverlay.cpp > page/ResourceUsageThread.cpp > page/RuntimeEnabledFeatures.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index ea6827d749306ae24d3c2e19523011e7c7f49221..bf54a0d9d457f905e56c0841e40f0516bab0e1bb 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -11137,7 +11137,6 @@ > A5071E831C56D079009951BE /* ResourceUsageThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageThread.cpp; sourceTree = "<group>"; }; > A5071E841C56D079009951BE /* ResourceUsageThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceUsageThread.h; sourceTree = "<group>"; }; > A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceUsageThreadCocoa.mm; sourceTree = "<group>"; }; >- A5071E8A1C56FAFA009951BE /* ResourceUsageData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageData.cpp; sourceTree = "<group>"; }; > A516E8B4136E04DB0076C3C0 /* LocalizedDateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedDateCache.h; sourceTree = "<group>"; }; > A516E8B5136E04DB0076C3C0 /* LocalizedDateCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedDateCache.mm; sourceTree = "<group>"; }; > A518225417E2A0D400A9BA1D /* InspectorOverlayPage.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = InspectorOverlayPage.css; sourceTree = "<group>"; }; >@@ -19386,7 +19385,6 @@ > 46BCBBC3208500A700710638 /* RemoteDOMWindow.idl */, > 46B9518C207D632900A7D2DD /* RemoteFrame.cpp */, > 46B95192207D632E00A7D2DD /* RemoteFrame.h */, >- A5071E8A1C56FAFA009951BE /* ResourceUsageData.cpp */, > A5071E821C56D079009951BE /* ResourceUsageData.h */, > ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */, > ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */, >diff --git a/Source/WebCore/page/ResourceUsageData.cpp b/Source/WebCore/page/ResourceUsageData.cpp >deleted file mode 100644 >index 7a170026b8ecc4a61d1280a03a0a3c341854398d..0000000000000000000000000000000000000000 >--- a/Source/WebCore/page/ResourceUsageData.cpp >+++ /dev/null >@@ -1,61 +0,0 @@ >-/* >- * Copyright (C) 2016-2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * 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 "ResourceUsageData.h" >- >-#if ENABLE(RESOURCE_USAGE) >- >-namespace WebCore { >- >-ResourceUsageData::ResourceUsageData() >-{ >- // VM tag categories. >- categories[MemoryCategory::JSJIT] = MemoryCategoryInfo(MemoryCategory::JSJIT); >- categories[MemoryCategory::WebAssembly] = MemoryCategoryInfo(MemoryCategory::WebAssembly); >- categories[MemoryCategory::Images] = MemoryCategoryInfo(MemoryCategory::Images); >- categories[MemoryCategory::Layers] = MemoryCategoryInfo(MemoryCategory::Layers); >- categories[MemoryCategory::LibcMalloc] = MemoryCategoryInfo(MemoryCategory::LibcMalloc); >- categories[MemoryCategory::bmalloc] = MemoryCategoryInfo(MemoryCategory::bmalloc); >- categories[MemoryCategory::Other] = MemoryCategoryInfo(MemoryCategory::Other); >- >- // Sub categories (e.g breakdown of bmalloc tag.) >- categories[MemoryCategory::GCHeap] = MemoryCategoryInfo(MemoryCategory::GCHeap, true); >- categories[MemoryCategory::GCOwned] = MemoryCategoryInfo(MemoryCategory::GCOwned, true); >-} >- >-ResourceUsageData::ResourceUsageData(const ResourceUsageData& other) >- : cpu(other.cpu) >- , totalDirtySize(other.totalDirtySize) >- , totalExternalSize(other.totalExternalSize) >- , timeOfNextEdenCollection(other.timeOfNextEdenCollection) >- , timeOfNextFullCollection(other.timeOfNextFullCollection) >-{ >- std::copy(other.categories.begin(), other.categories.end(), categories.begin()); >-} >- >-} >- >-#endif // ENABLE(RESOURCE_USAGE) >diff --git a/Source/WebCore/page/ResourceUsageData.h b/Source/WebCore/page/ResourceUsageData.h >index c881538bb55e34b94b86816c48f58be83e084a3d..219376bf9ad20ee3b7501e93f53e2adebe70a0d5 100644 >--- a/Source/WebCore/page/ResourceUsageData.h >+++ b/Source/WebCore/page/ResourceUsageData.h >@@ -32,22 +32,31 @@ > > namespace WebCore { > >+// v(name, id, subcategory) >+#define WEBCORE_EACH_MEMORY_CATEGORIES(v) \ >+ v(bmalloc, 0, false) \ >+ v(LibcMalloc, 1, false) \ >+ v(JSJIT, 2, false) \ >+ v(WebAssembly, 3, false) \ >+ v(Images, 4, false) \ >+ v(GCHeap, 5, true) \ >+ v(GCOwned, 6, true) \ >+ v(Other, 7, false) \ >+ v(Layers, 8, false) \ >+ > namespace MemoryCategory { >-static const unsigned bmalloc = 0; >-static const unsigned LibcMalloc = 1; >-static const unsigned JSJIT = 2; >-static const unsigned WebAssembly = 3; >-static const unsigned Images = 4; >-static const unsigned GCHeap = 5; >-static const unsigned GCOwned = 6; >-static const unsigned Other = 7; >-static const unsigned Layers = 8; >-static const unsigned NumberOfCategories = 9; >+#define WEBCORE_DEFINE_MEMORY_CATEGORY(name, id, subcategory) static constexpr unsigned name = id; >+WEBCORE_EACH_MEMORY_CATEGORIES(WEBCORE_DEFINE_MEMORY_CATEGORY) >+#undef WEBCORE_DEFINE_MEMORY_CATEGORY >+ >+#define WEBCORE_DEFINE_MEMORY_CATEGORY(name, id, subcategory) + 1 >+static constexpr unsigned NumberOfCategories = 0 WEBCORE_EACH_MEMORY_CATEGORIES(WEBCORE_DEFINE_MEMORY_CATEGORY); >+#undef WEBCORE_DEFINE_MEMORY_CATEGORY > } > > struct MemoryCategoryInfo { >- MemoryCategoryInfo() { } // Needed for std::array. >- MemoryCategoryInfo(unsigned category, bool subcategory = false) >+ constexpr MemoryCategoryInfo() = default; // Needed for std::array. >+ constexpr MemoryCategoryInfo(unsigned category, bool subcategory = false) > : isSubcategory(subcategory) > , type(category) > { >@@ -63,13 +72,16 @@ struct MemoryCategoryInfo { > }; > > struct ResourceUsageData { >- ResourceUsageData(); >- ResourceUsageData(const ResourceUsageData& data); >+ constexpr ResourceUsageData() = default; > > float cpu { 0 }; > size_t totalDirtySize { 0 }; > size_t totalExternalSize { 0 }; >- std::array<MemoryCategoryInfo, MemoryCategory::NumberOfCategories> categories; >+ std::array<MemoryCategoryInfo, MemoryCategory::NumberOfCategories> categories { >+#define WEBCORE_DEFINE_MEMORY_CATEGORY(name, id, subcategory) MemoryCategoryInfo(MemoryCategory::name, subcategory), >+WEBCORE_EACH_MEMORY_CATEGORIES(WEBCORE_DEFINE_MEMORY_CATEGORY) >+#undef WEBCORE_DEFINE_MEMORY_CATEGORY >+ }; > MonotonicTime timeOfNextEdenCollection { MonotonicTime::nan() }; > MonotonicTime timeOfNextFullCollection { MonotonicTime::nan() }; > }; >diff --git a/Source/WebCore/platform/gtk/PasteboardHelper.cpp b/Source/WebCore/platform/gtk/PasteboardHelper.cpp >index c2686fd4eabe0f7b7a648ff65da3bcee0536ea57..1cdcd51b4fdfe554628d581231724723954698b2 100644 >--- a/Source/WebCore/platform/gtk/PasteboardHelper.cpp >+++ b/Source/WebCore/platform/gtk/PasteboardHelper.cpp >@@ -40,14 +40,18 @@ static GdkAtom uriListAtom; > static GdkAtom smartPasteAtom; > static GdkAtom unknownAtom; > >-static const String gMarkupPrefix = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">"_s; >+static const String& markupPrefix() >+{ >+ static NeverDestroyed<const String> prefix(MAKE_STATIC_STRING_IMPL("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">")); >+ return prefix.get(); >+} > > static void removeMarkupPrefix(String& markup) > { > // The markup prefix is not harmful, but we remove it from the string anyway, so that > // we can have consistent results with other ports during the layout tests. >- if (markup.startsWith(gMarkupPrefix)) >- markup.remove(0, gMarkupPrefix.length()); >+ if (markup.startsWith(markupPrefix())) >+ markup.remove(0, markupPrefix().length()); > } > > PasteboardHelper& PasteboardHelper::singleton() >@@ -163,7 +167,7 @@ void PasteboardHelper::fillSelectionData(const SelectionData& selection, unsigne > else if (info == TargetTypeMarkup) { > // Some Linux applications refuse to accept pasted markup unless it is > // prefixed by a content-type meta tag. >- CString markup = String(gMarkupPrefix + selection.markup()).utf8(); >+ CString markup = makeString(markupPrefix(), selection.markup()).utf8(); > gtk_selection_data_set(selectionData, markupAtom, 8, reinterpret_cast<const guchar*>(markup.data()), markup.length()); > > } else if (info == TargetTypeURIList) { >diff --git a/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp b/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp >index 9c5aeafffcf12a2fe82b1835927f0e70c6b6b88b..0d57b23f45282fbb27aba97bb8994eea0530df8b 100644 >--- a/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp >+++ b/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp >@@ -34,7 +34,10 @@ > > namespace WebCore { > >-const static CapabilityValueOrRange defaultVolumeCapability = CapabilityValueOrRange(0.0, 1.0); >+static CapabilityValueOrRange defaultVolumeCapability() >+{ >+ return CapabilityValueOrRange(0.0, 1.0); >+} > const static RealtimeMediaSourceCapabilities::EchoCancellation defaultEchoCancellationCapability = RealtimeMediaSourceCapabilities::EchoCancellation::ReadWrite; > > GST_DEBUG_CATEGORY(webkit_audio_capture_source_debug); >@@ -162,7 +165,7 @@ const RealtimeMediaSourceCapabilities& GStreamerAudioCaptureSource::capabilities > RealtimeMediaSourceCapabilities capabilities(settings().supportedConstraints()); > capabilities.setDeviceId(id()); > capabilities.setEchoCancellation(defaultEchoCancellationCapability); >- capabilities.setVolume(defaultVolumeCapability); >+ capabilities.setVolume(defaultVolumeCapability()); > capabilities.setSampleRate(CapabilityValueOrRange(minSampleRate, maxSampleRate)); > m_capabilities = WTFMove(capabilities); > >diff --git a/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp b/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp >index 2c29a51f035694bae7430d47751811a734b8a406..adcd3e7131088da51de7b2a0ef580e29c9938133 100644 >--- a/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp >+++ b/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp >@@ -45,8 +45,16 @@ > namespace WebCore { > > static bool gIgnoreTLSErrors; >-static CString gInitialAcceptLanguages; >-static SoupNetworkProxySettings gProxySettings; >+static CString& initialAcceptLanguages() >+{ >+ static NeverDestroyed<CString> storage; >+ return storage.get(); >+} >+static SoupNetworkProxySettings proxySettings() >+{ >+ static NeverDestroyed<SoupNetworkProxySettings> settings; >+ return settings.get(); >+} > static GType gCustomProtocolRequestType; > > #if !LOG_DISABLED >@@ -124,8 +132,8 @@ SoupNetworkSession::SoupNetworkSession(PAL::SessionID sessionID, SoupCookieJar* > > setupCustomProtocols(); > >- if (!gInitialAcceptLanguages.isNull()) >- setAcceptLanguages(gInitialAcceptLanguages); >+ if (!initialAcceptLanguages().isNull()) >+ setAcceptLanguages(initialAcceptLanguages()); > > #if SOUP_CHECK_VERSION(2, 53, 92) > if (soup_auth_negotiate_supported() && !sessionID.isEphemeral()) { >@@ -137,7 +145,7 @@ SoupNetworkSession::SoupNetworkSession(PAL::SessionID sessionID, SoupCookieJar* > UNUSED_PARAM(sessionID); > #endif > >- if (gProxySettings.mode != SoupNetworkProxySettings::Mode::Default) >+ if (proxySettings().mode != SoupNetworkProxySettings::Mode::Default) > setupProxy(); > setupLogger(); > } >@@ -203,7 +211,7 @@ void SoupNetworkSession::clearOldSoupCache(const String& cacheDirectory) > void SoupNetworkSession::setupProxy() > { > GRefPtr<GProxyResolver> resolver; >- switch (gProxySettings.mode) { >+ switch (proxySettings().mode) { > case SoupNetworkProxySettings::Mode::Default: { > GRefPtr<GProxyResolver> currentResolver; > g_object_get(m_soupSession.get(), SOUP_SESSION_PROXY_RESOLVER, ¤tResolver.outPtr(), nullptr); >@@ -218,11 +226,11 @@ void SoupNetworkSession::setupProxy() > break; > case SoupNetworkProxySettings::Mode::Custom: > resolver = adoptGRef(g_simple_proxy_resolver_new(nullptr, nullptr)); >- if (!gProxySettings.defaultProxyURL.isNull()) >- g_simple_proxy_resolver_set_default_proxy(G_SIMPLE_PROXY_RESOLVER(resolver.get()), gProxySettings.defaultProxyURL.data()); >- if (gProxySettings.ignoreHosts) >- g_simple_proxy_resolver_set_ignore_hosts(G_SIMPLE_PROXY_RESOLVER(resolver.get()), gProxySettings.ignoreHosts.get()); >- for (const auto& iter : gProxySettings.proxyMap) >+ if (!proxySettings().defaultProxyURL.isNull()) >+ g_simple_proxy_resolver_set_default_proxy(G_SIMPLE_PROXY_RESOLVER(resolver.get()), proxySettings().defaultProxyURL.data()); >+ if (proxySettings().ignoreHosts) >+ g_simple_proxy_resolver_set_ignore_hosts(G_SIMPLE_PROXY_RESOLVER(resolver.get()), proxySettings().ignoreHosts.get()); >+ for (const auto& iter : proxySettings().proxyMap) > g_simple_proxy_resolver_set_uri_proxy(G_SIMPLE_PROXY_RESOLVER(resolver.get()), iter.key.data(), iter.value.data()); > break; > } >@@ -233,12 +241,12 @@ void SoupNetworkSession::setupProxy() > > void SoupNetworkSession::setProxySettings(const SoupNetworkProxySettings& settings) > { >- gProxySettings = settings; >+ proxySettings() = settings; > } > > void SoupNetworkSession::setInitialAcceptLanguages(const CString& languages) > { >- gInitialAcceptLanguages = languages; >+ initialAcceptLanguages() = languages; > } > > void SoupNetworkSession::setAcceptLanguages(const CString& languages) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 086eb7ee968b84c42363b630ff144a4848be3505..0f6e227866337762bf98f66881756f9feb15c89b 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,24 @@ >+2018-06-23 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ Remove static initializers more >+ https://bugs.webkit.org/show_bug.cgi?id=186969 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp: >+ (WTR::assignedUrlsCache): >+ (WTR::dumpResourceURL): >+ (WTR::InjectedBundlePage::resetAfterTest): >+ (WTR::InjectedBundlePage::didInitiateLoadForResource): >+ * WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp: >+ (WTR::AccessibilityNotificationHandler::setNotificationFunctionCallback): >+ (WTR::AccessibilityNotificationHandler::removeAccessibilityNotificationHandler): >+ (WTR::AccessibilityNotificationHandler::connectAccessibilityCallbacks): >+ (WTR::AccessibilityNotificationHandler::disconnectAccessibilityCallbacks): >+ * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp: >+ (WTR::AccessibilityUIElement::stringAttributeValue): >+ Use NeverDestroyed<> and static functions. >+ > 2018-06-23 Yusuke Suzuki <utatane.tea@gmail.com> > > [WTF] Add user-defined literal for ASCIILiteral >diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp >index a8e0e1197c3815bc083b69c8bcaadf4cb8d75a1c..6427fda4d36ae7d957b601d794c2ec91202f1199 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp >@@ -256,12 +256,16 @@ static inline WTF::String pathSuitableForTestResult(WKURLRef fileUrl) > return toWTFString(adoptWK(WKURLCopyLastPathComponent(fileUrl))); // We lose some information here, but it's better than exposing a full path, which is always machine specific. > } > >-static HashMap<uint64_t, String> assignedUrlsCache; >+static HashMap<uint64_t, String>& assignedUrlsCache() >+{ >+ static NeverDestroyed<HashMap<uint64_t, String>> cache; >+ return cache.get(); >+} > > static inline void dumpResourceURL(uint64_t identifier, StringBuilder& stringBuilder) > { >- if (assignedUrlsCache.contains(identifier)) >- stringBuilder.append(assignedUrlsCache.get(identifier)); >+ if (assignedUrlsCache().contains(identifier)) >+ stringBuilder.append(assignedUrlsCache().get(identifier)); > else > stringBuilder.appendLiteral("<unknown>"); > } >@@ -433,7 +437,7 @@ void InjectedBundlePage::resetAfterTest() > > JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame); > WebCoreTestSupport::resetInternalsObject(context); >- assignedUrlsCache.clear(); >+ assignedUrlsCache().clear(); > > // User scripts need to be removed after the test and before loading about:blank, as otherwise they would run in about:blank, and potentially leak results into a subsequest test. > WKBundlePageRemoveAllUserContent(m_page); >@@ -1118,7 +1122,7 @@ void InjectedBundlePage::didInitiateLoadForResource(WKBundlePageRef page, WKBund > return; > > WKRetainPtr<WKURLRef> url = adoptWK(WKURLRequestCopyURL(request)); >- assignedUrlsCache.add(identifier, pathSuitableForTestResult(url.get())); >+ assignedUrlsCache().add(identifier, pathSuitableForTestResult(url.get())); > } > > // Resource Load Client Callbacks >diff --git a/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp b/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp >index 30d8d81eb28d27ffbd661ad998017205cd46b2a0..a7cd7b5ebbdad0a108d73f5d140866c02bda4dd9 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp >@@ -40,8 +40,16 @@ namespace { > > typedef HashMap<AtkObject*, AccessibilityNotificationHandler*> NotificationHandlersMap; > >-WTF::Vector<unsigned> listenerIds; >-NotificationHandlersMap notificationHandlers; >+static WTF::Vector<unsigned>& listenerIds() >+{ >+ static NeverDestroyed<WTF::Vector<unsigned>> ids; >+ return ids.get(); >+} >+static NotificationHandlersMap& notificationHandlers() >+{ >+ static NeverDestroyed<NotificationHandlersMap> map; >+ return map.get(); >+} > AccessibilityNotificationHandler* globalNotificationHandler = nullptr; > > gboolean axObjectEventListener(GSignalInvocationHint* signalHint, unsigned numParamValues, const GValue* paramValues, gpointer data) >@@ -124,14 +132,14 @@ gboolean axObjectEventListener(GSignalInvocationHint* signalHint, unsigned numPa > if (notificationName) { > JSRetainPtr<JSStringRef> jsNotificationEventName(Adopt, JSStringCreateWithUTF8CString(notificationName)); > JSValueRef notificationNameArgument = JSValueMakeString(jsContext, jsNotificationEventName.get()); >- NotificationHandlersMap::iterator elementNotificationHandler = notificationHandlers.find(accessible); >+ NotificationHandlersMap::iterator elementNotificationHandler = notificationHandlers().find(accessible); > JSValueRef arguments[5]; // this dimension must be >= 2 + max(extraArgs.size()) > arguments[0] = toJS(jsContext, WTF::getPtr(WTR::AccessibilityUIElement::create(accessible))); > arguments[1] = notificationNameArgument; > size_t numOfExtraArgs = extraArgs.size(); > for (size_t i = 0; i < numOfExtraArgs; i++) > arguments[i + 2] = extraArgs[i]; >- if (elementNotificationHandler != notificationHandlers.end()) { >+ if (elementNotificationHandler != notificationHandlers().end()) { > // Listener for one element. As arguments, it gets the notification name > // and sometimes extra arguments. > JSObjectCallAsFunction(jsContext, >@@ -189,13 +197,13 @@ void AccessibilityNotificationHandler::setNotificationFunctionCallback(JSValueRe > JSValueProtect(jsContext, m_notificationFunctionCallback); > // Check if this notification handler is related to a specific element. > if (m_platformElement) { >- NotificationHandlersMap::iterator currentNotificationHandler = notificationHandlers.find(m_platformElement.get()); >- if (currentNotificationHandler != notificationHandlers.end()) { >+ NotificationHandlersMap::iterator currentNotificationHandler = notificationHandlers().find(m_platformElement.get()); >+ if (currentNotificationHandler != notificationHandlers().end()) { > ASSERT(currentNotificationHandler->value->platformElement()); > JSValueUnprotect(jsContext, currentNotificationHandler->value->notificationFunctionCallback()); >- notificationHandlers.remove(currentNotificationHandler->value->platformElement().get()); >+ notificationHandlers().remove(currentNotificationHandler->value->platformElement().get()); > } >- notificationHandlers.add(m_platformElement.get(), this); >+ notificationHandlers().add(m_platformElement.get(), this); > } else { > if (globalNotificationHandler) > JSValueUnprotect(jsContext, globalNotificationHandler->notificationFunctionCallback()); >@@ -219,10 +227,10 @@ void AccessibilityNotificationHandler::removeAccessibilityNotificationHandler() > JSValueUnprotect(jsContext, globalNotificationHandler->notificationFunctionCallback()); > globalNotificationHandler = nullptr; > } else if (m_platformElement.get()) { >- NotificationHandlersMap::iterator removeNotificationHandler = notificationHandlers.find(m_platformElement.get()); >- if (removeNotificationHandler != notificationHandlers.end()) { >+ NotificationHandlersMap::iterator removeNotificationHandler = notificationHandlers().find(m_platformElement.get()); >+ if (removeNotificationHandler != notificationHandlers().end()) { > JSValueUnprotect(jsContext, removeNotificationHandler->value->notificationFunctionCallback()); >- notificationHandlers.remove(removeNotificationHandler); >+ notificationHandlers().remove(removeNotificationHandler); > } > } > } >@@ -262,22 +270,22 @@ void AccessibilityNotificationHandler::connectAccessibilityCallbacks() > continue; > } > >- listenerIds.append(id); >+ listenerIds().append(id); > } > } > > bool AccessibilityNotificationHandler::disconnectAccessibilityCallbacks() > { > // Only disconnect if there is no notification handler. >- if (!notificationHandlers.isEmpty() || globalNotificationHandler) >+ if (!notificationHandlers().isEmpty() || globalNotificationHandler) > return false; > > // AtkObject signals. >- for (size_t i = 0; i < listenerIds.size(); i++) { >- ASSERT(listenerIds[i]); >- atk_remove_global_event_listener(listenerIds[i]); >+ for (size_t i = 0; i < listenerIds().size(); i++) { >+ ASSERT(listenerIds()[i]); >+ atk_remove_global_event_listener(listenerIds()[i]); > } >- listenerIds.clear(); >+ listenerIds().clear(); > return true; > } > >diff --git a/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp b/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp >index c1ef87a6985822ce3e3c4da441cb4421ab7ee143..430c022934bcd0044fa20fdfac4d251d54317d95 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp >@@ -63,11 +63,6 @@ enum AtkAttributeType { > TextAttributeType > }; > >-enum AttributeDomain { >- CoreDomain = 0, >- AtkDomain >-}; >- > enum AttributesIndex { > // Attribute names. > InvalidNameIndex = 0, >@@ -96,30 +91,39 @@ enum AttributesIndex { > }; > > // Attribute names & Values (keep on sync with enum AttributesIndex). >-const String attributesMap[][2] = { >- // Attribute names. >- { "AXInvalid", "invalid" }, >- { "AXARIAColumnCount", "colcount" }, >- { "AXARIAColumnIndex", "colindex" }, >- { "AXARIAColumnSpan", "colspan" }, >- { "AXARIARowCount", "rowcount" }, >- { "AXARIARowIndex", "rowindex" }, >- { "AXARIARowSpan", "rowspan" }, >- { "AXARIAPosInSet", "posinset" }, >- { "AXARIASetSize", "setsize" }, >- { "AXPlaceholderValue", "placeholder-text" } , >- { "AXSortDirection", "sort" }, >- { "AXARIACurrent", "current" }, >- { "AXARIALive", "live" }, >- { "AXARIAAtomic", "atomic" }, >- { "AXARIARelevant", "relevant" }, >- { "AXElementBusy", "busy" }, >- >- // Attribute values. >- { "AXAscendingSortDirection", "ascending" }, >- { "AXDescendingSortDirection", "descending" }, >- { "AXUnknownSortDirection", "unknown" } >+struct Attribute { >+ String coreDomain; >+ String atkDomain; > }; >+using Attributes = std::array<Attribute, NumberOfAttributes>; >+static const Attributes& attributesMap() >+{ >+ static NeverDestroyed<Attributes> attributes = Attributes({ >+ // Attribute names. >+ Attribute { "AXInvalid", "invalid" }, >+ Attribute { "AXARIAColumnCount", "colcount" }, >+ Attribute { "AXARIAColumnIndex", "colindex" }, >+ Attribute { "AXARIAColumnSpan", "colspan" }, >+ Attribute { "AXARIARowCount", "rowcount" }, >+ Attribute { "AXARIARowIndex", "rowindex" }, >+ Attribute { "AXARIARowSpan", "rowspan" }, >+ Attribute { "AXARIAPosInSet", "posinset" }, >+ Attribute { "AXARIASetSize", "setsize" }, >+ Attribute { "AXPlaceholderValue", "placeholder-text" } , >+ Attribute { "AXSortDirection", "sort" }, >+ Attribute { "AXARIACurrent", "current" }, >+ Attribute { "AXARIALive", "live" }, >+ Attribute { "AXARIAAtomic", "atomic" }, >+ Attribute { "AXARIARelevant", "relevant" }, >+ Attribute { "AXElementBusy", "busy" }, >+ >+ // Attribute values. >+ Attribute { "AXAscendingSortDirection", "ascending" }, >+ Attribute { "AXDescendingSortDirection", "descending" }, >+ Attribute { "AXUnknownSortDirection", "unknown" }, >+ }); >+ return attributes.get(); >+} > > #if ATK_CHECK_VERSION(2, 11, 3) > const char* landmarkStringBanner = "AXLandmarkBanner"; >@@ -145,8 +149,8 @@ String coreAttributeToAtkAttribute(JSStringRef attribute) > { > String attributeString = jsStringToWTFString(attribute); > for (int i = 0; i < NumberOfAttributes; ++i) { >- if (attributesMap[i][CoreDomain] == attributeString) >- return attributesMap[i][AtkDomain]; >+ if (attributesMap()[i].coreDomain == attributeString) >+ return attributesMap()[i].atkDomain; > } > > return attributeString; >@@ -156,23 +160,23 @@ String atkAttributeValueToCoreAttributeValue(AtkAttributeType type, const String > { > if (type == ObjectAttributeType) { > // We don't expose the "current" attribute if there is no author-provided value. >- if (id == attributesMap[CurrentNameIndex][AtkDomain] && value.isEmpty()) >+ if (id == attributesMap()[CurrentNameIndex].atkDomain && value.isEmpty()) > return "false"; > > // We need to translate ATK values exposed for 'aria-sort' (e.g. 'ascending') > // into those expected by the layout tests (e.g. 'AXAscendingSortDirection'). >- if (id == attributesMap[SortNameIndex][AtkDomain] && !value.isEmpty()) { >- if (value == attributesMap[SortAscendingValueIndex][AtkDomain]) >- return attributesMap[SortAscendingValueIndex][CoreDomain]; >- if (value == attributesMap[SortDescendingValueIndex][AtkDomain]) >- return attributesMap[SortDescendingValueIndex][CoreDomain]; >+ if (id == attributesMap()[SortNameIndex].atkDomain && !value.isEmpty()) { >+ if (value == attributesMap()[SortAscendingValueIndex].atkDomain) >+ return attributesMap()[SortAscendingValueIndex].coreDomain; >+ if (value == attributesMap()[SortDescendingValueIndex].atkDomain) >+ return attributesMap()[SortDescendingValueIndex].coreDomain; > >- return attributesMap[SortUnknownValueIndex][CoreDomain]; >+ return attributesMap()[SortUnknownValueIndex].coreDomain; > } > } else if (type == TextAttributeType) { > // In case of 'aria-invalid' when the attribute empty or has "false" for ATK > // it should not be mapped at all, but layout tests will expect 'false'. >- if (id == attributesMap[InvalidNameIndex][AtkDomain] && value.isEmpty()) >+ if (id == attributesMap()[InvalidNameIndex].atkDomain && value.isEmpty()) > return "false"; > } > >@@ -1094,7 +1098,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRe > > // Additional check to make sure that the exposure of the state ATK_STATE_INVALID_ENTRY > // is consistent with the exposure of aria-invalid as a text attribute, if present. >- if (atkAttributeName == attributesMap[InvalidNameIndex][AtkDomain]) { >+ if (atkAttributeName == attributesMap()[InvalidNameIndex].atkDomain) { > bool isInvalidState = checkElementState(m_element.get(), ATK_STATE_INVALID_ENTRY); > if (attributeValue.isEmpty()) > return JSStringCreateWithUTF8CString(isInvalidState ? "true" : "false");
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186969
:
343433
|
343436
|
343437
|
343492
|
343555
|
343566