Bug 1415214 - (Part 1) Fix the bound of the clip rect for drawing decoration lines. r=jfkthame
authorTommy Kuo <kuoe0@mozilla.com>
Fri, 10 Nov 2017 16:45:19 +0800
changeset 444431 647c6595838e0fd6f9dd5e4e8209c362b1159189
parent 444430 4762a6f8723887fc72c7adc28da8ee5731f0aa8d
child 444432 cd5fb16264419253aa515e80b4d6aeed41ac0fbe
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1415214
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1415214 - (Part 1) Fix the bound of the clip rect for drawing decoration lines. r=jfkthame MozReview-Commit-ID: KoDvzqaCSGB
layout/generic/nsTextFrame.cpp
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -7280,29 +7280,34 @@ nsTextFrame::DrawTextRunAndDecorations(R
     //   "text-combine-upright" (Bug 1408825)
     bool skipClipping = aRange.Length() == mTextRun->GetLength() ||
                         verticalDec != verticalRun;
 
     gfxRect clipRect;
     if (!skipClipping) {
       // Get the inline-size according to the specified range.
       gfxFloat clipLength = mTextRun->GetAdvanceWidth(aRange, aParams.provider);
-
-      clipRect.width = verticalDec ? frameSize.width : clipLength / app;
-      clipRect.height = verticalDec ? clipLength / app : frameSize.height;
+      nsRect visualRect = GetVisualOverflowRect();
 
       const bool isInlineReversed = mTextRun->IsInlineReversed();
       if (verticalDec) {
-        clipRect.y = (isInlineReversed ? aTextBaselinePt.y - clipLength
-                                       : aTextBaselinePt.y) / app;
+        clipRect.x = aParams.framePt.x + visualRect.x;
+        clipRect.y = isInlineReversed ? aTextBaselinePt.y - clipLength
+                                      : aTextBaselinePt.y;
+        clipRect.width = visualRect.width;
+        clipRect.height = clipLength;
       } else {
-        clipRect.x = (isInlineReversed ? aTextBaselinePt.x - clipLength
-                                       : aTextBaselinePt.x) / app;
-      }
-
+        clipRect.x = isInlineReversed ? aTextBaselinePt.x - clipLength
+                                      : aTextBaselinePt.x;
+        clipRect.y = aParams.framePt.y + visualRect.y;
+        clipRect.width = clipLength;
+        clipRect.height = visualRect.height;
+      }
+
+      clipRect.Scale(1 / app);
       clipRect.Round();
       params.context->Clip(clipRect);
     }
 
     // Underlines
     params.decoration = NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE;
     for (const LineDecoration& dec : Reversed(aDecorations.mUnderlines)) {
       paintDecorationLine(dec, &Metrics::underlineSize,