Diff
Modified: trunk/Source/WebCore/ChangeLog (265230 => 265231)
--- trunk/Source/WebCore/ChangeLog 2020-08-03 23:43:29 UTC (rev 265230)
+++ trunk/Source/WebCore/ChangeLog 2020-08-04 00:15:12 UTC (rev 265231)
@@ -1,3 +1,31 @@
+2020-08-03 Myles C. Maxfield <[email protected]>
+
+ Make FontCascade.drawText() return a FloatSize instead of a float
+ https://bugs.webkit.org/show_bug.cgi?id=215055
+
+ Reviewed by Darin Adler.
+
+ Advances are philosophically two-dimensional data structures.
+
+ This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=214769
+ and https://bugs.webkit.org/show_bug.cgi?id=206208.
+
+ No new tests because there shouldn't be any behavior change. But in the weird
+ rare case where there might be, we should be defensive and handle it correctly.
+ I've never seen one of these cases, though.
+
+ * inspector/InspectorOverlay.cpp:
+ (WebCore::InspectorOverlay::drawElementTitle):
+ * page/DebugPageOverlays.cpp:
+ (WebCore::drawRightAlignedText):
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::drawText const):
+ * platform/graphics/FontCascade.h:
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::drawText):
+ (WebCore::GraphicsContext::drawBidiText):
+ * platform/graphics/GraphicsContext.h:
+
2020-08-03 Tim Horton <[email protected]>
Occasional crashes when running nested runloops while using UIWebView
Modified: trunk/Source/WebCore/inspector/InspectorOverlay.cpp (265230 => 265231)
--- trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2020-08-03 23:43:29 UTC (rev 265230)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2020-08-04 00:15:12 UTC (rev 265231)
@@ -1058,14 +1058,13 @@
context.strokePath(path);
- float textPositionX = boxX + elementDataSpacing;
- float textPositionY = boxY - (elementDataSpacing / 2.0f) + fontHeight;
+ FloatPoint textPosition(boxX + elementDataSpacing, boxY - (elementDataSpacing / 2.0f) + fontHeight);
const auto drawText = [&] (const String& text, SRGBA<uint8_t> color) {
if (text.isEmpty())
return;
context.setFillColor(color);
- textPositionX += context.drawText(font, TextRun(text), { textPositionX, textPositionY });
+ textPosition += context.drawText(font, TextRun(text), textPosition);
};
drawText(elementTagName, { 136, 18, 128 }); // Keep this in sync with XMLViewer.css (.tag)
@@ -1082,9 +1081,6 @@
drawText("px"_s, Color::darkGray);
if (hasSecondLine) {
- textPositionX = boxX + elementDataSpacing;
- textPositionY += fontHeight;
-
drawText("Role"_s, { 170, 13, 145 });
drawText(" "_s, Color::black);
drawText(elementRole, Color::black);
Modified: trunk/Source/WebCore/page/DebugPageOverlays.cpp (265230 => 265231)
--- trunk/Source/WebCore/page/DebugPageOverlays.cpp 2020-08-03 23:43:29 UTC (rev 265230)
+++ trunk/Source/WebCore/page/DebugPageOverlays.cpp 2020-08-04 00:15:12 UTC (rev 265231)
@@ -167,8 +167,7 @@
float textBaselineFromTop = 14;
TextRun textRun = TextRun(text);
- context.setFillColor(Color::transparentBlack);
- float textWidth = context.drawText(font, textRun, { });
+ float textWidth = font.width(textRun);
context.setFillColor(Color::black);
context.drawText(font, textRun, boxLocation + FloatSize(-(textWidth + textGap), textBaselineFromTop));
}
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (265230 => 265231)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-03 23:43:29 UTC (rev 265230)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-08-04 00:15:12 UTC (rev 265231)
@@ -293,18 +293,17 @@
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
+FloatSize FontCascade::drawText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, unsigned from, Optional<unsigned> to, CustomFontNotReadyAction customFontNotReadyAction) const
{
unsigned destination = to.valueOr(run.length());
auto glyphBuffer = layoutText(codePath(run, from, to), run, from, destination);
if (glyphBuffer.isEmpty())
- return 0;
+ return FloatSize();
FloatPoint startPoint = point + FloatSize(glyphBuffer.initialAdvance());
- float oldStartX = startPoint.x();
drawGlyphBuffer(context, glyphBuffer, startPoint, customFontNotReadyAction);
- return startPoint.x() - oldStartX;
+ return startPoint - point;
}
void FontCascade::drawEmphasisMarks(GraphicsContext& context, const TextRun& run, const AtomString& mark, const FloatPoint& point, unsigned from, Optional<unsigned> to) const
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (265230 => 265231)
--- trunk/Source/WebCore/platform/graphics/FontCascade.h 2020-08-03 23:43:29 UTC (rev 265230)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.h 2020-08-04 00:15:12 UTC (rev 265231)
@@ -108,7 +108,7 @@
WEBCORE_EXPORT void update(RefPtr<FontSelector>&& = nullptr) const;
enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontNotReady };
- WEBCORE_EXPORT float drawText(GraphicsContext&, const TextRun&, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
+ WEBCORE_EXPORT FloatSize drawText(GraphicsContext&, const TextRun&, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
static void drawGlyphs(GraphicsContext&, const Font&, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint&, FontSmoothingMode);
void drawEmphasisMarks(GraphicsContext&, const TextRun&, const AtomString& mark, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt) const;
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (265230 => 265231)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2020-08-03 23:43:29 UTC (rev 265230)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2020-08-04 00:15:12 UTC (rev 265231)
@@ -660,10 +660,10 @@
--m_transparencyCount;
}
-float GraphicsContext::drawText(const FontCascade& font, const TextRun& run, const FloatPoint& point, unsigned from, Optional<unsigned> to)
+FloatSize GraphicsContext::drawText(const FontCascade& font, const TextRun& run, const FloatPoint& point, unsigned from, Optional<unsigned> to)
{
if (paintingDisabled())
- return 0;
+ return FloatSize();
// Display list recording for text content is done at glyphs level. See GraphicsContext::drawGlyphs.
return font.drawText(*this, run, point, from, to);
@@ -715,8 +715,8 @@
subrun.setDirection(isRTL ? TextDirection::RTL : TextDirection::LTR);
subrun.setDirectionalOverride(bidiRun->dirOverride(false));
- float width = font.drawText(*this, subrun, currPoint, 0, WTF::nullopt, customFontNotReadyAction);
- currPoint.move(width, 0);
+ auto advance = font.drawText(*this, subrun, currPoint, 0, WTF::nullopt, customFontNotReadyAction);
+ currPoint.move(advance);
bidiRun = bidiRun->next();
}
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (265230 => 265231)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2020-08-03 23:43:29 UTC (rev 265230)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2020-08-04 00:15:12 UTC (rev 265231)
@@ -419,7 +419,7 @@
bool useDarkAppearance() const { return m_state.useDarkAppearance; }
#endif
- float drawText(const FontCascade&, const TextRun&, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt);
+ FloatSize drawText(const FontCascade&, const TextRun&, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt);
void drawGlyphs(const Font&, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint&, FontSmoothingMode);
void drawEmphasisMarks(const FontCascade&, const TextRun&, const AtomString& mark, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt);
void drawBidiText(const FontCascade&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction = FontCascade::DoNotPaintIfFontNotReady);