Skip to content

Commit

Permalink
Replace enum by enum class in ComplexTextController
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273263
rdar://127064972

Reviewed by Matthieu Dubet.

This is the last "enum" use ComplexTextController.
We are replacing it by enum class here.

* Source/WebCore/platform/graphics/ComplexTextController.cpp:
(WebCore::TextLayout::width):
(WebCore::ComplexTextController::runWidthSoFarFraction const):
* Source/WebCore/platform/graphics/ComplexTextController.h:
* Source/WebCore/platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::widthOfTextRange const):

Canonical link: https://commits.webkit.org/278004@main
  • Loading branch information
vitorroriz committed Apr 25, 2024
1 parent 4762be1 commit 461df4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Source/WebCore/platform/graphics/ComplexTextController.cpp
Expand Up @@ -62,11 +62,11 @@ class TextLayout {

float width(unsigned from, unsigned len, SingleThreadWeakHashSet<const Font>* fallbackFonts)
{
m_controller->advance(from, 0, ByWholeGlyphs, fallbackFonts);
m_controller->advance(from, 0, GlyphIterationStyle::ByWholeGlyphs, fallbackFonts);
float beforeWidth = m_controller->runWidthSoFar();
if (m_font.wordSpacing() && from && FontCascade::treatAsSpace(m_run[from]))
beforeWidth += m_font.wordSpacing();
m_controller->advance(from + len, 0, ByWholeGlyphs, fallbackFonts);
m_controller->advance(from + len, 0, GlyphIterationStyle::ByWholeGlyphs, fallbackFonts);
float afterWidth = m_controller->runWidthSoFar();
return afterWidth - beforeWidth;
}
Expand Down Expand Up @@ -494,7 +494,7 @@ float ComplexTextController::runWidthSoFarFraction(unsigned glyphStartOffset, un
return 1;
}

if (iterationStyle == ByWholeGlyphs) {
if (iterationStyle == GlyphIterationStyle::ByWholeGlyphs) {
if (!oldCharacterInCurrentGlyph)
return 1;
return 0;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/ComplexTextController.h
Expand Up @@ -50,7 +50,7 @@ class FontCascade;
class Font;
class TextRun;

enum GlyphIterationStyle { IncludePartialGlyphs, ByWholeGlyphs };
enum class GlyphIterationStyle : bool { IncludePartialGlyphs, ByWholeGlyphs };

// See https://trac.webkit.org/wiki/ComplexTextController for more information about ComplexTextController.
class ComplexTextController {
Expand All @@ -62,7 +62,7 @@ class ComplexTextController {
WEBCORE_EXPORT ComplexTextController(const FontCascade&, const TextRun&, Vector<Ref<ComplexTextRun>>&);

// Advance and emit glyphs up to the specified character.
WEBCORE_EXPORT void advance(unsigned to, GlyphBuffer* = nullptr, GlyphIterationStyle = IncludePartialGlyphs, SingleThreadWeakHashSet<const Font>* fallbackFonts = nullptr);
WEBCORE_EXPORT void advance(unsigned to, GlyphBuffer* = nullptr, GlyphIterationStyle = GlyphIterationStyle::IncludePartialGlyphs, SingleThreadWeakHashSet<const Font>* fallbackFonts = nullptr);

// Compute the character offset for a given x coordinate.
unsigned offsetForPosition(float x, bool includePartialGlyphs);
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/platform/graphics/FontCascade.cpp
Expand Up @@ -263,11 +263,11 @@ float FontCascade::widthOfTextRange(const TextRun& run, unsigned from, unsigned
auto codePathToUse = codePath(run);
if (codePathToUse == CodePath::Complex) {
ComplexTextController complexIterator(*this, run, false, fallbackFonts);
complexIterator.advance(from, nullptr, IncludePartialGlyphs, fallbackFonts);
complexIterator.advance(from, nullptr, GlyphIterationStyle::IncludePartialGlyphs, fallbackFonts);
offsetBeforeRange = complexIterator.runWidthSoFar();
complexIterator.advance(to, nullptr, IncludePartialGlyphs, fallbackFonts);
complexIterator.advance(to, nullptr, GlyphIterationStyle::IncludePartialGlyphs, fallbackFonts);
offsetAfterRange = complexIterator.runWidthSoFar();
complexIterator.advance(run.length(), nullptr, IncludePartialGlyphs, fallbackFonts);
complexIterator.advance(run.length(), nullptr, GlyphIterationStyle::IncludePartialGlyphs, fallbackFonts);
totalWidth = complexIterator.runWidthSoFar();
} else {
WidthIterator simpleIterator(*this, run, fallbackFonts);
Expand Down

0 comments on commit 461df4d

Please sign in to comment.