Bug 1485581 - Makes nsImageFrame::GetMinISize and nsImageFrame::GetPrefISize "writing-mode responsive" r?dholbert draft default tip
authorZhang Junzhi <zjz@zjz.name>
Fri, 24 Aug 2018 14:59:27 +0800
changeset 831146 739bf37ecf82398f5ddcb59251ddf26bdb2bc899
parent 831145 49b70f7e6817131d79876ab88667bc6c2833e4a0
push id118868
push userbmo:zjz@zjz.name
push dateFri, 24 Aug 2018 07:04:39 +0000
reviewersdholbert
bugs1485581
milestone63.0a1
Bug 1485581 - Makes nsImageFrame::GetMinISize and nsImageFrame::GetPrefISize "writing-mode responsive" r?dholbert MozReview-Commit-ID: G3S4sfW6j9r
layout/generic/nsFrame.h
layout/generic/nsImageFrame.cpp
--- a/layout/generic/nsFrame.h
+++ b/layout/generic/nsFrame.h
@@ -849,18 +849,24 @@ public:
   };
 
 #define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status) \
   DR_cookie dr_cookie(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status);
 #define DISPLAY_REFLOW_CHANGE() \
   dr_cookie.Change();
 #define DISPLAY_LAYOUT(dr_frame) \
   DR_layout_cookie dr_cookie(dr_frame);
+// FIXME This macro(as well as the struct in the macro content) should go
+// through a renaming refactoring to reflect the fact that it's actually
+// displaying a minimum inline size, not a minimum width.
 #define DISPLAY_MIN_WIDTH(dr_frame, dr_result) \
   DR_intrinsic_width_cookie dr_cookie(dr_frame, "Min", dr_result)
+// FIXME This macro(as well as the struct in the macro content) should go
+// through a renaming refactoring to reflect the fact that it's actually
+// displaying a preferred inline size, not a preferred width.
 #define DISPLAY_PREF_WIDTH(dr_frame, dr_result) \
   DR_intrinsic_width_cookie dr_cookie(dr_frame, "Pref", dr_result)
 #define DISPLAY_PREF_SIZE(dr_frame, dr_result) \
   DR_intrinsic_size_cookie dr_cookie(dr_frame, "Pref", dr_result)
 #define DISPLAY_MIN_SIZE(dr_frame, dr_result) \
   DR_intrinsic_size_cookie dr_cookie(dr_frame, "Min", dr_result)
 #define DISPLAY_MAX_SIZE(dr_frame, dr_result) \
   DR_intrinsic_size_cookie dr_cookie(dr_frame, "Max", dr_result)
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1029,36 +1029,36 @@ nsImageFrame::GetContinuationOffset() co
   }
   NS_ASSERTION(offset >= 0, "bogus GetContentRect");
   return offset;
 }
 
 /* virtual */ nscoord
 nsImageFrame::GetMinISize(gfxContext *aRenderingContext)
 {
-  // XXX The caller doesn't account for constraints of the height,
-  // min-height, and max-height properties.
   DebugOnly<nscoord> result;
   DISPLAY_MIN_WIDTH(this, result);
   EnsureIntrinsicSizeAndRatio();
-  return mIntrinsicSize.width.GetUnit() == eStyleUnit_Coord ?
-    mIntrinsicSize.width.GetCoordValue() : 0;
+  MOZ_ASSERT(this->GetParent());
+  const nsStyleCoord& iSize = this->GetParent()->GetWritingMode().IsVertical() ?
+                                mIntrinsicSize.height : mIntrinsicSize.width;
+  return iSize.GetUnit() == eStyleUnit_Coord ? iSize.GetCoordValue() : 0;
 }
 
 /* virtual */ nscoord
 nsImageFrame::GetPrefISize(gfxContext *aRenderingContext)
 {
-  // XXX The caller doesn't account for constraints of the height,
-  // min-height, and max-height properties.
   DebugOnly<nscoord> result;
   DISPLAY_PREF_WIDTH(this, result);
   EnsureIntrinsicSizeAndRatio();
+  MOZ_ASSERT(this->GetParent());
+  const nsStyleCoord& iSize = this->GetParent()->GetWritingMode().IsVertical() ?
+                                mIntrinsicSize.height : mIntrinsicSize.width;
   // convert from normal twips to scaled twips (printing...)
-  return mIntrinsicSize.width.GetUnit() == eStyleUnit_Coord ?
-    mIntrinsicSize.width.GetCoordValue() : 0;
+  return iSize.GetUnit() == eStyleUnit_Coord ? iSize.GetCoordValue() : 0;
 }
 
 /* virtual */ IntrinsicSize
 nsImageFrame::GetIntrinsicSize()
 {
   return mIntrinsicSize;
 }