Title: [234347] trunk/Source/WebCore
Revision
234347
Author
[email protected]
Date
2018-07-29 11:13:28 -0700 (Sun, 29 Jul 2018)

Log Message

Use static global variables instead of static NeverDestroyed inside function if possible
https://bugs.webkit.org/show_bug.cgi?id=188146

Reviewed by Darin Adler.

This patch leverages constexpr constructors / trivial destructors more to remove unnecessary `static NeverDestroyed`
inside a function. It simplifies the code, removes the unnecessary function, and ensures the initialization at
a program loader phase.

We make StepRange::StepDescription constructor constexpr to remove bunch of `static NeverDestroyed<const StepRange::StepDescription>`.
And we use `static Lock` since WTF::Lock has constexpr constructor.

No behavior change.

* dom/MessagePort.cpp:
(WebCore::MessagePort::deref const):
(WebCore::MessagePort::isExistingMessagePortLocallyReachable):
(WebCore::MessagePort::notifyMessageAvailable):
(WebCore::MessagePort::MessagePort):
(WebCore::MessagePort::~MessagePort):
(WebCore::allMessagePortsLock): Deleted.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::contextIdentifier const):
(WebCore::ScriptExecutionContext::removeFromContextsMap):
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
(WebCore::ScriptExecutionContext::postTaskTo):
(WebCore::allScriptExecutionContextsMapLock): Deleted.
* html/DateInputType.cpp:
(WebCore::DateInputType::createStepRange const):
* html/DateTimeInputType.cpp:
(WebCore::DateTimeInputType::createStepRange const):
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::createStepRange const):
* html/MonthInputType.cpp:
(WebCore::MonthInputType::createStepRange const):
* html/RangeInputType.cpp:
(WebCore::RangeInputType::createStepRange const):
* html/StepRange.h:
(WebCore::StepRange::StepDescription::StepDescription):
* html/TimeInputType.cpp:
(WebCore::TimeInputType::createStepRange const):
* html/WeekInputType.cpp:
(WebCore::WeekInputType::createStepRange const):
* page/SecurityPolicy.cpp:
(WebCore::originAccessMap):
(WebCore::SecurityPolicy::isAccessWhiteListed):
(WebCore::SecurityPolicy::addOriginAccessWhitelistEntry):
(WebCore::SecurityPolicy::removeOriginAccessWhitelistEntry):
(WebCore::SecurityPolicy::resetOriginAccessWhitelists):
(WebCore::originAccessMapLock): Deleted.
* platform/SchemeRegistry.cpp:
(WebCore::allBuiltinSchemes):
(WebCore::builtinLocalURLSchemes):
(WebCore::localURLSchemes):
(WebCore::displayIsolatedURLSchemes):
(WebCore::builtinSecureSchemes):
(WebCore::secureSchemes):
(WebCore::builtinSchemesWithUniqueOrigins):
(WebCore::schemesWithUniqueOrigins):
(WebCore::builtinCanDisplayOnlyIfCanRequestSchemes):
(WebCore::canDisplayOnlyIfCanRequestSchemes):
(WebCore::SchemeRegistry::registerURLSchemeAsLocal):
(WebCore::SchemeRegistry::removeURLSchemeRegisteredAsLocal):
(WebCore::ContentSecurityPolicyBypassingSchemes):
(WebCore::cachePartitioningSchemes):
(WebCore::serviceWorkerSchemes):
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal):
(WebCore::SchemeRegistry::registerURLSchemeAsNoAccess):
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess):
(WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated):
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated):
(WebCore::SchemeRegistry::registerURLSchemeAsSecure):
(WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure):
(WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest):
(WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest):
(WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy):
(WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy):
(WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy):
(WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned):
(WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme):
(WebCore::SchemeRegistry::registerURLSchemeServiceWorkersCanHandle):
(WebCore::SchemeRegistry::canServiceWorkersHandleURLScheme):
(WebCore::SchemeRegistry::isServiceWorkerContainerCustomScheme):
(WebCore::schemeRegistryLock): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (234346 => 234347)


--- trunk/Source/WebCore/ChangeLog	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/ChangeLog	2018-07-29 18:13:28 UTC (rev 234347)
@@ -1,3 +1,90 @@
+2018-07-29  Yusuke Suzuki  <[email protected]>
+
+        Use static global variables instead of static NeverDestroyed inside function if possible
+        https://bugs.webkit.org/show_bug.cgi?id=188146
+
+        Reviewed by Darin Adler.
+
+        This patch leverages constexpr constructors / trivial destructors more to remove unnecessary `static NeverDestroyed`
+        inside a function. It simplifies the code, removes the unnecessary function, and ensures the initialization at
+        a program loader phase.
+
+        We make StepRange::StepDescription constructor constexpr to remove bunch of `static NeverDestroyed<const StepRange::StepDescription>`.
+        And we use `static Lock` since WTF::Lock has constexpr constructor.
+
+        No behavior change.
+
+        * dom/MessagePort.cpp:
+        (WebCore::MessagePort::deref const):
+        (WebCore::MessagePort::isExistingMessagePortLocallyReachable):
+        (WebCore::MessagePort::notifyMessageAvailable):
+        (WebCore::MessagePort::MessagePort):
+        (WebCore::MessagePort::~MessagePort):
+        (WebCore::allMessagePortsLock): Deleted.
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::contextIdentifier const):
+        (WebCore::ScriptExecutionContext::removeFromContextsMap):
+        (WebCore::ScriptExecutionContext::~ScriptExecutionContext):
+        (WebCore::ScriptExecutionContext::postTaskTo):
+        (WebCore::allScriptExecutionContextsMapLock): Deleted.
+        * html/DateInputType.cpp:
+        (WebCore::DateInputType::createStepRange const):
+        * html/DateTimeInputType.cpp:
+        (WebCore::DateTimeInputType::createStepRange const):
+        * html/DateTimeLocalInputType.cpp:
+        (WebCore::DateTimeLocalInputType::createStepRange const):
+        * html/MonthInputType.cpp:
+        (WebCore::MonthInputType::createStepRange const):
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::createStepRange const):
+        * html/StepRange.h:
+        (WebCore::StepRange::StepDescription::StepDescription):
+        * html/TimeInputType.cpp:
+        (WebCore::TimeInputType::createStepRange const):
+        * html/WeekInputType.cpp:
+        (WebCore::WeekInputType::createStepRange const):
+        * page/SecurityPolicy.cpp:
+        (WebCore::originAccessMap):
+        (WebCore::SecurityPolicy::isAccessWhiteListed):
+        (WebCore::SecurityPolicy::addOriginAccessWhitelistEntry):
+        (WebCore::SecurityPolicy::removeOriginAccessWhitelistEntry):
+        (WebCore::SecurityPolicy::resetOriginAccessWhitelists):
+        (WebCore::originAccessMapLock): Deleted.
+        * platform/SchemeRegistry.cpp:
+        (WebCore::allBuiltinSchemes):
+        (WebCore::builtinLocalURLSchemes):
+        (WebCore::localURLSchemes):
+        (WebCore::displayIsolatedURLSchemes):
+        (WebCore::builtinSecureSchemes):
+        (WebCore::secureSchemes):
+        (WebCore::builtinSchemesWithUniqueOrigins):
+        (WebCore::schemesWithUniqueOrigins):
+        (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes):
+        (WebCore::canDisplayOnlyIfCanRequestSchemes):
+        (WebCore::SchemeRegistry::registerURLSchemeAsLocal):
+        (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsLocal):
+        (WebCore::ContentSecurityPolicyBypassingSchemes):
+        (WebCore::cachePartitioningSchemes):
+        (WebCore::serviceWorkerSchemes):
+        (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal):
+        (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess):
+        (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess):
+        (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated):
+        (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated):
+        (WebCore::SchemeRegistry::registerURLSchemeAsSecure):
+        (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure):
+        (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest):
+        (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest):
+        (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy):
+        (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy):
+        (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy):
+        (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned):
+        (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme):
+        (WebCore::SchemeRegistry::registerURLSchemeServiceWorkersCanHandle):
+        (WebCore::SchemeRegistry::canServiceWorkersHandleURLScheme):
+        (WebCore::SchemeRegistry::isServiceWorkerContainerCustomScheme):
+        (WebCore::schemeRegistryLock): Deleted.
+
 2018-07-29  Basuke Suzuki  <[email protected]>
 
         [Curl] Fix the bug when client reject the redirect on WebKitLegacy.

Modified: trunk/Source/WebCore/dom/MessagePort.cpp (234346 => 234347)


--- trunk/Source/WebCore/dom/MessagePort.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/dom/MessagePort.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -38,6 +38,7 @@
 
 namespace WebCore {
 
+static Lock allMessagePortsLock;
 static HashMap<MessagePortIdentifier, MessagePort*>& allMessagePorts()
 {
     static NeverDestroyed<HashMap<MessagePortIdentifier, MessagePort*>> map;
@@ -44,12 +45,6 @@
     return map;
 }
 
-static Lock& allMessagePortsLock()
-{
-    static NeverDestroyed<Lock> lock;
-    return lock;
-}
-
 void MessagePort::ref() const
 {
     ++m_refCount;
@@ -61,7 +56,7 @@
     // This allows isExistingMessagePortLocallyReachable and notifyMessageAvailable to easily query the map and manipulate MessagePort instances.
 
     if (!--m_refCount) {
-        Locker<Lock> locker(allMessagePortsLock());
+        Locker<Lock> locker(allMessagePortsLock);
 
         if (m_refCount)
             return;
@@ -76,7 +71,7 @@
 
 bool MessagePort::isExistingMessagePortLocallyReachable(const MessagePortIdentifier& identifier)
 {
-    Locker<Lock> locker(allMessagePortsLock());
+    Locker<Lock> locker(allMessagePortsLock);
     auto* port = allMessagePorts().get(identifier);
     return port && port->isLocallyReachable();
 }
@@ -83,7 +78,7 @@
 
 void MessagePort::notifyMessageAvailable(const MessagePortIdentifier& identifier)
 {
-    Locker<Lock> locker(allMessagePortsLock());
+    Locker<Lock> locker(allMessagePortsLock);
     if (auto* port = allMessagePorts().get(identifier))
         port->messageAvailable();
 
@@ -101,7 +96,7 @@
 {
     LOG(MessagePorts, "Created MessagePort %s (%p) in process %" PRIu64, m_identifier.logString().utf8().data(), this, Process::identifier().toUInt64());
 
-    Locker<Lock> locker(allMessagePortsLock());
+    Locker<Lock> locker(allMessagePortsLock);
     allMessagePorts().set(m_identifier, this);
 
     m_scriptExecutionContext->createdMessagePort(*this);
@@ -114,7 +109,7 @@
 {
     LOG(MessagePorts, "Destroyed MessagePort %s (%p) in process %" PRIu64, m_identifier.logString().utf8().data(), this, Process::identifier().toUInt64());
 
-    ASSERT(allMessagePortsLock().isLocked());
+    ASSERT(allMessagePortsLock.isLocked());
 
     if (m_entangled)
         close();

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (234346 => 234347)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -66,16 +66,11 @@
 namespace WebCore {
 using namespace Inspector;
 
-static Lock& allScriptExecutionContextsMapLock()
-{
-    static NeverDestroyed<Lock> lock;
-    return lock;
-}
-
+static Lock allScriptExecutionContextsMapLock;
 static HashMap<ScriptExecutionContextIdentifier, ScriptExecutionContext*>& allScriptExecutionContextsMap()
 {
     static NeverDestroyed<HashMap<ScriptExecutionContextIdentifier, ScriptExecutionContext*>> contexts;
-    ASSERT(allScriptExecutionContextsMapLock().isLocked());
+    ASSERT(allScriptExecutionContextsMapLock.isLocked());
     return contexts;
 }
 
@@ -105,7 +100,7 @@
 {
     ASSERT(isContextThread());
     if (!m_contextIdentifier) {
-        Locker<Lock> locker(allScriptExecutionContextsMapLock());
+        Locker<Lock> locker(allScriptExecutionContextsMapLock);
 
         m_contextIdentifier = generateObjectIdentifier<ScriptExecutionContextIdentifierType>();
 
@@ -118,7 +113,7 @@
 void ScriptExecutionContext::removeFromContextsMap()
 {
     if (m_contextIdentifier) {
-        Locker<Lock> locker(allScriptExecutionContextsMapLock());
+        Locker<Lock> locker(allScriptExecutionContextsMapLock);
         ASSERT(allScriptExecutionContextsMap().contains(m_contextIdentifier));
         allScriptExecutionContextsMap().remove(m_contextIdentifier);
     }
@@ -154,7 +149,7 @@
 
 #if !ASSERT_DISABLED
     if (m_contextIdentifier) {
-        Locker<Lock> locker(allScriptExecutionContextsMapLock());
+        Locker<Lock> locker(allScriptExecutionContextsMapLock);
         ASSERT_WITH_MESSAGE(!allScriptExecutionContextsMap().contains(m_contextIdentifier),
             "A ScriptExecutionContext subclass instance implementing postTask should have already removed itself from the map");
     }
@@ -601,7 +596,7 @@
 
 bool ScriptExecutionContext::postTaskTo(ScriptExecutionContextIdentifier identifier, Task&& task)
 {
-    Locker<Lock> locker(allScriptExecutionContextsMapLock());
+    Locker<Lock> locker(allScriptExecutionContextsMapLock);
     auto* context = allScriptExecutionContextsMap().get(identifier);
 
     if (!context)

Modified: trunk/Source/WebCore/html/DateInputType.cpp (234346 => 234347)


--- trunk/Source/WebCore/html/DateInputType.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/html/DateInputType.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -35,7 +35,6 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
-#include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
@@ -44,6 +43,7 @@
 static const int dateDefaultStep = 1;
 static const int dateDefaultStepBase = 0;
 static const int dateStepScaleFactor = 86400000;
+static const StepRange::StepDescription dateStepDescription { dateDefaultStep, dateDefaultStepBase, dateStepScaleFactor, StepRange::ParsedStepValueShouldBeInteger };
 
 DateInputType::DateInputType(HTMLInputElement& element)
     : BaseChooserOnlyDateAndTimeInputType(element)
@@ -62,14 +62,12 @@
 
 StepRange DateInputType::createStepRange(AnyStepHandling anyStepHandling) const
 {
-    static NeverDestroyed<const StepRange::StepDescription> stepDescription(dateDefaultStep, dateDefaultStepBase, dateStepScaleFactor, StepRange::ParsedStepValueShouldBeInteger);
-
     ASSERT(element());
     const Decimal stepBase = parseToNumber(element()->attributeWithoutSynchronization(minAttr), 0);
     const Decimal minimum = parseToNumber(element()->attributeWithoutSynchronization(minAttr), Decimal::fromDouble(DateComponents::minimumDate()));
     const Decimal maximum = parseToNumber(element()->attributeWithoutSynchronization(maxAttr), Decimal::fromDouble(DateComponents::maximumDate()));
-    const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element()->attributeWithoutSynchronization(stepAttr));
-    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription);
+    const Decimal step = StepRange::parseStep(anyStepHandling, dateStepDescription, element()->attributeWithoutSynchronization(stepAttr));
+    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, dateStepDescription);
 }
 
 bool DateInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const

Modified: trunk/Source/WebCore/html/DateTimeInputType.cpp (234346 => 234347)


--- trunk/Source/WebCore/html/DateTimeInputType.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/html/DateTimeInputType.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -35,7 +35,6 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
-#include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
@@ -44,6 +43,7 @@
 static const int dateTimeDefaultStep = 60;
 static const int dateTimeDefaultStepBase = 0;
 static const int dateTimeStepScaleFactor = 1000;
+static const StepRange::StepDescription dateTimeStepDescription { dateTimeDefaultStep, dateTimeDefaultStepBase, dateTimeStepScaleFactor, StepRange::ScaledStepValueShouldBeInteger };
 
 const AtomicString& DateTimeInputType::formControlType() const
 {
@@ -62,13 +62,11 @@
 
 StepRange DateTimeInputType::createStepRange(AnyStepHandling anyStepHandling) const
 {
-    static NeverDestroyed<const StepRange::StepDescription> stepDescription(dateTimeDefaultStep, dateTimeDefaultStepBase, dateTimeStepScaleFactor, StepRange::ScaledStepValueShouldBeInteger);
-
     const Decimal stepBase = parseToNumber(element().attributeWithoutSynchronization(minAttr), 0);
     const Decimal minimum = parseToNumber(element().attributeWithoutSynchronization(minAttr), Decimal::fromDouble(DateComponents::minimumDateTime()));
     const Decimal maximum = parseToNumber(element().attributeWithoutSynchronization(maxAttr), Decimal::fromDouble(DateComponents::maximumDateTime()));
-    const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().attributeWithoutSynchronization(stepAttr));
-    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription);
+    const Decimal step = StepRange::parseStep(anyStepHandling, dateTimeStepDescription, element().attributeWithoutSynchronization(stepAttr));
+    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, dateTimeStepDescription);
 }
 
 bool DateTimeInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const

Modified: trunk/Source/WebCore/html/DateTimeLocalInputType.cpp (234346 => 234347)


--- trunk/Source/WebCore/html/DateTimeLocalInputType.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/html/DateTimeLocalInputType.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -36,7 +36,6 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
-#include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
@@ -45,6 +44,7 @@
 static const int dateTimeLocalDefaultStep = 60;
 static const int dateTimeLocalDefaultStepBase = 0;
 static const int dateTimeLocalStepScaleFactor = 1000;
+static const StepRange::StepDescription dateTimeLocalStepDescription { dateTimeLocalDefaultStep, dateTimeLocalDefaultStepBase, dateTimeLocalStepScaleFactor, StepRange::ScaledStepValueShouldBeInteger };
 
 const AtomicString& DateTimeLocalInputType::formControlType() const
 {
@@ -70,14 +70,12 @@
 
 StepRange DateTimeLocalInputType::createStepRange(AnyStepHandling anyStepHandling) const
 {
-    static NeverDestroyed<const StepRange::StepDescription> stepDescription(dateTimeLocalDefaultStep, dateTimeLocalDefaultStepBase, dateTimeLocalStepScaleFactor, StepRange::ScaledStepValueShouldBeInteger);
-
     ASSERT(element());
     const Decimal stepBase = parseToNumber(element()->attributeWithoutSynchronization(minAttr), 0);
     const Decimal minimum = parseToNumber(element()->attributeWithoutSynchronization(minAttr), Decimal::fromDouble(DateComponents::minimumDateTime()));
     const Decimal maximum = parseToNumber(element()->attributeWithoutSynchronization(maxAttr), Decimal::fromDouble(DateComponents::maximumDateTime()));
-    const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element()->attributeWithoutSynchronization(stepAttr));
-    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription);
+    const Decimal step = StepRange::parseStep(anyStepHandling, dateTimeLocalStepDescription, element()->attributeWithoutSynchronization(stepAttr));
+    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, dateTimeLocalStepDescription);
 }
 
 bool DateTimeLocalInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const

Modified: trunk/Source/WebCore/html/MonthInputType.cpp (234346 => 234347)


--- trunk/Source/WebCore/html/MonthInputType.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/html/MonthInputType.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -46,6 +46,7 @@
 static const int monthDefaultStep = 1;
 static const int monthDefaultStepBase = 0;
 static const int monthStepScaleFactor = 1;
+static const StepRange::StepDescription monthStepDescription { monthDefaultStep, monthDefaultStepBase, monthStepScaleFactor, StepRange::ParsedStepValueShouldBeInteger };
 
 const AtomicString& MonthInputType::formControlType() const
 {
@@ -91,14 +92,12 @@
 
 StepRange MonthInputType::createStepRange(AnyStepHandling anyStepHandling) const
 {
-    static NeverDestroyed<const StepRange::StepDescription> stepDescription(monthDefaultStep, monthDefaultStepBase, monthStepScaleFactor, StepRange::ParsedStepValueShouldBeInteger);
-
     ASSERT(element());
     const Decimal stepBase = parseToNumber(element()->attributeWithoutSynchronization(minAttr), Decimal::fromDouble(monthDefaultStepBase));
     const Decimal minimum = parseToNumber(element()->attributeWithoutSynchronization(minAttr), Decimal::fromDouble(DateComponents::minimumMonth()));
     const Decimal maximum = parseToNumber(element()->attributeWithoutSynchronization(maxAttr), Decimal::fromDouble(DateComponents::maximumMonth()));
-    const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element()->attributeWithoutSynchronization(stepAttr));
-    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription);
+    const Decimal step = StepRange::parseStep(anyStepHandling, monthStepDescription, element()->attributeWithoutSynchronization(stepAttr));
+    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, monthStepDescription);
 }
 
 Decimal MonthInputType::parseToNumber(const String& src, const Decimal& defaultValue) const

Modified: trunk/Source/WebCore/html/RangeInputType.cpp (234346 => 234347)


--- trunk/Source/WebCore/html/RangeInputType.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/html/RangeInputType.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -47,7 +47,6 @@
 #include "SliderThumbElement.h"
 #include <limits>
 #include <wtf/MathExtras.h>
-#include <wtf/NeverDestroyed.h>
 
 #if ENABLE(TOUCH_EVENTS)
 #include "Touch.h"
@@ -69,6 +68,7 @@
 static const int rangeDefaultStep = 1;
 static const int rangeDefaultStepBase = 0;
 static const int rangeStepScaleFactor = 1;
+static const StepRange::StepDescription rangeStepDescription { rangeDefaultStep, rangeDefaultStepBase, rangeStepScaleFactor };
 
 static Decimal ensureMaximum(const Decimal& proposedValue, const Decimal& minimum, const Decimal& fallbackValue)
 {
@@ -115,8 +115,6 @@
 
 StepRange RangeInputType::createStepRange(AnyStepHandling anyStepHandling) const
 {
-    static NeverDestroyed<const StepRange::StepDescription> stepDescription(rangeDefaultStep, rangeDefaultStepBase, rangeStepScaleFactor);
-
     ASSERT(element());
     const Decimal minimum = parseToNumber(element()->attributeWithoutSynchronization(minAttr), rangeDefaultMinimum);
     const Decimal maximum = ensureMaximum(parseToNumber(element()->attributeWithoutSynchronization(maxAttr), rangeDefaultMaximum), minimum, rangeDefaultMaximum);
@@ -124,11 +122,11 @@
     const AtomicString& precisionValue = element()->attributeWithoutSynchronization(precisionAttr);
     if (!precisionValue.isNull()) {
         const Decimal step = equalLettersIgnoringASCIICase(precisionValue, "float") ? Decimal::nan() : 1;
-        return StepRange(minimum, RangeLimitations::Valid, minimum, maximum, step, stepDescription);
+        return StepRange(minimum, RangeLimitations::Valid, minimum, maximum, step, rangeStepDescription);
     }
 
-    const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element()->attributeWithoutSynchronization(stepAttr));
-    return StepRange(minimum, RangeLimitations::Valid, minimum, maximum, step, stepDescription);
+    const Decimal step = StepRange::parseStep(anyStepHandling, rangeStepDescription, element()->attributeWithoutSynchronization(stepAttr));
+    return StepRange(minimum, RangeLimitations::Valid, minimum, maximum, step, rangeStepDescription);
 }
 
 bool RangeInputType::isSteppable() const

Modified: trunk/Source/WebCore/html/StepRange.h (234346 => 234347)


--- trunk/Source/WebCore/html/StepRange.h	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/html/StepRange.h	2018-07-29 18:13:28 UTC (rev 234347)
@@ -43,12 +43,12 @@
     struct StepDescription {
         WTF_MAKE_FAST_ALLOCATED;
     public:
-        int defaultStep;
-        int defaultStepBase;
-        int stepScaleFactor;
-        StepValueShouldBe stepValueShouldBe;
+        int defaultStep { 1 };
+        int defaultStepBase { 0 };
+        int stepScaleFactor { 1 };
+        StepValueShouldBe stepValueShouldBe { StepValueShouldBeReal };
 
-        StepDescription(int defaultStep, int defaultStepBase, int stepScaleFactor, StepValueShouldBe stepValueShouldBe = StepValueShouldBeReal)
+        constexpr StepDescription(int defaultStep, int defaultStepBase, int stepScaleFactor, StepValueShouldBe stepValueShouldBe = StepValueShouldBeReal)
             : defaultStep(defaultStep)
             , defaultStepBase(defaultStepBase)
             , stepScaleFactor(stepScaleFactor)
@@ -56,13 +56,7 @@
         {
         }
 
-        StepDescription()
-            : defaultStep(1)
-            , defaultStepBase(0)
-            , stepScaleFactor(1)
-            , stepValueShouldBe(StepValueShouldBeReal)
-        {
-        }
+        StepDescription() = default;
 
         Decimal defaultValue() const
         {

Modified: trunk/Source/WebCore/html/TimeInputType.cpp (234346 => 234347)


--- trunk/Source/WebCore/html/TimeInputType.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/html/TimeInputType.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -37,7 +37,6 @@
 #include "InputTypeNames.h"
 #include <wtf/DateMath.h>
 #include <wtf/MathExtras.h>
-#include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
@@ -46,6 +45,7 @@
 static const int timeDefaultStep = 60;
 static const int timeDefaultStepBase = 0;
 static const int timeStepScaleFactor = 1000;
+static const StepRange::StepDescription timeStepDescription { timeDefaultStep, timeDefaultStepBase, timeStepScaleFactor, StepRange::ScaledStepValueShouldBeInteger };
 
 TimeInputType::TimeInputType(HTMLInputElement& element)
     : BaseChooserOnlyDateAndTimeInputType(element)
@@ -77,14 +77,12 @@
 
 StepRange TimeInputType::createStepRange(AnyStepHandling anyStepHandling) const
 {
-    static NeverDestroyed<const StepRange::StepDescription> stepDescription(timeDefaultStep, timeDefaultStepBase, timeStepScaleFactor, StepRange::ScaledStepValueShouldBeInteger);
-
     ASSERT(element());
     const Decimal stepBase = parseToNumber(element()->attributeWithoutSynchronization(minAttr), 0);
     const Decimal minimum = parseToNumber(element()->attributeWithoutSynchronization(minAttr), Decimal::fromDouble(DateComponents::minimumTime()));
     const Decimal maximum = parseToNumber(element()->attributeWithoutSynchronization(maxAttr), Decimal::fromDouble(DateComponents::maximumTime()));
-    const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element()->attributeWithoutSynchronization(stepAttr));
-    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription);
+    const Decimal step = StepRange::parseStep(anyStepHandling, timeStepDescription, element()->attributeWithoutSynchronization(stepAttr));
+    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, timeStepDescription);
 }
 
 bool TimeInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const

Modified: trunk/Source/WebCore/html/WeekInputType.cpp (234346 => 234347)


--- trunk/Source/WebCore/html/WeekInputType.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/html/WeekInputType.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -35,7 +35,6 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
-#include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
@@ -44,6 +43,7 @@
 static const int weekDefaultStepBase = -259200000; // The first day of 1970-W01.
 static const int weekDefaultStep = 1;
 static const int weekStepScaleFactor = 604800000;
+static const StepRange::StepDescription weekStepDescription { weekDefaultStep, weekDefaultStepBase, weekStepScaleFactor, StepRange::ParsedStepValueShouldBeInteger };
 
 const AtomicString& WeekInputType::formControlType() const
 {
@@ -57,14 +57,12 @@
 
 StepRange WeekInputType::createStepRange(AnyStepHandling anyStepHandling) const
 {
-    static NeverDestroyed<const StepRange::StepDescription> stepDescription(weekDefaultStep, weekDefaultStepBase, weekStepScaleFactor, StepRange::ParsedStepValueShouldBeInteger);
-
     ASSERT(element());
     const Decimal stepBase = parseToNumber(element()->attributeWithoutSynchronization(minAttr), weekDefaultStepBase);
     const Decimal minimum = parseToNumber(element()->attributeWithoutSynchronization(minAttr), Decimal::fromDouble(DateComponents::minimumWeek()));
     const Decimal maximum = parseToNumber(element()->attributeWithoutSynchronization(maxAttr), Decimal::fromDouble(DateComponents::maximumWeek()));
-    const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element()->attributeWithoutSynchronization(stepAttr));
-    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription);
+    const Decimal step = StepRange::parseStep(anyStepHandling, weekStepDescription, element()->attributeWithoutSynchronization(stepAttr));
+    return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, weekStepDescription);
 }
 
 bool WeekInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const

Modified: trunk/Source/WebCore/page/SecurityPolicy.cpp (234346 => 234347)


--- trunk/Source/WebCore/page/SecurityPolicy.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/page/SecurityPolicy.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -45,15 +45,10 @@
 typedef Vector<OriginAccessEntry> OriginAccessWhiteList;
 typedef HashMap<String, std::unique_ptr<OriginAccessWhiteList>> OriginAccessMap;
 
-static Lock& originAccessMapLock()
-{
-    static NeverDestroyed<Lock> lock;
-    return lock;
-}
-
+static Lock originAccessMapLock;
 static OriginAccessMap& originAccessMap()
 {
-    ASSERT(originAccessMapLock().isHeld());
+    ASSERT(originAccessMapLock.isHeld());
     static NeverDestroyed<OriginAccessMap> originAccessMap;
     return originAccessMap;
 }
@@ -167,7 +162,7 @@
 
 bool SecurityPolicy::isAccessWhiteListed(const SecurityOrigin* activeOrigin, const SecurityOrigin* targetOrigin)
 {
-    Locker<Lock> locker(originAccessMapLock());
+    Locker<Lock> locker(originAccessMapLock);
     if (OriginAccessWhiteList* list = originAccessMap().get(activeOrigin->toString())) {
         for (auto& entry : *list) {
             if (entry.matchesOrigin(*targetOrigin))
@@ -191,7 +186,7 @@
 
     String sourceString = sourceOrigin.toString();
 
-    Locker<Lock> locker(originAccessMapLock());
+    Locker<Lock> locker(originAccessMapLock);
     OriginAccessMap::AddResult result = originAccessMap().add(sourceString, nullptr);
     if (result.isNewEntry)
         result.iterator->value = std::make_unique<OriginAccessWhiteList>();
@@ -208,7 +203,7 @@
 
     String sourceString = sourceOrigin.toString();
 
-    Locker<Lock> locker(originAccessMapLock());
+    Locker<Lock> locker(originAccessMapLock);
     OriginAccessMap& map = originAccessMap();
     OriginAccessMap::iterator it = map.find(sourceString);
     if (it == map.end())
@@ -225,7 +220,7 @@
 
 void SecurityPolicy::resetOriginAccessWhitelists()
 {
-    Locker<Lock> locker(originAccessMapLock());
+    Locker<Lock> locker(originAccessMapLock);
     originAccessMap().clear();
 }
 

Modified: trunk/Source/WebCore/platform/SchemeRegistry.cpp (234346 => 234347)


--- trunk/Source/WebCore/platform/SchemeRegistry.cpp	2018-07-29 16:18:32 UTC (rev 234346)
+++ trunk/Source/WebCore/platform/SchemeRegistry.cpp	2018-07-29 18:13:28 UTC (rev 234347)
@@ -65,11 +65,7 @@
     return set;
 }
 
-static Lock& schemeRegistryLock()
-{
-    static NeverDestroyed<Lock> lock;
-    return lock;
-}
+static Lock schemeRegistryLock;
 
 static const URLSchemesMap& allBuiltinSchemes()
 {
@@ -98,7 +94,7 @@
 
         URLSchemesMap set;
         {
-            Locker<Lock> locker(schemeRegistryLock());
+            Locker<Lock> locker(schemeRegistryLock);
             for (auto& scheme : builtinLocalURLSchemes())
                 set.add(scheme);
 
@@ -114,7 +110,7 @@
 
 static const URLSchemesMap& builtinLocalURLSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static const auto schemes = makeNeverDestroyed(URLSchemesMap {
         "file",
 #if PLATFORM(COCOA)
@@ -126,7 +122,7 @@
 
 static URLSchemesMap& localURLSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static NeverDestroyed<URLSchemesMap> localSchemes = builtinLocalURLSchemes();
     return localSchemes;
 }
@@ -133,7 +129,7 @@
 
 static URLSchemesMap& displayIsolatedURLSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static NeverDestroyed<URLSchemesMap> displayIsolatedSchemes;
     return displayIsolatedSchemes;
 }
@@ -140,7 +136,7 @@
 
 const Vector<String>& builtinSecureSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static const auto schemes = makeNeverDestroyed(Vector<String> {
         "https",
         "about",
@@ -155,7 +151,7 @@
 
 static URLSchemesMap& secureSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static auto secureSchemes = makeNeverDestroyedSchemeSet(builtinSecureSchemes);
     return secureSchemes;
 }
@@ -162,7 +158,7 @@
 
 const Vector<String>& builtinSchemesWithUniqueOrigins()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static const auto schemes = makeNeverDestroyed(Vector<String> {
         "about",
         "_javascript_",
@@ -175,7 +171,7 @@
 
 static URLSchemesMap& schemesWithUniqueOrigins()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static auto schemesWithUniqueOrigins = makeNeverDestroyedSchemeSet(builtinSchemesWithUniqueOrigins);
     return schemesWithUniqueOrigins;
 }
@@ -203,7 +199,7 @@
 
 const Vector<String>& builtinCanDisplayOnlyIfCanRequestSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static const auto schemes = makeNeverDestroyed(Vector<String> { "blob" });
     return schemes;
 }
@@ -210,7 +206,7 @@
 
 static URLSchemesMap& canDisplayOnlyIfCanRequestSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static auto canDisplayOnlyIfCanRequestSchemes = makeNeverDestroyedSchemeSet(builtinCanDisplayOnlyIfCanRequestSchemes);
     return canDisplayOnlyIfCanRequestSchemes;
 }
@@ -227,13 +223,13 @@
     if (scheme.isNull())
         return;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     localURLSchemes().add(scheme);
 }
 
 void SchemeRegistry::removeURLSchemeRegisteredAsLocal(const String& scheme)
 {
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     if (builtinLocalURLSchemes().contains(scheme))
         return;
 
@@ -271,7 +267,7 @@
 
 static URLSchemesMap& ContentSecurityPolicyBypassingSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static NeverDestroyed<URLSchemesMap> schemes;
     return schemes;
 }
@@ -278,7 +274,7 @@
 
 static URLSchemesMap& cachePartitioningSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static NeverDestroyed<URLSchemesMap> schemes;
     return schemes;
 }
@@ -285,7 +281,7 @@
 
 static URLSchemesMap& serviceWorkerSchemes()
 {
-    ASSERT(schemeRegistryLock().isHeld());
+    ASSERT(schemeRegistryLock.isHeld());
     static NeverDestroyed<URLSchemesMap> schemes;
     return schemes;
 }
@@ -302,7 +298,7 @@
     if (scheme.isNull())
         return false;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     return localURLSchemes().contains(scheme);
 }
 
@@ -311,7 +307,7 @@
     if (scheme.isNull())
         return;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     schemesWithUniqueOrigins().add(scheme);
 }
 
@@ -320,7 +316,7 @@
     if (scheme.isNull())
         return false;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     return schemesWithUniqueOrigins().contains(scheme);
 }
 
@@ -329,7 +325,7 @@
     if (scheme.isNull())
         return;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     displayIsolatedURLSchemes().add(scheme);
 }
 
@@ -338,7 +334,7 @@
     if (scheme.isNull())
         return false;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     return displayIsolatedURLSchemes().contains(scheme);
 }
 
@@ -347,7 +343,7 @@
     if (scheme.isNull())
         return;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     secureSchemes().add(scheme);
 }
 
@@ -356,7 +352,7 @@
     if (scheme.isNull())
         return false;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     return secureSchemes().contains(scheme);
 }
 
@@ -393,7 +389,7 @@
     if (scheme.isNull())
         return false;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     return canDisplayOnlyIfCanRequestSchemes().contains(scheme);
 }
 
@@ -402,7 +398,7 @@
     if (scheme.isNull())
         return;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     canDisplayOnlyIfCanRequestSchemes().add(scheme);
 }
 
@@ -459,7 +455,7 @@
     if (scheme.isNull())
         return;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     ContentSecurityPolicyBypassingSchemes().add(scheme);
 }
 
@@ -468,7 +464,7 @@
     if (scheme.isNull())
         return;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     ContentSecurityPolicyBypassingSchemes().remove(scheme);
 }
 
@@ -477,7 +473,7 @@
     if (scheme.isNull())
         return false;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     return ContentSecurityPolicyBypassingSchemes().contains(scheme);
 }
 
@@ -498,7 +494,7 @@
     if (scheme.isNull())
         return;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     cachePartitioningSchemes().add(scheme);
 }
 
@@ -507,7 +503,7 @@
     if (scheme.isNull())
         return false;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     return cachePartitioningSchemes().contains(scheme);
 }
 
@@ -516,7 +512,7 @@
     if (scheme.isNull())
         return;
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     serviceWorkerSchemes().add(scheme);
 }
 
@@ -532,13 +528,13 @@
             return true;
     }
 
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     return serviceWorkerSchemes().contains(scheme);
 }
 
 bool SchemeRegistry::isServiceWorkerContainerCustomScheme(const String& scheme)
 {
-    Locker<Lock> locker(schemeRegistryLock());
+    Locker<Lock> locker(schemeRegistryLock);
     return !scheme.isNull() && serviceWorkerSchemes().contains(scheme);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to