Index: Source/core/css/CSSPrimitiveValue.cpp |
diff --git a/Source/core/css/CSSPrimitiveValue.cpp b/Source/core/css/CSSPrimitiveValue.cpp |
index 7861288d6162c02a3a7200dffaa741209fbb04b8..9a039059b40d629ca97e0f13c7427fa4bcfc95de 100644 |
--- a/Source/core/css/CSSPrimitiveValue.cpp |
+++ b/Source/core/css/CSSPrimitiveValue.cpp |
@@ -36,6 +36,8 @@ |
#include "platform/LayoutUnit.h" |
#include "platform/fonts/FontMetrics.h" |
#include "wtf/StdLibExtras.h" |
+#include "wtf/ThreadSpecific.h" |
+#include "wtf/Threading.h" |
#include "wtf/text/StringBuffer.h" |
#include "wtf/text/StringBuilder.h" |
@@ -43,6 +45,8 @@ using namespace WTF; |
namespace blink { |
+namespace { |
+ |
// Max/min values for CSS, needs to slightly smaller/larger than the true max/min values to allow for rounding without overflowing. |
// Subtract two (rather than one) to allow for values to be converted to float and back without exceeding the LayoutUnit::max. |
const int maxValueForCssLength = INT_MAX / kFixedPointDenominator - 2; |
@@ -139,10 +143,24 @@ StringToUnitTable createStringToUnitTable() |
return table; |
} |
-CSSPrimitiveValue::UnitType CSSPrimitiveValue::fromName(const String& unit) |
+StringToUnitTable& unitTable() |
{ |
DEFINE_STATIC_LOCAL(StringToUnitTable, unitTable, (createStringToUnitTable())); |
- return unitTable.get(unit.lower()); |
+ return unitTable; |
+} |
+ |
+} // namespace |
+ |
+void CSSPrimitiveValue::initUnitTable() |
+{ |
+ // Make sure we initialize this during blink initialization |
+ // to avoid racy static local initialization. |
+ unitTable(); |
+} |
+ |
+CSSPrimitiveValue::UnitType CSSPrimitiveValue::fromName(const String& unit) |
+{ |
+ return unitTable().get(unit.lower()); |
} |
CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitCategory(UnitType type) |
@@ -198,8 +216,8 @@ bool CSSPrimitiveValue::colorIsDerivedFromElement() const |
typedef HashMap<const CSSPrimitiveValue*, String> CSSTextCache; |
static CSSTextCache& cssTextCache() |
{ |
- DEFINE_STATIC_LOCAL(CSSTextCache, cache, ()); |
- return cache; |
+ AtomicallyInitializedStaticReference(ThreadSpecific<CSSTextCache>, cache, new ThreadSpecific<CSSTextCache>()); |
sof
2015/12/02 13:32:41
fwiw, http/tests/misc/client-hints-picture-source-
|
+ return *cache; |
} |
CSSPrimitiveValue::UnitType CSSPrimitiveValue::primitiveType() const |