bug 735577 - pt 4.2 - convert width and height fields in nsHTMLReflowMetrics to logical coordinates. r=smontagu
authorJonathan Kew <jkew@mozilla.com>
Fri, 27 Dec 2013 18:00:04 +0000
changeset 161817 07f8896db19cbc95ac470406e0b810f8e68eed8b
parent 161816 72591e9d49a8432c45b304c7ccb86a8e09947bb1
child 161818 1ed3e04b050b17fac55c0a951917beae6cbd28ba
push id37993
push userjkew@mozilla.com
push dateFri, 27 Dec 2013 18:02:20 +0000
treeherdermozilla-inbound@07f8896db19c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs735577
milestone29.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 735577 - pt 4.2 - convert width and height fields in nsHTMLReflowMetrics to logical coordinates. r=smontagu
layout/generic/nsHTMLReflowMetrics.h
--- a/layout/generic/nsHTMLReflowMetrics.h
+++ b/layout/generic/nsHTMLReflowMetrics.h
@@ -198,31 +198,72 @@ class nsHTMLReflowMetrics {
 public:
   // XXXldb Should |aFlags| generally be passed from parent to child?
   // Some places do it, and some don't.  |aFlags| should perhaps go away
   // entirely.
   // XXX width/height/ascent are OUT parameters and so they shouldn't
   // have to be initialized, but there are some bad frame classes that
   // aren't properly setting them when returning from Reflow()...
   nsHTMLReflowMetrics(mozilla::WritingMode aWritingMode, uint32_t aFlags = 0)
-    : mWidth(0)
-    , mHeight(0)
-    , mAscent(ASK_FOR_BASELINE)
+    : mISize(0)
+    , mBSize(0)
+    , mBlockStartAscent(ASK_FOR_BASELINE)
     , mFlags(aFlags)
     , mWritingMode(aWritingMode)
   {}
 
-  const nscoord& Width() const { return mWidth; }
-  const nscoord& Height() const { return mHeight; }
-  const nscoord& TopAscent() const { return mAscent; }
+  nscoord ISize() const { return mISize; }
+  nscoord BSize() const { return mBSize; }
+
+  nscoord& ISize() { return mISize; }
+  nscoord& BSize() { return mBSize; }
+
+  nscoord Width() const { return mWritingMode.IsVertical() ? mBSize : mISize; }
+  nscoord Height() const { return mWritingMode.IsVertical() ? mISize : mBSize; }
+
+  nscoord TopAscent() const
+  {
+    return mWritingMode.IsVertical() ? 0 : mBlockStartAscent;
+  }
+  nscoord LeftAscent() const
+  {
+    return mWritingMode.IsVertical() && mWritingMode.IsVerticalLR() ?
+           mBlockStartAscent : 0;
+  }
+  nscoord RightAscent() const
+  {
+    return mWritingMode.IsVertical() && !mWritingMode.IsVerticalLR() ?
+           mBlockStartAscent : 0;
+  }
 
-  nscoord& Width() { return mWidth; }
-  nscoord& Height() { return mHeight; }
+  nscoord& Width() { return mWritingMode.IsVertical() ? mBSize : mISize; }
+  nscoord& Height() { return mWritingMode.IsVertical() ? mISize : mBSize; }
 
-  void SetTopAscent(nscoord aAscent) { mAscent = aAscent; }
+  void SetBlockStartAscent(mozilla::WritingMode aWritingMode, nscoord aAscent)
+  {
+    NS_ASSERTION(aWritingMode == mWritingMode, "writing mode mismatch");
+    mBlockStartAscent = aAscent;
+  }
+  void SetTopAscent(nscoord aAscent)
+  {
+    NS_ASSERTION(!mWritingMode.IsVertical(), "writing mode mismatch");
+    mBlockStartAscent = aAscent;
+  }
+  void SetLeftAscent(nscoord aAscent)
+  {
+    NS_ASSERTION(mWritingMode.IsVertical() && mWritingMode.IsVerticalLR(),
+                 "writing mode mismatch");
+    mBlockStartAscent = aAscent;
+  }
+  void SetRightAscent(nscoord aAscent)
+  {
+    NS_ASSERTION(mWritingMode.IsVertical() && !mWritingMode.IsVerticalLR(),
+                 "writing mode mismatch");
+    mBlockStartAscent = aAscent;
+  }
 
   enum { ASK_FOR_BASELINE = nscoord_MAX };
 
   // Metrics that _exactly_ enclose the text to allow precise MathML placements.
   // If the NS_REFLOW_CALC_BOUNDING_METRICS flag is set, then the caller is 
   // requesting that you also compute additional details about your inner
   // bounding box and italic correction. For example, the bounding box of
   // msup is the smallest rectangle that _exactly_ encloses both the text
@@ -256,18 +297,18 @@ public:
   void SetOverflowAreasToDesiredBounds();
 
   // Union all of mOverflowAreas with (0, 0, width, height).
   void UnionOverflowAreasWithDesiredBounds();
 
   mozilla::WritingMode GetWritingMode() const { return mWritingMode; }
 
 private:
-  nscoord mWidth, mHeight; // [OUT] desired width and height (border-box)
-  nscoord mAscent;         // [OUT] baseline (from top), or ASK_FOR_BASELINE
+  nscoord mISize, mBSize; // [OUT] desired width and height (border-box)
+  nscoord mBlockStartAscent; // [OUT] baseline (in Block direction), or ASK_FOR_BASELINE
 
 public:
   uint32_t mFlags;
 
 private:
   mozilla::WritingMode mWritingMode;
 };