| Index: Source/platform/fonts/Font.cpp
|
| diff --git a/Source/platform/fonts/Font.cpp b/Source/platform/fonts/Font.cpp
|
| index 03bcf14f77afc0846a860bcdd7bb81673a4dbf3d..9ae22e13e04857c08b2a8c24775366a58f53f91b 100644
|
| --- a/Source/platform/fonts/Font.cpp
|
| +++ b/Source/platform/fonts/Font.cpp
|
| @@ -178,7 +178,7 @@ float Font::width(const TextRun& run, int& charsConsumed, String& glyphName) con
|
| return width(run);
|
| }
|
|
|
| -FloatRect Font::selectionRectForText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
|
| +FloatRect Font::selectionRectForText(const TextRun& run, const FloatPoint& point, int h, int from, int to, bool accountForGlyphBounds) const
|
| {
|
| to = (to == -1 ? run.length() : to);
|
|
|
| @@ -188,7 +188,7 @@ FloatRect Font::selectionRectForText(const TextRun& run, const FloatPoint& point
|
| codePathToUse = ComplexPath;
|
|
|
| if (codePathToUse != ComplexPath)
|
| - return selectionRectForSimpleText(run, point, h, from, to);
|
| + return selectionRectForSimpleText(run, point, h, from, to, accountForGlyphBounds);
|
|
|
| return selectionRectForComplexText(run, point, h, from, to);
|
| }
|
| @@ -755,10 +755,10 @@ float Font::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFont
|
| return it.m_runWidthSoFar;
|
| }
|
|
|
| -FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
|
| +FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& point, int h, int from, int to, bool accountForGlyphBounds) const
|
| {
|
| GlyphBuffer glyphBuffer;
|
| - WidthIterator it(this, run);
|
| + WidthIterator it(this, run, 0, accountForGlyphBounds);
|
| it.advance(from, &glyphBuffer);
|
| float beforeWidth = it.m_runWidthSoFar;
|
| it.advance(to, &glyphBuffer);
|
| @@ -772,13 +772,15 @@ FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint&
|
| it.advance(run.length(), &glyphBuffer);
|
| float totalWidth = it.m_runWidthSoFar;
|
| float pixelAlignedX = floorf(point.x() + totalWidth - afterWidth + LayoutUnit::epsilon());
|
| - return FloatRect(pixelAlignedX, point.y(),
|
| - roundf(point.x() + totalWidth - beforeWidth) - pixelAlignedX, h);
|
| + return FloatRect(pixelAlignedX, point.y() + accountForGlyphBounds ? it.minGlyphBoundingBoxY() : 0,
|
| + roundf(point.x() + totalWidth - beforeWidth) - pixelAlignedX,
|
| + accountForGlyphBounds ? it.maxGlyphBoundingBoxY() - it.minGlyphBoundingBoxY() : h);
|
| }
|
|
|
| float pixelAlignedX = floorf(point.x() + beforeWidth + LayoutUnit::epsilon());
|
| - return FloatRect(pixelAlignedX, point.y(),
|
| - roundf(point.x() + afterWidth) - pixelAlignedX, h);
|
| + return FloatRect(pixelAlignedX, point.y() + accountForGlyphBounds ? it.minGlyphBoundingBoxY() : 0,
|
| + roundf(point.x() + afterWidth) - pixelAlignedX,
|
| + accountForGlyphBounds ? it.maxGlyphBoundingBoxY() - it.minGlyphBoundingBoxY() : h);
|
| }
|
|
|
| int Font::offsetForPositionForSimpleText(const TextRun& run, float x, bool includePartialGlyphs) const
|
|
|