diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /dom/html/HTMLAnchorElement.cpp | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/HTMLAnchorElement.cpp')
-rw-r--r-- | dom/html/HTMLAnchorElement.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/dom/html/HTMLAnchorElement.cpp b/dom/html/HTMLAnchorElement.cpp index fffe8d9545..8c1689fe7d 100644 --- a/dom/html/HTMLAnchorElement.cpp +++ b/dom/html/HTMLAnchorElement.cpp @@ -14,7 +14,7 @@ #include "nsCOMPtr.h" #include "nsContentUtils.h" #include "nsGkAtoms.h" -#include "nsAttrValueOrString.h" +#include "mozilla/FocusModel.h" #include "mozilla/dom/Document.h" #include "nsPresContext.h" #include "nsIURI.h" @@ -68,10 +68,7 @@ nsresult HTMLAnchorElement::BindToTree(BindContext& aContext, Link::BindToTree(aContext); // Prefetch links - if (IsInComposedDoc()) { - TryDNSPrefetch(*this); - } - + MaybeTryDNSPrefetch(); return rv; } @@ -89,10 +86,10 @@ void HTMLAnchorElement::UnbindFromTree(UnbindContext& aContext) { Link::UnbindFromTree(); } -bool HTMLAnchorElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, +bool HTMLAnchorElement::IsHTMLFocusable(IsFocusableFlags aFlags, + bool* aIsFocusable, int32_t* aTabIndex) { - if (nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, - aTabIndex)) { + if (nsGenericHTMLElement::IsHTMLFocusable(aFlags, aIsFocusable, aTabIndex)) { return true; } @@ -122,7 +119,7 @@ bool HTMLAnchorElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, } } - if ((sTabFocusModel & eTabFocus_linksMask) == 0) { + if (!FocusModel::IsTabFocusable(TabFocusableType::Links)) { *aTabIndex = -1; } *aIsFocusable = true; @@ -194,8 +191,8 @@ void HTMLAnchorElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, if (aNamespaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::href) { Link::ResetLinkState(aNotify, !!aValue); - if (aValue && IsInComposedDoc()) { - TryDNSPrefetch(*this); + if (aValue) { + MaybeTryDNSPrefetch(); } } } @@ -210,4 +207,22 @@ void HTMLAnchorElement::AddSizeOfExcludingThis(nsWindowSizes& aSizes, *aNodeSize += Link::SizeOfExcludingThis(aSizes.mState); } +void HTMLAnchorElement::MaybeTryDNSPrefetch() { + if (IsInComposedDoc()) { + nsIURI* docURI = OwnerDoc()->GetDocumentURI(); + if (!docURI) { + return; + } + + bool docIsHttps = docURI->SchemeIs("https"); + if ((docIsHttps && + StaticPrefs::dom_prefetch_dns_for_anchor_https_document()) || + (!docIsHttps && + StaticPrefs::dom_prefetch_dns_for_anchor_http_document())) { + TryDNSPrefetch( + *this, HTMLDNSPrefetch::PrefetchSource::AnchorSpeculativePrefetch); + } + } +} + } // namespace mozilla::dom |