Bug 1602003 - Correct writing-mode handling of nsDocumentViewer::GetContentSize. r=jfkthame
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 18 Dec 2019 17:16:49 +0000
changeset 507558 2f8098e1060dcd472f5f8cca7ad24e2cdf77bab7
parent 507557 1429df580f4cfac3968cbb1bb69f90093c05955b
child 507559 fab28f89bb4443f96da59349148044d5940da359
push id36931
push useropoprus@mozilla.com
push dateThu, 19 Dec 2019 09:50:06 +0000
treeherdermozilla-central@5e8b48c8cd93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1602003
milestone73.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 1602003 - Correct writing-mode handling of nsDocumentViewer::GetContentSize. r=jfkthame Differential Revision: https://phabricator.services.mozilla.com/D57640
layout/base/nsDocumentViewer.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -3128,33 +3128,35 @@ nsresult nsDocumentViewer::GetContentSiz
 
   // Flush out all content and style updates. We can't use a resize reflow
   // because it won't change some sizes that a style change reflow will.
   mDocument->FlushPendingNotifications(FlushType::Layout);
 
   nsIFrame* root = presShell->GetRootFrame();
   NS_ENSURE_TRUE(root, NS_ERROR_FAILURE);
 
-  nscoord prefWidth;
+  WritingMode wm = root->GetWritingMode();
+
+  nscoord prefISize;
   {
     RefPtr<gfxContext> rcx(presShell->CreateReferenceRenderingContext());
-    prefWidth = root->GetPrefISize(rcx);
-  }
-  if (prefWidth > aMaxWidth) {
-    prefWidth = aMaxWidth;
+    nscoord maxISize = wm.IsVertical() ? aMaxHeight : aMaxWidth;
+    prefISize = std::min(root->GetPrefISize(rcx), maxISize);
   }
 
   // We should never intentionally get here with this sentinel value, but it's
   // possible that a document with huge sizes might inadvertently have a
-  // prefWidth that exactly matches NS_UNCONSTRAINEDSIZE.
+  // prefISize that exactly matches NS_UNCONSTRAINEDSIZE.
   // Just bail if that happens.
-  NS_ENSURE_TRUE(prefWidth != NS_UNCONSTRAINEDSIZE, NS_ERROR_FAILURE);
-
-  nsresult rv = presShell->ResizeReflow(prefWidth, aMaxHeight,
-                                        ResizeReflowOptions::BSizeLimit);
+  NS_ENSURE_TRUE(prefISize != NS_UNCONSTRAINEDSIZE, NS_ERROR_FAILURE);
+
+  nscoord height = wm.IsVertical() ? prefISize : aMaxHeight;
+  nscoord width = wm.IsVertical() ? aMaxWidth : prefISize;
+  nsresult rv =
+      presShell->ResizeReflow(width, height, ResizeReflowOptions::BSizeLimit);
   NS_ENSURE_SUCCESS(rv, rv);
 
   RefPtr<nsPresContext> presContext = GetPresContext();
   NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
 
   // Protect against bogus returns here
   nsRect shellArea = presContext->GetVisibleArea();
   NS_ENSURE_TRUE(shellArea.width != NS_UNCONSTRAINEDSIZE &&