Add some logical setters/getters to nsIFrame.h. Bug 735577, r=jfkthame
authorSimon Montagu <smontagu@smontagu.org>
Wed, 12 Feb 2014 23:55:06 -0800
changeset 168561 a63da21ad30b244c6488a4068cbf5136d564d8bc
parent 168560 72a491f40e45687fedf8222636ec97b45d5a3756
child 168562 e41e1fd3c90042505001445cb72e4933fdf8ced2
push id26209
push userryanvm@gmail.com
push dateThu, 13 Feb 2014 15:30:03 +0000
treeherdermozilla-central@a2939bac372b [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 some logical setters/getters to nsIFrame.h. Bug 735577, r=jfkthame
layout/generic/nsIFrame.h
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -681,16 +681,25 @@ public:
    * position.
    */
   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
+   */
+  mozilla::LogicalRect GetLogicalRect(nscoord aContainerWidth) const {
+    return mozilla::LogicalRect(GetWritingMode(), GetRect(), aContainerWidth);
+  }
+  mozilla::LogicalPoint GetLogicalPosition(nscoord aContainerWidth) const {
+    return GetLogicalRect(aContainerWidth).Origin(GetWritingMode());
+  }
 
   /**
    * 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.)
    */
   void SetRect(const nsRect& aRect) {
@@ -698,16 +707,32 @@ public:
         mOverflow.mType != NS_FRAME_OVERFLOW_NONE) {
       nsOverflowAreas overflow = GetOverflowAreas();
       mRect = aRect;
       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);
+  }
+  /**
+   * 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) {
+    SetRect(aRect.GetPhysicalRect(aWritingMode, aContainerWidth));
+  }
   void SetSize(const nsSize& aSize) {
     SetRect(nsRect(mRect.TopLeft(), aSize));
   }
   void SetPosition(const nsPoint& aPt) { mRect.MoveTo(aPt); }
 
   /**
    * Move the frame, accounting for relative positioning. Use this when
    * adjusting the frame's position by a known amount, to properly update its