Bug 1079154 patch 3: logical versions of ApplyRelativePositioning, r=jfkthame
authorSimon Montagu <smontagu@smontagu.org>
Tue, 06 Jan 2015 23:10:07 -0800
changeset 248193 1fa61a0310e7b7c65ce81d1c4eba7ec3fb47ed31
parent 248192 679016653e34a44324437abdebe9d4b5012e3272
child 248194 c16d59bb79d13ff7221511a13b134241dbdc7f44
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1079154
milestone37.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 1079154 patch 3: logical versions of ApplyRelativePositioning, r=jfkthame
layout/generic/nsHTMLReflowState.h
--- a/layout/generic/nsHTMLReflowState.h
+++ b/layout/generic/nsHTMLReflowState.h
@@ -820,16 +820,44 @@ public:
   static void ApplyRelativePositioning(nsIFrame* aFrame,
                                        const nsMargin& aComputedOffsets,
                                        nsPoint* aPosition);
 
   void ApplyRelativePositioning(nsPoint* aPosition) const {
     ApplyRelativePositioning(frame, ComputedPhysicalOffsets(), aPosition);
   }
 
+  static void
+  ApplyRelativePositioning(nsIFrame* aFrame,
+                           mozilla::WritingMode aWritingMode,
+                           const mozilla::LogicalMargin& aComputedOffsets,
+                           mozilla::LogicalPoint* aPosition,
+                           nscoord aContainerWidth) {
+    // Subtract the width of the frame from the container width that we
+    // use for converting between the logical and physical origins of
+    // the frame. This accounts for the fact that logical origins in RTL
+    // coordinate systems are at the top right of the frame instead of
+    // the top left.
+    nscoord frameWidth = aFrame->GetSize().width;
+    nsPoint pos = aPosition->GetPhysicalPoint(aWritingMode,
+                                              aContainerWidth - frameWidth);
+    ApplyRelativePositioning(aFrame,
+                             aComputedOffsets.GetPhysicalMargin(aWritingMode),
+                             &pos);
+    *aPosition = mozilla::LogicalPoint(aWritingMode, pos,
+                                       aContainerWidth - frameWidth);
+  }
+
+  void ApplyRelativePositioning(mozilla::LogicalPoint* aPosition,
+                                nscoord aContainerWidth) const {
+    ApplyRelativePositioning(frame, mWritingMode,
+                             ComputedLogicalOffsets(), aPosition,
+                             aContainerWidth);
+  }
+
 #ifdef DEBUG
   // Reflow trace methods.  Defined in nsFrame.cpp so they have access
   // to the display-reflow infrastructure.
   static void* DisplayInitConstraintsEnter(nsIFrame* aFrame,
                                            nsHTMLReflowState* aState,
                                            nscoord aCBWidth,
                                            nscoord aCBHeight,
                                            const nsMargin* aBorder,