Add more logical-coordinate API to nsIFrame. Bug 735577, r=jfkthame
authorSimon Montagu <smontagu@smontagu.org>
Tue, 04 Mar 2014 23:31:47 -0800
changeset 171944 ca402c27bf50aa91b19b290ff8814e149b747f0d
parent 171943 ecd0fa3e4a8e5abc6f091590e0ec99289e1e89a4
child 171945 7f7d0399102a8703d675007a3c61465ba3a4c4d3
push id26342
push usercbook@mozilla.com
push dateWed, 05 Mar 2014 12:04:59 +0000
treeherdermozilla-central@7f7d0399102a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs735577
milestone30.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
Add more logical-coordinate API to nsIFrame. Bug 735577, r=jfkthame
layout/generic/nsIFrame.h
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -682,23 +682,60 @@ public:
    */
   nsRect GetRect() const { return mRect; }
   nsPoint GetPosition() const { return mRect.TopLeft(); }
   nsSize GetSize() const { return mRect.Size(); }
   nsRect GetRectRelativeToSelf() const {
     return nsRect(nsPoint(0, 0), mRect.Size());
   }
   /**
-   * Rect and position in logical coordinates in the frame's writing mode
+   * Dimensions and position in logical coordinates in the frame's writing mode
+   *  or another writing mode
    */
   mozilla::LogicalRect GetLogicalRect(nscoord aContainerWidth) const {
-    return mozilla::LogicalRect(GetWritingMode(), GetRect(), aContainerWidth);
+    return GetLogicalRect(GetWritingMode(), aContainerWidth);
   }
   mozilla::LogicalPoint GetLogicalPosition(nscoord aContainerWidth) const {
-    return GetLogicalRect(aContainerWidth).Origin(GetWritingMode());
+    return GetLogicalPosition(GetWritingMode(), aContainerWidth);
+  }
+  mozilla::LogicalSize GetLogicalSize() const {
+    return GetLogicalSize(GetWritingMode());
+  }
+  mozilla::LogicalRect GetLogicalRect(mozilla::WritingMode aWritingMode,
+                                      nscoord aContainerWidth) const {
+    return mozilla::LogicalRect(aWritingMode, GetRect(), aContainerWidth);
+  }
+  mozilla::LogicalPoint GetLogicalPosition(mozilla::WritingMode aWritingMode,
+                                           nscoord aContainerWidth) const {
+    return GetLogicalRect(aWritingMode, aContainerWidth).Origin(aWritingMode);
+  }
+  mozilla::LogicalSize GetLogicalSize(mozilla::WritingMode aWritingMode) const {
+    return mozilla::LogicalSize(aWritingMode, GetSize());
+  }
+  nscoord IStart(nscoord aContainerWidth) const {
+    return IStart(GetWritingMode(), aContainerWidth);
+  }
+  nscoord IStart(mozilla::WritingMode aWritingMode,
+                 nscoord aContainerWidth) const {
+    return GetLogicalPosition(aWritingMode, aContainerWidth).I(aWritingMode);
+  }
+  nscoord BStart(nscoord aContainerWidth) const {
+    return BStart(GetWritingMode(), aContainerWidth);
+  }
+  nscoord BStart(mozilla::WritingMode aWritingMode,
+                 nscoord aContainerWidth) const {
+    return GetLogicalPosition(aWritingMode, aContainerWidth).B(aWritingMode);
+  }
+  nscoord ISize() const { return ISize(GetWritingMode()); }
+  nscoord ISize(mozilla::WritingMode aWritingMode) const {
+    return GetLogicalSize(aWritingMode).ISize(aWritingMode);
+  }
+  nscoord BSize() const { return BSize(GetWritingMode()); }
+  nscoord BSize(mozilla::WritingMode aWritingMode) const {
+    return GetLogicalSize(aWritingMode).BSize(aWritingMode);
   }
 
   /**
    * When we change the size of the frame's border-box rect, we may need to
    * reset the overflow rect if it was previously stored as deltas.
    * (If it is currently a "large" overflow and could be re-packed as deltas,
    * we don't bother as the cost of the allocation has already been paid.)
    */
@@ -710,27 +747,26 @@ public:
       SetOverflowAreas(overflow);
     } else {
       mRect = aRect;
     }
   }
   /**
    * Set this frame's rect from a logical rect in its own writing direction
    */
-  void SetRectFromLogicalRect(const mozilla::LogicalRect& aRect,
-                              nscoord aContainerWidth) {
-    SetRectFromLogicalRect(GetWritingMode(), aRect, aContainerWidth);
+  void SetRect(const mozilla::LogicalRect& aRect, nscoord aContainerWidth) {
+    SetRect(GetWritingMode(), aRect, aContainerWidth);
   }
   /**
    * Set this frame's rect from a logical rect in a different writing direction
    * (GetPhysicalRect will assert if the writing mode doesn't match)
    */
-  void SetRectFromLogicalRect(mozilla::WritingMode aWritingMode,
-                              const mozilla::LogicalRect& aRect,
-                              nscoord aContainerWidth) {
+  void SetRect(mozilla::WritingMode aWritingMode,
+               const mozilla::LogicalRect& aRect,
+               nscoord aContainerWidth) {
     SetRect(aRect.GetPhysicalRect(aWritingMode, aContainerWidth));
   }
   void SetSize(const nsSize& aSize) {
     SetRect(nsRect(mRect.TopLeft(), aSize));
   }
   void SetPosition(const nsPoint& aPt) { mRect.MoveTo(aPt); }
 
   /**