Changeset 275500 in webkit
- Timestamp:
- Apr 6, 2021 2:59:36 AM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r275498 r275500 1 2021-04-06 Chris Lord <clord@igalia.com> 2 3 BidiContext caching is not thread-safe 4 https://bugs.webkit.org/show_bug.cgi?id=224179 5 6 Reviewed by Darin Adler. 7 8 Make BidiContext ThreadSafeRefCounted and make shared context creation 9 thread-safe. This is needed by OffscreenCanvas to use text in Workers. 10 11 No new tests, covered by existing tests. 12 13 * platform/text/BidiContext.cpp: 14 (WebCore::BidiContext::create): 15 * platform/text/BidiContext.h: 16 1 17 2021-04-06 Frédéric Wang <fwang@igalia.com> 2 18 -
trunk/Source/WebCore/platform/text/BidiContext.cpp
r210492 r275500 27 27 namespace WebCore { 28 28 29 struct SameSizeAsBidiContext : public RefCounted<SameSizeAsBidiContext> {29 struct SameSizeAsBidiContext : public ThreadSafeRefCounted<SameSizeAsBidiContext> { 30 30 uint32_t bitfields : 16; 31 31 void* parent; … … 58 58 if (!level) { 59 59 if (!override) { 60 static BidiContext& ltrContext = createUncached(0, U_LEFT_TO_RIGHT, false, FromStyleOrDOM, 0).leakRef(); 61 return ltrContext; 60 static NeverDestroyed<RefPtr<BidiContext>> ltrContext; 61 static std::once_flag ltrContextOnceFlag; 62 std::call_once(ltrContextOnceFlag, [&]() { 63 ltrContext.get() = createUncached(0, U_LEFT_TO_RIGHT, false, FromStyleOrDOM, 0); 64 }); 65 return *ltrContext.get(); 62 66 } 63 67 64 static BidiContext& ltrOverrideContext = createUncached(0, U_LEFT_TO_RIGHT, true, FromStyleOrDOM, 0).leakRef(); 65 return ltrOverrideContext; 68 static NeverDestroyed<RefPtr<BidiContext>> ltrOverrideContext; 69 static std::once_flag ltrOverrideContextOnceFlag; 70 std::call_once(ltrOverrideContextOnceFlag, [&]() { 71 ltrOverrideContext.get() = createUncached(0, U_LEFT_TO_RIGHT, true, FromStyleOrDOM, 0); 72 }); 73 return *ltrOverrideContext.get(); 66 74 } 67 75 68 76 if (!override) { 69 static BidiContext& rtlContext = createUncached(1, U_RIGHT_TO_LEFT, false, FromStyleOrDOM, 0).leakRef(); 70 return rtlContext; 77 static NeverDestroyed<RefPtr<BidiContext>> rtlContext; 78 static std::once_flag rtlContextOnceFlag; 79 std::call_once(rtlContextOnceFlag, [&]() { 80 rtlContext.get() = createUncached(1, U_RIGHT_TO_LEFT, false, FromStyleOrDOM, 0); 81 }); 82 return *rtlContext.get(); 71 83 } 72 84 73 static BidiContext& rtlOverrideContext = createUncached(1, U_RIGHT_TO_LEFT, true, FromStyleOrDOM, 0).leakRef(); 74 return rtlOverrideContext; 85 static NeverDestroyed<RefPtr<BidiContext>> rtlOverrideContext; 86 static std::once_flag rtlOverrideContextOnceFlag; 87 std::call_once(rtlOverrideContextOnceFlag, [&]() { 88 rtlOverrideContext.get() = createUncached(1, U_RIGHT_TO_LEFT, true, FromStyleOrDOM, 0); 89 }); 90 return *rtlOverrideContext.get(); 75 91 } 76 92 -
trunk/Source/WebCore/platform/text/BidiContext.h
r210492 r275500 23 23 24 24 #include <unicode/uchar.h> 25 #include <wtf/RefCounted.h>26 25 #include <wtf/RefPtr.h> 26 #include <wtf/ThreadSafeRefCounted.h> 27 27 28 28 namespace WebCore { … … 31 31 32 32 // Used to keep track of explicit embeddings. 33 class BidiContext : public RefCounted<BidiContext> {33 class BidiContext : public ThreadSafeRefCounted<BidiContext> { 34 34 public: 35 35 WEBCORE_EXPORT static Ref<BidiContext> create(unsigned char level, UCharDirection, bool override = false, BidiEmbeddingSource = FromStyleOrDOM, BidiContext* parent = nullptr);
Note: See TracChangeset
for help on using the changeset viewer.