Diff
Modified: trunk/Source/WebCore/ChangeLog (265410 => 265411)
--- trunk/Source/WebCore/ChangeLog 2020-08-09 03:23:25 UTC (rev 265410)
+++ trunk/Source/WebCore/ChangeLog 2020-08-09 03:57:08 UTC (rev 265411)
@@ -1,3 +1,37 @@
+2020-08-08 Myles C. Maxfield <[email protected]>
+
+ Use references instead of pointers for GlyphBuffer::add()'s Font argument
+ https://bugs.webkit.org/show_bug.cgi?id=215309
+
+ Reviewed by Darin Adler.
+
+ They're not allowed to be null.
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/ComplexTextController.cpp:
+ (WebCore::ComplexTextController::advance):
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::widthForSimpleText const):
+ (WebCore::FontCascade::drawGlyphBuffer const):
+ (WebCore::offsetToMiddleOfGlyph):
+ (WebCore::FontCascade::drawEmphasisMarks const):
+ (WebCore::GlyphToPathTranslator::GlyphToPathTranslator):
+ (WebCore::GlyphToPathTranslator::advance):
+ (WebCore::FontCascade::dashesForIntersectionsWithRect const):
+ * platform/graphics/GlyphBuffer.h:
+ (WebCore::GlyphBuffer::fontAt const):
+ (WebCore::GlyphBuffer::add):
+ * platform/graphics/WidthIterator.cpp:
+ (WebCore::WidthIterator::advanceInternal):
+ * platform/graphics/displaylists/DisplayListItems.cpp:
+ (WebCore::DisplayList::DrawGlyphs::generateGlyphBuffer const):
+ * rendering/mathml/MathOperator.cpp:
+ (WebCore::MathOperator::paintGlyph):
+ (WebCore::MathOperator::paint):
+ * rendering/mathml/RenderMathMLToken.cpp:
+ (WebCore::RenderMathMLToken::paint):
+
2020-08-07 Chris Dumez <[email protected]>
AudioContext / OfflineAudioContext should support a wider sample rate range
Modified: trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp (265410 => 265411)
--- trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp 2020-08-09 03:23:25 UTC (rev 265410)
+++ trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp 2020-08-09 03:57:08 UTC (rev 265411)
@@ -621,7 +621,7 @@
paintAdvance.setHeight(paintAdvance.height() - glyphOrigin(glyphIndexIntoComplexTextController + 1).y() + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().height());
}
paintAdvance.setHeight(-paintAdvance.height()); // Increasing y points down
- glyphBuffer->add(m_adjustedGlyphs[glyphIndexIntoComplexTextController], &complexTextRun.font(), paintAdvance, complexTextRun.indexAt(m_glyphInCurrentRun));
+ glyphBuffer->add(m_adjustedGlyphs[glyphIndexIntoComplexTextController], complexTextRun.font(), paintAdvance, complexTextRun.indexAt(m_glyphInCurrentRun));
}
unsigned oldCharacterInCurrentGlyph = m_characterInCurrentGlyph;
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (265410 => 265411)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-09 03:23:25 UTC (rev 265410)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-09 03:57:08 UTC (rev 265411)
@@ -444,7 +444,7 @@
runWidth += glyphWidth;
if (!hasKerningOrLigatures)
continue;
- glyphBuffer.add(glyph, &font, glyphWidth);
+ glyphBuffer.add(glyph, font, glyphWidth);
}
if (hasKerningOrLigatures) {
font.applyTransforms(glyphBuffer, 0, enableKerning(), requiresShaping(), fontDescription().computedLocale());
@@ -1446,7 +1446,7 @@
void FontCascade::drawGlyphBuffer(GraphicsContext& context, const GlyphBuffer& glyphBuffer, FloatPoint& point, CustomFontNotReadyAction customFontNotReadyAction) const
{
ASSERT(glyphBuffer.isFlattened());
- const Font* fontData = glyphBuffer.fontAt(0);
+ const Font* fontData = &glyphBuffer.fontAt(0);
FloatPoint startPoint = point;
float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width();
float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height();
@@ -1453,14 +1453,14 @@
unsigned lastFrom = 0;
unsigned nextGlyph = 1;
while (nextGlyph < glyphBuffer.size()) {
- const Font* nextFontData = glyphBuffer.fontAt(nextGlyph);
+ const Font& nextFontData = glyphBuffer.fontAt(nextGlyph);
- if (nextFontData != fontData) {
+ if (&nextFontData != fontData) {
if (shouldDrawIfLoading(*fontData, customFontNotReadyAction))
context.drawGlyphs(*fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint, m_fontDescription.fontSmoothing());
lastFrom = nextGlyph;
- fontData = nextFontData;
+ fontData = &nextFontData;
startPoint.setX(nextX);
startPoint.setY(nextY);
}
@@ -1474,14 +1474,14 @@
point.setX(nextX);
}
-inline static float offsetToMiddleOfGlyph(const Font* fontData, Glyph glyph)
+inline static float offsetToMiddleOfGlyph(const Font& fontData, Glyph glyph)
{
- if (fontData->platformData().orientation() == FontOrientation::Horizontal) {
- FloatRect bounds = fontData->boundsForGlyph(glyph);
+ if (fontData.platformData().orientation() == FontOrientation::Horizontal) {
+ FloatRect bounds = fontData.boundsForGlyph(glyph);
return bounds.x() + bounds.width() / 2;
}
// FIXME: Use glyph bounds once they make sense for vertical fonts.
- return fontData->widthForGlyph(glyph) / 2;
+ return fontData.widthForGlyph(glyph) / 2;
}
inline static float offsetToMiddleOfGlyphAtIndex(const GlyphBuffer& glyphBuffer, unsigned i)
@@ -1505,16 +1505,16 @@
Glyph spaceGlyph = markFontData->spaceGlyph();
float middleOfLastGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, 0);
- FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph(markFontData, markGlyph), point.y());
+ FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph(*markFontData, markGlyph), point.y());
GlyphBuffer markBuffer;
for (unsigned i = 0; i + 1 < glyphBuffer.size(); ++i) {
float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1);
float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph;
- markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFontData, advance);
+ markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, *markFontData, advance);
middleOfLastGlyph = middleOfNextGlyph;
}
- markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spaceGlyph, markFontData, 0);
+ markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spaceGlyph, *markFontData, 0);
drawGlyphBuffer(context, markBuffer, startPoint, CustomFontNotReadyAction::DoNotPaintIfFontNotReady);
}
@@ -1717,7 +1717,7 @@
: m_index(0)
, m_textRun(textRun)
, m_glyphBuffer(glyphBuffer)
- , m_fontData(glyphBuffer.fontAt(m_index))
+ , m_fontData(&glyphBuffer.fontAt(m_index))
, m_translation(AffineTransform::translation(textOrigin.x(), textOrigin.y()))
{
#if USE(CG)
@@ -1765,7 +1765,7 @@
m_translation.translate(FloatSize(advance.width(), advance.height()));
++m_index;
if (m_index < m_glyphBuffer.size())
- m_fontData = m_glyphBuffer.fontAt(m_index);
+ m_fontData = &m_glyphBuffer.fontAt(m_index);
}
DashArray FontCascade::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
@@ -1783,12 +1783,6 @@
DashArray result;
for (unsigned index = 0; translator.containsMorePaths(); ++index, translator.advance()) {
GlyphIterationState info = { FloatPoint(0, 0), FloatPoint(0, 0), lineExtents.y(), lineExtents.y() + lineExtents.height(), lineExtents.x() + lineExtents.width(), lineExtents.x() };
- const Font* localFont = glyphBuffer.fontAt(index);
- if (!localFont) {
- // The advances will get all messed up if we do anything other than bail here.
- result.clear();
- break;
- }
switch (translator.underlineType()) {
case GlyphUnderlineType::SkipDescenders: {
Path path = translator.path();
Modified: trunk/Source/WebCore/platform/graphics/GlyphBuffer.h (265410 => 265411)
--- trunk/Source/WebCore/platform/graphics/GlyphBuffer.h 2020-08-09 03:23:25 UTC (rev 265410)
+++ trunk/Source/WebCore/platform/graphics/GlyphBuffer.h 2020-08-09 03:57:08 UTC (rev 265411)
@@ -191,7 +191,11 @@
const GlyphBufferOrigin* origins(unsigned from) const { return m_origins.data() + from; }
const GlyphBufferStringOffset* offsetsInString(unsigned from) const { return m_offsetsInString.data() + from; }
- const Font* fontAt(unsigned index) const { return m_fonts[index]; }
+ const Font& fontAt(unsigned index) const
+ {
+ ASSERT(m_fonts[index]);
+ return *m_fonts[index];
+ }
Glyph glyphAt(unsigned index) const { return m_glyphs[index]; }
GlyphBufferAdvance advanceAt(unsigned index) const { return m_advances[index]; }
GlyphBufferStringOffset stringOffsetAt(unsigned index) const { return m_offsetsInString[index]; }
@@ -200,7 +204,7 @@
const GlyphBufferAdvance& initialAdvance() const { return m_initialAdvance; }
static constexpr GlyphBufferStringOffset noOffset = std::numeric_limits<GlyphBufferStringOffset>::max();
- void add(Glyph glyph, const Font* font, float width, GlyphBufferStringOffset offsetInString = noOffset)
+ void add(Glyph glyph, const Font& font, float width, GlyphBufferStringOffset offsetInString = noOffset)
{
GlyphBufferAdvance advance;
advance.setWidth(width);
@@ -208,9 +212,9 @@
add(glyph, font, advance, offsetInString);
}
- void add(Glyph glyph, const Font* font, GlyphBufferAdvance advance, GlyphBufferStringOffset offsetInString)
+ void add(Glyph glyph, const Font& font, GlyphBufferAdvance advance, GlyphBufferStringOffset offsetInString)
{
- m_fonts.append(font);
+ m_fonts.append(&font);
m_glyphs.append(glyph);
m_advances.append(advance);
m_origins.append(GlyphBufferOrigin());
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (265410 => 265411)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-08-09 03:23:25 UTC (rev 265410)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-08-09 03:57:08 UTC (rev 265411)
@@ -287,9 +287,9 @@
if (glyphBuffer) {
if (glyphBuffer->isEmpty()) {
if (m_forTextEmphasis)
- glyphBuffer->add(font->zeroWidthSpaceGlyph(), font, m_expansionPerOpportunity, currentCharacterIndex);
+ glyphBuffer->add(font->zeroWidthSpaceGlyph(), *font, m_expansionPerOpportunity, currentCharacterIndex);
else
- glyphBuffer->add(font->spaceGlyph(), font, m_expansionPerOpportunity, currentCharacterIndex);
+ glyphBuffer->add(font->spaceGlyph(), *font, m_expansionPerOpportunity, currentCharacterIndex);
} else
glyphBuffer->expandLastAdvance(m_expansionPerOpportunity);
}
@@ -339,7 +339,7 @@
widthSinceLastRounding += width;
if (glyphBuffer)
- glyphBuffer->add(glyph, font, (rtl ? oldWidth + lastRoundingWidth : width), currentCharacterIndex);
+ glyphBuffer->add(glyph, *font, (rtl ? oldWidth + lastRoundingWidth : width), currentCharacterIndex);
lastRoundingWidth = width - oldWidth;
@@ -353,9 +353,9 @@
if (glyphBuffer && leftoverJustificationWidth) {
if (m_forTextEmphasis)
- glyphBuffer->add(lastFontData->zeroWidthSpaceGlyph(), lastFontData, leftoverJustificationWidth, m_run.length() - 1);
+ glyphBuffer->add(lastFontData->zeroWidthSpaceGlyph(), *lastFontData, leftoverJustificationWidth, m_run.length() - 1);
else
- glyphBuffer->add(lastFontData->spaceGlyph(), lastFontData, leftoverJustificationWidth, m_run.length() - 1);
+ glyphBuffer->add(lastFontData->spaceGlyph(), *lastFontData, leftoverJustificationWidth, m_run.length() - 1);
}
auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (265410 => 265411)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-08-09 03:23:25 UTC (rev 265410)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-08-09 03:57:08 UTC (rev 265411)
@@ -544,7 +544,7 @@
{
GlyphBuffer result;
for (size_t i = 0; i < m_glyphs.size(); ++i)
- result.add(m_glyphs[i], &m_font.get(), m_advances[i], GlyphBuffer::noOffset);
+ result.add(m_glyphs[i], m_font.get(), m_advances[i], GlyphBuffer::noOffset);
return result;
}
Modified: trunk/Source/WebCore/rendering/mathml/MathOperator.cpp (265410 => 265411)
--- trunk/Source/WebCore/rendering/mathml/MathOperator.cpp 2020-08-09 03:23:25 UTC (rev 265410)
+++ trunk/Source/WebCore/rendering/mathml/MathOperator.cpp 2020-08-09 03:57:08 UTC (rev 265411)
@@ -525,7 +525,7 @@
info.context().clip(clipBounds);
GlyphBuffer buffer;
- buffer.add(data.glyph, data.font, advanceWidthForGlyph(data));
+ buffer.add(data.glyph, *data.font, advanceWidthForGlyph(data));
info.context().drawGlyphs(*data.font, buffer, 0, 1, origin, style.fontCascade().fontDescription().fontSmoothing());
return glyphPaintRect;
@@ -729,7 +729,7 @@
glyphData.glyph = m_variantGlyph;
GlyphBuffer buffer;
- buffer.add(glyphData.glyph, glyphData.font, advanceWidthForGlyph(glyphData));
+ buffer.add(glyphData.glyph, *glyphData.font, advanceWidthForGlyph(glyphData));
LayoutPoint operatorTopLeft = paintOffset;
FloatRect glyphBounds = boundsForGlyph(glyphData);
LayoutPoint operatorOrigin { operatorTopLeft.x(), LayoutUnit(operatorTopLeft.y() - glyphBounds.y()) };
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp (265410 => 265411)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp 2020-08-09 03:23:25 UTC (rev 265410)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp 2020-08-09 03:57:08 UTC (rev 265411)
@@ -607,7 +607,7 @@
info.context().setFillColor(style().visitedDependentColorWithColorFilter(CSSPropertyColor));
GlyphBuffer buffer;
- buffer.add(mathVariantGlyph.glyph, mathVariantGlyph.font, mathVariantGlyph.font->widthForGlyph(mathVariantGlyph.glyph));
+ buffer.add(mathVariantGlyph.glyph, *mathVariantGlyph.font, mathVariantGlyph.font->widthForGlyph(mathVariantGlyph.glyph));
LayoutUnit glyphAscent = static_cast<int>(lroundf(-mathVariantGlyph.font->boundsForGlyph(mathVariantGlyph.glyph).y()));
info.context().drawGlyphs(*mathVariantGlyph.font, buffer, 0, 1, paintOffset + location() + LayoutPoint(0_lu, glyphAscent), style().fontCascade().fontDescription().fontSmoothing());
}