Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: third_party/WebKit/Source/core/css/CSSValuePool.cpp

Issue 1844083002: Color parsing in CSSParser: avoid using ColorValueCache on worker thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-fillRect-in-worker-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/CSSValuePool.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSValuePool.cpp b/third_party/WebKit/Source/core/css/CSSValuePool.cpp
index 8d7b22faf22cbefa0f234fa54b727c09c53b0603..cb89241e6affff0475d5c066ae9706a2c11af5cb 100644
--- a/third_party/WebKit/Source/core/css/CSSValuePool.cpp
+++ b/third_party/WebKit/Source/core/css/CSSValuePool.cpp
@@ -28,6 +28,7 @@
#include "core/css/CSSValueList.h"
#include "core/css/parser/CSSParser.h"
#include "core/style/ComputedStyle.h"
+#include "wtf/Threading.h"
namespace blink {
@@ -78,6 +79,14 @@ PassRefPtrWillBeRawPtr<CSSColorValue> CSSValuePool::createColorValue(RGBA32 rgbV
if (rgbValue == Color::black)
return m_colorBlack;
+ if (!isMainThread()) {
+ // TODO (crbug.com/599659): Make CSS color parsing work properly in a
+ // worker thread.
+ // Currently, ColorValueCache is not thread-safe; so we avoid interacting
+ // with it on a non-main thread.
+ return CSSColorValue::create(rgbValue);
+ }
+
// Just wipe out the cache and start rebuilding if it gets too big.
const unsigned maximumColorCacheSize = 512;
if (m_colorValueCache.size() > maximumColorCacheSize)
@@ -87,6 +96,7 @@ PassRefPtrWillBeRawPtr<CSSColorValue> CSSValuePool::createColorValue(RGBA32 rgbV
ColorValueCache::AddResult entry = m_colorValueCache.add(rgbValue, dummyValue);
if (entry.isNewEntry)
entry.storedValue->value = CSSColorValue::create(rgbValue);
+
return entry.storedValue->value;
}
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-fillRect-in-worker-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698