| Index: Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
|
| diff --git a/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp b/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
|
| index b2cc9d20f4f83c29f3348055547a9aeb662be7ea..0582c1f9cedd11a489c791eefb3eed883c4ad381 100644
|
| --- a/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
|
| +++ b/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
|
| @@ -34,6 +34,7 @@
|
|
|
| #include "RuntimeEnabledFeatures.h"
|
| #include "hb.h"
|
| +#include "platform/LayoutUnit.h"
|
| #include "platform/fonts/Character.h"
|
| #include "platform/fonts/Font.h"
|
| #include "platform/fonts/harfbuzz/HarfBuzzFace.h"
|
| @@ -1111,9 +1112,21 @@ FloatRect HarfBuzzShaper::selectionRect(const FloatPoint& point, int height, int
|
| toX = m_run.rtl() ? 0 : m_totalWidth;
|
|
|
| // Using floorf() and roundf() as the same as mac port.
|
| - if (fromX < toX)
|
| - return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - fromX), height);
|
| - return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), height);
|
| + // Use LayoutUnit::epsilon() to ensure that values that cannot be stored as
|
| + // an integer are floored to n and not n-1 due to floating point imprecision.
|
| + if (fromX < toX) {
|
| + float pixelAlignedX = floorf(point.x() + fromX + LayoutUnit::epsilon());
|
| + return FloatRect(floorf(point.x() + fromX),
|
| + point.y(),
|
| + roundf(point.x() + toX) - pixelAlignedX,
|
| + height);
|
| + }
|
| +
|
| + float pixelAlignedX = floorf(point.x() + toX + LayoutUnit::epsilon());
|
| + return FloatRect(floorf(point.x() + toX),
|
| + point.y(),
|
| + roundf(point.x() + fromX) - pixelAlignedX,
|
| + height);
|
| }
|
|
|
| } // namespace WebCore
|
|
|