summaryrefslogtreecommitdiffstats
path: root/dom/html/HTMLAnchorElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/html/HTMLAnchorElement.cpp')
-rw-r--r--dom/html/HTMLAnchorElement.cpp37
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