Bug 1500530 - Make the anonymous child <label> have display:inline-block so that it applies its min-inline-size. r=jfkthame
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -629,16 +629,21 @@ nsFileControlFrame::UpdateDisplayedValue
uint32_t oldLength = aNotify ? 0 : text->TextLength();
text->SetText(aValue, aNotify);
if (!aNotify) {
// We can't notify during Reflow so we need to tell the text frame
// about the text content change we just did.
if (auto* textFrame = static_cast<nsTextFrame*>(text->GetPrimaryFrame())) {
textFrame->NotifyNativeAnonymousTextnodeChange(oldLength);
}
+ nsBlockFrame* label = do_QueryFrame(mTextContent->GetPrimaryFrame());
+ if (label && label->LinesBegin() != label->LinesEnd()) {
+ label->AddStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
+ label->LinesBegin()->MarkDirty();
+ }
}
}
nsresult
nsFileControlFrame::SetFormProperty(nsAtom* aName,
const nsAString& aValue)
{
if (nsGkAtoms::value == aName) {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/file/label-min-inline-size-ref.html
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML>
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html><head>
+ <meta charset="utf-8">
+ <title>Testcase for bug 1500530</title>
+ <style type="text/css">
+html,body {
+ color:black; background-color:black; font:48pt/1 Arial; padding:0; margin:0;
+}
+
+div { width: 100px; height: 20px; margin-top: -2px; background: lime; }
+
+ </style>
+</head>
+<body>
+
+<div></div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/file/label-min-inline-size.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html><head>
+ <meta charset="utf-8">
+ <title>Testcase for bug 1500530</title>
+ <style type="text/css">
+html,body {
+ color:black; background-color:white; font:48pt/1 Arial; padding:0; margin:0;
+}
+
+input {
+ font-family: Arial;
+ font-size: 48pt;
+ vertical-align: top;
+ background: lime;
+}
+div { text-indent: -24ch; margin-top: -2px; }
+
+mask {
+ position: absolute;
+ left: 100px; right: 0; top: 0; bottom: 0;
+ background: black;
+}
+
+mask2 {
+ position: absolute;
+ left: 0; right: 0; top: 18px; bottom: 0;
+ background: black;
+}
+
+ </style>
+</head>
+<body>
+
+<mask></mask>
+<mask2></mask2>
+<div><input type="file"></div>
+
+
+</body>
+</html>
--- a/layout/reftests/forms/input/file/reftest.list
+++ b/layout/reftests/forms/input/file/reftest.list
@@ -1,8 +1,9 @@
fuzzy-if(gtkWidget||webrender,0-1,0-34) fails-if(Android) == simple.html simple-ref.xul
fuzzy-if(gtkWidget||webrender,0-1,0-17) fails-if(Android) == rtl.html rtl-ref.xul
fuzzy-if(gtkWidget||webrender,0-1,0-34) fails-if(Android) == size.html simple-ref.xul
fuzzy-if(gtkWidget||webrender,0-1,0-10) fails-if(Android) == background.html background-ref.xul
fuzzy-if(gtkWidget,0-1,0-10) fails-if(Android) == style.html style-ref.xul
!= width-clip.html width-clip-ref.html
fails-if(Android) == color-inherit.html color-inherit-ref.html
-fuzzy-if(Android,1-2,2-2) fails-if(webrender) == dynamic-max-width.html dynamic-max-width-ref.html # bug 1496542 for webrender.
+fuzzy-if(Android,1-2,2-2) fails-if(webrender&&!cocoaWidget) == dynamic-max-width.html dynamic-max-width-ref.html # bug 1496542 for webrender.
+== label-min-inline-size.html label-min-inline-size-ref.html
--- a/layout/style/res/forms.css
+++ b/layout/style/res/forms.css
@@ -481,16 +481,17 @@ input[type="file"] {
cursor: default;
border: none;
background-color: transparent;
padding: unset;
}
input[type="file"] > label {
+ display: inline-block;
min-inline-size: 12em;
padding-inline-start: 5px;
text-align: match-parent;
color: unset;
font-size: unset;
letter-spacing: unset;