Bug 1418217 - Move visited links pref to StylePrefs. r=TYLin
MozReview-Commit-ID: HLukaX0EFFv
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -230,17 +230,16 @@ nsLayoutStatics::Initialize()
rv = nsCCUncollectableMarker::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsCCUncollectableMarker");
return rv;
}
StylePrefs::Init();
- nsCSSRuleProcessor::Startup();
#ifdef MOZ_XUL
rv = nsXULPopupManager::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsXULPopupManager");
return rv;
}
#endif
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -302,22 +302,16 @@ Gecko_IsPrivateBrowsingEnabled(const nsI
{
MOZ_ASSERT(aDoc);
MOZ_ASSERT(NS_IsMainThread());
nsILoadContext* loadContext = aDoc->GetLoadContext();
return loadContext && loadContext->UsePrivateBrowsing();
}
-bool
-Gecko_AreVisitedLinksEnabled()
-{
- return nsCSSRuleProcessor::VisitedLinksEnabled();
-}
-
EventStates::ServoType
Gecko_ElementState(RawGeckoElementBorrowed aElement)
{
return aElement->StyleState().ServoValue();
}
EventStates::ServoType
Gecko_DocumentState(const nsIDocument* aDocument)
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -230,18 +230,16 @@ RawServoDeclarationBlockStrongBorrowedOr
Gecko_GetVisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetActiveLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
// Visited handling.
// Returns whether private browsing is enabled for a given element.
bool Gecko_IsPrivateBrowsingEnabled(const nsIDocument* aDoc);
-// Returns whether visited links are enabled.
-bool Gecko_AreVisitedLinksEnabled();
// Animations
bool
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElementOrPseudo,
mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
RawServoAnimationValueMapBorrowedMut aAnimationValues);
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetSMILOverrideDeclarationBlock(RawGeckoElementBorrowed element);
--- a/layout/style/StylePrefs.cpp
+++ b/layout/style/StylePrefs.cpp
@@ -13,16 +13,17 @@ namespace mozilla {
bool StylePrefs::sFontDisplayEnabled;
bool StylePrefs::sOpentypeSVGEnabled;
bool StylePrefs::sWebkitPrefixedAliasesEnabled;
bool StylePrefs::sWebkitDevicePixelRatioEnabled;
bool StylePrefs::sMozGradientsEnabled;
bool StylePrefs::sControlCharVisibility;
bool StylePrefs::sFramesTimingFunctionEnabled;
bool StylePrefs::sUnprefixedFullscreenApiEnabled;
+bool StylePrefs::sVisitedLinksEnabled;
/* static */ void
StylePrefs::Init()
{
Preferences::AddBoolVarCache(&sFontDisplayEnabled,
"layout.css.font-display.enabled");
Preferences::AddBoolVarCache(&sOpentypeSVGEnabled,
"gfx.font_rendering.opentype_svg.enabled");
@@ -33,11 +34,13 @@ StylePrefs::Init()
Preferences::AddBoolVarCache(&sMozGradientsEnabled,
"layout.css.prefixes.gradients");
Preferences::AddBoolVarCache(&sControlCharVisibility,
"layout.css.control-characters.visible");
Preferences::AddBoolVarCache(&sFramesTimingFunctionEnabled,
"layout.css.frames-timing.enabled");
Preferences::AddBoolVarCache(&sUnprefixedFullscreenApiEnabled,
"full-screen-api.unprefix.enabled");
+ Preferences::AddBoolVarCache(&sVisitedLinksEnabled,
+ "layout.css.visited_links_enabled");
}
} // namespace mozilla
--- a/layout/style/StylePrefs.h
+++ b/layout/style/StylePrefs.h
@@ -16,15 +16,16 @@ struct StylePrefs
static bool sFontDisplayEnabled;
static bool sOpentypeSVGEnabled;
static bool sWebkitPrefixedAliasesEnabled;
static bool sWebkitDevicePixelRatioEnabled;
static bool sMozGradientsEnabled;
static bool sControlCharVisibility;
static bool sFramesTimingFunctionEnabled;
static bool sUnprefixedFullscreenApiEnabled;
+ static bool sVisitedLinksEnabled;
static void Init();
};
} // namespace mozilla
#endif // mozilla_StylePrefs_h
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -56,20 +56,16 @@
#include "RuleProcessorCache.h"
#include "nsIDOMMutationEvent.h"
using namespace mozilla;
using namespace mozilla::dom;
typedef ArenaAllocator<4096, 8> CascadeAllocator;
-#define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled"
-
-static bool gSupportVisitedPseudo = true;
-
static nsTArray< RefPtr<nsAtom> >* sSystemMetrics = 0;
#ifdef XP_WIN
uint8_t nsCSSRuleProcessor::sWinThemeId = LookAndFeel::eWindowsTheme_Generic;
#endif
/**
* A struct representing a given CSS rule and a particular selector
@@ -1047,29 +1043,16 @@ nsCSSRuleProcessor::ClearSheets()
{
for (sheet_array_type::size_type i = mSheets.Length(); i-- != 0; ) {
mSheets[i]->DropRuleProcessor(this);
}
mSheets.Clear();
}
/* static */ void
-nsCSSRuleProcessor::Startup()
-{
- Preferences::AddBoolVarCache(&gSupportVisitedPseudo, VISITED_PSEUDO_PREF,
- true);
-}
-
-/* static */ bool
-nsCSSRuleProcessor::VisitedLinksEnabled()
-{
- return gSupportVisitedPseudo;
-}
-
-/* static */ void
nsCSSRuleProcessor::InitSystemMetrics()
{
if (sSystemMetrics)
return;
MOZ_ASSERT(NS_IsMainThread());
sSystemMetrics = new nsTArray< RefPtr<nsAtom> >;
@@ -1254,17 +1237,17 @@ nsCSSRuleProcessor::GetContentState(cons
{
EventStates state = aElement->StyleState();
// If we are not supposed to mark visited links as such, be sure to
// flip the bits appropriately. We want to do this here, rather
// than in GetContentStateForVisitedHandling, so that we don't
// expose that :visited support is disabled to the Web page.
if (state.HasState(NS_EVENT_STATE_VISITED) &&
- (!gSupportVisitedPseudo ||
+ (!StylePrefs::sVisitedLinksEnabled ||
aElement->OwnerDoc()->IsBeingUsedAsImage() ||
aUsingPrivateBrowsing)) {
state &= ~NS_EVENT_STATE_VISITED;
state |= NS_EVENT_STATE_UNVISITED;
}
return state;
}
--- a/layout/style/nsCSSRuleProcessor.h
+++ b/layout/style/nsCSSRuleProcessor.h
@@ -76,18 +76,16 @@ public:
bool aIsShared = false);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsCSSRuleProcessor)
public:
nsresult ClearRuleCascades();
- static bool VisitedLinksEnabled();
- static void Startup();
static void InitSystemMetrics();
static void Shutdown();
static void FreeSystemMetrics();
static bool HasSystemMetric(nsAtom* aMetric);
/*
* Returns true if the given aElement matches one of the
* selectors in aSelectorList. Note that this method will assume