diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list index 93fef3361e52..bc60d0b175f7 100644 --- a/layout/reftests/svg/reftest.list +++ b/layout/reftests/svg/reftest.list @@ -490,6 +490,7 @@ fuzzy-if(cocoaWidget&&layersGPUAccelerated,0-1,0-3) random-if(/^Windows\x20NT\x2 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == text-layout-07.svg text-layout-07-ref.svg # Bug 1392106 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == text-layout-08.svg text-layout-08-ref.svg # Bug 1392106 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == text-layout-09.svg pass.svg # Bug 1392106 +random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == text-layout-10.svg pass.svg # Bug 1392106 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == text-scale-01.svg text-scale-01-ref.svg # Bug 1392106 fuzzy-if(skiaContent,0-2,0-1000) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == text-scale-02.svg text-scale-02-ref.svg # Bug 1392106 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == text-scale-03.svg text-scale-03-ref.svg # Bug 1392106 diff --git a/layout/reftests/svg/text-layout-09.svg b/layout/reftests/svg/text-layout-09.svg index 2ab40960c90a..c5a0626c0858 100644 --- a/layout/reftests/svg/text-layout-09.svg +++ b/layout/reftests/svg/text-layout-09.svg @@ -20,9 +20,11 @@ } ]]> + diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index c8c03a108664..f7409a615704 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -283,24 +283,31 @@ static nscoord GetBaselinePosition(nsTextFrame* aFrame, gfxTextRun* aTextRun, gfxTextRun::Metrics metrics = aTextRun->MeasureText(gfxFont::LOOSE_INK_EXTENTS, nullptr); + auto convertIfVerticalRL = [&](gfxFloat dominantBaseline) { + return writingMode.IsVerticalRL() + ? metrics.mAscent + metrics.mDescent - dominantBaseline + : dominantBaseline; + }; + switch (aDominantBaseline) { case StyleDominantBaseline::Hanging: - return metrics.mAscent * 0.2; + return convertIfVerticalRL(metrics.mAscent * 0.2); case StyleDominantBaseline::TextBeforeEdge: - return writingMode.IsVerticalRL() ? metrics.mAscent + metrics.mDescent - : 0; + return convertIfVerticalRL(0); - case StyleDominantBaseline::Auto: case StyleDominantBaseline::Alphabetic: return writingMode.IsVerticalRL() - ? metrics.mAscent + metrics.mDescent - - aFrame->GetLogicalBaseline(writingMode) + ? metrics.mAscent * 0.5 : aFrame->GetLogicalBaseline(writingMode); + case StyleDominantBaseline::Auto: + return convertIfVerticalRL(aFrame->GetLogicalBaseline(writingMode)); + case StyleDominantBaseline::Middle: - return aFrame->GetLogicalBaseline(writingMode) - - SVGContentUtils::GetFontXHeight(aFrame) / 2.0 * - AppUnitsPerCSSPixel() * aFontSizeScaleFactor; + return convertIfVerticalRL(aFrame->GetLogicalBaseline(writingMode) - + SVGContentUtils::GetFontXHeight(aFrame) / 2.0 * + AppUnitsPerCSSPixel() * + aFontSizeScaleFactor); case StyleDominantBaseline::TextAfterEdge: case StyleDominantBaseline::Ideographic: @@ -310,11 +317,11 @@ static nscoord GetBaselinePosition(nsTextFrame* aFrame, gfxTextRun* aTextRun, case StyleDominantBaseline::Central: return (metrics.mAscent + metrics.mDescent) / 2.0; case StyleDominantBaseline::Mathematical: - return metrics.mAscent / 2.0; + return convertIfVerticalRL(metrics.mAscent / 2.0); } MOZ_ASSERT_UNREACHABLE("unexpected dominant-baseline value"); - return aFrame->GetLogicalBaseline(writingMode); + return convertIfVerticalRL(aFrame->GetLogicalBaseline(writingMode)); } /**