Bug 1679682 - Deal with the ::file-selector-button pseudo having no frame. r=emilio
authorMats Palmgren <mats@mozilla.com>
Sun, 29 Nov 2020 17:18:32 +0000
changeset 558606 9fe7eb376ecdde24bb9d8c3eec71075be2b8c624
parent 558605 69e6477b290b4f6d2beffffd3520e07d51685182
child 558607 7137d009d9799735a8a7056aefe12eeb732a815d
push id37989
push userbtara@mozilla.com
push dateMon, 30 Nov 2020 09:30:31 +0000
treeherdermozilla-central@b0865ea58462 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1679682
milestone85.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 1679682 - Deal with the ::file-selector-button pseudo having no frame. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D98111
layout/forms/nsFileControlFrame.cpp
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -162,20 +162,22 @@ void nsFileControlFrame::Reflow(nsPresCo
       auto* labelFrame = mTextContent->GetPrimaryFrame();
       nscoord labelBP =
           labelFrame->GetLogicalUsedBorderAndPadding(wm).IStartEnd(wm);
       auto* lastLabelCont = labelFrame->LastContinuation();
       if (lastLabelCont != labelFrame) {
         labelBP +=
             lastLabelCont->GetLogicalUsedBorderAndPadding(wm).IStartEnd(wm);
       }
-      auto* buttonFrame = mBrowseFilesOrDirs->GetPrimaryFrame();
-      nscoord availableISizeForLabel =
-          contentISize - buttonFrame->ISize(wm) -
-          buttonFrame->GetLogicalUsedMargin(wm).IStartEnd(wm);
+      nscoord availableISizeForLabel = contentISize;
+      if (auto* buttonFrame = mBrowseFilesOrDirs->GetPrimaryFrame()) {
+        availableISizeForLabel -=
+            buttonFrame->ISize(wm) +
+            buttonFrame->GetLogicalUsedMargin(wm).IStartEnd(wm);
+      }
       if (CropTextToWidth(*aReflowInput.mRenderingContext, labelFrame,
                           availableISizeForLabel - labelBP, filename)) {
         nsBlockFrame::DidReflow(aPresContext, &aReflowInput);
         aStatus.Reset();
         labelFrame->MarkSubtreeDirty();
         labelFrame->AddStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
         mCachedMinISize = NS_INTRINSIC_ISIZE_UNKNOWN;
         mCachedPrefISize = NS_INTRINSIC_ISIZE_UNKNOWN;