Log Message
Clean up text layout code a bit https://bugs.webkit.org/show_bug.cgi?id=215013
Reviewed by Zalan Bujtas.
This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=214769.
See file-specific ChangeLog entries for more information.
No tests because there is no behavior change.
* platform/graphics/Font.h: Remove unnecessary declaration.
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::layoutText const): Rename glyphBufferForTextRun() to layoutText().
Also, make it return a GlyphBuffer instead of taking a GlyphBuffer as an out param.
Its previous return, the initial advance, is now returned in GlyphBuffer::initialAdvance.
(WebCore::FontCascade::drawText const): Update to new signature of layoutText().
(WebCore::FontCascade::drawEmphasisMarks const): Inline drawEmphasisMarksForSimpleText()
and drawEmphasisMarksForComplexText(), since they're nearly identical. Update to the new
signature of layoutText().
(WebCore::FontCascade::displayListForTextRun const): Update to the new signature of
layoutText().
(WebCore::FontCascade::layoutSimpleText const): Make this return a new GlyphBuffer, instead
of taking one as an out param. Also, use accessors of WidthIterator instead of reaching
into its guts. The previous return value is now returned in GlyphBuffer::initialAdvance.
(WebCore::FontCascade::layoutComplexText const): Ditto.
(WebCore::FontCascade::floatWidthForSimpleText const): Use accessors of WidthIterator
instead of reaching into its guts.
(WebCore::FontCascade::adjustSelectionRectForSimpleText const): Ditto.
(WebCore::FontCascade::offsetForPositionForSimpleText const): Ditto.
(WebCore::FontCascade::dashesForIntersectionsWithRect const): Same as
FontCascade::drawEmphasisMarks() above.
(WebCore::FontCascade::glyphBufferForTextRun const): Renamed to layoutText().
(WebCore::FontCascade::getGlyphsAndAdvancesForSimpleText const): Renamed to
layoutSimpleText().
(WebCore::FontCascade::getGlyphsAndAdvancesForComplexText const): Renamed to
layoutComplexText().
(WebCore::FontCascade::drawEmphasisMarksForSimpleText const): Inlined into
drawEmphasisMarks().
(WebCore::FontCascade::drawEmphasisMarksForComplexText const): Ditto.
* platform/graphics/FontCascade.h:
* platform/graphics/GlyphBuffer.h:
(WebCore::GlyphBufferAdvance::GlyphBufferAdvance):
(WebCore::GlyphBufferAdvance::operator FloatSize):
* platform/graphics/TextRun.h: Remove unnecessary declaration.
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::WidthIterator): Update for changes to WidthIterator.h
* platform/graphics/WidthIterator.h: Rearrange the class members to sort them by size,
to get better packing. Also, make all member variables private, and initialize them
all with { } syntax.
(WebCore::WidthIterator::finalRoundingWidth const):
(WebCore::WidthIterator::currentCharacter const):
* rendering/svg/SVGTextMetrics.cpp: Remove unnecessary include.
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/platform/graphics/Font.h
- trunk/Source/WebCore/platform/graphics/FontCascade.cpp
- trunk/Source/WebCore/platform/graphics/FontCascade.h
- trunk/Source/WebCore/platform/graphics/GlyphBuffer.h
- trunk/Source/WebCore/platform/graphics/TextRun.h
- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp
- trunk/Source/WebCore/platform/graphics/WidthIterator.h
- trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp
Diff
Modified: trunk/Source/WebCore/ChangeLog (265169 => 265170)
--- trunk/Source/WebCore/ChangeLog 2020-08-01 00:30:07 UTC (rev 265169)
+++ trunk/Source/WebCore/ChangeLog 2020-08-01 00:36:14 UTC (rev 265170)
@@ -1,3 +1,59 @@
+2020-07-31 Myles C. Maxfield <[email protected]>
+
+ Clean up text layout code a bit
+ https://bugs.webkit.org/show_bug.cgi?id=215013
+
+ Reviewed by Zalan Bujtas.
+
+ This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=214769.
+
+ See file-specific ChangeLog entries for more information.
+
+ No tests because there is no behavior change.
+
+ * platform/graphics/Font.h: Remove unnecessary declaration.
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::layoutText const): Rename glyphBufferForTextRun() to layoutText().
+ Also, make it return a GlyphBuffer instead of taking a GlyphBuffer as an out param.
+ Its previous return, the initial advance, is now returned in GlyphBuffer::initialAdvance.
+ (WebCore::FontCascade::drawText const): Update to new signature of layoutText().
+ (WebCore::FontCascade::drawEmphasisMarks const): Inline drawEmphasisMarksForSimpleText()
+ and drawEmphasisMarksForComplexText(), since they're nearly identical. Update to the new
+ signature of layoutText().
+ (WebCore::FontCascade::displayListForTextRun const): Update to the new signature of
+ layoutText().
+ (WebCore::FontCascade::layoutSimpleText const): Make this return a new GlyphBuffer, instead
+ of taking one as an out param. Also, use accessors of WidthIterator instead of reaching
+ into its guts. The previous return value is now returned in GlyphBuffer::initialAdvance.
+ (WebCore::FontCascade::layoutComplexText const): Ditto.
+ (WebCore::FontCascade::floatWidthForSimpleText const): Use accessors of WidthIterator
+ instead of reaching into its guts.
+ (WebCore::FontCascade::adjustSelectionRectForSimpleText const): Ditto.
+ (WebCore::FontCascade::offsetForPositionForSimpleText const): Ditto.
+ (WebCore::FontCascade::dashesForIntersectionsWithRect const): Same as
+ FontCascade::drawEmphasisMarks() above.
+ (WebCore::FontCascade::glyphBufferForTextRun const): Renamed to layoutText().
+ (WebCore::FontCascade::getGlyphsAndAdvancesForSimpleText const): Renamed to
+ layoutSimpleText().
+ (WebCore::FontCascade::getGlyphsAndAdvancesForComplexText const): Renamed to
+ layoutComplexText().
+ (WebCore::FontCascade::drawEmphasisMarksForSimpleText const): Inlined into
+ drawEmphasisMarks().
+ (WebCore::FontCascade::drawEmphasisMarksForComplexText const): Ditto.
+ * platform/graphics/FontCascade.h:
+ * platform/graphics/GlyphBuffer.h:
+ (WebCore::GlyphBufferAdvance::GlyphBufferAdvance):
+ (WebCore::GlyphBufferAdvance::operator FloatSize):
+ * platform/graphics/TextRun.h: Remove unnecessary declaration.
+ * platform/graphics/WidthIterator.cpp:
+ (WebCore::WidthIterator::WidthIterator): Update for changes to WidthIterator.h
+ * platform/graphics/WidthIterator.h: Rearrange the class members to sort them by size,
+ to get better packing. Also, make all member variables private, and initialize them
+ all with { } syntax.
+ (WebCore::WidthIterator::finalRoundingWidth const):
+ (WebCore::WidthIterator::currentCharacter const):
+ * rendering/svg/SVGTextMetrics.cpp: Remove unnecessary include.
+
2020-07-31 Chris Dumez <[email protected]>
Add OfflineAudioCompletionEvent constructor
Modified: trunk/Source/WebCore/platform/graphics/Font.h (265169 => 265170)
--- trunk/Source/WebCore/platform/graphics/Font.h 2020-08-01 00:30:07 UTC (rev 265169)
+++ trunk/Source/WebCore/platform/graphics/Font.h 2020-08-01 00:36:14 UTC (rev 265170)
@@ -59,7 +59,6 @@
class FontDescription;
class SharedBuffer;
struct GlyphData;
-struct WidthIterator;
enum FontVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMarkVariant, BrokenIdeographVariant };
enum Pitch { UnknownPitch, FixedPitch, VariablePitch };
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (265169 => 265170)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-01 00:30:07 UTC (rev 265169)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-01 00:36:14 UTC (rev 265170)
@@ -285,18 +285,19 @@
m_requiresShaping = computeRequiresShaping();
}
-FloatSize FontCascade::glyphBufferForTextRun(CodePath codePathToUse, const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer) const
+GlyphBuffer FontCascade::layoutText(CodePath codePathToUse, const TextRun& run, unsigned from, unsigned to, ShouldSaveOffsets shouldSaveOffsets, ForTextEmphasisOrNot forTextEmphasis) const
{
if (codePathToUse != Complex)
- return { getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer), 0 };
- return getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);
+ return layoutSimpleText(run, from, to, shouldSaveOffsets, forTextEmphasis);
+
+ return layoutComplexText(run, from, to, shouldSaveOffsets, forTextEmphasis);
}
float FontCascade::drawText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, unsigned from, Optional<unsigned> to, CustomFontNotReadyAction customFontNotReadyAction) const
{
unsigned destination = to.valueOr(run.length());
- GlyphBuffer glyphBuffer;
- FloatPoint startPoint = point + glyphBufferForTextRun(codePath(run, from, to), run, from, destination, glyphBuffer);
+ 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;
@@ -312,10 +313,14 @@
return;
unsigned destination = to.valueOr(run.length());
- if (codePath(run, from, to) != Complex)
- drawEmphasisMarksForSimpleText(context, run, mark, point, from, destination);
- else
- drawEmphasisMarksForComplexText(context, run, mark, point, from, destination);
+
+ auto glyphBuffer = layoutText(codePath(run, from, to), run, from, destination, ShouldSaveOffsets::No, ForTextEmphasisOrNot::ForTextEmphasis);
+
+ if (glyphBuffer.isEmpty())
+ return;
+
+ FloatPoint startPoint = point + FloatSize(glyphBuffer.initialAdvance());
+ drawEmphasisMarks(context, glyphBuffer, mark, startPoint);
}
std::unique_ptr<DisplayList::DisplayList> FontCascade::displayListForTextRun(GraphicsContext& context, const TextRun& run, unsigned from, Optional<unsigned> to, CustomFontNotReadyAction customFontNotReadyAction) const
@@ -327,9 +332,9 @@
CodePath codePathToUse = codePath(run);
if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || destination != run.length()))
codePathToUse = Complex;
-
- GlyphBuffer glyphBuffer;
- FloatPoint startPoint = toFloatPoint(glyphBufferForTextRun(codePathToUse, run, from, destination, glyphBuffer));
+
+ 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;
@@ -1364,9 +1369,11 @@
return markFontData->fontMetrics().height();
}
-float FontCascade::getGlyphsAndAdvancesForSimpleText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
+GlyphBuffer FontCascade::layoutSimpleText(const TextRun& run, unsigned from, unsigned to, ShouldSaveOffsets shouldSaveOffsets, ForTextEmphasisOrNot forTextEmphasis) const
{
- float initialAdvance;
+ GlyphBuffer glyphBuffer;
+ if (shouldSaveOffsets == ShouldSaveOffsets::Yes)
+ glyphBuffer.saveOffsetsInString();
WidthIterator it(this, run, 0, false, forTextEmphasis);
// FIXME: Using separate glyph buffers for the prefix and the suffix is incorrect when kerning or
@@ -1373,30 +1380,34 @@
// ligatures are enabled.
GlyphBuffer localGlyphBuffer;
it.advance(from, &localGlyphBuffer);
- float beforeWidth = it.m_runWidthSoFar;
+ float beforeWidth = it.runWidthSoFar();
it.advance(to, &glyphBuffer);
if (glyphBuffer.isEmpty())
- return 0;
+ return glyphBuffer;
- float afterWidth = it.m_runWidthSoFar;
+ float afterWidth = it.runWidthSoFar();
+ float initialAdvance = 0;
if (run.rtl()) {
- float finalRoundingWidth = it.m_finalRoundingWidth;
+ float finalRoundingWidth = it.finalRoundingWidth();
it.advance(run.length(), &localGlyphBuffer);
- initialAdvance = finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
+ initialAdvance = finalRoundingWidth + it.runWidthSoFar() - afterWidth;
} else
initialAdvance = beforeWidth;
+ glyphBuffer.setInitialAdvance(FloatSize(initialAdvance, 0));
if (run.rtl())
glyphBuffer.reverse(0, glyphBuffer.size());
- return initialAdvance;
+ return glyphBuffer;
}
-FloatSize FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
+GlyphBuffer FontCascade::layoutComplexText(const TextRun& run, unsigned from, unsigned to, ShouldSaveOffsets shouldSaveOffsets, ForTextEmphasisOrNot forTextEmphasis) const
{
- FloatSize initialAdvance;
+ GlyphBuffer glyphBuffer;
+ if (shouldSaveOffsets == ShouldSaveOffsets::Yes)
+ glyphBuffer.saveOffsetsInString();
ComplexTextController controller(*this, run, false, 0, forTextEmphasis);
GlyphBuffer dummyGlyphBuffer;
@@ -1404,37 +1415,30 @@
controller.advance(to, &glyphBuffer);
if (glyphBuffer.isEmpty())
- return { };
+ return glyphBuffer;
if (run.rtl()) {
// Exploit the fact that the sum of the paint advances is equal to
// the sum of the layout advances.
- initialAdvance = controller.totalAdvance();
+ FloatSize initialAdvance = controller.totalAdvance();
for (unsigned i = 0; i < dummyGlyphBuffer.size(); ++i)
initialAdvance -= toFloatSize(dummyGlyphBuffer.advanceAt(i));
for (unsigned i = 0; i < glyphBuffer.size(); ++i)
initialAdvance -= toFloatSize(glyphBuffer.advanceAt(i));
+ // FIXME: Shouldn't we subtract the other initial advance?
glyphBuffer.reverse(0, glyphBuffer.size());
+ glyphBuffer.setInitialAdvance(initialAdvance);
} else {
- initialAdvance = toFloatSize(dummyGlyphBuffer.initialAdvance());
+ FloatSize initialAdvance = toFloatSize(dummyGlyphBuffer.initialAdvance());
for (unsigned i = 0; i < dummyGlyphBuffer.size(); ++i)
initialAdvance += toFloatSize(dummyGlyphBuffer.advanceAt(i));
+ // FIXME: Shouldn't we add the other initial advance?
+ glyphBuffer.setInitialAdvance(initialAdvance);
}
- return initialAdvance;
+ return glyphBuffer;
}
-void FontCascade::drawEmphasisMarksForSimpleText(GraphicsContext& context, const TextRun& run, const AtomString& mark, const FloatPoint& point, unsigned from, unsigned to) const
-{
- GlyphBuffer glyphBuffer;
- float initialAdvance = getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer, ForTextEmphasis);
-
- if (glyphBuffer.isEmpty())
- return;
-
- drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
-}
-
inline bool shouldDrawIfLoading(const Font& font, FontCascade::CustomFontNotReadyAction customFontNotReadyAction)
{
// Don't draw anything while we are using custom fonts that are in the process of loading,
@@ -1531,7 +1535,7 @@
glyphOverflow->right = ceilf(it.lastGlyphOverflow());
}
- return it.m_runWidthSoFar;
+ return it.runWidthSoFar();
}
float FontCascade::floatWidthForComplexText(const TextRun& run, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
@@ -1551,14 +1555,14 @@
GlyphBuffer glyphBuffer;
WidthIterator it(this, run);
it.advance(from, &glyphBuffer);
- float beforeWidth = it.m_runWidthSoFar;
+ float beforeWidth = it.runWidthSoFar();
it.advance(to, &glyphBuffer);
- float afterWidth = it.m_runWidthSoFar;
+ float afterWidth = it.runWidthSoFar();
float totalWidth = -1;
if (run.rtl()) {
it.advance(run.length(), &glyphBuffer);
- totalWidth = it.m_runWidthSoFar;
+ totalWidth = it.runWidthSoFar();
selectionRect.move(totalWidth - afterWidth, 0);
} else
selectionRect.move(beforeWidth, 0);
@@ -1590,7 +1594,7 @@
if (run.rtl()) {
delta -= floatWidthForSimpleText(run);
while (1) {
- offset = it.m_currentCharacter;
+ offset = it.currentCharacter();
float w;
if (!it.advanceOneCharacter(w, localGlyphBuffer))
break;
@@ -1605,7 +1609,7 @@
}
} else {
while (1) {
- offset = it.m_currentCharacter;
+ offset = it.currentCharacter();
float w;
if (!it.advanceOneCharacter(w, localGlyphBuffer))
break;
@@ -1644,17 +1648,6 @@
}
#endif
-void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomString& mark, const FloatPoint& point, unsigned from, unsigned to) const
-{
- GlyphBuffer glyphBuffer;
- auto initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);
-
- if (glyphBuffer.isEmpty())
- return;
-
- drawEmphasisMarks(context, glyphBuffer, mark, point + initialAdvance);
-}
-
struct GlyphIterationState {
FloatPoint startingPoint;
FloatPoint currentPoint;
@@ -1784,18 +1777,12 @@
if (isLoadingCustomFonts())
return DashArray();
- GlyphBuffer glyphBuffer;
- glyphBuffer.saveOffsetsInString();
- float deltaX;
- if (codePath(run) != FontCascade::Complex)
- deltaX = getGlyphsAndAdvancesForSimpleText(run, 0, run.length(), glyphBuffer);
- else
- deltaX = getGlyphsAndAdvancesForComplexText(run, 0, run.length(), glyphBuffer).width();
+ auto glyphBuffer = layoutText(codePath(run), run, 0, run.length(), ShouldSaveOffsets::Yes);
if (!glyphBuffer.size())
return DashArray();
- FloatPoint origin = FloatPoint(textOrigin.x() + deltaX, textOrigin.y());
+ FloatPoint origin = textOrigin + FloatSize(glyphBuffer.initialAdvance());
GlyphToPathTranslator translator(run, glyphBuffer, origin);
DashArray result;
for (unsigned index = 0; translator.containsMorePaths(); ++index, translator.advance()) {
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (265169 => 265170)
--- trunk/Source/WebCore/platform/graphics/FontCascade.h 2020-08-01 00:30:07 UTC (rev 265169)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.h 2020-08-01 00:36:14 UTC (rev 265170)
@@ -203,11 +203,13 @@
#endif
private:
enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };
+ enum class ShouldSaveOffsets : uint8_t {
+ Yes,
+ No
+ };
- FloatSize glyphBufferForTextRun(CodePath, const TextRun&, unsigned from, unsigned to, GlyphBuffer&) const;
- // Returns the initial in-stream advance.
- float getGlyphsAndAdvancesForSimpleText(const TextRun&, unsigned from, unsigned to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
- void drawEmphasisMarksForSimpleText(GraphicsContext&, const TextRun&, const AtomString& mark, const FloatPoint&, unsigned from, unsigned to) const;
+ GlyphBuffer layoutText(CodePath, const TextRun&, unsigned from, unsigned to, ShouldSaveOffsets = ShouldSaveOffsets::No, ForTextEmphasisOrNot = NotForTextEmphasis) const;
+ GlyphBuffer layoutSimpleText(const TextRun&, unsigned from, unsigned to, ShouldSaveOffsets = ShouldSaveOffsets::No, ForTextEmphasisOrNot = NotForTextEmphasis) const;
void drawGlyphBuffer(GraphicsContext&, const GlyphBuffer&, FloatPoint&, CustomFontNotReadyAction) const;
void drawEmphasisMarks(GraphicsContext&, const GlyphBuffer&, const AtomString&, const FloatPoint&) const;
float floatWidthForSimpleText(const TextRun&, HashSet<const Font*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
@@ -219,9 +221,7 @@
static bool canReturnFallbackFontsForComplexText();
static bool canExpandAroundIdeographsInComplexText();
- // Returns the initial in-stream advance.
- FloatSize getGlyphsAndAdvancesForComplexText(const TextRun&, unsigned from, unsigned to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
- void drawEmphasisMarksForComplexText(GraphicsContext&, const TextRun&, const AtomString& mark, const FloatPoint&, unsigned from, unsigned to) const;
+ GlyphBuffer layoutComplexText(const TextRun&, unsigned from, unsigned to, ShouldSaveOffsets = ShouldSaveOffsets::No, ForTextEmphasisOrNot = NotForTextEmphasis) const;
float floatWidthForComplexText(const TextRun&, HashSet<const Font*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
int offsetForPositionForComplexText(const TextRun&, float position, bool includePartialGlyphs) const;
void adjustSelectionRectForComplexText(const TextRun&, LayoutRect& selectionRect, unsigned from, unsigned to) const;
Modified: trunk/Source/WebCore/platform/graphics/GlyphBuffer.h (265169 => 265170)
--- trunk/Source/WebCore/platform/graphics/GlyphBuffer.h 2020-08-01 00:30:07 UTC (rev 265169)
+++ trunk/Source/WebCore/platform/graphics/GlyphBuffer.h 2020-08-01 00:36:14 UTC (rev 265170)
@@ -58,6 +58,10 @@
: CGSize(size)
{
}
+ GlyphBufferAdvance(FloatSize size)
+ : CGSize(size)
+ {
+ }
GlyphBufferAdvance(float width, float height)
: CGSize(CGSizeMake(width, height))
{
@@ -66,6 +70,8 @@
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static Optional<GlyphBufferAdvance> decode(Decoder&);
+ operator FloatSize() { return { static_cast<float>(this->CGSize::width), static_cast<float>(this->CGSize::height) }; }
+
void setWidth(CGFloat width) { this->CGSize::width = width; }
void setHeight(CGFloat height) { this->CGSize::height = height; }
CGFloat width() const { return this->CGSize::width; }
Modified: trunk/Source/WebCore/platform/graphics/TextRun.h (265169 => 265170)
--- trunk/Source/WebCore/platform/graphics/TextRun.h 2020-08-01 00:30:07 UTC (rev 265169)
+++ trunk/Source/WebCore/platform/graphics/TextRun.h 2020-08-01 00:36:14 UTC (rev 265170)
@@ -39,7 +39,6 @@
class Font;
struct GlyphData;
-struct WidthIterator;
class TextRun {
WTF_MAKE_FAST_ALLOCATED;
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (265169 => 265170)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-08-01 00:30:07 UTC (rev 265169)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-08-01 00:36:14 UTC (rev 265170)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2003 - 2020 Apple Inc. All rights reserved.
* Copyright (C) 2008 Holger Hans Peter Freyther
*
* This library is free software; you can redistribute it and/or
@@ -38,19 +38,14 @@
WidthIterator::WidthIterator(const FontCascade* font, const TextRun& run, HashSet<const Font*>* fallbackFonts, bool accountForGlyphBounds, bool forTextEmphasis)
: m_font(font)
, m_run(run)
- , m_currentCharacter(0)
- , m_runWidthSoFar(0)
+ , m_fallbackFonts(fallbackFonts)
+ , m_expansion(run.expansion())
, m_isAfterExpansion((run.expansionBehavior() & LeadingExpansionMask) == ForbidLeadingExpansion)
- , m_finalRoundingWidth(0)
- , m_fallbackFonts(fallbackFonts)
, m_accountForGlyphBounds(accountForGlyphBounds)
, m_enableKerning(font->enableKerning())
, m_requiresShaping(font->requiresShaping())
, m_forTextEmphasis(forTextEmphasis)
{
- // If the padding is non-zero, count the number of spaces in the run
- // and divide that by the padding for per space addition.
- m_expansion = m_run.expansion();
if (!m_expansion)
m_expansionPerOpportunity = 0;
else {
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.h (265169 => 265170)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.h 2020-08-01 00:30:07 UTC (rev 265169)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.h 2020-08-01 00:36:14 UTC (rev 265170)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006, 2008, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2003 - 2020 Apple Inc. All rights reserved.
* Copyright (C) 2008 Holger Hans Peter Freyther
*
* This library is free software; you can redistribute it and/or
@@ -52,18 +52,9 @@
const TextRun& run() const { return m_run; }
float runWidthSoFar() const { return m_runWidthSoFar; }
+ float finalRoundingWidth() const { return m_finalRoundingWidth; }
+ unsigned currentCharacter() const { return m_currentCharacter; }
- const FontCascade* m_font;
-
- const TextRun& m_run;
-
- unsigned m_currentCharacter;
- float m_runWidthSoFar;
- float m_expansion;
- float m_expansionPerOpportunity;
- bool m_isAfterExpansion;
- float m_finalRoundingWidth;
-
private:
GlyphData glyphDataForCharacter(UChar32, bool mirror);
template <typename TextIterator>
@@ -73,15 +64,24 @@
TransformsType shouldApplyFontTransforms(const GlyphBuffer*, unsigned lastGlyphCount, UChar32 previousCharacter) const;
float applyFontTransforms(GlyphBuffer*, bool ltr, unsigned& lastGlyphCount, const Font*, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace&);
+ const FontCascade* m_font;
+ const TextRun& m_run;
HashSet<const Font*>* m_fallbackFonts { nullptr };
+
+ unsigned m_currentCharacter { 0 };
+ float m_runWidthSoFar { 0 };
+ float m_expansion { 0 };
+ float m_expansionPerOpportunity { 0 };
+ float m_finalRoundingWidth { 0 };
+ float m_maxGlyphBoundingBoxY { std::numeric_limits<float>::min() };
+ float m_minGlyphBoundingBoxY { std::numeric_limits<float>::max() };
+ float m_firstGlyphOverflow { 0 };
+ float m_lastGlyphOverflow { 0 };
+ bool m_isAfterExpansion { false };
bool m_accountForGlyphBounds { false };
bool m_enableKerning { false };
bool m_requiresShaping { false };
bool m_forTextEmphasis { false };
- float m_maxGlyphBoundingBoxY { std::numeric_limits<float>::min() };
- float m_minGlyphBoundingBoxY { std::numeric_limits<float>::max() };
- float m_firstGlyphOverflow { 0 };
- float m_lastGlyphOverflow { 0 };
};
}
Modified: trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp (265169 => 265170)
--- trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp 2020-08-01 00:30:07 UTC (rev 265169)
+++ trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp 2020-08-01 00:36:14 UTC (rev 265170)
@@ -21,7 +21,6 @@
#include "SVGTextMetrics.h"
#include "RenderSVGInlineText.h"
-#include "WidthIterator.h"
namespace WebCore {
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
