--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -152,18 +152,16 @@ using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::image;
using namespace mozilla::layers;
using namespace mozilla::layout;
using namespace mozilla::gfx;
using mozilla::dom::HTMLMediaElementBinding::HAVE_NOTHING;
using mozilla::dom::HTMLMediaElementBinding::HAVE_METADATA;
-#define WEBKIT_PREFIXES_ENABLED_PREF_NAME "layout.css.prefixes.webkit"
-#define TEXT_ALIGN_UNSAFE_ENABLED_PREF_NAME "layout.css.text-align-unsafe-value.enabled"
#define INTERCHARACTER_RUBY_ENABLED_PREF_NAME "layout.css.ruby.intercharacter.enabled"
#define CONTENT_SELECT_ENABLED_PREF_NAME "dom.select_popup_in_content.enabled"
// The time in number of frames that we estimate for a refresh driver
// to be quiescent
#define DEFAULT_QUIESCENT_FRAMES 2
// The time (milliseconds) we estimate is needed between the end of an
// idle time and the next Tick.
@@ -200,124 +198,16 @@ typedef nsDataHashtable<nsUint64HashKey,
static ContentMap* sContentMap = nullptr;
static ContentMap& GetContentMap() {
if (!sContentMap) {
sContentMap = new ContentMap();
}
return *sContentMap;
}
-// When the pref "layout.css.prefixes.webkit" changes, this function is invoked
-// to let us update kDisplayKTable, to selectively disable or restore the
-// entries for "-webkit-box" and "-webkit-inline-box" in that table.
-static void
-WebkitPrefixEnabledPrefChangeCallback(const char* aPrefName, void* aClosure)
-{
- MOZ_ASSERT(strncmp(aPrefName, WEBKIT_PREFIXES_ENABLED_PREF_NAME,
- ArrayLength(WEBKIT_PREFIXES_ENABLED_PREF_NAME)) == 0,
- "We only registered this callback for a single pref, so it "
- "should only be called for that pref");
-
- static int32_t sIndexOfWebkitBoxInDisplayTable;
- static int32_t sIndexOfWebkitInlineBoxInDisplayTable;
- static int32_t sIndexOfWebkitFlexInDisplayTable;
- static int32_t sIndexOfWebkitInlineFlexInDisplayTable;
-
- static bool sAreKeywordIndicesInitialized; // initialized to false
-
- bool isWebkitPrefixSupportEnabled =
- Preferences::GetBool(WEBKIT_PREFIXES_ENABLED_PREF_NAME, false);
- if (!sAreKeywordIndicesInitialized) {
- // First run: find the position of the keywords in kDisplayKTable.
- sIndexOfWebkitBoxInDisplayTable =
- nsCSSProps::FindIndexOfKeyword(eCSSKeyword__webkit_box,
- nsCSSProps::kDisplayKTable);
- MOZ_ASSERT(sIndexOfWebkitBoxInDisplayTable >= 0,
- "Couldn't find -webkit-box in kDisplayKTable");
- sIndexOfWebkitInlineBoxInDisplayTable =
- nsCSSProps::FindIndexOfKeyword(eCSSKeyword__webkit_inline_box,
- nsCSSProps::kDisplayKTable);
- MOZ_ASSERT(sIndexOfWebkitInlineBoxInDisplayTable >= 0,
- "Couldn't find -webkit-inline-box in kDisplayKTable");
-
- sIndexOfWebkitFlexInDisplayTable =
- nsCSSProps::FindIndexOfKeyword(eCSSKeyword__webkit_flex,
- nsCSSProps::kDisplayKTable);
- MOZ_ASSERT(sIndexOfWebkitFlexInDisplayTable >= 0,
- "Couldn't find -webkit-flex in kDisplayKTable");
- sIndexOfWebkitInlineFlexInDisplayTable =
- nsCSSProps::FindIndexOfKeyword(eCSSKeyword__webkit_inline_flex,
- nsCSSProps::kDisplayKTable);
- MOZ_ASSERT(sIndexOfWebkitInlineFlexInDisplayTable >= 0,
- "Couldn't find -webkit-inline-flex in kDisplayKTable");
- sAreKeywordIndicesInitialized = true;
- }
-
- // OK -- now, stomp on or restore the "-webkit-{box|flex}" entries in
- // kDisplayKTable, depending on whether the webkit prefix pref is enabled
- // vs. disabled.
- if (sIndexOfWebkitBoxInDisplayTable >= 0) {
- nsCSSProps::kDisplayKTable[sIndexOfWebkitBoxInDisplayTable].mKeyword =
- isWebkitPrefixSupportEnabled ?
- eCSSKeyword__webkit_box : eCSSKeyword_UNKNOWN;
- }
- if (sIndexOfWebkitInlineBoxInDisplayTable >= 0) {
- nsCSSProps::kDisplayKTable[sIndexOfWebkitInlineBoxInDisplayTable].mKeyword =
- isWebkitPrefixSupportEnabled ?
- eCSSKeyword__webkit_inline_box : eCSSKeyword_UNKNOWN;
- }
- if (sIndexOfWebkitFlexInDisplayTable >= 0) {
- nsCSSProps::kDisplayKTable[sIndexOfWebkitFlexInDisplayTable].mKeyword =
- isWebkitPrefixSupportEnabled ?
- eCSSKeyword__webkit_flex : eCSSKeyword_UNKNOWN;
- }
- if (sIndexOfWebkitInlineFlexInDisplayTable >= 0) {
- nsCSSProps::kDisplayKTable[sIndexOfWebkitInlineFlexInDisplayTable].mKeyword =
- isWebkitPrefixSupportEnabled ?
- eCSSKeyword__webkit_inline_flex : eCSSKeyword_UNKNOWN;
- }
-}
-
-// When the pref "layout.css.text-align-unsafe-value.enabled" changes, this
-// function is called to let us update kTextAlignKTable & kTextAlignLastKTable,
-// to selectively disable or restore the entries for "unsafe" in those tables.
-static void
-TextAlignUnsafeEnabledPrefChangeCallback(const char* aPrefName, void* aClosure)
-{
- NS_ASSERTION(strcmp(aPrefName, TEXT_ALIGN_UNSAFE_ENABLED_PREF_NAME) == 0,
- "Did you misspell " TEXT_ALIGN_UNSAFE_ENABLED_PREF_NAME " ?");
-
- static bool sIsInitialized;
- static int32_t sIndexOfUnsafeInTextAlignTable;
- static int32_t sIndexOfUnsafeInTextAlignLastTable;
- bool isTextAlignUnsafeEnabled =
- Preferences::GetBool(TEXT_ALIGN_UNSAFE_ENABLED_PREF_NAME, false);
-
- if (!sIsInitialized) {
- // First run: find the position of "unsafe" in kTextAlignKTable.
- sIndexOfUnsafeInTextAlignTable =
- nsCSSProps::FindIndexOfKeyword(eCSSKeyword_unsafe,
- nsCSSProps::kTextAlignKTable);
- // First run: find the position of "unsafe" in kTextAlignLastKTable.
- sIndexOfUnsafeInTextAlignLastTable =
- nsCSSProps::FindIndexOfKeyword(eCSSKeyword_unsafe,
- nsCSSProps::kTextAlignLastKTable);
- sIsInitialized = true;
- }
-
- // OK -- now, stomp on or restore the "unsafe" entry in the keyword tables,
- // depending on whether the pref is enabled vs. disabled.
- MOZ_ASSERT(sIndexOfUnsafeInTextAlignTable >= 0);
- nsCSSProps::kTextAlignKTable[sIndexOfUnsafeInTextAlignTable].mKeyword =
- isTextAlignUnsafeEnabled ? eCSSKeyword_unsafe : eCSSKeyword_UNKNOWN;
- MOZ_ASSERT(sIndexOfUnsafeInTextAlignLastTable >= 0);
- nsCSSProps::kTextAlignLastKTable[sIndexOfUnsafeInTextAlignLastTable].mKeyword =
- isTextAlignUnsafeEnabled ? eCSSKeyword_unsafe : eCSSKeyword_UNKNOWN;
-}
-
template<typename TestType>
static bool
HasMatchingAnimations(EffectSet* aEffects, TestType&& aTest)
{
for (KeyframeEffectReadOnly* effect : *aEffects) {
if (aTest(*effect)) {
return true;
}
@@ -641,32 +531,16 @@ nsLayoutUtils::UnsetValueEnabled()
"layout.css.unset-value.enabled",
false);
}
return sUnsetValueEnabled;
}
bool
-nsLayoutUtils::IsTextAlignUnsafeValueEnabled()
-{
- static bool sTextAlignUnsafeValueEnabled;
- static bool sTextAlignUnsafeValueEnabledPrefCached = false;
-
- if (!sTextAlignUnsafeValueEnabledPrefCached) {
- sTextAlignUnsafeValueEnabledPrefCached = true;
- Preferences::AddBoolVarCache(&sTextAlignUnsafeValueEnabled,
- TEXT_ALIGN_UNSAFE_ENABLED_PREF_NAME,
- false);
- }
-
- return sTextAlignUnsafeValueEnabled;
-}
-
-bool
nsLayoutUtils::IsInterCharacterRubyEnabled()
{
static bool sInterCharacterRubyEnabled;
static bool sInterCharacterRubyEnabledPrefCached = false;
if (!sInterCharacterRubyEnabledPrefCached) {
sInterCharacterRubyEnabledPrefCached = true;
Preferences::AddBoolVarCache(&sInterCharacterRubyEnabled,
@@ -8145,28 +8019,16 @@ nsLayoutUtils::SizeOfTextRunsForFrames(n
for (nsFrameList::Enumerator e(childLists.CurrentList());
!e.AtEnd(); e.Next()) {
total += SizeOfTextRunsForFrames(e.get(), aMallocSizeOf, clear);
}
}
return total;
}
-struct PrefCallbacks
-{
- const char* name;
- PrefChangedFunc func;
-};
-static const PrefCallbacks kPrefCallbacks[] = {
- { WEBKIT_PREFIXES_ENABLED_PREF_NAME,
- WebkitPrefixEnabledPrefChangeCallback },
- { TEXT_ALIGN_UNSAFE_ENABLED_PREF_NAME,
- TextAlignUnsafeEnabledPrefChangeCallback },
-};
-
/* static */
void
nsLayoutUtils::Initialize()
{
Preferences::AddUintVarCache(&sFontSizeInflationMaxRatio,
"font.size.inflation.maxRatio");
Preferences::AddUintVarCache(&sFontSizeInflationEmPerLine,
"font.size.inflation.emPerLine");
@@ -8196,34 +8058,28 @@ nsLayoutUtils::Initialize()
"layout.css.text-combine-upright-digits.enabled");
Preferences::AddUintVarCache(&sIdlePeriodDeadlineLimit,
"layout.idle_period.time_limit",
DEFAULT_IDLE_PERIOD_TIME_LIMIT);
Preferences::AddUintVarCache(&sQuiescentFramesBeforeIdlePeriod,
"layout.idle_period.required_quiescent_frames",
DEFAULT_QUIESCENT_FRAMES);
- for (auto& callback : kPrefCallbacks) {
- Preferences::RegisterCallbackAndCall(callback.func, callback.name);
- }
nsComputedDOMStyle::RegisterPrefChangeCallbacks();
}
/* static */
void
nsLayoutUtils::Shutdown()
{
if (sContentMap) {
delete sContentMap;
sContentMap = nullptr;
}
- for (auto& callback : kPrefCallbacks) {
- Preferences::UnregisterCallback(callback.func, callback.name);
- }
nsComputedDOMStyle::UnregisterPrefChangeCallbacks();
// so the cached initial quotes array doesn't appear to be a leak
nsStyleList::Shutdown();
}
/* static */
void