зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1495153 part 1 - Replace the XUL label in <input type=file> with an HTML label. r=emilio
This commit is contained in:
Родитель
20d9bc4191
Коммит
771d50381e
|
@ -141,25 +141,19 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and setup the text showing the selected files.
|
// Create and setup the text showing the selected files.
|
||||||
RefPtr<NodeInfo> nodeInfo;
|
mTextContent = doc->CreateHTMLElement(nsGkAtoms::label);
|
||||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::label, nullptr,
|
|
||||||
kNameSpaceID_XUL,
|
|
||||||
nsINode::ELEMENT_NODE);
|
|
||||||
NS_TrustedNewXULElement(getter_AddRefs(mTextContent), nodeInfo.forget());
|
|
||||||
// NOTE: SetIsNativeAnonymousRoot() has to be called before setting any
|
// NOTE: SetIsNativeAnonymousRoot() has to be called before setting any
|
||||||
// attribute.
|
// attribute.
|
||||||
mTextContent->SetIsNativeAnonymousRoot();
|
mTextContent->SetIsNativeAnonymousRoot();
|
||||||
mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::crop,
|
RefPtr<nsTextNode> text = new nsTextNode(doc->NodeInfoManager());
|
||||||
NS_LITERAL_STRING("center"), false);
|
mTextContent->AppendChildTo(text, false);
|
||||||
|
|
||||||
// Update the displayed text to reflect the current element's value.
|
// Update the displayed text to reflect the current element's value.
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
HTMLInputElement::FromNode(mContent)->GetDisplayFileName(value);
|
HTMLInputElement::FromNode(mContent)->GetDisplayFileName(value);
|
||||||
UpdateDisplayedValue(value, false);
|
UpdateDisplayedValue(value, false);
|
||||||
|
|
||||||
if (!aElements.AppendElement(mTextContent)) {
|
aElements.AppendElement(mTextContent);
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We should be able to interact with the element by doing drag and drop.
|
// We should be able to interact with the element by doing drag and drop.
|
||||||
mContent->AddSystemEventListener(NS_LITERAL_STRING("drop"),
|
mContent->AddSystemEventListener(NS_LITERAL_STRING("drop"),
|
||||||
|
@ -475,7 +469,8 @@ nsFileControlFrame::GetFrameName(nsAString& aResult) const
|
||||||
void
|
void
|
||||||
nsFileControlFrame::UpdateDisplayedValue(const nsAString& aValue, bool aNotify)
|
nsFileControlFrame::UpdateDisplayedValue(const nsAString& aValue, bool aNotify)
|
||||||
{
|
{
|
||||||
mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::value, aValue, aNotify);
|
auto* text = Text::FromNode(mTextContent->GetFirstChild());
|
||||||
|
text->SetText(aValue, aNotify);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
|
|
||||||
@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace to HTML */
|
@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace to HTML */
|
||||||
@namespace xul url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
|
|
||||||
|
|
||||||
*|*::-moz-fieldset-content {
|
*|*::-moz-fieldset-content {
|
||||||
display: block; /* StyleAdjuster::adjust_for_fieldset_content overrides this in some cases */
|
display: block; /* StyleAdjuster::adjust_for_fieldset_content overrides this in some cases */
|
||||||
|
@ -480,7 +479,7 @@ input[type="image"]:-moz-focusring {
|
||||||
/* file selector */
|
/* file selector */
|
||||||
input[type="file"] {
|
input[type="file"] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
white-space: nowrap;
|
white-space: nowrap !important;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
overflow-clip-box: padding-box;
|
overflow-clip-box: padding-box;
|
||||||
color: unset;
|
color: unset;
|
||||||
|
@ -495,7 +494,7 @@ input[type="file"] {
|
||||||
padding: unset;
|
padding: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="file"] > xul|label {
|
input[type="file"] > label {
|
||||||
min-inline-size: 12em;
|
min-inline-size: 12em;
|
||||||
padding-inline-start: 5px;
|
padding-inline-start: 5px;
|
||||||
text-align: match-parent;
|
text-align: match-parent;
|
||||||
|
@ -504,11 +503,8 @@ input[type="file"] > xul|label {
|
||||||
font-size: unset;
|
font-size: unset;
|
||||||
letter-spacing: unset;
|
letter-spacing: unset;
|
||||||
|
|
||||||
/*
|
-moz-user-select: none;
|
||||||
* Force the text to have LTR directionality. Otherwise filenames containing
|
unicode-bidi: plaintext;
|
||||||
* RTL characters will be reordered with chaotic results.
|
|
||||||
*/
|
|
||||||
direction: ltr !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button part of file selector */
|
/* button part of file selector */
|
||||||
|
@ -532,14 +528,6 @@ input[type="color"]::-moz-color-swatch {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to make RTL <input type='file'> look nicer. */
|
|
||||||
/* TODO: find a better solution than forcing direction: ltr on all file
|
|
||||||
input labels and remove this override -- bug 1161482 */
|
|
||||||
input[type="file"]:dir(rtl) > xul|label {
|
|
||||||
padding-inline-start: 0px;
|
|
||||||
padding-inline-end: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* radio buttons */
|
/* radio buttons */
|
||||||
input[type="radio"] {
|
input[type="radio"] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче