bug 1046950 pt 1 - additional/modified APIs on LogicalSize. r=smontagu
authorJonathan Kew <jkew@mozilla.com>
Sun, 24 Aug 2014 15:34:21 +0100
changeset 222955 ee3477f5614b0e8220d2a8918825a2262e455ead
parent 222954 7f6c7446236208965c91178c17c3a14d0bf0be94
child 222956 54ada5ad66bb17c41aa9295e63296a6b189e6b40
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs1046950
milestone34.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 1046950 pt 1 - additional/modified APIs on LogicalSize. r=smontagu
layout/forms/nsHTMLButtonControlFrame.cpp
layout/generic/WritingModes.h
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -264,19 +264,19 @@ nsHTMLButtonControlFrame::ReflowButtonCo
     nscoord extraleft = extrawidth / 2;
     nscoord extraright = extrawidth - extraleft;
     NS_ASSERTION(extraright >=0, "How'd that happen?");
 
     // Do not allow the extras to be bigger than the relevant padding
     extraleft = std::min(extraleft, aButtonReflowState.ComputedPhysicalPadding().left);
     extraright = std::min(extraright, aButtonReflowState.ComputedPhysicalPadding().right);
     xoffset -= extraleft;
-    availSize.SetWidth(wm, availSize.Width(wm) + extraleft + extraright);
+    availSize.Width(wm) = availSize.Width(wm) + extraleft + extraright;
   }
-  availSize.SetWidth(wm, std::max(availSize.Width(wm), 0));
+  availSize.Width(wm) = std::max(availSize.Width(wm), 0);
 
   // Give child a clone of the button's reflow state, with height/width reduced
   // by focusPadding, so that descendants with height:100% don't protrude.
   nsHTMLReflowState adjustedButtonReflowState =
     CloneReflowStateWithReducedContentBox(aButtonReflowState, focusPadding);
 
   nsHTMLReflowState contentsReflowState(aPresContext,
                                         adjustedButtonReflowState,
--- a/layout/generic/WritingModes.h
+++ b/layout/generic/WritingModes.h
@@ -626,49 +626,38 @@ public:
   }
   nscoord Height(WritingMode aWritingMode) const
   {
     CHECK_WRITING_MODE(aWritingMode);
     return aWritingMode.IsVertical() ? ISize() : BSize();
   }
 
   /**
-   * Writable references to the logical dimensions
+   * Writable references to the logical and physical dimensions
    */
   nscoord& ISize(WritingMode aWritingMode) // inline-size
   {
     CHECK_WRITING_MODE(aWritingMode);
     return mSize.width;
   }
   nscoord& BSize(WritingMode aWritingMode) // block-size
   {
     CHECK_WRITING_MODE(aWritingMode);
     return mSize.height;
   }
 
-  /**
-   * Setters for the physical dimensions
-   */
-  void SetWidth(WritingMode aWritingMode, nscoord aWidth)
+  nscoord& Width(WritingMode aWritingMode)
   {
     CHECK_WRITING_MODE(aWritingMode);
-    if (aWritingMode.IsVertical()) {
-      BSize() = aWidth;
-    } else {
-      ISize() = aWidth;
-    }
+    return aWritingMode.IsVertical() ? BSize() : ISize();
   }
-  void SetHeight(WritingMode aWritingMode, nscoord aHeight)
+  nscoord& Height(WritingMode aWritingMode)
   {
     CHECK_WRITING_MODE(aWritingMode);
-    if (aWritingMode.IsVertical()) {
-      ISize() = aHeight;
-    } else {
-      BSize() = aHeight;
-    }
+    return aWritingMode.IsVertical() ? ISize() : BSize();
   }
 
   /**
    * Return an nsSize containing our physical dimensions
    */
   nsSize GetPhysicalSize(WritingMode aWritingMode) const
   {
     CHECK_WRITING_MODE(aWritingMode);
@@ -691,16 +680,44 @@ public:
     return mWritingMode == aOther.mWritingMode && mSize == aOther.mSize;
   }
 
   bool operator!=(const LogicalSize& aOther) const
   {
     return mWritingMode != aOther.mWritingMode || mSize != aOther.mSize;
   }
 
+  LogicalSize operator+(const LogicalSize& aOther) const
+  {
+    CHECK_WRITING_MODE(aOther.GetWritingMode());
+    return LogicalSize(mWritingMode, ISize() + aOther.ISize(),
+                                     BSize() + aOther.BSize());
+  }
+  LogicalSize& operator+=(const LogicalSize& aOther)
+  {
+    CHECK_WRITING_MODE(aOther.GetWritingMode());
+    ISize() += aOther.ISize();
+    BSize() += aOther.BSize();
+    return *this;
+  }
+
+  LogicalSize operator-(const LogicalSize& aOther) const
+  {
+    CHECK_WRITING_MODE(aOther.GetWritingMode());
+    return LogicalSize(mWritingMode, ISize() - aOther.ISize(),
+                                     BSize() - aOther.BSize());
+  }
+  LogicalSize& operator-=(const LogicalSize& aOther)
+  {
+    CHECK_WRITING_MODE(aOther.GetWritingMode());
+    ISize() -= aOther.ISize();
+    BSize() -= aOther.BSize();
+    return *this;
+  }
+
 private:
   friend class LogicalRect;
 
   LogicalSize() MOZ_DELETE;
 
 #ifdef DEBUG
   WritingMode GetWritingMode() const { return mWritingMode; }
 #else
@@ -834,16 +851,26 @@ public:
   }
   nscoord BStartEnd(WritingMode aWritingMode) const // block margins
   {
     CHECK_WRITING_MODE(aWritingMode);
     return mMargin.TopBottom();
   }
 
   /**
+   * Return a LogicalSize representing the total size of the inline-
+   * and block-dimension margins.
+   */
+  LogicalSize Size(WritingMode aWritingMode) const
+  {
+    CHECK_WRITING_MODE(aWritingMode);
+    return LogicalSize(aWritingMode, IStartEnd(), BStartEnd());
+  }
+
+  /**
    * Accessors for physical margins, using our writing mode to convert from
    * logical values.
    */
   nscoord Top(WritingMode aWritingMode) const
   {
     CHECK_WRITING_MODE(aWritingMode);
     return aWritingMode.IsVertical() ?
       (aWritingMode.IsBidiLTR() ? IStart() : IEnd()) : BStart();