summaryrefslogtreecommitdiffstats
path: root/dom/html
diff options
context:
space:
mode:
authorathenian200 <athenian200@outlook.com>2020-08-14 11:06:13 -0500
committerathenian200 <athenian200@outlook.com>2020-08-14 11:34:13 -0500
commit931e8d29faf577e3cec64b896ee1a06cd93b27b9 (patch)
tree4dc5574eaaed3ce6884616309a0c795ed5f75292 /dom/html
parent68623263573f5a087ad878f1609de272cc617399 (diff)
downloadUXP-931e8d29faf577e3cec64b896ee1a06cd93b27b9.tar
UXP-931e8d29faf577e3cec64b896ee1a06cd93b27b9.tar.gz
UXP-931e8d29faf577e3cec64b896ee1a06cd93b27b9.tar.lz
UXP-931e8d29faf577e3cec64b896ee1a06cd93b27b9.tar.xz
UXP-931e8d29faf577e3cec64b896ee1a06cd93b27b9.zip
Issue #1629 - Part 3: Implement behind preference.
This is not very "clean," and is mostly done in the same sloppy way as Emilio did it because that's basically the only way you can do it. Note well that this does NOT actually turn off everything I've done in a clean fashion like ifdefs would. For instance, the Explicitly Enabled flag is still present, but is now always false because the only condition that can set it true is behind the pref and therefore inert when this pref is off. Also, because the arguments of SetDisabled have changed, my modifications to SetMozDisabled must be present regardless of whether the pref is on or off. What I have done is turn off the actual reflection of the disabled attribute in Disabled and SetDisabled, as well as in AfterSetAttr. However, turning the pref off seems to restore more or less our old behavior, though there may be subtle differences unlike with an ifdef since this is, unfortunately, not an exact science and I can only turn off changes that happen within individual functions and not changes in how functions interact with each other.
Diffstat (limited to 'dom/html')
-rw-r--r--dom/html/HTMLLinkElement.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/dom/html/HTMLLinkElement.cpp b/dom/html/HTMLLinkElement.cpp
index 352cbc755..c2972784c 100644
--- a/dom/html/HTMLLinkElement.cpp
+++ b/dom/html/HTMLLinkElement.cpp
@@ -33,6 +33,8 @@
#define LINK_ELEMENT_FLAG_BIT(n_) \
NODE_FLAG_BIT(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + (n_))
+#define LINK_DISABLED Preferences::GetBool("dom.link.disabled_attribute.enabled", true)
+
// Link element specific bits
enum {
// Indicates that a DNS Prefetch has been requested from this Link element.
@@ -92,10 +94,13 @@ NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLElement)
NS_IMPL_ELEMENT_CLONE(HTMLLinkElement)
+
bool
HTMLLinkElement::Disabled() const
{
- return GetBoolAttr(nsGkAtoms::disabled);
+ if (LINK_DISABLED) {
+ return GetBoolAttr(nsGkAtoms::disabled);
+ }
StyleSheet* ss = GetSheet();
return ss && ss->Disabled();
@@ -110,8 +115,10 @@ HTMLLinkElement::GetMozDisabled(bool* aDisabled)
void
HTMLLinkElement::SetDisabled(bool aDisabled, ErrorResult& aRv)
-{
+{
+ if (LINK_DISABLED) {
return SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aRv);
+ }
if (StyleSheet* ss = GetSheet()) {
ss->SetDisabled(aDisabled);
@@ -123,7 +130,7 @@ HTMLLinkElement::SetMozDisabled(bool aDisabled)
{
ErrorResult rv;
SetDisabled(aDisabled, rv);
- return rv.StealNSResult();
+ return rv.StealNSResult();
}
NS_IMPL_STRING_ATTR(HTMLLinkElement, Charset, charset)
@@ -375,7 +382,7 @@ HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
aName == nsGkAtoms::title ||
aName == nsGkAtoms::media ||
aName == nsGkAtoms::type ||
- aName == nsGkAtoms::disabled)) {
+ (LINK_DISABLED && aName == nsGkAtoms::disabled))) {
bool dropSheet = false;
if (aName == nsGkAtoms::rel) {
nsAutoString value;
@@ -403,12 +410,12 @@ HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
(aName == nsGkAtoms::title ||
aName == nsGkAtoms::media ||
aName == nsGkAtoms::type ||
- aName == nsGkAtoms::disabled));
+ (LINK_DISABLED && aName == nsGkAtoms::disabled)));
}
} else {
// If the disabled attribute is removed from a link element, the
// stylesheet may be explicitly enabled.
- if (aNameSpaceID == kNameSpaceID_None) {
+ if (aNameSpaceID == kNameSpaceID_None && LINK_DISABLED) {
if (aName == nsGkAtoms::disabled) {
mExplicitlyEnabled = true;
}
@@ -419,7 +426,7 @@ HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
aName == nsGkAtoms::title ||
aName == nsGkAtoms::media ||
aName == nsGkAtoms::type ||
- aName == nsGkAtoms::disabled) {
+ (LINK_DISABLED && aName == nsGkAtoms::disabled)) {
UpdateStyleSheetInternal(nullptr, nullptr, true);
}
if (aName == nsGkAtoms::href ||
@@ -530,6 +537,8 @@ HTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
return;
}
+ if (LINK_DISABLED) {
+
// Is the link disabled?
if (Disabled()) {
return;
@@ -540,6 +549,8 @@ HTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
*aIsExplicitlyEnabled = true;
}
+ }
+
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();