Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (265352 => 265353)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-06 23:39:31 UTC (rev 265352)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-06 23:46:49 UTC (rev 265353)
@@ -372,7 +372,7 @@
complexIterator.advance(run.length(), nullptr, IncludePartialGlyphs, fallbackFonts);
totalWidth = complexIterator.runWidthSoFar();
} else {
- WidthIterator simpleIterator(this, run, fallbackFonts);
+ WidthIterator simpleIterator(*this, run, fallbackFonts);
simpleIterator.advance(from, nullptr);
offsetBeforeRange = simpleIterator.runWidthSoFar();
simpleIterator.advance(to, nullptr);
@@ -1372,7 +1372,7 @@
{
GlyphBuffer glyphBuffer;
- WidthIterator it(this, run, 0, false, forTextEmphasis);
+ WidthIterator it(*this, run, 0, false, forTextEmphasis);
// FIXME: Using separate glyph buffers for the prefix and the suffix is incorrect when kerning or
// ligatures are enabled.
GlyphBuffer localGlyphBuffer;
@@ -1521,7 +1521,7 @@
float FontCascade::floatWidthForSimpleText(const TextRun& run, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
- WidthIterator it(this, run, fallbackFonts, glyphOverflow);
+ WidthIterator it(*this, run, fallbackFonts, glyphOverflow);
GlyphBuffer glyphBuffer;
it.advance(run.length(), (enableKerning() || requiresShaping()) ? &glyphBuffer : nullptr);
@@ -1550,7 +1550,7 @@
void FontCascade::adjustSelectionRectForSimpleText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const
{
GlyphBuffer glyphBuffer;
- WidthIterator it(this, run);
+ WidthIterator it(*this, run);
it.advance(from, &glyphBuffer);
float beforeWidth = it.runWidthSoFar();
it.advance(to, &glyphBuffer);
@@ -1584,7 +1584,7 @@
{
float delta = x;
- WidthIterator it(this, run);
+ WidthIterator it(*this, run);
GlyphBuffer localGlyphBuffer;
unsigned offset;
if (run.rtl()) {
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (265352 => 265353)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-08-06 23:39:31 UTC (rev 265352)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-08-06 23:46:49 UTC (rev 265353)
@@ -34,7 +34,7 @@
using namespace WTF::Unicode;
-WidthIterator::WidthIterator(const FontCascade* font, const TextRun& run, HashSet<const Font*>* fallbackFonts, bool accountForGlyphBounds, bool forTextEmphasis)
+WidthIterator::WidthIterator(const FontCascade& font, const TextRun& run, HashSet<const Font*>* fallbackFonts, bool accountForGlyphBounds, bool forTextEmphasis)
: m_font(font)
, m_run(run)
, m_fallbackFonts(fallbackFonts)
@@ -41,8 +41,8 @@
, m_expansion(run.expansion())
, m_isAfterExpansion((run.expansionBehavior() & LeftExpansionMask) == ForbidLeftExpansion)
, m_accountForGlyphBounds(accountForGlyphBounds)
- , m_enableKerning(font->enableKerning())
- , m_requiresShaping(font->requiresShaping())
+ , m_enableKerning(font.enableKerning())
+ , m_requiresShaping(font.requiresShaping())
, m_forTextEmphasis(forTextEmphasis)
{
if (!m_expansion)
@@ -85,7 +85,7 @@
return TransformsType::NotForced;
}
-inline float WidthIterator::applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, unsigned& lastGlyphCount, const Font* font, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace& charactersTreatedAsSpace)
+inline float WidthIterator::applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, unsigned& lastGlyphCount, const Font& font, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace& charactersTreatedAsSpace)
{
ASSERT_UNUSED(previousCharacter, shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter) != WidthIterator::TransformsType::None);
@@ -107,7 +107,7 @@
if (!ltr)
glyphBuffer->reverse(lastGlyphCount, glyphBufferSize - lastGlyphCount);
- font->applyTransforms(*glyphBuffer, lastGlyphCount, m_enableKerning, m_requiresShaping, m_font->fontDescription().computedLocale());
+ font.applyTransforms(*glyphBuffer, lastGlyphCount, m_enableKerning, m_requiresShaping, m_font.fontDescription().computedLocale());
glyphBufferSize = glyphBuffer->size();
for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i)
@@ -173,7 +173,7 @@
{
// The core logic here needs to match SimpleLineLayout::widthForSimpleText()
bool rtl = m_run.rtl();
- bool hasExtraSpacing = (m_font->letterSpacing() || m_font->wordSpacing() || m_expansion) && !m_run.spacingDisabled();
+ bool hasExtraSpacing = (m_font.letterSpacing() || m_font.wordSpacing() || m_expansion) && !m_run.spacingDisabled();
bool runForcesLeftExpansion = (m_run.expansionBehavior() & LeftExpansionMask) == ForceLeftExpansion;
bool runForcesRightExpansion = (m_run.expansionBehavior() & RightExpansionMask) == ForceRightExpansion;
@@ -187,7 +187,7 @@
float lastRoundingWidth = m_finalRoundingWidth;
FloatRect bounds;
- const Font& primaryFont = m_font->primaryFont();
+ const Font& primaryFont = m_font.primaryFont();
const Font* lastFontData = &primaryFont;
unsigned lastGlyphCount = glyphBuffer ? glyphBuffer->size() : 0;
@@ -209,19 +209,19 @@
}
#endif
int currentCharacterIndex = textIterator.currentIndex();
- const GlyphData& glyphData = m_font->glyphDataForCharacter(character, rtl);
+ const GlyphData& glyphData = m_font.glyphDataForCharacter(character, rtl);
Glyph glyph = glyphData.glyph;
if (!glyph && !characterMustDrawSomething) {
textIterator.advance(advanceLength);
continue;
}
- const Font* font = glyphData.font ? glyphData.font : &m_font->primaryFont();
+ const Font* font = glyphData.font ? glyphData.font : &m_font.primaryFont();
ASSERT(font);
// Now that we have a glyph and font data, get its width.
float width;
if (character == '\t' && m_run.allowTabs())
- width = m_font->tabWidth(*font, m_run.tabSize(), m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding);
+ width = m_font.tabWidth(*font, m_run.tabSize(), m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding);
else {
width = font->widthForGlyph(glyph);
@@ -232,7 +232,7 @@
if (font != lastFontData && width) {
auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
if (transformsType != TransformsType::None) {
- m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
+ m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, *lastFontData, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
if (glyphBuffer)
glyphBuffer->shrink(lastGlyphCount);
}
@@ -241,10 +241,10 @@
if (m_fallbackFonts && font != &primaryFont) {
// FIXME: This does a little extra work that could be avoided if
// glyphDataForCharacter() returned whether it chose to use a small caps font.
- if (!m_font->isSmallCaps() || character == u_toupper(character))
+ if (!m_font.isSmallCaps() || character == u_toupper(character))
m_fallbackFonts->add(font);
else {
- const GlyphData& uppercaseGlyphData = m_font->glyphDataForCharacter(u_toupper(character), rtl);
+ const GlyphData& uppercaseGlyphData = m_font.glyphDataForCharacter(u_toupper(character), rtl);
if (uppercaseGlyphData.font != &primaryFont)
m_fallbackFonts->add(uppercaseGlyphData.font);
}
@@ -254,7 +254,7 @@
if (hasExtraSpacing) {
// Account for letter-spacing.
if (width) {
- width += m_font->letterSpacing();
+ width += m_font.letterSpacing();
width += leftoverJustificationWidth;
leftoverJustificationWidth = 0;
}
@@ -310,8 +310,8 @@
// Account for word spacing.
// We apply additional space between "words" by adding width to the space character.
- if (treatAsSpace && (character != '\t' || !m_run.allowTabs()) && (currentCharacterIndex || character == noBreakSpace) && m_font->wordSpacing())
- width += m_font->wordSpacing();
+ if (treatAsSpace && (character != '\t' || !m_run.allowTabs()) && (currentCharacterIndex || character == noBreakSpace) && m_font.wordSpacing())
+ width += m_font.wordSpacing();
} else
m_isAfterExpansion = false;
}
@@ -360,7 +360,7 @@
auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
if (transformsType != TransformsType::None) {
- m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
+ m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, *lastFontData, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
if (glyphBuffer)
glyphBuffer->shrink(lastGlyphCount);
}
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.h (265352 => 265353)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.h 2020-08-06 23:39:31 UTC (rev 265352)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.h 2020-08-06 23:46:49 UTC (rev 265353)
@@ -40,7 +40,7 @@
struct WidthIterator {
WTF_MAKE_FAST_ALLOCATED;
public:
- WidthIterator(const FontCascade*, const TextRun&, HashSet<const Font*>* fallbackFonts = 0, bool accountForGlyphBounds = false, bool forTextEmphasis = false);
+ WidthIterator(const FontCascade&, const TextRun&, HashSet<const Font*>* fallbackFonts = 0, bool accountForGlyphBounds = false, bool forTextEmphasis = false);
void advance(unsigned to, GlyphBuffer*);
bool advanceOneCharacter(float& width, GlyphBuffer&);
@@ -62,9 +62,9 @@
enum class TransformsType { None, Forced, NotForced };
TransformsType shouldApplyFontTransforms(const GlyphBuffer*, unsigned lastGlyphCount, UChar32 previousCharacter) const;
- float applyFontTransforms(GlyphBuffer*, bool ltr, unsigned& lastGlyphCount, const Font*, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace&);
+ float applyFontTransforms(GlyphBuffer*, bool ltr, unsigned& lastGlyphCount, const Font&, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace&);
- const FontCascade* m_font;
+ const FontCascade& m_font;
const TextRun& m_run;
HashSet<const Font*>* m_fallbackFonts { nullptr };