Bug 1326407 Part 4 - Extract a function to convert a rect to float manager's logical coordinate. r=dbaron
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 16 Feb 2017 10:51:48 +0800
changeset 343238 366e6522665c6dfff386d76798d1ffbf232cc0c8
parent 343237 b0af1a8bdcaf6952ba6be848bf83248e6fb455c4
child 343239 f45cac0c1b91cb5220b74b1dd5b708a4154c9d1f
push id31372
push usercbook@mozilla.com
push dateThu, 16 Feb 2017 12:16:10 +0000
treeherdermozilla-central@2737f66ad6ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1326407
milestone54.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 1326407 Part 4 - Extract a function to convert a rect to float manager's logical coordinate. r=dbaron MozReview-Commit-ID: Ag6V6XmlHIU
layout/generic/nsFloatManager.cpp
layout/generic/nsFloatManager.h
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -645,20 +645,18 @@ nsFloatManager::EllipseShapeInfo::LineRi
 // FloatInfo
 
 nsFloatManager::FloatInfo::FloatInfo(nsIFrame* aFrame,
                                      nscoord aLineLeft, nscoord aBlockStart,
                                      const LogicalRect& aMarginRect,
                                      WritingMode aWM,
                                      const nsSize& aContainerSize)
   : mFrame(aFrame)
-  , mRect(aMarginRect.LineLeft(aWM, aContainerSize) + aLineLeft,
-          aMarginRect.BStart(aWM) + aBlockStart,
-          aMarginRect.ISize(aWM),
-          aMarginRect.BSize(aWM))
+  , mRect(ShapeInfo::ConvertToFloatLogical(aMarginRect, aWM, aContainerSize) +
+          nsPoint(aLineLeft, aBlockStart))
 {
   MOZ_COUNT_CTOR(nsFloatManager::FloatInfo);
 
   const StyleShapeOutside& shapeOutside = mFrame->StyleDisplay()->mShapeOutside;
 
   if (shapeOutside.GetType() == StyleShapeSourceType::None) {
     return;
   }
@@ -670,20 +668,18 @@ nsFloatManager::FloatInfo::FloatInfo(nsI
     return;
   }
 
   // Initialize <shape-box>'s reference rect.
   LogicalRect shapeBoxRect =
     ShapeInfo::ComputeShapeBoxRect(shapeOutside, mFrame, aMarginRect, aWM);
 
   if (shapeOutside.GetType() == StyleShapeSourceType::Box) {
-    nsRect rect(shapeBoxRect.LineLeft(aWM, aContainerSize),
-                shapeBoxRect.BStart(aWM),
-                shapeBoxRect.ISize(aWM),
-                shapeBoxRect.BSize(aWM));
+    nsRect rect = ShapeInfo::ConvertToFloatLogical(shapeBoxRect, aWM,
+                                                   aContainerSize);
     mShapeInfo = MakeUnique<BoxShapeInfo>(rect, mFrame);
   } else if (shapeOutside.GetType() == StyleShapeSourceType::Shape) {
     StyleBasicShape* const basicShape = shapeOutside.GetBasicShape();
 
     switch (basicShape->GetShapeType()) {
       case StyleBasicShapeType::Polygon:
         // Bug 1326409 - Implement the rendering of basic shape polygon()
         // for CSS shape-outside.
--- a/layout/generic/nsFloatManager.h
+++ b/layout/generic/nsFloatManager.h
@@ -362,16 +362,26 @@ private:
     virtual void Translate(nscoord aLineLeft, nscoord aBlockStart) = 0;
 
     static mozilla::LogicalRect ComputeShapeBoxRect(
       const mozilla::StyleShapeOutside& aShapeOutside,
       nsIFrame* const aFrame,
       const mozilla::LogicalRect& aMarginRect,
       mozilla::WritingMode aWM);
 
+    // Convert the LogicalRect to the special logical coordinate space used
+    // in float manager.
+    static nsRect ConvertToFloatLogical(const mozilla::LogicalRect& aRect,
+                                        mozilla::WritingMode aWM,
+                                        const nsSize& aContainerSize)
+    {
+      return nsRect(aRect.LineLeft(aWM, aContainerSize), aRect.BStart(aWM),
+                    aRect.ISize(aWM), aRect.BSize(aWM));
+    }
+
     static mozilla::UniquePtr<ShapeInfo> CreateCircleOrEllipse(
       mozilla::StyleBasicShape* const aBasicShape,
       const mozilla::LogicalRect& aShapeBoxRect,
       mozilla::WritingMode aWM,
       const nsSize& aContainerSize);
 
   protected:
     // Compute the minimum line-axis difference between the bounding shape