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 558623 9fe7eb376ecdde24bb9d8c3eec71075be2b8c624
parent 558622 69e6477b290b4f6d2beffffd3520e07d51685182
child 558624 7137d009d9799735a8a7056aefe12eeb732a815d
push id131692
push usermpalmgren@mozilla.com
push dateSun, 29 Nov 2020 17:21:09 +0000
treeherderautoland@9fe7eb376ecd [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;