Bug 1415214 - (Part 1) Fix the bound of the clip rect for drawing decoration lines draft
authorKuoE0 <kuoe0.tw@gmail.com>
Wed, 08 Nov 2017 15:57:43 +0800
changeset 696158 fcc168b8aaedefeec142a8ee6a5ff638c5db622e
parent 695940 ed94dc665071d8d510688ff50bbedad2c7cb33ee
child 696159 0b285abd49e6b95bbeec71bbf090319da46aebd5
push id88655
push userbmo:kuoe0@mozilla.com
push dateFri, 10 Nov 2017 08:41:17 +0000
bugs1415214
milestone58.0a1
Bug 1415214 - (Part 1) Fix the bound of the clip rect for drawing decoration lines MozReview-Commit-ID: 6nUBwEtsJbs
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,