Bug 1829225 - Make BeforeSetAttr take the parsed nsAttrValue. r=smaug

ParseAttribute ideally would be const (see bug 1829138), but the SVG and
SMIL code is rather messy. Still, now that BeforeSetAttr can't really
fail, swapping the order of ParseAttribute and BeforeSetAttr shouldn't
really change behavior.

Sorry for the extra `virtual` keyword removal and such. I had to do this
one by hand unlike the dependent bugs, and I went a bit drive-by, lmk if
you want me to split those changes.

Differential Revision: https://phabricator.services.mozilla.com/D176086
This commit is contained in:
Emilio Cobos Álvarez
2023-04-21 09:25:17 +00:00
parent dc08c242b1
commit c1c1e7460b
38 changed files with 295 additions and 377 deletions

View File

@@ -50,13 +50,13 @@ class HTMLTextAreaElement final : public TextControlElement,
NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLTextAreaElement, textarea)
virtual int32_t TabIndexDefault() override;
int32_t TabIndexDefault() override;
// Element
virtual bool IsInteractiveHTMLContent() const override { return true; }
bool IsInteractiveHTMLContent() const override { return true; }
// nsGenericHTMLElement
virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override;
bool IsDisabledForEvents(WidgetEvent* aEvent) override;
// nsGenericHTMLFormElement
void SaveState() override;
@@ -67,80 +67,74 @@ class HTMLTextAreaElement final : public TextControlElement,
NS_IMETHOD Reset() override;
NS_IMETHOD SubmitNamesValues(FormData* aFormData) override;
virtual void FieldSetDisabledChanged(bool aNotify) override;
void FieldSetDisabledChanged(bool aNotify) override;
virtual ElementState IntrinsicState() const override;
ElementState IntrinsicState() const override;
void SetLastValueChangeWasInteractive(bool);
// TextControlElement
virtual nsresult SetValueChanged(bool aValueChanged) override;
virtual bool IsSingleLineTextControl() const override;
virtual bool IsTextArea() const override;
virtual bool IsPasswordTextControl() const override;
virtual int32_t GetCols() override;
virtual int32_t GetWrapCols() override;
virtual int32_t GetRows() override;
virtual void GetDefaultValueFromContent(nsAString& aValue) override;
virtual bool ValueChanged() const override;
virtual void GetTextEditorValue(nsAString& aValue,
bool aIgnoreWrap) const override;
MOZ_CAN_RUN_SCRIPT virtual TextEditor* GetTextEditor() override;
virtual TextEditor* GetTextEditorWithoutCreation() override;
virtual nsISelectionController* GetSelectionController() override;
virtual nsFrameSelection* GetConstFrameSelection() override;
virtual TextControlState* GetTextControlState() const override {
return mState;
}
virtual nsresult BindToFrame(nsTextControlFrame* aFrame) override;
MOZ_CAN_RUN_SCRIPT virtual void UnbindFromFrame(
nsTextControlFrame* aFrame) override;
MOZ_CAN_RUN_SCRIPT virtual nsresult CreateEditor() override;
virtual void SetPreviewValue(const nsAString& aValue) override;
virtual void GetPreviewValue(nsAString& aValue) override;
virtual void EnablePreview() override;
virtual bool IsPreviewEnabled() override;
virtual void InitializeKeyboardEventListeners() override;
virtual void OnValueChanged(ValueChangeKind) override;
virtual void GetValueFromSetRangeText(nsAString& aValue) override;
MOZ_CAN_RUN_SCRIPT virtual nsresult SetValueFromSetRangeText(
const nsAString& aValue) override;
virtual bool HasCachedSelection() override;
nsresult SetValueChanged(bool aValueChanged) override;
bool IsSingleLineTextControl() const override;
bool IsTextArea() const override;
bool IsPasswordTextControl() const override;
int32_t GetCols() override;
int32_t GetWrapCols() override;
int32_t GetRows() override;
void GetDefaultValueFromContent(nsAString& aValue) override;
bool ValueChanged() const override;
void GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const override;
MOZ_CAN_RUN_SCRIPT TextEditor* GetTextEditor() override;
TextEditor* GetTextEditorWithoutCreation() override;
nsISelectionController* GetSelectionController() override;
nsFrameSelection* GetConstFrameSelection() override;
TextControlState* GetTextControlState() const override { return mState; }
nsresult BindToFrame(nsTextControlFrame* aFrame) override;
MOZ_CAN_RUN_SCRIPT void UnbindFromFrame(nsTextControlFrame* aFrame) override;
MOZ_CAN_RUN_SCRIPT nsresult CreateEditor() override;
void SetPreviewValue(const nsAString& aValue) override;
void GetPreviewValue(nsAString& aValue) override;
void EnablePreview() override;
bool IsPreviewEnabled() override;
void InitializeKeyboardEventListeners() override;
void OnValueChanged(ValueChangeKind) override;
void GetValueFromSetRangeText(nsAString& aValue) override;
MOZ_CAN_RUN_SCRIPT nsresult
SetValueFromSetRangeText(const nsAString& aValue) override;
bool HasCachedSelection() override;
// nsIContent
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction()
const override;
virtual nsChangeHint GetAttributeChangeHint(const nsAtom* aAttribute,
int32_t aModType) const override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(bool aNullParent = true) override;
bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
nsChangeHint GetAttributeChangeHint(const nsAtom* aAttribute,
int32_t aModType) const override;
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
virtual nsresult PreHandleEvent(EventChainVisitor& aVisitor) override;
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
nsresult PreHandleEvent(EventChainVisitor& aVisitor) override;
nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
int32_t* aTabIndex) override;
bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
int32_t* aTabIndex) override;
virtual void DoneAddingChildren(bool aHaveNotified) override;
virtual bool IsDoneAddingChildren() override;
void DoneAddingChildren(bool aHaveNotified) override;
bool IsDoneAddingChildren() override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
nsresult CopyInnerTo(Element* aDest);
/**
* Called when an attribute is about to be changed
*/
virtual void BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValueOrString* aValue,
bool aNotify) override;
void BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValue* aValue, bool aNotify) override;
// nsIMutationObserver
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
@@ -290,8 +284,7 @@ class HTMLTextAreaElement final : public TextControlElement,
// get rid of the compiler warning
using nsGenericHTMLFormControlElementWithState::IsSingleLineTextControl;
virtual JSObject* WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
nsCOMPtr<nsIControllers> mControllers;
/** Whether or not the value has changed since its default value was given. */
@@ -349,11 +342,9 @@ class HTMLTextAreaElement final : public TextControlElement,
*/
void ContentChanged(nsIContent* aContent);
virtual void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal,
bool aNotify) override;
void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValue* aValue, const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal, bool aNotify) override;
/**
* Return if an element should have a specific validity UI