commit 7f5dfaee90fce960bcc43fe3f8525770048ed156 parent 4a687553db2f5d26dbe09213a1fe56349e4a4c6f Author: Emilio Cobos Álvarez <emilio@crisal.io> Date: Fri, 12 Dec 2025 17:16:29 +0000 Bug 840878 - Snap text decorations as border widths as per CSSWG resolution. r=layout-reviewers,jfkthame See https://github.com/w3c/csswg-drafts/issues/12696 Co-authored-by: Logan Rosen <loganrosen@gmail.com> Differential Revision: https://phabricator.services.mozilla.com/D275894 Diffstat:
19 files changed, 512 insertions(+), 344 deletions(-)
diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp @@ -40,6 +40,7 @@ #include "mozilla/intl/Bidi.h" #include "mozilla/intl/Segmenter.h" #include "mozilla/intl/UnicodeProperties.h" +#include "mozilla/widget/ThemeDrawing.h" #include "nsBlockFrame.h" #include "nsCOMPtr.h" #include "nsCSSColorUtils.h" @@ -5690,14 +5691,14 @@ static gfxFloat ComputeDecorationLineThickness( const gfxFont::Metrics& aFontMetrics, const gfxFloat aAppUnitsPerDevPixel, const nsIFrame* aFrame) { if (aThickness.IsAuto()) { - return aAutoValue; + return widget::ThemeDrawing::SnapBorderWidth(aAutoValue); } - if (aThickness.IsFromFont()) { - return aFontMetrics.underlineSize; + return widget::ThemeDrawing::SnapBorderWidth(aFontMetrics.underlineSize); } auto em = [&] { return aFrame->StyleFont()->mSize.ToAppUnits(); }; - return aThickness.AsLengthPercentage().Resolve(em) / aAppUnitsPerDevPixel; + return widget::ThemeDrawing::SnapBorderWidth( + aThickness.AsLengthPercentage().Resolve(em) / aAppUnitsPerDevPixel); } // Helper function for implementing text-underline-offset and -position @@ -6005,7 +6006,6 @@ void nsTextFrame::UnionAdditionalOverflow(nsPresContext* aPresContext, decorationStyle = StyleTextDecorationStyle::Solid; } nsCSSRendering::DecorationRectParams params; - bool useVerticalMetrics = verticalRun && mTextRun->UseCenterBaseline(); nsFontMetrics* fontMetrics = aProvider.GetFontMetrics(); RefPtr<gfxFont> font = diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp @@ -4207,11 +4207,10 @@ void nsCSSRendering::PaintDecorationLine( void nsCSSRendering::PaintDecorationLineInternal( nsIFrame* aFrame, DrawTarget& aDrawTarget, const PaintDecorationLineParams& aParams, Rect aRect) { - Float lineThickness = std::max(NS_round(aParams.lineSize.height), 1.0); - + const Float lineThickness = aParams.lineSize.height; DeviceColor color = ToDeviceColor(aParams.color); ColorPattern colorPat(color); - StrokeOptions strokeOptions(lineThickness); + StrokeOptions strokeOptions(aParams.lineSize.height); DrawOptions drawOptions; Float dash[2]; @@ -4489,8 +4488,7 @@ Rect nsCSSRendering::DecorationLineToPath( return path; } - Float lineThickness = std::max(NS_round(aParams.lineSize.height), 1.0); - + const Float lineThickness = aParams.lineSize.height; // The block-direction position should be set to the middle of the line. if (aParams.vertical) { rect.x += lineThickness / 2; @@ -4546,8 +4544,7 @@ gfxRect nsCSSRendering::GetTextDecorationRectInternal( // and horizontal coordinates at the end if vertical was requested. gfxRect r(left, 0, right - left, 0); - gfxFloat lineThickness = NS_round(aParams.lineSize.height); - lineThickness = std::max(lineThickness, 1.0); + const gfxFloat lineThickness = aParams.lineSize.height; gfxFloat defaultLineThickness = NS_round(aParams.defaultLineThickness); defaultLineThickness = std::max(defaultLineThickness, 1.0); diff --git a/layout/reftests/text-decoration/line-through-thickness-rounding-1-ref.html b/layout/reftests/text-decoration/line-through-thickness-rounding-1-ref.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Reference: Line-through thickness 1px</title> +<style> + html, body { margin: 0; background: white; } + .test { + font: 40px/1 sans-serif; + color: black; + text-decoration-line: line-through; + text-decoration-style: solid; + text-decoration-color: black; + text-decoration-skip-ink: none; + text-decoration-thickness: 1px; + } + .pad { height: 40px; } +</style> +<div class="pad"></div> +<div class="test">TEST TEST TEST</div> diff --git a/layout/reftests/text-decoration/line-through-thickness-rounding-1.html b/layout/reftests/text-decoration/line-through-thickness-rounding-1.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Line-through thickness upward rounding test (0.6px should equal 1px)</title> +<style> + html, body { margin: 0; background: white; } + .test { + font: 40px/1 sans-serif; + color: black; + text-decoration-line: line-through; + text-decoration-style: solid; + text-decoration-color: black; + text-decoration-skip-ink: none; + text-decoration-thickness: 0.6px; /* Rounds via ceil(t * DPR) with a minimum of 1 device px; here 0.6 CSS px → 1 device px at DPR=1 */ + } + .pad { height: 40px; } +</style> +<div class="pad"></div> +<div class="test">TEST TEST TEST</div> diff --git a/layout/reftests/text-decoration/overline-thickness-rounding-1-ref.html b/layout/reftests/text-decoration/overline-thickness-rounding-1-ref.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Reference: Overline thickness 1px</title> +<style> + html, body { margin: 0; background: white; } + .test { + font: 40px/1 sans-serif; + color: black; + text-decoration-line: overline; + text-decoration-style: solid; + text-decoration-color: black; + text-decoration-skip-ink: none; + text-decoration-thickness: 1px; + } + .pad { height: 40px; } +</style> +<div class="pad"></div> +<div class="test">TEST TEST TEST</div> diff --git a/layout/reftests/text-decoration/overline-thickness-rounding-1.html b/layout/reftests/text-decoration/overline-thickness-rounding-1.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Overline thickness upward rounding test (0.1px should equal 1 device pixel)</title> +<style> + html, body { margin: 0; background: white; } + .test { + font: 40px/1 sans-serif; + color: black; + text-decoration-line: overline; + text-decoration-style: solid; + text-decoration-color: black; + text-decoration-skip-ink: none; + text-decoration-thickness: 0.1px; + } + .pad { height: 40px; } +</style> +<div class="pad"></div> +<div class="test">TEST TEST TEST</div> diff --git a/layout/reftests/text-decoration/reftest.list b/layout/reftests/text-decoration/reftest.list @@ -121,3 +121,7 @@ fuzzy(0-94,0-4) == skip-ink-cjk-1.html skip-ink-cjk-1-ref.html == skip-ink-cjk-3.html skip-ink-cjk-3-ref.html != always-underline-links.html always-underline-links-ref.html pref(layout.css.always_underline_links,true) == always-underline-links.html always-underline-links-ref.html +== underline-thickness-rounding-1.html underline-thickness-rounding-1-ref.html +== overline-thickness-rounding-1.html overline-thickness-rounding-1-ref.html +== line-through-thickness-rounding-1.html line-through-thickness-rounding-1-ref.html +== underline-thickness-rounding-dppx2-1.html underline-thickness-rounding-dppx2-1-ref.html # needs drawSnapshot; headless SWGL (no widget layers) makes drawWindow fail at forced DPR 2.0 diff --git a/layout/reftests/text-decoration/underline-thickness-rounding-1-ref.html b/layout/reftests/text-decoration/underline-thickness-rounding-1-ref.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Reference: Underline thickness 1px</title> +<style> + html, body { margin: 0; background: white; } + .test { + font: 40px/1 sans-serif; + color: black; + text-decoration-line: underline; + text-decoration-style: solid; + text-decoration-color: black; + text-decoration-skip-ink: none; + text-decoration-thickness: 1px; + } + .pad { height: 40px; } +</style> +<div class="pad"></div> +<div class="test">TEST TEST TEST</div> diff --git a/layout/reftests/text-decoration/underline-thickness-rounding-1.html b/layout/reftests/text-decoration/underline-thickness-rounding-1.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Underline thickness upward rounding test (0.1px should equal 1 device px)</title> +<style> + html, body { margin: 0; background: white; } + .test { + font: 40px/1 sans-serif; + color: black; + text-decoration-line: underline; + text-decoration-style: solid; + text-decoration-color: black; + text-decoration-skip-ink: none; + text-decoration-thickness: 0.1px; + } + .pad { height: 40px; } +</style> +<div class="pad"></div> +<div class="test">TEST TEST TEST</div> diff --git a/layout/reftests/text-decoration/underline-thickness-rounding-dppx2-1-ref.html b/layout/reftests/text-decoration/underline-thickness-rounding-dppx2-1-ref.html @@ -0,0 +1,23 @@ +<!doctype html> +<html reftest-zoom="2.0"> +<meta charset="utf-8"> +<title>Reference: Underline thickness 1px at effective 2x zoom (2 device px)</title> +<style> + html, body { margin: 0; background: white; } + .test { + font: 40px/1 sans-serif; + color: black; + text-decoration-line: underline; + text-decoration-style: solid; + text-decoration-color: black; + text-decoration-skip-ink: none; + /* 0.5 CSS px -> 1 device px at 2x zoom */ + text-decoration-thickness: 0.5px; + } + .pad { height: 40px; } +</style> +<div style="width:240px"> + <div class="pad"></div> + <div class="test">TEST TEST TEST</div> +</div> +</html> diff --git a/layout/reftests/text-decoration/underline-thickness-rounding-dppx2-1.html b/layout/reftests/text-decoration/underline-thickness-rounding-dppx2-1.html @@ -0,0 +1,28 @@ +<!doctype html> +<html reftest-zoom="2.0"> +<meta charset="utf-8"> +<title>Underline thickness upward rounding test at effective 2x zoom (0.6px should equal 1px => 2 device px)</title> +<!-- + High-DPI (2.0 dppx) underline thickness rounding test. + DPR 2.0 is forced via reftest-zoom. + 0.6 CSS px -> 1.2 device px at 2.0 dppx, which should floor to 1 (matching 1 dev px). +--> +<style> + html, body { margin: 0; background: white; } + .test { + font: 40px/1 sans-serif; + color: black; + text-decoration-line: underline; + text-decoration-style: solid; + text-decoration-color: black; + text-decoration-skip-ink: none; + /* 0.6 CSS px -> 1.2 device px at 2.0 dppx; should floor to 1 device px */ + text-decoration-thickness: 0.6px; + } + .pad { height: 40px; } +</style> +<div style="width:240px"> + <div class="pad"></div> + <div class="test">TEST TEST TEST</div> + </div> +</html> diff --git a/testing/web-platform/meta/svg/text/reftests/dominant-baseline-central-large-font-size.svg.ini b/testing/web-platform/meta/svg/text/reftests/dominant-baseline-central-large-font-size.svg.ini @@ -1,3 +1,3 @@ [dominant-baseline-central-large-font-size.svg] - expected: - if (os == "win") and not debug: [PASS, FAIL] + # Underline anti-aliasing. + fuzzy: maxDifference=0-5;totalPixels=0-100 diff --git a/testing/web-platform/tests/css/css-text-decor/text-decoration-thickness-length-rounding-001.html b/testing/web-platform/tests/css/css-text-decor/text-decoration-thickness-length-rounding-001.html @@ -0,0 +1,163 @@ +<!DOCTYPE html> +<html> + <head> + <title> + CSS Text Decoration Test: text-decoration-thickness length rounding down + </title> + + <link rel="author" title="Traian Captan" href="mailto:tcaptan@chromium.org"> + <link rel="help" href="https://drafts.csswg.org/css-text-decor-4/#text-decoration-width-property"> + <link rel="match" href="reference/text-decoration-thickness-length-rounding-ref.tentative.html"> + + <meta name="assert" content="text-decoration-thickness length is rounded down to 2px"> + <!-- NOTE: This test assumes DPI of 1 --> + + <style> + table { + border: 3px solid gray; + border-collapse: collapse; + } + + th, + td{ + border: 2px solid gray; + padding: 10px; + text-align: center; + } + + .two_point3_px { + text-decoration-thickness: 2.3px; + } + + .solid { + text-decoration-style: solid; + } + + .double { + text-decoration-style: double; + } + + .dotted { + text-decoration-style: dotted; + } + + .dashed { + text-decoration-style: dashed; + } + + .wavy { + text-decoration-style: wavy; + } + + .underline { + text-decoration-line: underline; + } + + .line_through { + text-decoration-line: line-through; + } + + .overline { + text-decoration-line: overline; + } + </style> + </head> + + <body> + <h1> + Test passes if text-decoration-thickness length is rounded to 2px + </h1> + + <table> + <thead> + <tr> + <th rowspan="2"> + Line Type + </th> + <th colspan="5"> + Line Style + </th> + </tr> + <tr> + <th> + Solid + </th> + <th> + Double + </th> + <th> + Dotted + </th> + <th> + Dashed + </th> + <th> + Wavy + </th> + </tr> + </thead> + <tbody> + <tr> + <th> + Underline + </th> + <td class="two_point3_px solid underline"> + Thickness test. + </td> + <td class="two_point3_px double underline"> + Thickness test. + </td> + <td class="two_point3_px dotted underline"> + Thickness test. + </td> + <td class="two_point3_px dashed underline"> + Thickness test. + </td> + <td class="two_point3_px wavy underline"> + Thickness test. + </td> + </tr> + <tr> + <th> + Line-through + </th> + <td class="two_point3_px solid line_through"> + Thickness test. + </td> + <td class="two_point3_px double line_through"> + Thickness test. + </td> + <td class="two_point3_px dotted line_through"> + Thickness test. + </td> + <td class="two_point3_px dashed line_through"> + Thickness test. + </td> + <td class="two_point3_px wavy line_through"> + Thickness test. + </td> + </tr> + <tr> + <th> + Overline + </th> + <td class="two_point3_px solid overline"> + Thickness test. + </td> + <td class="two_point3_px double overline"> + Thickness test. + </td> + <td class="two_point3_px dotted overline"> + Thickness test. + </td> + <td class="two_point3_px dashed overline"> + Thickness test. + </td> + <td class="two_point3_px wavy overline"> + Thickness test. + </td> + </tr> + </tbody> + </table> + </body> +</html> diff --git a/testing/web-platform/tests/css/css-text-decor/text-decoration-thickness-length-rounding-002.html b/testing/web-platform/tests/css/css-text-decor/text-decoration-thickness-length-rounding-002.html @@ -0,0 +1,163 @@ +<!DOCTYPE html> +<html> + <head> + <title> + CSS Text Decoration Test: text-decoration-thickness length rounding up + </title> + + <link rel="author" title="Traian Captan" href="mailto:tcaptan@chromium.org"> + <link rel="help" href="https://drafts.csswg.org/css-text-decor-4/#text-decoration-width-property"> + <link rel="match" href="reference/text-decoration-thickness-length-rounding-ref.tentative.html"> + + <meta name="assert" content="text-decoration-thickness length is floored to 2px"> + <!-- NOTE: This test assumes DPI of 1 --> + + <style> + table { + border: 3px solid gray; + border-collapse: collapse; + } + + th, + td{ + border: 2px solid gray; + padding: 10px; + text-align: center; + } + + .two_point7_px { + text-decoration-thickness: 2.7px; + } + + .solid { + text-decoration-style: solid; + } + + .double { + text-decoration-style: double; + } + + .dotted { + text-decoration-style: dotted; + } + + .dashed { + text-decoration-style: dashed; + } + + .wavy { + text-decoration-style: wavy; + } + + .underline { + text-decoration-line: underline; + } + + .line_through { + text-decoration-line: line-through; + } + + .overline { + text-decoration-line: overline; + } + </style> + </head> + + <body> + <h1> + Test passes if text-decoration-thickness length is rounded to 2px + </h1> + + <table> + <thead> + <tr> + <th rowspan="2"> + Line Type + </th> + <th colspan="5"> + Line Style + </th> + </tr> + <tr> + <th> + Solid + </th> + <th> + Double + </th> + <th> + Dotted + </th> + <th> + Dashed + </th> + <th> + Wavy + </th> + </tr> + </thead> + <tbody> + <tr> + <th> + Underline + </th> + <td class="two_point7_px solid underline"> + Thickness test. + </td> + <td class="two_point7_px double underline"> + Thickness test. + </td> + <td class="two_point7_px dotted underline"> + Thickness test. + </td> + <td class="two_point7_px dashed underline"> + Thickness test. + </td> + <td class="two_point7_px wavy underline"> + Thickness test. + </td> + </tr> + <tr> + <th> + Line-through + </th> + <td class="two_point7_px solid line_through"> + Thickness test. + </td> + <td class="two_point7_px double line_through"> + Thickness test. + </td> + <td class="two_point7_px dotted line_through"> + Thickness test. + </td> + <td class="two_point7_px dashed line_through"> + Thickness test. + </td> + <td class="two_point7_px wavy line_through"> + Thickness test. + </td> + </tr> + <tr> + <th> + Overline + </th> + <td class="two_point7_px solid overline"> + Thickness test. + </td> + <td class="two_point7_px double overline"> + Thickness test. + </td> + <td class="two_point7_px dotted overline"> + Thickness test. + </td> + <td class="two_point7_px dashed overline"> + Thickness test. + </td> + <td class="two_point7_px wavy overline"> + Thickness test. + </td> + </tr> + </tbody> + </table> + </body> +</html> diff --git a/testing/web-platform/tests/css/css-text-decor/text-decoration-thickness-length-rounding-down.tentative.html b/testing/web-platform/tests/css/css-text-decor/text-decoration-thickness-length-rounding-down.tentative.html @@ -1,162 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title> - CSS Text Decoration Test: text-decoration-thickness length rounding down - </title> - - <link rel="author" title="Traian Captan" href="mailto:tcaptan@chromium.org"> - <link rel="help" href="https://drafts.csswg.org/css-text-decor-4/#text-decoration-width-property"> - <link rel="match" href="reference/text-decoration-thickness-length-rounding-ref.tentative.html"> - - <meta name="assert" content="text-decoration-thickness length is rounded down to 2px"> - - <style> - table { - border: 3px solid gray; - border-collapse: collapse; - } - - th, - td{ - border: 2px solid gray; - padding: 10px; - text-align: center; - } - - .two_point3_px { - text-decoration-thickness: 2.3px; - } - - .solid { - text-decoration-style: solid; - } - - .double { - text-decoration-style: double; - } - - .dotted { - text-decoration-style: dotted; - } - - .dashed { - text-decoration-style: dashed; - } - - .wavy { - text-decoration-style: wavy; - } - - .underline { - text-decoration-line: underline; - } - - .line_through { - text-decoration-line: line-through; - } - - .overline { - text-decoration-line: overline; - } - </style> - </head> - - <body> - <h1> - Test passes if text-decoration-thickness length is rounded to 2px - </h1> - - <table> - <thead> - <tr> - <th rowspan="2"> - Line Type - </th> - <th colspan="5"> - Line Style - </th> - </tr> - <tr> - <th> - Solid - </th> - <th> - Double - </th> - <th> - Dotted - </th> - <th> - Dashed - </th> - <th> - Wavy - </th> - </tr> - </thead> - <tbody> - <tr> - <th> - Underline - </th> - <td class="two_point3_px solid underline"> - Thickness test. - </td> - <td class="two_point3_px double underline"> - Thickness test. - </td> - <td class="two_point3_px dotted underline"> - Thickness test. - </td> - <td class="two_point3_px dashed underline"> - Thickness test. - </td> - <td class="two_point3_px wavy underline"> - Thickness test. - </td> - </tr> - <tr> - <th> - Line-through - </th> - <td class="two_point3_px solid line_through"> - Thickness test. - </td> - <td class="two_point3_px double line_through"> - Thickness test. - </td> - <td class="two_point3_px dotted line_through"> - Thickness test. - </td> - <td class="two_point3_px dashed line_through"> - Thickness test. - </td> - <td class="two_point3_px wavy line_through"> - Thickness test. - </td> - </tr> - <tr> - <th> - Overline - </th> - <td class="two_point3_px solid overline"> - Thickness test. - </td> - <td class="two_point3_px double overline"> - Thickness test. - </td> - <td class="two_point3_px dotted overline"> - Thickness test. - </td> - <td class="two_point3_px dashed overline"> - Thickness test. - </td> - <td class="two_point3_px wavy overline"> - Thickness test. - </td> - </tr> - </tbody> - </table> - </body> -</html> diff --git a/testing/web-platform/tests/css/css-text-decor/text-decoration-thickness-length-rounding-up.tentative.html b/testing/web-platform/tests/css/css-text-decor/text-decoration-thickness-length-rounding-up.tentative.html @@ -1,162 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title> - CSS Text Decoration Test: text-decoration-thickness length rounding up - </title> - - <link rel="author" title="Traian Captan" href="mailto:tcaptan@chromium.org"> - <link rel="help" href="https://drafts.csswg.org/css-text-decor-4/#text-decoration-width-property"> - <link rel="match" href="reference/text-decoration-thickness-length-rounding-ref.tentative.html"> - - <meta name="assert" content="text-decoration-thickness length is rounded up to 2px"> - - <style> - table { - border: 3px solid gray; - border-collapse: collapse; - } - - th, - td{ - border: 2px solid gray; - padding: 10px; - text-align: center; - } - - .one_point7_px { - text-decoration-thickness: 1.7px; - } - - .solid { - text-decoration-style: solid; - } - - .double { - text-decoration-style: double; - } - - .dotted { - text-decoration-style: dotted; - } - - .dashed { - text-decoration-style: dashed; - } - - .wavy { - text-decoration-style: wavy; - } - - .underline { - text-decoration-line: underline; - } - - .line_through { - text-decoration-line: line-through; - } - - .overline { - text-decoration-line: overline; - } - </style> - </head> - - <body> - <h1> - Test passes if text-decoration-thickness length is rounded to 2px - </h1> - - <table> - <thead> - <tr> - <th rowspan="2"> - Line Type - </th> - <th colspan="5"> - Line Style - </th> - </tr> - <tr> - <th> - Solid - </th> - <th> - Double - </th> - <th> - Dotted - </th> - <th> - Dashed - </th> - <th> - Wavy - </th> - </tr> - </thead> - <tbody> - <tr> - <th> - Underline - </th> - <td class="one_point7_px solid underline"> - Thickness test. - </td> - <td class="one_point7_px double underline"> - Thickness test. - </td> - <td class="one_point7_px dotted underline"> - Thickness test. - </td> - <td class="one_point7_px dashed underline"> - Thickness test. - </td> - <td class="one_point7_px wavy underline"> - Thickness test. - </td> - </tr> - <tr> - <th> - Line-through - </th> - <td class="one_point7_px solid line_through"> - Thickness test. - </td> - <td class="one_point7_px double line_through"> - Thickness test. - </td> - <td class="one_point7_px dotted line_through"> - Thickness test. - </td> - <td class="one_point7_px dashed line_through"> - Thickness test. - </td> - <td class="one_point7_px wavy line_through"> - Thickness test. - </td> - </tr> - <tr> - <th> - Overline - </th> - <td class="one_point7_px solid overline"> - Thickness test. - </td> - <td class="one_point7_px double overline"> - Thickness test. - </td> - <td class="one_point7_px dotted overline"> - Thickness test. - </td> - <td class="one_point7_px dashed overline"> - Thickness test. - </td> - <td class="one_point7_px wavy overline"> - Thickness test. - </td> - </tr> - </tbody> - </table> - </body> -</html> diff --git a/widget/ThemeDrawing.cpp b/widget/ThemeDrawing.cpp @@ -25,12 +25,16 @@ void ThemeDrawing::FillRect(WebRenderBackendData& aWrData, } /*static*/ -LayoutDeviceIntCoord ThemeDrawing::SnapBorderWidth(const CSSCoord& aCssWidth, - const DPIRatio& aDpiRatio) { - if (aCssWidth == 0.0f) { +LayoutDeviceIntCoord ThemeDrawing::SnapBorderWidth(CSSCoord aCssWidth, + DPIRatio aDpiRatio) { + return SnapBorderWidth(aCssWidth * aDpiRatio); +} + +LayoutDeviceIntCoord ThemeDrawing::SnapBorderWidth(LayoutDeviceCoord aWidth) { + if (aWidth == 0.0f) { return 0; } - return std::max(LayoutDeviceIntCoord(1), (aCssWidth * aDpiRatio).Truncated()); + return std::max(LayoutDeviceIntCoord(1), aWidth.Truncated()); } /*static*/ diff --git a/widget/ThemeDrawing.h b/widget/ThemeDrawing.h @@ -41,8 +41,9 @@ class ThemeDrawing { return std::min(aRect.width, aRect.height) / aSize; } - static LayoutDeviceIntCoord SnapBorderWidth(const CSSCoord& aCssWidth, - const DPIRatio& aDpiRatio); + static LayoutDeviceIntCoord SnapBorderWidth(CSSCoord aCssWidth, + DPIRatio aDpiRatio); + static LayoutDeviceIntCoord SnapBorderWidth(LayoutDeviceCoord); static void PaintArrow(DrawTarget&, const LayoutDeviceRect&, const float aArrowPolygonX[], diff --git a/widget/moz.build b/widget/moz.build @@ -234,6 +234,7 @@ EXPORTS.mozilla.widget += [ "ScreenManager.h", "TextRecognition.h", "ThemeChangeKind.h", + "ThemeDrawing.h", "WidgetLogging.h", "WidgetMessageUtils.h", "WindowOcclusionState.h",