Clean up interface to Font::expansionOpportunityCount()
[WebKit-https.git] / Source / WebCore / platform / graphics / Font.cpp
index 5ec424ac6b4cd4ccd93a6a7ae5dccafbc3181938..a5b4d12c3b81c6fbe8a9b8f95109958a12a61e98 100644 (file)
@@ -968,7 +968,7 @@ bool Font::isCJKIdeographOrSymbol(UChar32 c)
     return isCJKIdeograph(c);
 }
 
-unsigned Font::expansionOpportunityCount(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion)
+unsigned Font::expansionOpportunityCountInternal(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion)
 {
     unsigned count = 0;
     if (direction == LTR) {
@@ -991,7 +991,7 @@ unsigned Font::expansionOpportunityCount(const LChar* characters, size_t length,
     return count;
 }
 
-unsigned Font::expansionOpportunityCount(const UChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion)
+unsigned Font::expansionOpportunityCountInternal(const UChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion)
 {
     static bool expandAroundIdeographs = canExpandAroundIdeographsInComplexText();
     unsigned count = 0;
@@ -1041,6 +1041,13 @@ unsigned Font::expansionOpportunityCount(const UChar* characters, size_t length,
     return count;
 }
 
+unsigned Font::expansionOpportunityCount(const StringView& stringView, TextDirection direction, bool& isAfterExpansion)
+{
+    if (stringView.is8Bit())
+        return expansionOpportunityCountInternal(stringView.characters8(), stringView.length(), direction, isAfterExpansion);
+    return expansionOpportunityCountInternal(stringView.characters16(), stringView.length(), direction, isAfterExpansion);
+}
+
 bool Font::canReceiveTextEmphasis(UChar32 c)
 {
     if (U_GET_GC_MASK(c) & (U_GC_Z_MASK | U_GC_CN_MASK | U_GC_CC_MASK | U_GC_CF_MASK))