Diff
Modified: trunk/Source/WebCore/ChangeLog (265217 => 265218)
--- trunk/Source/WebCore/ChangeLog 2020-08-03 21:02:49 UTC (rev 265217)
+++ trunk/Source/WebCore/ChangeLog 2020-08-03 21:04:38 UTC (rev 265218)
@@ -1,3 +1,32 @@
+2020-08-03 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Make WidthIterator::advance() return void
+ https://bugs.webkit.org/show_bug.cgi?id=215053
+
+ Reviewed by Darin Adler.
+
+ This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=214769
+ and https://bugs.webkit.org/show_bug.cgi?id=206208.
+
+ This is a small simplification in the fast text codepath. It used to return
+ how many characters were consumed. However, this information is already
+ exposed by just calling currentCharacter() on the width iterator before and
+ after calling advance().
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::drawText const):
+ (WebCore::FontCascade::displayListForTextRun const):
+ (WebCore::FontCascade::layoutSimpleText const):
+ (WebCore::FontCascade::adjustSelectionRectForSimpleText const):
+ * platform/graphics/WidthIterator.cpp:
+ (WebCore::WidthIterator::advanceInternal):
+ (WebCore::WidthIterator::advance):
+ * platform/graphics/WidthIterator.h:
+ * rendering/svg/SVGTextMetricsBuilder.cpp:
+ (WebCore::SVGTextMetricsBuilder::advanceSimpleText):
+
2020-08-03 Youenn Fablet <you...@apple.com>
MediaRecorderPrivateWriter should ensure its writer input is ready for more data before appending new samples
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (265217 => 265218)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-03 21:02:49 UTC (rev 265217)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-03 21:04:38 UTC (rev 265218)
@@ -297,11 +297,11 @@
{
unsigned destination = to.valueOr(run.length());
auto glyphBuffer = layoutText(codePath(run, from, to), run, from, destination);
- FloatPoint startPoint = point + FloatSize(glyphBuffer.initialAdvance());
- // We couldn't generate any glyphs for the run. Give up.
+
if (glyphBuffer.isEmpty())
return 0;
- // Draw the glyph buffer now at the starting point returned in startX.
+
+ FloatPoint startPoint = point + FloatSize(glyphBuffer.initialAdvance());
float oldStartX = startPoint.x();
drawGlyphBuffer(context, glyphBuffer, startPoint, customFontNotReadyAction);
return startPoint.x() - oldStartX;
@@ -334,8 +334,7 @@
codePathToUse = Complex;
auto glyphBuffer = layoutText(codePathToUse, run, from, destination);
- FloatPoint startPoint = toFloatPoint(FloatSize(glyphBuffer.initialAdvance()));
- // We couldn't generate any glyphs for the run. Give up.
+
if (glyphBuffer.isEmpty())
return nullptr;
@@ -344,6 +343,7 @@
return makeUnique<DisplayList::Recorder>(displayListContext, *displayList, context.state(), FloatRect(), AffineTransform());
});
+ FloatPoint startPoint = toFloatPoint(FloatSize(glyphBuffer.initialAdvance()));
drawGlyphBuffer(recordingContext, glyphBuffer, startPoint, customFontNotReadyAction);
return displayList;
}
@@ -1395,6 +1395,7 @@
initialAdvance = finalRoundingWidth + it.runWidthSoFar() - afterWidth;
} else
initialAdvance = beforeWidth;
+ // FIXME: Deal with the GlyphBuffer's current initialAdvance.
glyphBuffer.setInitialAdvance(FloatSize(initialAdvance, 0));
if (run.rtl())
@@ -1558,11 +1559,10 @@
float beforeWidth = it.runWidthSoFar();
it.advance(to, &glyphBuffer);
float afterWidth = it.runWidthSoFar();
- float totalWidth = -1;
if (run.rtl()) {
it.advance(run.length(), &glyphBuffer);
- totalWidth = it.runWidthSoFar();
+ float totalWidth = it.runWidthSoFar();
selectionRect.move(totalWidth - afterWidth, 0);
} else
selectionRect.move(beforeWidth, 0);
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (265217 => 265218)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-08-03 21:02:49 UTC (rev 265217)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-08-03 21:04:38 UTC (rev 265218)
@@ -30,7 +30,6 @@
#include "SurrogatePairAwareTextIterator.h"
#include <wtf/MathExtras.h>
-
namespace WebCore {
using namespace WTF::Unicode;
@@ -170,7 +169,7 @@
}
template <typename TextIterator>
-inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, GlyphBuffer* glyphBuffer)
+inline void WidthIterator::advanceInternal(TextIterator& textIterator, GlyphBuffer* glyphBuffer)
{
// The core logic here needs to match SimpleLineLayout::widthForSimpleText()
bool rtl = m_run.rtl();
@@ -366,14 +365,12 @@
glyphBuffer->shrink(lastGlyphCount);
}
- unsigned consumedCharacters = textIterator.currentIndex() - m_currentCharacter;
m_currentCharacter = textIterator.currentIndex();
m_runWidthSoFar += widthSinceLastRounding;
m_finalRoundingWidth = lastRoundingWidth;
- return consumedCharacters;
}
-unsigned WidthIterator::advance(unsigned offset, GlyphBuffer* glyphBuffer)
+void WidthIterator::advance(unsigned offset, GlyphBuffer* glyphBuffer)
{
unsigned length = m_run.length();
@@ -381,15 +378,16 @@
offset = length;
if (m_currentCharacter >= offset)
- return 0;
+ return;
if (m_run.is8Bit()) {
Latin1TextIterator textIterator(m_run.data8(m_currentCharacter), m_currentCharacter, offset, length);
- return advanceInternal(textIterator, glyphBuffer);
+ advanceInternal(textIterator, glyphBuffer);
+ return;
}
SurrogatePairAwareTextIterator textIterator(m_run.data16(m_currentCharacter), m_currentCharacter, offset, length);
- return advanceInternal(textIterator, glyphBuffer);
+ advanceInternal(textIterator, glyphBuffer);
}
bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer& glyphBuffer)
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.h (265217 => 265218)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.h 2020-08-03 21:02:49 UTC (rev 265217)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.h 2020-08-03 21:04:38 UTC (rev 265218)
@@ -42,7 +42,7 @@
public:
WidthIterator(const FontCascade*, const TextRun&, HashSet<const Font*>* fallbackFonts = 0, bool accountForGlyphBounds = false, bool forTextEmphasis = false);
- unsigned advance(unsigned to, GlyphBuffer*);
+ void advance(unsigned to, GlyphBuffer*);
bool advanceOneCharacter(float& width, GlyphBuffer&);
float maxGlyphBoundingBoxY() const { ASSERT(m_accountForGlyphBounds); return m_maxGlyphBoundingBoxY; }
@@ -58,7 +58,7 @@
private:
GlyphData glyphDataForCharacter(UChar32, bool mirror);
template <typename TextIterator>
- inline unsigned advanceInternal(TextIterator&, GlyphBuffer*);
+ inline void advanceInternal(TextIterator&, GlyphBuffer*);
enum class TransformsType { None, Forced, NotForced };
TransformsType shouldApplyFontTransforms(const GlyphBuffer*, unsigned lastGlyphCount, UChar32 previousCharacter) const;
Modified: trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp (265217 => 265218)
--- trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp 2020-08-03 21:02:49 UTC (rev 265217)
+++ trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp 2020-08-03 21:04:38 UTC (rev 265218)
@@ -58,8 +58,10 @@
void SVGTextMetricsBuilder::advanceSimpleText()
{
GlyphBuffer glyphBuffer;
- unsigned metricsLength = m_simpleWidthIterator->advance(m_textPosition + 1, &glyphBuffer);
- if (!metricsLength) {
+ auto before = m_simpleWidthIterator->currentCharacter();
+ m_simpleWidthIterator->advance(m_textPosition + 1, &glyphBuffer);
+ auto after = m_simpleWidthIterator->currentCharacter();
+ if (before == after) {
m_currentMetrics = SVGTextMetrics();
return;
}
@@ -67,7 +69,7 @@
float currentWidth = m_simpleWidthIterator->runWidthSoFar() - m_totalWidth;
m_totalWidth = m_simpleWidthIterator->runWidthSoFar();
- m_currentMetrics = SVGTextMetrics(*m_text, metricsLength, currentWidth);
+ m_currentMetrics = SVGTextMetrics(*m_text, after - before, currentWidth);
}
void SVGTextMetricsBuilder::advanceComplexText()