mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-03 05:47:29 +09:00
Issue #2790 - Part 1: Add: event state, pseudo-class mapping, SetAutofilled methods
This commit is contained in:
parent
2855cd6ded
commit
13d1054046
9 changed files with 73 additions and 0 deletions
|
|
@ -293,6 +293,9 @@ private:
|
||||||
// Modal <dialog> element
|
// Modal <dialog> element
|
||||||
#define NS_EVENT_STATE_MODAL_DIALOG NS_DEFINE_EVENT_STATE_MACRO(54)
|
#define NS_EVENT_STATE_MODAL_DIALOG NS_DEFINE_EVENT_STATE_MACRO(54)
|
||||||
|
|
||||||
|
// Autofilled input element (for :autofill pseudo-class)
|
||||||
|
#define NS_EVENT_STATE_AUTOFILL NS_DEFINE_EVENT_STATE_MACRO(55)
|
||||||
|
|
||||||
#define DIR_ATTR_STATES (NS_EVENT_STATE_HAS_DIR_ATTR | \
|
#define DIR_ATTR_STATES (NS_EVENT_STATE_HAS_DIR_ATTR | \
|
||||||
NS_EVENT_STATE_DIR_ATTR_LTR | \
|
NS_EVENT_STATE_DIR_ATTR_LTR | \
|
||||||
NS_EVENT_STATE_DIR_ATTR_RTL | \
|
NS_EVENT_STATE_DIR_ATTR_RTL | \
|
||||||
|
|
|
||||||
|
|
@ -2832,6 +2832,16 @@ HTMLInputElement::SetUserInput(const nsAString& aValue)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HTMLInputElement::SetAutofilled(bool aAutofilled)
|
||||||
|
{
|
||||||
|
if (aAutofilled) {
|
||||||
|
AddStates(NS_EVENT_STATE_AUTOFILL);
|
||||||
|
} else {
|
||||||
|
RemoveStates(NS_EVENT_STATE_AUTOFILL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsIEditor*
|
nsIEditor*
|
||||||
HTMLInputElement::GetEditor()
|
HTMLInputElement::GetEditor()
|
||||||
{
|
{
|
||||||
|
|
@ -8507,6 +8517,11 @@ HTMLInputElement::OnValueChanged(bool aNotify, bool aWasInteractiveUserChange)
|
||||||
{
|
{
|
||||||
mLastValueChangeWasInteractive = aWasInteractiveUserChange;
|
mLastValueChangeWasInteractive = aWasInteractiveUserChange;
|
||||||
|
|
||||||
|
// Clear autofilled state if this was an interactive user change
|
||||||
|
if (aWasInteractiveUserChange && State().HasState(NS_EVENT_STATE_AUTOFILL)) {
|
||||||
|
RemoveStates(NS_EVENT_STATE_AUTOFILL);
|
||||||
|
}
|
||||||
|
|
||||||
UpdateAllValidityStates(aNotify);
|
UpdateAllValidityStates(aNotify);
|
||||||
|
|
||||||
if (HasDirAuto()) {
|
if (HasDirAuto()) {
|
||||||
|
|
|
||||||
|
|
@ -845,6 +845,16 @@ public:
|
||||||
void SetUserInput(const nsAString& aInput,
|
void SetUserInput(const nsAString& aInput,
|
||||||
nsIPrincipal& aSubjectPrincipal);
|
nsIPrincipal& aSubjectPrincipal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets or clears the autofilled state of this input element.
|
||||||
|
* This is used by the browser's autofill system to indicate when
|
||||||
|
* a value has been automatically filled (e.g., from saved passwords
|
||||||
|
* or form data).
|
||||||
|
*
|
||||||
|
* @param aAutofilled Whether the element should be marked as autofilled
|
||||||
|
*/
|
||||||
|
void SetAutofilled(bool aAutofilled);
|
||||||
|
|
||||||
// XPCOM GetPhonetic() is OK
|
// XPCOM GetPhonetic() is OK
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -366,6 +366,16 @@ HTMLTextAreaElement::SetUserInput(const nsAString& aValue)
|
||||||
return SetValueInternal(aValue, nsTextEditorState::eSetValue_BySetUserInput);
|
return SetValueInternal(aValue, nsTextEditorState::eSetValue_BySetUserInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HTMLTextAreaElement::SetAutofilled(bool aAutofilled)
|
||||||
|
{
|
||||||
|
if (aAutofilled) {
|
||||||
|
AddStates(NS_EVENT_STATE_AUTOFILL);
|
||||||
|
} else {
|
||||||
|
RemoveStates(NS_EVENT_STATE_AUTOFILL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HTMLTextAreaElement::SetValueChanged(bool aValueChanged)
|
HTMLTextAreaElement::SetValueChanged(bool aValueChanged)
|
||||||
{
|
{
|
||||||
|
|
@ -1633,6 +1643,11 @@ HTMLTextAreaElement::OnValueChanged(bool aNotify, bool aWasInteractiveUserChange
|
||||||
{
|
{
|
||||||
mLastValueChangeWasInteractive = aWasInteractiveUserChange;
|
mLastValueChangeWasInteractive = aWasInteractiveUserChange;
|
||||||
|
|
||||||
|
// Clear autofilled state if this was an interactive user change
|
||||||
|
if (aWasInteractiveUserChange && State().HasState(NS_EVENT_STATE_AUTOFILL)) {
|
||||||
|
RemoveStates(NS_EVENT_STATE_AUTOFILL);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the validity state
|
// Update the validity state
|
||||||
bool validBefore = IsValid();
|
bool validBefore = IsValid();
|
||||||
UpdateTooLongValidityState();
|
UpdateTooLongValidityState();
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,15 @@ public:
|
||||||
}
|
}
|
||||||
NS_IMETHOD SetUserInput(const nsAString& aInput) override;
|
NS_IMETHOD SetUserInput(const nsAString& aInput) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets or clears the autofilled state of this textarea element.
|
||||||
|
* This is used by the browser's autofill system to indicate when
|
||||||
|
* a value has been automatically filled (e.g., from saved form data).
|
||||||
|
*
|
||||||
|
* @param aAutofilled Whether the element should be marked as autofilled
|
||||||
|
*/
|
||||||
|
void SetAutofilled(bool aAutofilled);
|
||||||
|
|
||||||
// nsIFormControl
|
// nsIFormControl
|
||||||
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_TEXTAREA; }
|
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_TEXTAREA; }
|
||||||
NS_IMETHOD Reset() override;
|
NS_IMETHOD Reset() override;
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,13 @@ partial interface HTMLInputElement {
|
||||||
// for example will be dispatched when focusing out the element.
|
// for example will be dispatched when focusing out the element.
|
||||||
[Func="IsChromeOrXBL", NeedsSubjectPrincipal]
|
[Func="IsChromeOrXBL", NeedsSubjectPrincipal]
|
||||||
void setUserInput(DOMString input);
|
void setUserInput(DOMString input);
|
||||||
|
|
||||||
|
// Sets or clears the autofilled state of this input element.
|
||||||
|
// This is used by the browser's autofill system to indicate when
|
||||||
|
// a value has been automatically filled (e.g., from saved passwords
|
||||||
|
// or form data).
|
||||||
|
[ChromeOnly]
|
||||||
|
void setAutofilled(boolean autofilled);
|
||||||
};
|
};
|
||||||
|
|
||||||
partial interface HTMLInputElement {
|
partial interface HTMLInputElement {
|
||||||
|
|
|
||||||
|
|
@ -97,4 +97,10 @@ partial interface HTMLTextAreaElement {
|
||||||
// element.
|
// element.
|
||||||
[ChromeOnly]
|
[ChromeOnly]
|
||||||
void setUserInput(DOMString input);
|
void setUserInput(DOMString input);
|
||||||
|
|
||||||
|
// Sets or clears the autofilled state of this textarea element.
|
||||||
|
// This is used by the browser's autofill system to indicate when
|
||||||
|
// a value has been automatically filled (e.g., from saved form data).
|
||||||
|
[ChromeOnly]
|
||||||
|
void setAutofilled(boolean autofilled);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,9 @@ CSS_STATE_PSEUDO_CLASS(mozFullScreen, ":-moz-full-screen", 0, "", NS_EVENT_STATE
|
||||||
CSS_STATE_PSEUDO_CLASS(modal, ":modal", 0, "", NS_EVENT_STATE_MODAL_DIALOG)
|
CSS_STATE_PSEUDO_CLASS(modal, ":modal", 0, "", NS_EVENT_STATE_MODAL_DIALOG)
|
||||||
CSS_STATE_PSEUDO_CLASS(mozModalDialog, ":-moz-modal-dialog", 0, "", NS_EVENT_STATE_MODAL_DIALOG)
|
CSS_STATE_PSEUDO_CLASS(mozModalDialog, ":-moz-modal-dialog", 0, "", NS_EVENT_STATE_MODAL_DIALOG)
|
||||||
|
|
||||||
|
// Matches autofilled input elements
|
||||||
|
CSS_STATE_PSEUDO_CLASS(autofill, ":autofill", 0, "", NS_EVENT_STATE_AUTOFILL)
|
||||||
|
|
||||||
// Matches if the element is focused and should show a focus ring
|
// Matches if the element is focused and should show a focus ring
|
||||||
CSS_STATE_PSEUDO_CLASS(mozFocusRing, ":-moz-focusring", 0, "", NS_EVENT_STATE_FOCUSRING)
|
CSS_STATE_PSEUDO_CLASS(mozFocusRing, ":-moz-focusring", 0, "", NS_EVENT_STATE_FOCUSRING)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -238,6 +238,11 @@ FormHandler.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldDetail.element.value = field.value;
|
fieldDetail.element.value = field.value;
|
||||||
|
|
||||||
|
// Set the autofilled state on the element
|
||||||
|
if (typeof fieldDetail.element.setAutofilled === 'function') {
|
||||||
|
fieldDetail.element.setAutofilled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue