зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1366956 part 1 - Move CSS prefs from nsCSSParser into an independent class. r=heycam
MozReview-Commit-ID: S5xaJcP1jb --HG-- extra : rebase_source : bf483459609aa05031d68224ce17228298f3a80f
This commit is contained in:
Родитель
a8c266ed22
Коммит
9dc5b62112
|
@ -121,6 +121,7 @@
|
|||
#include "MediaPrefs.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/StaticPresData.h"
|
||||
#include "mozilla/StylePrefs.h"
|
||||
#include "mozilla/dom/WebIDLGlobalNameHash.h"
|
||||
#include "mozilla/dom/ipc/IPCBlobInputStreamStorage.h"
|
||||
#include "mozilla/dom/U2FTokenManager.h"
|
||||
|
@ -234,7 +235,7 @@ nsLayoutStatics::Initialize()
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCSSParser::Startup();
|
||||
StylePrefs::Init();
|
||||
nsCSSRuleProcessor::Startup();
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
|
|
|
@ -61,6 +61,7 @@ headers = [
|
|||
"mozilla/dom/ChildIterator.h",
|
||||
"mozilla/dom/NameSpaceConstants.h",
|
||||
"mozilla/LookAndFeel.h",
|
||||
"mozilla/StylePrefs.h",
|
||||
"mozilla/ServoBindings.h",
|
||||
"mozilla/ServoMediaList.h",
|
||||
"mozilla/ServoStyleContext.h",
|
||||
|
@ -136,6 +137,7 @@ whitelist-types = [
|
|||
"mozilla::MallocSizeOf",
|
||||
"mozilla::PropertyStyleAnimationValuePair",
|
||||
"mozilla::ServoTraversalFlags",
|
||||
"mozilla::StylePrefs",
|
||||
"mozilla::StyleShapeRadius",
|
||||
"mozilla::StyleGrid.*",
|
||||
"mozilla::UpdateAnimationsTasks",
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/StylePrefs.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
bool StylePrefs::sOpentypeSVGEnabled;
|
||||
bool StylePrefs::sWebkitPrefixedAliasesEnabled;
|
||||
bool StylePrefs::sWebkitDevicePixelRatioEnabled;
|
||||
bool StylePrefs::sMozGradientsEnabled;
|
||||
bool StylePrefs::sControlCharVisibility;
|
||||
bool StylePrefs::sFramesTimingFunctionEnabled;
|
||||
|
||||
/* static */ void
|
||||
StylePrefs::Init()
|
||||
{
|
||||
Preferences::AddBoolVarCache(&sOpentypeSVGEnabled,
|
||||
"gfx.font_rendering.opentype_svg.enabled");
|
||||
Preferences::AddBoolVarCache(&sWebkitPrefixedAliasesEnabled,
|
||||
"layout.css.prefixes.webkit");
|
||||
Preferences::AddBoolVarCache(&sWebkitDevicePixelRatioEnabled,
|
||||
"layout.css.prefixes.device-pixel-ratio-webkit");
|
||||
Preferences::AddBoolVarCache(&sMozGradientsEnabled,
|
||||
"layout.css.prefixes.gradients");
|
||||
Preferences::AddBoolVarCache(&sControlCharVisibility,
|
||||
"layout.css.control-characters.visible");
|
||||
Preferences::AddBoolVarCache(&sFramesTimingFunctionEnabled,
|
||||
"layout.css.frames-timing.enabled");
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,28 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* A namespace class for style system prefs */
|
||||
|
||||
#ifndef mozilla_StylePrefs_h
|
||||
#define mozilla_StylePrefs_h
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct StylePrefs
|
||||
{
|
||||
static bool sOpentypeSVGEnabled;
|
||||
static bool sWebkitPrefixedAliasesEnabled;
|
||||
static bool sWebkitDevicePixelRatioEnabled;
|
||||
static bool sMozGradientsEnabled;
|
||||
static bool sControlCharVisibility;
|
||||
static bool sFramesTimingFunctionEnabled;
|
||||
|
||||
static void Init();
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_StylePrefs_h
|
|
@ -131,6 +131,7 @@ EXPORTS.mozilla += [
|
|||
'StyleAnimationValue.h',
|
||||
'StyleBackendType.h',
|
||||
'StyleComplexColor.h',
|
||||
'StylePrefs.h',
|
||||
'StyleSetHandle.h',
|
||||
'StyleSetHandleInlines.h',
|
||||
'StyleSheet.h',
|
||||
|
@ -266,6 +267,7 @@ UNIFIED_SOURCES += [
|
|||
'ServoStyleSheet.cpp',
|
||||
'ServoSupportsRule.cpp',
|
||||
'StyleAnimationValue.cpp',
|
||||
'StylePrefs.cpp',
|
||||
'StyleRule.cpp',
|
||||
'StyleSheet.cpp',
|
||||
'URLExtraData.cpp',
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StylePrefs.h"
|
||||
#include "nsRuleData.h"
|
||||
#include "mozilla/CSSVariableValues.h"
|
||||
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h"
|
||||
|
@ -70,14 +71,6 @@ using namespace mozilla::css;
|
|||
|
||||
typedef nsCSSProps::KTableEntry KTableEntry;
|
||||
|
||||
// pref-backed bool values (hooked up in nsCSSParser::Startup)
|
||||
static bool sOpentypeSVGEnabled;
|
||||
static bool sWebkitPrefixedAliasesEnabled;
|
||||
static bool sWebkitDevicePixelRatioEnabled;
|
||||
static bool sMozGradientsEnabled;
|
||||
static bool sControlCharVisibility;
|
||||
static bool sFramesTimingFunctionEnabled;
|
||||
|
||||
const uint32_t
|
||||
nsCSSProps::kParserVariantTable[eCSSProperty_COUNT_no_shorthands] = {
|
||||
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, \
|
||||
|
@ -3507,12 +3500,12 @@ CSSParserImpl::ParseMediaQueryExpression(nsMediaQuery* aQuery)
|
|||
uint8_t satisfiedReqFlags = 0;
|
||||
|
||||
// Strip off "-webkit-" prefix from featureString:
|
||||
if (sWebkitPrefixedAliasesEnabled &&
|
||||
if (StylePrefs::sWebkitPrefixedAliasesEnabled &&
|
||||
StringBeginsWith(featureString, NS_LITERAL_STRING("-webkit-"))) {
|
||||
satisfiedReqFlags |= nsMediaFeature::eHasWebkitPrefix;
|
||||
featureString.Rebind(featureString, 8);
|
||||
}
|
||||
if (sWebkitDevicePixelRatioEnabled) {
|
||||
if (StylePrefs::sWebkitDevicePixelRatioEnabled) {
|
||||
satisfiedReqFlags |= nsMediaFeature::eWebkitDevicePixelRatioPrefEnabled;
|
||||
}
|
||||
|
||||
|
@ -7028,7 +7021,7 @@ CSSParserImpl::LookupKeywordPrefixAware(nsAString& aKeywordStr,
|
|||
{
|
||||
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(aKeywordStr);
|
||||
|
||||
if (!sWebkitPrefixedAliasesEnabled) {
|
||||
if (!StylePrefs::sWebkitPrefixedAliasesEnabled) {
|
||||
// Not accepting webkit-prefixed keywords -> don't do anything special.
|
||||
return keyword;
|
||||
}
|
||||
|
@ -7053,7 +7046,7 @@ CSSParserImpl::LookupKeywordPrefixAware(nsAString& aKeywordStr,
|
|||
// display-value, via the CSS cascade. To prevent this problem, we treat
|
||||
// "display: -moz-box" & "-moz-inline-box" as if they were simply a
|
||||
// repetition of the webkit equivalent that we already parsed.
|
||||
MOZ_ASSERT(sWebkitPrefixedAliasesEnabled,
|
||||
MOZ_ASSERT(StylePrefs::sWebkitPrefixedAliasesEnabled,
|
||||
"The only way mWebkitBoxUnprefixState can be eHaveUnprefixed "
|
||||
"is if we're supporting webkit-prefixed aliases");
|
||||
return (keyword == eCSSKeyword__moz_box) ?
|
||||
|
@ -7648,7 +7641,7 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue,
|
|||
}
|
||||
}
|
||||
if ((aVariantMask & VARIANT_OPENTYPE_SVG_KEYWORD) != 0) {
|
||||
if (sOpentypeSVGEnabled) {
|
||||
if (StylePrefs::sOpentypeSVGEnabled) {
|
||||
aVariantMask |= VARIANT_KEYWORD;
|
||||
}
|
||||
}
|
||||
|
@ -7726,11 +7719,11 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue,
|
|||
// a generated gradient
|
||||
nsDependentString tmp(tk->mIdent, 0);
|
||||
uint8_t gradientFlags = 0;
|
||||
if (sMozGradientsEnabled &&
|
||||
if (StylePrefs::sMozGradientsEnabled &&
|
||||
StringBeginsWith(tmp, NS_LITERAL_STRING("-moz-"))) {
|
||||
tmp.Rebind(tmp, 5);
|
||||
gradientFlags |= eGradient_MozLegacy;
|
||||
} else if (sWebkitPrefixedAliasesEnabled &&
|
||||
} else if (StylePrefs::sWebkitPrefixedAliasesEnabled &&
|
||||
StringBeginsWith(tmp, NS_LITERAL_STRING("-webkit-"))) {
|
||||
tmp.Rebind(tmp, 8);
|
||||
gradientFlags |= eGradient_WebkitLegacy;
|
||||
|
@ -7848,7 +7841,7 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue,
|
|||
}
|
||||
return CSSParseResult::Ok;
|
||||
}
|
||||
if (sFramesTimingFunctionEnabled &&
|
||||
if (StylePrefs::sFramesTimingFunctionEnabled &&
|
||||
tk->mIdent.LowerCaseEqualsLiteral("frames")) {
|
||||
if (!ParseTransitionFramesTimingFunctionValues(aValue)) {
|
||||
SkipUntil(')');
|
||||
|
@ -12216,7 +12209,7 @@ CSSParserImpl::IsFunctionTokenValidForImageLayerImage(
|
|||
funcName.LowerCaseEqualsLiteral("-moz-repeating-radial-gradient") ||
|
||||
funcName.LowerCaseEqualsLiteral("-moz-image-rect") ||
|
||||
funcName.LowerCaseEqualsLiteral("-moz-element") ||
|
||||
(sWebkitPrefixedAliasesEnabled &&
|
||||
(StylePrefs::sWebkitPrefixedAliasesEnabled &&
|
||||
(funcName.LowerCaseEqualsLiteral("-webkit-gradient") ||
|
||||
funcName.LowerCaseEqualsLiteral("-webkit-linear-gradient") ||
|
||||
funcName.LowerCaseEqualsLiteral("-webkit-radial-gradient") ||
|
||||
|
@ -17873,23 +17866,6 @@ CSSParserImpl::IsValueValidForProperty(const nsCSSPropertyID aPropID,
|
|||
|
||||
static CSSParserImpl* gFreeList = nullptr;
|
||||
|
||||
/* static */ void
|
||||
nsCSSParser::Startup()
|
||||
{
|
||||
Preferences::AddBoolVarCache(&sOpentypeSVGEnabled,
|
||||
"gfx.font_rendering.opentype_svg.enabled");
|
||||
Preferences::AddBoolVarCache(&sWebkitPrefixedAliasesEnabled,
|
||||
"layout.css.prefixes.webkit");
|
||||
Preferences::AddBoolVarCache(&sWebkitDevicePixelRatioEnabled,
|
||||
"layout.css.prefixes.device-pixel-ratio-webkit");
|
||||
Preferences::AddBoolVarCache(&sMozGradientsEnabled,
|
||||
"layout.css.prefixes.gradients");
|
||||
Preferences::AddBoolVarCache(&sControlCharVisibility,
|
||||
"layout.css.control-characters.visible");
|
||||
Preferences::AddBoolVarCache(&sFramesTimingFunctionEnabled,
|
||||
"layout.css.frames-timing.enabled");
|
||||
}
|
||||
|
||||
nsCSSParser::nsCSSParser(mozilla::css::Loader* aLoader,
|
||||
CSSStyleSheet* aSheet)
|
||||
{
|
||||
|
@ -18231,7 +18207,7 @@ nsCSSParser::IsValueValidForProperty(const nsCSSPropertyID aPropID,
|
|||
uint8_t
|
||||
nsCSSParser::ControlCharVisibilityDefault()
|
||||
{
|
||||
return sControlCharVisibility
|
||||
return StylePrefs::sControlCharVisibility
|
||||
? NS_STYLE_CONTROL_CHARACTER_VISIBILITY_VISIBLE
|
||||
: NS_STYLE_CONTROL_CHARACTER_VISIBILITY_HIDDEN;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ public:
|
|||
mozilla::CSSStyleSheet* aSheet = nullptr);
|
||||
~nsCSSParser();
|
||||
|
||||
static void Startup();
|
||||
static void Shutdown();
|
||||
|
||||
private:
|
||||
|
|
Загрузка…
Ссылка в новой задаче