Skip to content

Commit

Permalink
Bug 1288681 - Rename HTMLInputElement::directory to HTMLInputElement:…
Browse files Browse the repository at this point in the history
…:allowdirs, r=smaug
  • Loading branch information
bakulf committed Jul 23, 2016
1 parent e8580c6 commit c7516be
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions dom/base/nsGkAtomList.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ GK_ATOM(after_start, "after_start")
GK_ATOM(align, "align")
GK_ATOM(alink, "alink")
GK_ATOM(all, "all")
GK_ATOM(allowdirs, "allowdirs")
GK_ATOM(allowevents, "allowevents")
GK_ATOM(allownegativeassertions, "allownegativeassertions")
GK_ATOM(allowforms,"allow-forms")
Expand Down
4 changes: 2 additions & 2 deletions dom/filesystem/tests/test_webkitdirectory.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<input id="inputFileWebkitDirectory" type="file" webkitdirectory></input>
<input id="inputFileWebkitDirectoryAndDirectory" type="file" webkitdirectory directory></input>
<input id="inputFileDirectory" type="file" directory></input>
<input id="inputFileWebkitDirectoryAndDirectory" type="file" webkitdirectory allowdirs></input>
<input id="inputFileDirectory" type="file" allowdirs></input>
<input id="inputFileDirectoryChange" type="file" webkitdirectory></input>

<script type="application/javascript;version=1.7">
Expand Down
11 changes: 4 additions & 7 deletions dom/html/HTMLInputElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2825,8 +2825,7 @@ HTMLInputElement::GetDisplayFileName(nsAString& aValue) const
nsXPIDLString value;

if (mFilesOrDirectories.IsEmpty()) {
if ((Preferences::GetBool("dom.input.dirpicker", false) &&
HasAttr(kNameSpaceID_None, nsGkAtoms::directory)) ||
if ((Preferences::GetBool("dom.input.dirpicker", false) && Allowdirs()) ||
(Preferences::GetBool("dom.webkitBlink.dirPicker.enabled", false) &&
HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) {
nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
Expand Down Expand Up @@ -2973,8 +2972,7 @@ HTMLInputElement::GetFiles()
return nullptr;
}

if (Preferences::GetBool("dom.input.dirpicker", false) &&
HasAttr(kNameSpaceID_None, nsGkAtoms::directory) &&
if (Preferences::GetBool("dom.input.dirpicker", false) && Allowdirs() &&
(!Preferences::GetBool("dom.webkitBlink.dirPicker.enabled", false) ||
!HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) {
return nullptr;
Expand Down Expand Up @@ -4091,8 +4089,7 @@ HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor)
if (target &&
target->GetParent() == this &&
target->IsRootOfNativeAnonymousSubtree() &&
((Preferences::GetBool("dom.input.dirpicker", false) &&
HasAttr(kNameSpaceID_None, nsGkAtoms::directory)) ||
((Preferences::GetBool("dom.input.dirpicker", false) && Allowdirs()) ||
(Preferences::GetBool("dom.webkitBlink.dirPicker.enabled", false) &&
HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)))) {
type = FILE_PICKER_DIRECTORY;
Expand Down Expand Up @@ -5388,7 +5385,7 @@ HTMLInputElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
if (aAttribute == nsGkAtoms::type ||
// The presence or absence of the 'directory' attribute determines what
// buttons we show for type=file.
aAttribute == nsGkAtoms::directory ||
aAttribute == nsGkAtoms::allowdirs ||
aAttribute == nsGkAtoms::webkitdirectory) {
retval |= nsChangeHint_ReconstructFrame;
} else if (mType == NS_FORM_INPUT_IMAGE &&
Expand Down
8 changes: 4 additions & 4 deletions dom/html/HTMLInputElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -708,14 +708,14 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
ErrorResult& aRv, int32_t aSelectionStart = -1,
int32_t aSelectionEnd = -1);

bool DirectoryAttr() const
bool Allowdirs() const
{
return HasAttr(kNameSpaceID_None, nsGkAtoms::directory);
return HasAttr(kNameSpaceID_None, nsGkAtoms::allowdirs);
}

void SetDirectoryAttr(bool aValue, ErrorResult& aRv)
void SetAllowdirs(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::directory, aValue, aRv);
SetHTMLBoolAttr(nsGkAtoms::allowdirs, aValue, aRv);
}

bool WebkitDirectoryAttr() const
Expand Down
4 changes: 2 additions & 2 deletions dom/webidl/HTMLInputElement.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ partial interface HTMLInputElement {
};

partial interface HTMLInputElement {
[Pref="dom.input.dirpicker", BinaryName="DirectoryAttr", SetterThrows]
attribute boolean directory;
[Pref="dom.input.dirpicker", SetterThrows]
attribute boolean allowdirs;

[Pref="dom.input.dirpicker"]
readonly attribute boolean isFilesAndDirectoriesSupported;
Expand Down

0 comments on commit c7516be

Please sign in to comment.