[Webkit-unassigned] [Bug 264897] Text controls: Intrinsic widths should not be smaller than AverageCharWidth() * N

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Apr 12 14:06:47 PDT 2024


https://bugs.webkit.org/show_bug.cgi?id=264897

--- Comment #5 from Ahmad Saleem <ahmad.saleem792 at gmail.com> ---
I took the change into 'RenderTextControl.cpp':

https://searchfox.org/wubkat/rev/8856ae172a088c3c1dbfcdcf8ac8a2fb87625ddd/Source/WebCore/rendering/RenderTextControl.cpp#138

float RenderTextControl::getAverageCharWidth()
{
    // We apply roundf() only if the fractional part of 'width' is >= 0.5
    // because:
    // * We have done it for a long time.
    // * Removing roundf() would make the intrinsic width smaller, and it
    //   would have a compatibility risk.
    float width = style().fontCascade().primaryFont().avgCharWidth();
    if (style().fontCascade().fastAverageCharWidthIfAvailable(width))
        return std::max(width, roundf(width));

    const UChar ch = '0';
    const String str = span(ch);
    const FontCascade& font = style().fontCascade();
    TextRun textRun = constructTextRun(str, style(), ExpansionBehavior::allowRightOnly());
    return font.width(textRun);
}

&

float RenderTextControl::getAverageCharWidth()
{
    // We apply roundf() only if the fractional part of 'width' is >= 0.5
    // because:
    // * We have done it for a long time.
    // * Removing roundf() would make the intrinsic width smaller, and it
    //   would have a compatibility risk.
    float width;
    if (style().fontCascade().fastAverageCharWidthIfAvailable(width))
        return std::max(width, roundf(width));

    const UChar ch = '0';
    const String str = span(ch);
    const FontCascade& font = style().fontCascade();
    TextRun textRun = constructTextRun(str, style(), ExpansionBehavior::allowRightOnly());
    return font.width(textRun);
}

___

Both didn't fix this. :-(

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240412/e66d7bb8/attachment-0001.htm>


More information about the webkit-unassigned mailing list