Issue #1838 - Part 1: Remove CSS grid preference

Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1398492
This commit is contained in:
FranklinDM 2022-04-02 00:49:25 +08:00 committed by roytam1
commit 4f059d2c8b
15 changed files with 585 additions and 664 deletions

View file

@ -145,7 +145,6 @@ using namespace mozilla::layers;
using namespace mozilla::layout;
using namespace mozilla::gfx;
#define GRID_ENABLED_PREF_NAME "layout.css.grid.enabled"
#define GRID_TEMPLATE_SUBGRID_ENABLED_PREF_NAME "layout.css.grid-template-subgrid-value.enabled"
#define WEBKIT_PREFIXES_ENABLED_PREF_NAME "layout.css.prefixes.webkit"
#define DISPLAY_FLOW_ROOT_ENABLED_PREF_NAME "layout.css.display-flow-root.enabled"
@ -198,51 +197,6 @@ static ContentMap& GetContentMap() {
return *sContentMap;
}
// When the pref "layout.css.grid.enabled" changes, this function is invoked
// to let us update kDisplayKTable, to selectively disable or restore the
// entries for "grid" and "inline-grid" in that table.
static void
GridEnabledPrefChangeCallback(const char* aPrefName, void* aClosure)
{
MOZ_ASSERT(strncmp(aPrefName, GRID_ENABLED_PREF_NAME,
ArrayLength(GRID_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 sIndexOfGridInDisplayTable;
static int32_t sIndexOfInlineGridInDisplayTable;
static bool sAreGridKeywordIndicesInitialized; // initialized to false
bool isGridEnabled =
Preferences::GetBool(GRID_ENABLED_PREF_NAME, false);
if (!sAreGridKeywordIndicesInitialized) {
// First run: find the position of "grid" and "inline-grid" in
// kDisplayKTable.
sIndexOfGridInDisplayTable =
nsCSSProps::FindIndexOfKeyword(eCSSKeyword_grid,
nsCSSProps::kDisplayKTable);
MOZ_ASSERT(sIndexOfGridInDisplayTable >= 0,
"Couldn't find grid in kDisplayKTable");
sIndexOfInlineGridInDisplayTable =
nsCSSProps::FindIndexOfKeyword(eCSSKeyword_inline_grid,
nsCSSProps::kDisplayKTable);
MOZ_ASSERT(sIndexOfInlineGridInDisplayTable >= 0,
"Couldn't find inline-grid in kDisplayKTable");
sAreGridKeywordIndicesInitialized = true;
}
// OK -- now, stomp on or restore the "grid" entries in kDisplayKTable,
// depending on whether the grid pref is enabled vs. disabled.
if (sIndexOfGridInDisplayTable >= 0) {
nsCSSProps::kDisplayKTable[sIndexOfGridInDisplayTable].mKeyword =
isGridEnabled ? eCSSKeyword_grid : eCSSKeyword_UNKNOWN;
}
if (sIndexOfInlineGridInDisplayTable >= 0) {
nsCSSProps::kDisplayKTable[sIndexOfInlineGridInDisplayTable].mKeyword =
isGridEnabled ? eCSSKeyword_inline_grid : eCSSKeyword_UNKNOWN;
}
}
// 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.
@ -7575,8 +7529,6 @@ struct PrefCallbacks
PrefChangedFunc func;
};
static const PrefCallbacks kPrefCallbacks[] = {
{ GRID_ENABLED_PREF_NAME,
GridEnabledPrefChangeCallback },
{ WEBKIT_PREFIXES_ENABLED_PREF_NAME,
WebkitPrefixEnabledPrefChangeCallback },
{ TEXT_ALIGN_UNSAFE_ENABLED_PREF_NAME,