Bug 907396 - Put display:contents support behind a pref - disabled by default. r=dholbert

This commit is contained in:
Mats Palmgren 2014-11-20 18:24:09 +00:00
parent a3d4913e72
commit bcd179e7d1
3 changed files with 40 additions and 2 deletions

View File

@ -114,6 +114,7 @@ using namespace mozilla::gfx;
#define GRID_ENABLED_PREF_NAME "layout.css.grid.enabled"
#define RUBY_ENABLED_PREF_NAME "layout.css.ruby.enabled"
#define STICKY_ENABLED_PREF_NAME "layout.css.sticky.enabled"
#define DISPLAY_CONTENTS_ENABLED_PREF_NAME "layout.css.display-contents.enabled"
#define TEXT_ALIGN_TRUE_ENABLED_PREF_NAME "layout.css.text-align-true-value.enabled"
#ifdef DEBUG
@ -295,6 +296,36 @@ StickyEnabledPrefChangeCallback(const char* aPrefName, void* aClosure)
isStickyEnabled ? eCSSKeyword_sticky : eCSSKeyword_UNKNOWN;
}
// When the pref "layout.css.display-contents.enabled" changes, this function is
// invoked to let us update kDisplayKTable, to selectively disable or restore
// the entries for "contents" in that table.
static void
DisplayContentsEnabledPrefChangeCallback(const char* aPrefName, void* aClosure)
{
NS_ASSERTION(strcmp(aPrefName, DISPLAY_CONTENTS_ENABLED_PREF_NAME) == 0,
"Did you misspell " DISPLAY_CONTENTS_ENABLED_PREF_NAME " ?");
static bool sIsDisplayContentsKeywordIndexInitialized;
static int32_t sIndexOfContentsInDisplayTable;
bool isDisplayContentsEnabled =
Preferences::GetBool(DISPLAY_CONTENTS_ENABLED_PREF_NAME, false);
if (!sIsDisplayContentsKeywordIndexInitialized) {
// First run: find the position of "contents" in kDisplayKTable.
sIndexOfContentsInDisplayTable =
nsCSSProps::FindIndexOfKeyword(eCSSKeyword_contents,
nsCSSProps::kDisplayKTable);
sIsDisplayContentsKeywordIndexInitialized = true;
}
// OK -- now, stomp on or restore the "contents" entry in kDisplayKTable,
// depending on whether the pref is enabled vs. disabled.
if (sIndexOfContentsInDisplayTable >= 0) {
nsCSSProps::kDisplayKTable[sIndexOfContentsInDisplayTable] =
isDisplayContentsEnabled ? eCSSKeyword_contents : eCSSKeyword_UNKNOWN;
}
}
// When the pref "layout.css.text-align-true-value.enabled" changes, this
// function is called to let us update kTextAlignKTable & kTextAlignLastKTable,
// to selectively disable or restore the entries for "true" in those tables.
@ -6670,6 +6701,10 @@ nsLayoutUtils::Initialize()
StickyEnabledPrefChangeCallback(STICKY_ENABLED_PREF_NAME, nullptr);
Preferences::RegisterCallback(TextAlignTrueEnabledPrefChangeCallback,
TEXT_ALIGN_TRUE_ENABLED_PREF_NAME);
Preferences::RegisterCallback(DisplayContentsEnabledPrefChangeCallback,
DISPLAY_CONTENTS_ENABLED_PREF_NAME);
DisplayContentsEnabledPrefChangeCallback(DISPLAY_CONTENTS_ENABLED_PREF_NAME,
nullptr);
TextAlignTrueEnabledPrefChangeCallback(TEXT_ALIGN_TRUE_ENABLED_PREF_NAME,
nullptr);

View File

@ -564,8 +564,8 @@ public:
static const KTableValue kControlCharacterVisibilityKTable[];
static const KTableValue kCursorKTable[];
static const KTableValue kDirectionKTable[];
// Not const because we modify its entries when the pref
// "layout.css.grid.enabled" changes:
// Not const because we modify its entries when various
// "layout.css.*.enabled" prefs changes:
static KTableValue kDisplayKTable[];
static const KTableValue kElevationKTable[];
static const KTableValue kEmptyCellsKTable[];

View File

@ -2156,6 +2156,9 @@ pref("layout.css.grid.enabled", false);
// otherwise needed) are removed.
pref("layout.css.ruby.enabled", false);
// Is support for CSS display:contents enabled?
pref("layout.css.display-contents.enabled", false);
// Is support for CSS box-decoration-break enabled?
pref("layout.css.box-decoration-break.enabled", true);