Title: [286637] trunk/Source/WebCore
Revision
286637
Author
[email protected]
Date
2021-12-07 18:11:05 -0800 (Tue, 07 Dec 2021)

Log Message

Remove expandAroundIdeographs static variables
https://bugs.webkit.org/show_bug.cgi?id=233750

Reviewed by Myles Maxfield.

With OffscreenCanvas, we can call into
ComplexTextController::adjustGlyphsAndAdvances,
FontCascade::expansionOpportunityCountInternal, and
WidthIterator::calculateAdditionalWidth from worker threads.
These all have a static variable variable with an initializer
that calls FontCascade::canExpandAroundIdeographsInComplexText,
and such initializers are not safe under -fno-threadsafe-statics.

canExpandAroundIdeographsInComplexText is a simple enough function in
all ports (it just returns a constant bool) that it's not worth caching
the result in a static.

* platform/graphics/ComplexTextController.cpp:
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::expansionOpportunityCountInternal):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::calculateAdditionalWidth const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286636 => 286637)


--- trunk/Source/WebCore/ChangeLog	2021-12-08 02:09:34 UTC (rev 286636)
+++ trunk/Source/WebCore/ChangeLog	2021-12-08 02:11:05 UTC (rev 286637)
@@ -1,5 +1,31 @@
 2021-12-07  Cameron McCormack  <[email protected]>
 
+        Remove expandAroundIdeographs static variables
+        https://bugs.webkit.org/show_bug.cgi?id=233750
+
+        Reviewed by Myles Maxfield.
+
+        With OffscreenCanvas, we can call into
+        ComplexTextController::adjustGlyphsAndAdvances,
+        FontCascade::expansionOpportunityCountInternal, and
+        WidthIterator::calculateAdditionalWidth from worker threads.
+        These all have a static variable variable with an initializer
+        that calls FontCascade::canExpandAroundIdeographsInComplexText,
+        and such initializers are not safe under -fno-threadsafe-statics.
+
+        canExpandAroundIdeographsInComplexText is a simple enough function in
+        all ports (it just returns a constant bool) that it's not worth caching
+        the result in a static.
+
+        * platform/graphics/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::FontCascade::expansionOpportunityCountInternal):
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::calculateAdditionalWidth const):
+
+2021-12-07  Cameron McCormack  <[email protected]>
+
         Move shouldAutoActivateFontIfNeeded knownFamilies cache to FontCache
         https://bugs.webkit.org/show_bug.cgi?id=233749
 

Modified: trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp (286636 => 286637)


--- trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp	2021-12-08 02:09:34 UTC (rev 286636)
+++ trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp	2021-12-08 02:11:05 UTC (rev 286637)
@@ -752,8 +752,7 @@
                 if (runForbidsRightExpansion)
                     forbidRightExpansion = m_run.ltr() ? isLastCharacter : isFirstCharacter;
                 // Handle justification and word-spacing.
-                static bool expandAroundIdeographs = FontCascade::canExpandAroundIdeographsInComplexText();
-                bool ideograph = expandAroundIdeographs && FontCascade::isCJKIdeographOrSymbol(ch);
+                bool ideograph = FontCascade::canExpandAroundIdeographsInComplexText() && FontCascade::isCJKIdeographOrSymbol(ch);
                 if (treatAsSpace || ideograph || forceLeftExpansion || forceRightExpansion) {
                     // Distribute the run's total expansion evenly over all expansion opportunities in the run.
                     if (m_expansion) {

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (286636 => 286637)


--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2021-12-08 02:09:34 UTC (rev 286636)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2021-12-08 02:11:05 UTC (rev 286637)
@@ -1001,7 +1001,6 @@
 
 std::pair<unsigned, bool> FontCascade::expansionOpportunityCountInternal(const UChar* characters, unsigned length, TextDirection direction, ExpansionBehavior expansionBehavior)
 {
-    static bool expandAroundIdeographs = canExpandAroundIdeographsInComplexText();
     unsigned count = 0;
     bool isAfterExpansion = (expansionBehavior & LeftExpansionMask) == ForbidLeftExpansion;
     if ((expansionBehavior & LeftExpansionMask) == ForceLeftExpansion) {
@@ -1020,7 +1019,7 @@
                 character = U16_GET_SUPPLEMENTARY(character, characters[i + 1]);
                 i++;
             }
-            if (expandAroundIdeographs && isCJKIdeographOrSymbol(character)) {
+            if (canExpandAroundIdeographsInComplexText() && isCJKIdeographOrSymbol(character)) {
                 if (!isAfterExpansion)
                     count++;
                 count++;
@@ -1041,7 +1040,7 @@
                 character = U16_GET_SUPPLEMENTARY(characters[i - 2], character);
                 i--;
             }
-            if (expandAroundIdeographs && isCJKIdeographOrSymbol(character)) {
+            if (canExpandAroundIdeographsInComplexText() && isCJKIdeographOrSymbol(character)) {
                 if (!isAfterExpansion)
                     count++;
                 count++;

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (286636 => 286637)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2021-12-08 02:09:34 UTC (rev 286636)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2021-12-08 02:11:05 UTC (rev 286637)
@@ -390,8 +390,7 @@
             bool forbidLeftExpansion = isLeftmostCharacter && (m_run.expansionBehavior() & LeftExpansionMask) == ForbidLeftExpansion;
             bool forbidRightExpansion = isRightmostCharacter && (m_run.expansionBehavior() & RightExpansionMask) == ForbidRightExpansion;
 
-            static const bool expandAroundIdeographs = FontCascade::canExpandAroundIdeographsInComplexText();
-            bool isIdeograph = expandAroundIdeographs && FontCascade::isCJKIdeographOrSymbol(character);
+            bool isIdeograph = FontCascade::canExpandAroundIdeographsInComplexText() && FontCascade::isCJKIdeographOrSymbol(character);
 
             if (treatAsSpace || isIdeograph || forceLeftExpansion || forceRightExpansion) {
                 auto [expandLeft, expandRight] = expansionLocation(isIdeograph, treatAsSpace, m_run.ltr(), m_isAfterExpansion, forbidLeftExpansion, forbidRightExpansion, forceLeftExpansion, forceRightExpansion);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to