mirror of
https://github.com/Basilisk-Development-Team/UXP-mirror.git
synced 2026-11-18 06:59:44 -05:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e71937e76a | ||
|
|
4a44bfe8fa | ||
|
|
adb58c5761 | ||
|
|
8f7e7bfbdc | ||
|
|
96ad821193 | ||
|
|
0742779ec4 |
No files matched your search
@@ -33,6 +33,7 @@
|
|||||||
#include "nsFocusManager.h"
|
#include "nsFocusManager.h"
|
||||||
#include "mozilla/dom/HTMLFormElement.h"
|
#include "mozilla/dom/HTMLFormElement.h"
|
||||||
#include "mozAutoDocUpdate.h"
|
#include "mozAutoDocUpdate.h"
|
||||||
|
#include "mozilla/Preferences.h"
|
||||||
|
|
||||||
#define NS_IN_SUBMIT_CLICK (1 << 0)
|
#define NS_IN_SUBMIT_CLICK (1 << 0)
|
||||||
#define NS_OUTER_ACTIVATE_EVENT (1 << 1)
|
#define NS_OUTER_ACTIVATE_EVENT (1 << 1)
|
||||||
@@ -186,6 +187,9 @@ HTMLButtonElement::ParseAttribute(int32_t aNamespaceID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aAttribute == nsGkAtoms::formmethod) {
|
if (aAttribute == nsGkAtoms::formmethod) {
|
||||||
|
if (Preferences::GetBool("dom.dialog_element.enabled", true)) {
|
||||||
|
return aResult.ParseEnumValue(aValue, kFormMethodTableDialogEnabled, false);
|
||||||
|
}
|
||||||
return aResult.ParseEnumValue(aValue, kFormMethodTable, false);
|
return aResult.ParseEnumValue(aValue, kFormMethodTable, false);
|
||||||
}
|
}
|
||||||
if (aAttribute == nsGkAtoms::formenctype) {
|
if (aAttribute == nsGkAtoms::formenctype) {
|
||||||
|
|||||||
@@ -321,6 +321,9 @@ HTMLFormElement::ParseAttribute(int32_t aNamespaceID,
|
|||||||
{
|
{
|
||||||
if (aNamespaceID == kNameSpaceID_None) {
|
if (aNamespaceID == kNameSpaceID_None) {
|
||||||
if (aAttribute == nsGkAtoms::method) {
|
if (aAttribute == nsGkAtoms::method) {
|
||||||
|
if (Preferences::GetBool("dom.dialog_element.enabled", true)) {
|
||||||
|
return aResult.ParseEnumValue(aValue, kFormMethodTableDialogEnabled, false);
|
||||||
|
}
|
||||||
return aResult.ParseEnumValue(aValue, kFormMethodTable, false);
|
return aResult.ParseEnumValue(aValue, kFormMethodTable, false);
|
||||||
}
|
}
|
||||||
if (aAttribute == nsGkAtoms::enctype) {
|
if (aAttribute == nsGkAtoms::enctype) {
|
||||||
@@ -673,6 +676,30 @@ HTMLFormElement::DoSubmit(WidgetEvent* aEvent)
|
|||||||
|
|
||||||
mSubmitInitiatedFromUserInput = EventStateManager::IsHandlingUserInput();
|
mSubmitInitiatedFromUserInput = EventStateManager::IsHandlingUserInput();
|
||||||
|
|
||||||
|
//
|
||||||
|
// perform the submission
|
||||||
|
//
|
||||||
|
if (!submission) {
|
||||||
|
mIsSubmitting = false;
|
||||||
|
#ifdef DEBUG
|
||||||
|
HTMLDialogElement* dialog = nullptr;
|
||||||
|
for (nsIContent* parent = GetParent(); parent;
|
||||||
|
parent = parent->GetParent()) {
|
||||||
|
dialog = HTMLDialogElement::FromContentOrNull(parent);
|
||||||
|
if (dialog) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MOZ_ASSERT(!dialog || !dialog->Open());
|
||||||
|
#endif
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DialogFormSubmission* dialogSubmission =
|
||||||
|
submission->GetAsDialogSubmission()) {
|
||||||
|
return SubmitDialog(dialogSubmission);
|
||||||
|
}
|
||||||
|
|
||||||
if(mDeferSubmission) {
|
if(mDeferSubmission) {
|
||||||
// we are in an event handler, JS submitted so we have to
|
// we are in an event handler, JS submitted so we have to
|
||||||
// defer this submission. let's remember it and return
|
// defer this submission. let's remember it and return
|
||||||
@@ -683,9 +710,6 @@ HTMLFormElement::DoSubmit(WidgetEvent* aEvent)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// perform the submission
|
|
||||||
//
|
|
||||||
return SubmitSubmission(submission);
|
return SubmitSubmission(submission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,8 +746,10 @@ HTMLFormElement::BuildSubmission(HTMLFormSubmission** aFormSubmission,
|
|||||||
//
|
//
|
||||||
// Dump the data into the submission object
|
// Dump the data into the submission object
|
||||||
//
|
//
|
||||||
rv = WalkFormElements(*aFormSubmission);
|
if (!(*aFormSubmission)->GetAsDialogSubmission()) {
|
||||||
NS_ENSURE_SUBMIT_SUCCESS(rv);
|
rv = WalkFormElements(*aFormSubmission);
|
||||||
|
NS_ENSURE_SUBMIT_SUCCESS(rv);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -862,6 +888,22 @@ HTMLFormElement::SubmitSubmission(HTMLFormSubmission* aFormSubmission)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-dialog
|
||||||
|
nsresult HTMLFormElement::SubmitDialog(DialogFormSubmission* aFormSubmission) {
|
||||||
|
mIsSubmitting = false;
|
||||||
|
|
||||||
|
// Close the dialog subject. If there is a result, let that be the return
|
||||||
|
// value.
|
||||||
|
HTMLDialogElement* dialog = aFormSubmission->DialogElement();
|
||||||
|
MOZ_ASSERT(dialog);
|
||||||
|
|
||||||
|
Optional<nsAString> retValue;
|
||||||
|
retValue = &aFormSubmission->ReturnValue();
|
||||||
|
dialog->Close(retValue);
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
HTMLFormElement::DoSecureToInsecureSubmitCheck(nsIURI* aActionURL,
|
HTMLFormElement::DoSecureToInsecureSubmitCheck(nsIURI* aActionURL,
|
||||||
bool* aCancelSubmit)
|
bool* aCancelSubmit)
|
||||||
|
|||||||
@@ -483,6 +483,12 @@ protected:
|
|||||||
*/
|
*/
|
||||||
nsresult SubmitSubmission(HTMLFormSubmission* aFormSubmission);
|
nsresult SubmitSubmission(HTMLFormSubmission* aFormSubmission);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submit a form[method=dialog]
|
||||||
|
* @param aFormSubmission the submission object
|
||||||
|
*/
|
||||||
|
nsresult SubmitDialog(DialogFormSubmission* aFormSubmission);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify any submit observers of the submit.
|
* Notify any submit observers of the submit.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -944,6 +944,30 @@ HTMLFormSubmission::GetFromForm(nsGenericHTMLElement* aForm,
|
|||||||
charset.AssignLiteral("UTF-8");
|
charset.AssignLiteral("UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (method == NS_FORM_METHOD_DIALOG) {
|
||||||
|
HTMLDialogElement* dialog = nullptr;
|
||||||
|
for (nsIContent* parent = aForm->GetParent(); parent;
|
||||||
|
parent = parent->GetParent()) {
|
||||||
|
dialog = HTMLDialogElement::FromContentOrNull(parent);
|
||||||
|
if (dialog) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there isn't one, or if it does not have an open attribute, do
|
||||||
|
// nothing.
|
||||||
|
if (!dialog || !dialog->Open()) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsAutoString result;
|
||||||
|
if (aOriginatingElement) {
|
||||||
|
aOriginatingElement->ResultForDialogSubmit(result);
|
||||||
|
}
|
||||||
|
*aFormSubmission = new DialogFormSubmission(result, charset, aOriginatingElement, dialog);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// Choose encoder
|
// Choose encoder
|
||||||
if (method == NS_FORM_METHOD_POST &&
|
if (method == NS_FORM_METHOD_POST &&
|
||||||
enctype == NS_FORM_ENCTYPE_MULTIPART) {
|
enctype == NS_FORM_ENCTYPE_MULTIPART) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#define mozilla_dom_HTMLFormSubmission_h
|
#define mozilla_dom_HTMLFormSubmission_h
|
||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
#include "mozilla/dom/HTMLDialogElement.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsNCRFallbackEncoderWrapper.h"
|
#include "nsNCRFallbackEncoderWrapper.h"
|
||||||
@@ -121,6 +122,8 @@ public:
|
|||||||
return mOriginatingElement.get();
|
return mOriginatingElement.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual DialogFormSubmission* GetAsDialogSubmission() { return nullptr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Can only be constructed by subclasses.
|
* Can only be constructed by subclasses.
|
||||||
@@ -168,6 +171,50 @@ private:
|
|||||||
nsNCRFallbackEncoderWrapper mEncoder;
|
nsNCRFallbackEncoderWrapper mEncoder;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class DialogFormSubmission final : public HTMLFormSubmission {
|
||||||
|
public:
|
||||||
|
DialogFormSubmission(nsAString& aResult,
|
||||||
|
const nsACString& aCharset, Element* aSubmitter,
|
||||||
|
HTMLDialogElement* aDialogElement)
|
||||||
|
: HTMLFormSubmission(aCharset, aSubmitter)
|
||||||
|
, mDialogElement(aDialogElement)
|
||||||
|
, mReturnValue(aResult) {
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult AddNameValuePair(const nsAString& aName,
|
||||||
|
const nsAString& aValue) override {
|
||||||
|
MOZ_CRASH("This method should not be called");
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult AddNameBlobOrNullPair(const nsAString& aName, Blob* aBlob) override {
|
||||||
|
MOZ_CRASH("This method should not be called");
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult AddNameDirectoryPair(const nsAString& aName,
|
||||||
|
Directory* aDirectory) override {
|
||||||
|
MOZ_CRASH("This method should not be called");
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult GetEncodedSubmission(nsIURI* aURI, nsIInputStream** aPostDataStream) override {
|
||||||
|
MOZ_CRASH("This method should not be called");
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogFormSubmission* GetAsDialogSubmission() override { return this; }
|
||||||
|
|
||||||
|
HTMLDialogElement* DialogElement() { return mDialogElement; }
|
||||||
|
|
||||||
|
nsString& ReturnValue() { return mReturnValue; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
const RefPtr<HTMLDialogElement> mDialogElement;
|
||||||
|
nsString mReturnValue;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle multipart/form-data encoding, which does files as well as normal
|
* Handle multipart/form-data encoding, which does files as well as normal
|
||||||
* inputs. This always does POST.
|
* inputs. This always does POST.
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ static const nsAttrValue::EnumTable kFormMethodTable[] = {
|
|||||||
{ nullptr, 0 }
|
{ nullptr, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const nsAttrValue::EnumTable kFormMethodTableDialogEnabled[] = {
|
||||||
|
{"get", NS_FORM_METHOD_GET},
|
||||||
|
{"post", NS_FORM_METHOD_POST},
|
||||||
|
{"dialog", NS_FORM_METHOD_DIALOG},
|
||||||
|
{nullptr, 0}
|
||||||
|
};
|
||||||
|
|
||||||
// Default method is 'get'.
|
// Default method is 'get'.
|
||||||
static const nsAttrValue::EnumTable* kFormDefaultMethod = &kFormMethodTable[0];
|
static const nsAttrValue::EnumTable* kFormDefaultMethod = &kFormMethodTable[0];
|
||||||
|
|
||||||
|
|||||||
@@ -1482,6 +1482,26 @@ NS_IMPL_STRING_ATTR(HTMLInputElement, Placeholder, placeholder)
|
|||||||
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLInputElement, Type, type,
|
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLInputElement, Type, type,
|
||||||
kInputDefaultType->tag)
|
kInputDefaultType->tag)
|
||||||
|
|
||||||
|
void HTMLInputElement::ResultForDialogSubmit(nsAString& aResult) {
|
||||||
|
if (mType == NS_FORM_INPUT_IMAGE) {
|
||||||
|
// Get a property set by the frame to find out where it was clicked.
|
||||||
|
nsIntPoint* lastClickedPoint =
|
||||||
|
static_cast<nsIntPoint*>(GetProperty(nsGkAtoms::imageClickedPoint));
|
||||||
|
int32_t x, y;
|
||||||
|
if (lastClickedPoint) {
|
||||||
|
x = lastClickedPoint->x;
|
||||||
|
y = lastClickedPoint->y;
|
||||||
|
} else {
|
||||||
|
x = y = 0;
|
||||||
|
}
|
||||||
|
aResult.AppendInt(x);
|
||||||
|
aResult.AppendLiteral(",");
|
||||||
|
aResult.AppendInt(y);
|
||||||
|
} else {
|
||||||
|
GetAttr(kNameSpaceID_None, nsGkAtoms::value, aResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HTMLInputElement::GetAutocomplete(nsAString& aValue)
|
HTMLInputElement::GetAutocomplete(nsAString& aValue)
|
||||||
{
|
{
|
||||||
@@ -5916,6 +5936,9 @@ HTMLInputElement::ParseAttribute(int32_t aNamespaceID,
|
|||||||
return aResult.ParseEnumValue(aValue, kFormMethodTable, false);
|
return aResult.ParseEnumValue(aValue, kFormMethodTable, false);
|
||||||
}
|
}
|
||||||
if (aAttribute == nsGkAtoms::formenctype) {
|
if (aAttribute == nsGkAtoms::formenctype) {
|
||||||
|
if (Preferences::GetBool("dom.dialog_element.enabled", true)) {
|
||||||
|
return aResult.ParseEnumValue(aValue, kFormMethodTableDialogEnabled, false);
|
||||||
|
}
|
||||||
return aResult.ParseEnumValue(aValue, kFormEnctypeTable, false);
|
return aResult.ParseEnumValue(aValue, kFormEnctypeTable, false);
|
||||||
}
|
}
|
||||||
if (aAttribute == nsGkAtoms::autocomplete) {
|
if (aAttribute == nsGkAtoms::autocomplete) {
|
||||||
|
|||||||
@@ -968,6 +968,8 @@ protected:
|
|||||||
const nsAttrValue* aOldValue,
|
const nsAttrValue* aOldValue,
|
||||||
bool aNotify) override;
|
bool aNotify) override;
|
||||||
|
|
||||||
|
virtual void ResultForDialogSubmit(nsAString& aResult) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatch a select event. Returns true if the event was not cancelled.
|
* Dispatch a select event. Returns true if the event was not cancelled.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -861,6 +861,10 @@ public:
|
|||||||
static bool
|
static bool
|
||||||
IsScrollGrabAllowed(JSContext*, JSObject*);
|
IsScrollGrabAllowed(JSContext*, JSObject*);
|
||||||
|
|
||||||
|
virtual inline void ResultForDialogSubmit(nsAString& aResult) {
|
||||||
|
GetAttr(kNameSpaceID_None, nsGkAtoms::value, aResult);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Add/remove this element to the documents name cache
|
* Add/remove this element to the documents name cache
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class nsIFormControl;
|
|||||||
|
|
||||||
#define NS_FORM_METHOD_GET 0
|
#define NS_FORM_METHOD_GET 0
|
||||||
#define NS_FORM_METHOD_POST 1
|
#define NS_FORM_METHOD_POST 1
|
||||||
|
#define NS_FORM_METHOD_DIALOG 2
|
||||||
#define NS_FORM_ENCTYPE_URLENCODED 0
|
#define NS_FORM_ENCTYPE_URLENCODED 0
|
||||||
#define NS_FORM_ENCTYPE_MULTIPART 1
|
#define NS_FORM_ENCTYPE_MULTIPART 1
|
||||||
#define NS_FORM_ENCTYPE_TEXTPLAIN 2
|
#define NS_FORM_ENCTYPE_TEXTPLAIN 2
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace dom {
|
|||||||
class Element;
|
class Element;
|
||||||
class HTMLFieldSetElement;
|
class HTMLFieldSetElement;
|
||||||
class HTMLFormSubmission;
|
class HTMLFormSubmission;
|
||||||
|
class DialogFormSubmission;
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
|||||||
@@ -2214,11 +2214,20 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We don't want to preventDefault for escape key if the dropdown
|
||||||
|
// popup is not shown.
|
||||||
|
// Need to do the check before AboutToRollup because AboutToRollup
|
||||||
|
// may update the dropdown flags.
|
||||||
|
bool doPreventDefault =
|
||||||
|
!mComboboxFrame || mComboboxFrame->IsDroppedDownOrHasParentPopup();
|
||||||
|
|
||||||
AboutToRollup();
|
AboutToRollup();
|
||||||
// If the select element is a dropdown style, Enter key should be
|
// If the select element is a dropdown style, Escape key should be
|
||||||
// consumed everytime since Escape key may be pressed accidentally after
|
// consumed everytime since Escape key may be pressed accidentally after
|
||||||
// the dropdown is closed by Escepe key.
|
// the dropdown is closed by Escepe key.
|
||||||
aKeyEvent->PreventDefault();
|
if (doPreventDefault) {
|
||||||
|
aKeyEvent->PreventDefault();
|
||||||
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
case NS_VK_PAGE_UP: {
|
case NS_VK_PAGE_UP: {
|
||||||
|
|||||||
@@ -320,6 +320,8 @@
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0; left: 0;
|
top: 0; left: 0;
|
||||||
right: 0; bottom: 0;
|
right: 0; bottom: 0;
|
||||||
|
/* This prevents undesired interactions with the selection code. */
|
||||||
|
-moz-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
*|*:-moz-full-screen:not(:root)::backdrop {
|
*|*:-moz-full-screen:not(:root)::backdrop {
|
||||||
|
|||||||
Reference in new issue
Block a user