diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /dom/html/nsGenericHTMLElement.cpp | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-adbda400be353e676059e335c3c0aaf99e719475.tar.xz firefox-adbda400be353e676059e335c3c0aaf99e719475.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/nsGenericHTMLElement.cpp')
-rw-r--r-- | dom/html/nsGenericHTMLElement.cpp | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index de29276fdc..1014ba2a25 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -18,7 +18,6 @@ #include "mozilla/StaticPrefs_dom.h" #include "mozilla/TextEditor.h" #include "mozilla/TextEvents.h" -#include "mozilla/StaticPrefs_html5.h" #include "mozilla/StaticPrefs_accessibility.h" #include "mozilla/dom/FetchPriority.h" #include "mozilla/dom/FormData.h" @@ -29,6 +28,7 @@ #include "nsQueryObject.h" #include "mozilla/dom/BindContext.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/UnbindContext.h" #include "nsPIDOMWindow.h" #include "nsIFrameInlines.h" #include "nsIScrollableFrame.h" @@ -524,7 +524,7 @@ nsresult nsGenericHTMLElement::BindToTree(BindContext& aContext, return rv; } -void nsGenericHTMLElement::UnbindFromTree(bool aNullParent) { +void nsGenericHTMLElement::UnbindFromTree(UnbindContext& aContext) { if (IsInComposedDoc()) { // https://html.spec.whatwg.org/#dom-trees:hide-popover-algorithm // If removedNode's popover attribute is not in the no popover state, then @@ -544,7 +544,7 @@ void nsGenericHTMLElement::UnbindFromTree(bool aNullParent) { } } - nsStyledElement::UnbindFromTree(aNullParent); + nsStyledElement::UnbindFromTree(aContext); // Invalidate .labels list. It will be repopulated when used the next time. nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots(); @@ -745,6 +745,16 @@ void nsGenericHTMLElement::AfterSetPopoverAttr() { } } +void nsGenericHTMLElement::OnAttrSetButNotChanged( + int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, + bool aNotify) { + if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::popovertarget) { + ClearExplicitlySetAttrElement(aName); + } + return nsGenericHTMLElementBase::OnAttrSetButNotChanged(aNamespaceID, aName, + aValue, aNotify); +} + void nsGenericHTMLElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, @@ -763,7 +773,7 @@ void nsGenericHTMLElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, NewRunnableMethod("nsGenericHTMLElement::AfterSetPopoverAttr", this, &nsGenericHTMLElement::AfterSetPopoverAttr)); } else if (aName == nsGkAtoms::popovertarget) { - ClearExplicitlySetAttrElement(nsGkAtoms::popovertarget); + ClearExplicitlySetAttrElement(aName); } else if (aName == nsGkAtoms::dir) { auto dir = Directionality::Ltr; // A boolean tracking whether we need to recompute our directionality. @@ -1259,25 +1269,24 @@ bool nsGenericHTMLElement::ParseImageAttribute(nsAtom* aAttribute, bool nsGenericHTMLElement::ParseReferrerAttribute(const nsAString& aString, nsAttrValue& aResult) { using mozilla::dom::ReferrerInfo; + // This is a bit sketchy, we assume GetEnumString(…).get() points to a static + // buffer, relying on the fact that GetEnumString(…) returns a literal string. static const nsAttrValue::EnumTable kReferrerPolicyTable[] = { - {ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::No_referrer), + {GetEnumString(ReferrerPolicy::No_referrer).get(), static_cast<int16_t>(ReferrerPolicy::No_referrer)}, - {ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Origin), + {GetEnumString(ReferrerPolicy::Origin).get(), static_cast<int16_t>(ReferrerPolicy::Origin)}, - {ReferrerInfo::ReferrerPolicyToString( - ReferrerPolicy::Origin_when_cross_origin), + {GetEnumString(ReferrerPolicy::Origin_when_cross_origin).get(), static_cast<int16_t>(ReferrerPolicy::Origin_when_cross_origin)}, - {ReferrerInfo::ReferrerPolicyToString( - ReferrerPolicy::No_referrer_when_downgrade), + {GetEnumString(ReferrerPolicy::No_referrer_when_downgrade).get(), static_cast<int16_t>(ReferrerPolicy::No_referrer_when_downgrade)}, - {ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Unsafe_url), + {GetEnumString(ReferrerPolicy::Unsafe_url).get(), static_cast<int16_t>(ReferrerPolicy::Unsafe_url)}, - {ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Strict_origin), + {GetEnumString(ReferrerPolicy::Strict_origin).get(), static_cast<int16_t>(ReferrerPolicy::Strict_origin)}, - {ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Same_origin), + {GetEnumString(ReferrerPolicy::Same_origin).get(), static_cast<int16_t>(ReferrerPolicy::Same_origin)}, - {ReferrerInfo::ReferrerPolicyToString( - ReferrerPolicy::Strict_origin_when_cross_origin), + {GetEnumString(ReferrerPolicy::Strict_origin_when_cross_origin).get(), static_cast<int16_t>(ReferrerPolicy::Strict_origin_when_cross_origin)}, {nullptr, ReferrerPolicy::_empty}}; return aResult.ParseEnumValue(aString, kReferrerPolicyTable, false); @@ -1811,14 +1820,14 @@ nsresult nsGenericHTMLFormElement::BindToTree(BindContext& aContext, return NS_OK; } -void nsGenericHTMLFormElement::UnbindFromTree(bool aNullParent) { +void nsGenericHTMLFormElement::UnbindFromTree(UnbindContext& aContext) { // Save state before doing anything else. SaveState(); if (IsFormAssociatedElement()) { if (HTMLFormElement* form = GetFormInternal()) { // Might need to unset form - if (aNullParent) { + if (aContext.IsUnbindRoot(this)) { // No more parent means no more form ClearForm(true, true); } else { @@ -1839,7 +1848,7 @@ void nsGenericHTMLFormElement::UnbindFromTree(bool aNullParent) { } } - nsGenericHTMLElement::UnbindFromTree(aNullParent); + nsGenericHTMLElement::UnbindFromTree(aContext); // The element might not have a fieldset anymore. UpdateFieldSet(false); |