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/ElementInternals.cpp | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.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/ElementInternals.cpp')
-rw-r--r-- | dom/html/ElementInternals.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/dom/html/ElementInternals.cpp b/dom/html/ElementInternals.cpp index aaf58f818e..9a19744603 100644 --- a/dom/html/ElementInternals.cpp +++ b/dom/html/ElementInternals.cpp @@ -22,6 +22,10 @@ #include "nsDebug.h" #include "nsGenericHTMLElement.h" +#ifdef ACCESSIBILITY +# include "nsAccessibilityService.h" +#endif + namespace mozilla::dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(ElementInternals) @@ -482,4 +486,44 @@ void ElementInternals::InitializeControlNumber() { mControlNumber = mTarget->OwnerDoc()->GetNextControlNumber(); } +void ElementInternals::SetAttrElement(nsAtom* aAttr, Element* aElement) { + // Accessibility requires that no other attribute changes occur between + // AttrElementWillChange and AttrElementChanged. Scripts could cause + // this, so don't let them run here. We do this even if accessibility isn't + // running so that the JS behavior is consistent regardless of accessibility. + // Otherwise, JS might be able to use this difference to determine whether + // accessibility is running, which would be a privacy concern. + nsAutoScriptBlocker scriptBlocker; + +#ifdef ACCESSIBILITY + // If the target has this attribute defined then it overrides the defaults + // defined here in the Internals instance. In that case we don't need to + // notify the change to a11y since the attribute hasn't changed, just the + // underlying default. We can set accService to null and not notify. + nsAccessibilityService* accService = + !mTarget->HasAttr(aAttr) ? GetAccService() : nullptr; + if (accService) { + accService->NotifyAttrElementWillChange(mTarget, aAttr); + } +#endif + + if (aElement) { + mAttrElements.InsertOrUpdate(aAttr, do_GetWeakReference(aElement)); + } else { + mAttrElements.Remove(aAttr); + } + +#ifdef ACCESSIBILITY + if (accService) { + accService->NotifyAttrElementChanged(mTarget, aAttr); + } +#endif +} + +Element* ElementInternals::GetAttrElement(nsAtom* aAttr) const { + nsWeakPtr weakAttrEl = mAttrElements.Get(aAttr); + nsCOMPtr<Element> attrEl = do_QueryReferent(weakAttrEl); + return attrEl; +} + } // namespace mozilla::dom |