Bug 1111944 - part 2 - Update nsBulletFrame::PaintBullet to handle vertical text in list item markers. r=smontagu
authorJonathan Kew <jkew@mozilla.com>
Tue, 06 Jan 2015 20:56:03 +0000
changeset 239009 603b4a6ccd6a9334dfc693e5cac3886b374a2faf
parent 239008 646e58995d5356cdc21cb64d909dfa8f3fd8ba44
child 239010 d3bbe13bbd085772208cfb0dcb3bc458f8ee7d5c
push id7472
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 20:36:27 +0000
treeherdermozilla-aurora@300ca104f8fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs1111944
milestone37.0a1
Bug 1111944 - part 2 - Update nsBulletFrame::PaintBullet to handle vertical text in list item markers. r=smontagu
layout/generic/nsBulletFrame.cpp
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -301,17 +301,16 @@ nsBulletFrame::PaintBullet(nsRenderingCo
 
   nsRefPtr<nsFontMetrics> fm;
   ColorPattern color(ToDeviceColor(
                        nsLayoutUtils::GetColor(this, eCSSProperty_color)));
 
   DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
   int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
 
-  nsAutoString text;
   switch (listStyleType->GetStyle()) {
   case NS_STYLE_LIST_STYLE_NONE:
     break;
 
   case NS_STYLE_LIST_STYLE_DISC:
   case NS_STYLE_LIST_STYLE_CIRCLE:
     {
       nsRect rect(padding.left + aPt.x,
@@ -399,32 +398,43 @@ nsBulletFrame::PaintBullet(nsRenderingCo
         }
       }
       RefPtr<Path> path = builder->Finish();
       drawTarget->Fill(path, color);
     }
     break;
 
   default:
-    aRenderingContext.ThebesContext()->SetColor(
-                        nsLayoutUtils::GetColor(this, eCSSProperty_color));
+    {
+      aRenderingContext.ThebesContext()->SetColor(
+                          nsLayoutUtils::GetColor(this, eCSSProperty_color));
 
-    nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
-                                          GetFontSizeInflation());
-    GetListItemText(text);
-    nscoord ascent = fm->MaxAscent();
-    aPt.MoveBy(padding.left, padding.top);
-    aPt.y = NSToCoordRound(nsLayoutUtils::GetSnappedBaselineY(
-            this, aRenderingContext.ThebesContext(), aPt.y, ascent));
-    nsPresContext* presContext = PresContext();
-    if (!presContext->BidiEnabled() && HasRTLChars(text)) {
-      presContext->SetBidiEnabled();
+      nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
+                                            GetFontSizeInflation());
+      nsAutoString text;
+      GetListItemText(text);
+      WritingMode wm = GetWritingMode();
+      nscoord ascent = wm.IsLineInverted()
+                         ? fm->MaxDescent() : fm->MaxAscent();
+      aPt.MoveBy(padding.left, padding.top);
+      if (wm.IsVertical()) {
+        // XXX what about baseline snapping?
+        aPt.x += (wm.IsVerticalLR() ? ascent
+                                    : mRect.width - ascent);
+      } else {
+        aPt.y = NSToCoordRound(nsLayoutUtils::GetSnappedBaselineY(
+                this, aRenderingContext.ThebesContext(), aPt.y, ascent));
+      }
+      nsPresContext* presContext = PresContext();
+      if (!presContext->BidiEnabled() && HasRTLChars(text)) {
+        presContext->SetBidiEnabled();
+      }
+      nsLayoutUtils::DrawString(this, *fm, &aRenderingContext,
+                                text.get(), text.Length(), aPt);
     }
-    nsLayoutUtils::DrawString(this, *fm, &aRenderingContext,
-                              text.get(), text.Length(), aPt);
     break;
   }
 }
 
 int32_t
 nsBulletFrame::SetListItemOrdinal(int32_t aNextOrdinal,
                                   bool* aChanged,
                                   int32_t aIncrement)
@@ -580,17 +590,18 @@ nsBulletFrame::GetDesiredSize(nsPresCont
       break;
 
     default:
       GetListItemText(text);
       finalSize.BSize(wm) = fm->MaxHeight();
       finalSize.ISize(wm) =
         nsLayoutUtils::AppUnitWidthOfStringBidi(text, this, *fm,
                                                 *aRenderingContext);
-      aMetrics.SetBlockStartAscent(fm->MaxAscent());
+      aMetrics.SetBlockStartAscent(wm.IsLineInverted()
+                                     ? fm->MaxDescent() : fm->MaxAscent());
       break;
   }
   aMetrics.SetSize(wm, finalSize);
 }
 
 void
 nsBulletFrame::Reflow(nsPresContext* aPresContext,
                       nsHTMLReflowMetrics& aMetrics,