WebKit Bugzilla
Attachment 346028 Details for
Bug 188146
: Use static global variables instead of static NeverDestroyed inside function if possible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188146-20180729230517.patch (text/plain), 39.16 KB, created by
Yusuke Suzuki
on 2018-07-29 07:05:18 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-07-29 07:05:18 PDT
Size:
39.16 KB
patch
obsolete
>Subversion Revision: 234345 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 2775997bf44aca302fc91872ed2a5bed4044d9ef..b189ed224152a051f122c3cce8b6d692519534a5 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,89 @@ >+2018-07-29 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ Use constexpr constructors more instead of NeverDestroyed >+ https://bugs.webkit.org/show_bug.cgi?id=188146 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch leverages constexpr constructors more to remove unnecessary NeverDestroyed. >+ It simplifies the code, removes the unnecessary function, and ensures the initialization at the loading time. >+ >+ We make StepRange::StepDescription constructor constexpr to remove bunch of `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-28 Simon Fraser <simon.fraser@apple.com> > > Reset CompositingPolicyOverride between tests >diff --git a/Source/WebCore/dom/MessagePort.cpp b/Source/WebCore/dom/MessagePort.cpp >index 6f7fd36be3de21fa66284102af6c5607e4b070d1..188cc31febb787f94d474d1d661f187e5664499a 100644 >--- a/Source/WebCore/dom/MessagePort.cpp >+++ b/Source/WebCore/dom/MessagePort.cpp >@@ -38,18 +38,13 @@ > > namespace WebCore { > >+static Lock allMessagePortsLock; > static HashMap<MessagePortIdentifier, MessagePort*>& allMessagePorts() > { > static NeverDestroyed<HashMap<MessagePortIdentifier, MessagePort*>> map; > return map; > } > >-static Lock& allMessagePortsLock() >-{ >- static NeverDestroyed<Lock> lock; >- return lock; >-} >- > void MessagePort::ref() const > { > ++m_refCount; >@@ -61,7 +56,7 @@ void MessagePort::deref() const > // 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,14 +71,14 @@ void MessagePort::deref() const > > bool MessagePort::isExistingMessagePortLocallyReachable(const MessagePortIdentifier& identifier) > { >- Locker<Lock> locker(allMessagePortsLock()); >+ Locker<Lock> locker(allMessagePortsLock); > auto* port = allMessagePorts().get(identifier); > return port && port->isLocallyReachable(); > } > > 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 @@ MessagePort::MessagePort(ScriptExecutionContext& scriptExecutionContext, const M > { > 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 @@ MessagePort::~MessagePort() > { > 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(); >diff --git a/Source/WebCore/dom/ScriptExecutionContext.cpp b/Source/WebCore/dom/ScriptExecutionContext.cpp >index afe26f25f190c0463c9171b8d80642653172fd1e..d8c44d870eec25f12e68c3448aada6666db11536 100644 >--- a/Source/WebCore/dom/ScriptExecutionContext.cpp >+++ b/Source/WebCore/dom/ScriptExecutionContext.cpp >@@ -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 @@ ScriptExecutionContextIdentifier ScriptExecutionContext::contextIdentifier() con > { > ASSERT(isContextThread()); > if (!m_contextIdentifier) { >- Locker<Lock> locker(allScriptExecutionContextsMapLock()); >+ Locker<Lock> locker(allScriptExecutionContextsMapLock); > > m_contextIdentifier = generateObjectIdentifier<ScriptExecutionContextIdentifierType>(); > >@@ -118,7 +113,7 @@ ScriptExecutionContextIdentifier ScriptExecutionContext::contextIdentifier() con > 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 @@ ScriptExecutionContext::~ScriptExecutionContext() > > #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(const DocumentOrWorkerIdentifier& contex > > bool ScriptExecutionContext::postTaskTo(ScriptExecutionContextIdentifier identifier, Task&& task) > { >- Locker<Lock> locker(allScriptExecutionContextsMapLock()); >+ Locker<Lock> locker(allScriptExecutionContextsMapLock); > auto* context = allScriptExecutionContextsMap().get(identifier); > > if (!context) >diff --git a/Source/WebCore/html/DateInputType.cpp b/Source/WebCore/html/DateInputType.cpp >index 5188ad34710ddfb4640ce19e0c20d175553ca1a1..c848a87dc670a79bb9a78918d032036712cd669c 100644 >--- a/Source/WebCore/html/DateInputType.cpp >+++ b/Source/WebCore/html/DateInputType.cpp >@@ -35,7 +35,6 @@ > #include "HTMLInputElement.h" > #include "HTMLNames.h" > #include "InputTypeNames.h" >-#include <wtf/NeverDestroyed.h> > > namespace WebCore { > >@@ -44,6 +43,7 @@ using namespace HTMLNames; > 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 @@ DateComponents::Type DateInputType::dateType() const > > 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 >diff --git a/Source/WebCore/html/DateTimeInputType.cpp b/Source/WebCore/html/DateTimeInputType.cpp >index 291ff83fea869329b52234d209a7c10f2d92febd..ecfd638d6695c2b9ec6d376470ab2ace4ae518e7 100644 >--- a/Source/WebCore/html/DateTimeInputType.cpp >+++ b/Source/WebCore/html/DateTimeInputType.cpp >@@ -35,7 +35,6 @@ > #include "HTMLInputElement.h" > #include "HTMLNames.h" > #include "InputTypeNames.h" >-#include <wtf/NeverDestroyed.h> > > namespace WebCore { > >@@ -44,6 +43,7 @@ using namespace HTMLNames; > 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 @@ Decimal DateTimeInputType::defaultValueForStepUp() const > > 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 >diff --git a/Source/WebCore/html/DateTimeLocalInputType.cpp b/Source/WebCore/html/DateTimeLocalInputType.cpp >index 74f5866b170740efd362511eb2dc3e19aa1abc49..7cac1d9cbd633b95419b8e1fbf21b9e21613c98d 100644 >--- a/Source/WebCore/html/DateTimeLocalInputType.cpp >+++ b/Source/WebCore/html/DateTimeLocalInputType.cpp >@@ -36,7 +36,6 @@ > #include "HTMLInputElement.h" > #include "HTMLNames.h" > #include "InputTypeNames.h" >-#include <wtf/NeverDestroyed.h> > > namespace WebCore { > >@@ -45,6 +44,7 @@ using namespace HTMLNames; > 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 @@ ExceptionOr<void> DateTimeLocalInputType::setValueAsDate(double value) const > > 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 >diff --git a/Source/WebCore/html/MonthInputType.cpp b/Source/WebCore/html/MonthInputType.cpp >index 5977caa0ab001f758807f53497a7b53ef526e74f..f92b35535a1d6ea23367a696052f18a23f1e24e1 100644 >--- a/Source/WebCore/html/MonthInputType.cpp >+++ b/Source/WebCore/html/MonthInputType.cpp >@@ -46,6 +46,7 @@ using namespace HTMLNames; > 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 @@ Decimal MonthInputType::defaultValueForStepUp() const > > 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 >diff --git a/Source/WebCore/html/RangeInputType.cpp b/Source/WebCore/html/RangeInputType.cpp >index 27595586801f6c7762c0983af999e7002e9d1a0f..4460d71982d67b6f3c80f419c83fbc31c9c87fa0 100644 >--- a/Source/WebCore/html/RangeInputType.cpp >+++ b/Source/WebCore/html/RangeInputType.cpp >@@ -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 rangeDefaultMaximum = 100; > 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 @@ bool RangeInputType::supportsRequired() const > > 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 @@ StepRange RangeInputType::createStepRange(AnyStepHandling anyStepHandling) const > 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 >diff --git a/Source/WebCore/html/StepRange.h b/Source/WebCore/html/StepRange.h >index 48e981767d46e433613fba8d72e9a9701bfbda48..4b6d019d5ae719527a5732f3b6c3a2b4535e46cd 100644 >--- a/Source/WebCore/html/StepRange.h >+++ b/Source/WebCore/html/StepRange.h >@@ -43,12 +43,12 @@ class StepRange { > 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 @@ class StepRange { > { > } > >- StepDescription() >- : defaultStep(1) >- , defaultStepBase(0) >- , stepScaleFactor(1) >- , stepValueShouldBe(StepValueShouldBeReal) >- { >- } >+ StepDescription() = default; > > Decimal defaultValue() const > { >diff --git a/Source/WebCore/html/TimeInputType.cpp b/Source/WebCore/html/TimeInputType.cpp >index 079939cc635ce74b31918edf0acffbd92a5a7a43..42c3911ede22bf127f9c2c9adaeed1de369e2577 100644 >--- a/Source/WebCore/html/TimeInputType.cpp >+++ b/Source/WebCore/html/TimeInputType.cpp >@@ -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 @@ using namespace HTMLNames; > 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 @@ Decimal TimeInputType::defaultValueForStepUp() const > > 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 >diff --git a/Source/WebCore/html/WeekInputType.cpp b/Source/WebCore/html/WeekInputType.cpp >index d63790dead2b64066ffd36692869e2f8553ecdf3..bcb6af2caad5e5f3bea9454a5103eb951cd43d62 100644 >--- a/Source/WebCore/html/WeekInputType.cpp >+++ b/Source/WebCore/html/WeekInputType.cpp >@@ -35,7 +35,6 @@ > #include "HTMLInputElement.h" > #include "HTMLNames.h" > #include "InputTypeNames.h" >-#include <wtf/NeverDestroyed.h> > > namespace WebCore { > >@@ -44,6 +43,7 @@ using namespace HTMLNames; > 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 @@ DateComponents::Type WeekInputType::dateType() const > > 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 >diff --git a/Source/WebCore/page/SecurityPolicy.cpp b/Source/WebCore/page/SecurityPolicy.cpp >index fe6128397630ac81bedc83e70f0582ab4ee5e295..153edd819d125555568876566de31f98b6c0553b 100644 >--- a/Source/WebCore/page/SecurityPolicy.cpp >+++ b/Source/WebCore/page/SecurityPolicy.cpp >@@ -45,15 +45,10 @@ static SecurityPolicy::LocalLoadPolicy localLoadPolicy = SecurityPolicy::AllowLo > 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::allowSubstituteDataAccessToLocal() > > 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 @@ void SecurityPolicy::addOriginAccessWhitelistEntry(const SecurityOrigin& sourceO > > 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 @@ void SecurityPolicy::removeOriginAccessWhitelistEntry(const SecurityOrigin& sour > > 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::removeOriginAccessWhitelistEntry(const SecurityOrigin& sour > > void SecurityPolicy::resetOriginAccessWhitelists() > { >- Locker<Lock> locker(originAccessMapLock()); >+ Locker<Lock> locker(originAccessMapLock); > originAccessMap().clear(); > } > >diff --git a/Source/WebCore/platform/SchemeRegistry.cpp b/Source/WebCore/platform/SchemeRegistry.cpp >index 90dc461df5b70e221f7e28691c5732ab94d8c825..949de63aef06cfcfaf0c02d24c6ac44e66fe0b97 100644 >--- a/Source/WebCore/platform/SchemeRegistry.cpp >+++ b/Source/WebCore/platform/SchemeRegistry.cpp >@@ -65,11 +65,7 @@ static NeverDestroyed<URLSchemesMap> makeNeverDestroyedSchemeSet(const Vector<St > return set; > } > >-static Lock& schemeRegistryLock() >-{ >- static NeverDestroyed<Lock> lock; >- return lock; >-} >+static Lock schemeRegistryLock; > > static const URLSchemesMap& allBuiltinSchemes() > { >@@ -98,7 +94,7 @@ static const URLSchemesMap& allBuiltinSchemes() > > URLSchemesMap set; > { >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > for (auto& scheme : builtinLocalURLSchemes()) > set.add(scheme); > >@@ -114,7 +110,7 @@ static const URLSchemesMap& allBuiltinSchemes() > > static const URLSchemesMap& builtinLocalURLSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static const auto schemes = makeNeverDestroyed(URLSchemesMap { > "file", > #if PLATFORM(COCOA) >@@ -126,21 +122,21 @@ static const URLSchemesMap& builtinLocalURLSchemes() > > static URLSchemesMap& localURLSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static NeverDestroyed<URLSchemesMap> localSchemes = builtinLocalURLSchemes(); > return localSchemes; > } > > static URLSchemesMap& displayIsolatedURLSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static NeverDestroyed<URLSchemesMap> displayIsolatedSchemes; > return displayIsolatedSchemes; > } > > const Vector<String>& builtinSecureSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static const auto schemes = makeNeverDestroyed(Vector<String> { > "https", > "about", >@@ -155,14 +151,14 @@ const Vector<String>& builtinSecureSchemes() > > static URLSchemesMap& secureSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static auto secureSchemes = makeNeverDestroyedSchemeSet(builtinSecureSchemes); > return secureSchemes; > } > > const Vector<String>& builtinSchemesWithUniqueOrigins() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static const auto schemes = makeNeverDestroyed(Vector<String> { > "about", > "javascript", >@@ -175,7 +171,7 @@ const Vector<String>& builtinSchemesWithUniqueOrigins() > > static URLSchemesMap& schemesWithUniqueOrigins() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static auto schemesWithUniqueOrigins = makeNeverDestroyedSchemeSet(builtinSchemesWithUniqueOrigins); > return schemesWithUniqueOrigins; > } >@@ -203,14 +199,14 @@ static URLSchemesMap& schemesForbiddenFromDomainRelaxation() > > const Vector<String>& builtinCanDisplayOnlyIfCanRequestSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static const auto schemes = makeNeverDestroyed(Vector<String> { "blob" }); > return schemes; > } > > static URLSchemesMap& canDisplayOnlyIfCanRequestSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static auto canDisplayOnlyIfCanRequestSchemes = makeNeverDestroyedSchemeSet(builtinCanDisplayOnlyIfCanRequestSchemes); > return canDisplayOnlyIfCanRequestSchemes; > } >@@ -227,13 +223,13 @@ void SchemeRegistry::registerURLSchemeAsLocal(const String& scheme) > 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,21 +267,21 @@ static URLSchemesMap& CORSEnabledSchemes() > > static URLSchemesMap& ContentSecurityPolicyBypassingSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static NeverDestroyed<URLSchemesMap> schemes; > return schemes; > } > > static URLSchemesMap& cachePartitioningSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static NeverDestroyed<URLSchemesMap> schemes; > return schemes; > } > > static URLSchemesMap& serviceWorkerSchemes() > { >- ASSERT(schemeRegistryLock().isHeld()); >+ ASSERT(schemeRegistryLock.isHeld()); > static NeverDestroyed<URLSchemesMap> schemes; > return schemes; > } >@@ -302,7 +298,7 @@ bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme) > if (scheme.isNull()) > return false; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > return localURLSchemes().contains(scheme); > } > >@@ -311,7 +307,7 @@ void SchemeRegistry::registerURLSchemeAsNoAccess(const String& scheme) > if (scheme.isNull()) > return; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > schemesWithUniqueOrigins().add(scheme); > } > >@@ -320,7 +316,7 @@ bool SchemeRegistry::shouldTreatURLSchemeAsNoAccess(const String& scheme) > if (scheme.isNull()) > return false; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > return schemesWithUniqueOrigins().contains(scheme); > } > >@@ -329,7 +325,7 @@ void SchemeRegistry::registerURLSchemeAsDisplayIsolated(const String& scheme) > if (scheme.isNull()) > return; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > displayIsolatedURLSchemes().add(scheme); > } > >@@ -338,7 +334,7 @@ bool SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(const String& scheme) > if (scheme.isNull()) > return false; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > return displayIsolatedURLSchemes().contains(scheme); > } > >@@ -347,7 +343,7 @@ void SchemeRegistry::registerURLSchemeAsSecure(const String& scheme) > if (scheme.isNull()) > return; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > secureSchemes().add(scheme); > } > >@@ -356,7 +352,7 @@ bool SchemeRegistry::shouldTreatURLSchemeAsSecure(const String& scheme) > if (scheme.isNull()) > return false; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > return secureSchemes().contains(scheme); > } > >@@ -393,7 +389,7 @@ bool SchemeRegistry::canDisplayOnlyIfCanRequest(const String& scheme) > if (scheme.isNull()) > return false; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > return canDisplayOnlyIfCanRequestSchemes().contains(scheme); > } > >@@ -402,7 +398,7 @@ void SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest(const String& scheme) > if (scheme.isNull()) > return; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > canDisplayOnlyIfCanRequestSchemes().add(scheme); > } > >@@ -459,7 +455,7 @@ void SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(const Str > if (scheme.isNull()) > return; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > ContentSecurityPolicyBypassingSchemes().add(scheme); > } > >@@ -468,7 +464,7 @@ void SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(c > if (scheme.isNull()) > return; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > ContentSecurityPolicyBypassingSchemes().remove(scheme); > } > >@@ -477,7 +473,7 @@ bool SchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& schem > if (scheme.isNull()) > return false; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > return ContentSecurityPolicyBypassingSchemes().contains(scheme); > } > >@@ -498,7 +494,7 @@ void SchemeRegistry::registerURLSchemeAsCachePartitioned(const String& scheme) > if (scheme.isNull()) > return; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > cachePartitioningSchemes().add(scheme); > } > >@@ -507,7 +503,7 @@ bool SchemeRegistry::shouldPartitionCacheForURLScheme(const String& scheme) > if (scheme.isNull()) > return false; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > return cachePartitioningSchemes().contains(scheme); > } > >@@ -516,7 +512,7 @@ void SchemeRegistry::registerURLSchemeServiceWorkersCanHandle(const String& sche > if (scheme.isNull()) > return; > >- Locker<Lock> locker(schemeRegistryLock()); >+ Locker<Lock> locker(schemeRegistryLock); > serviceWorkerSchemes().add(scheme); > } > >@@ -532,13 +528,13 @@ bool SchemeRegistry::canServiceWorkersHandleURLScheme(const String& scheme) > 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); > } >
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
Flags:
darin
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188146
: 346028