Bug 1122918 - Put the logical values for 'float' and 'clear' behind a pref, and enable them only on nightly builds and for B2G. r=heycam

This commit is contained in:
Jonathan Kew 2015-11-10 09:07:01 +00:00
parent afa29d34e0
commit 6393c0d04d
6 changed files with 94 additions and 10 deletions

View File

@ -135,6 +135,7 @@ using namespace mozilla::gfx;
#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"
#define FLOAT_LOGICAL_VALUES_ENABLED_PREF_NAME "layout.css.float-logical-values.enabled"
#ifdef DEBUG
// TODO: remove, see bug 598468.
@ -384,6 +385,61 @@ TextAlignTrueEnabledPrefChangeCallback(const char* aPrefName, void* aClosure)
isTextAlignTrueEnabled ? eCSSKeyword_true : eCSSKeyword_UNKNOWN;
}
// When the pref "layout.css.float-logical-values.enabled" changes, this
// function is called to let us update kFloatKTable & kClearKTable,
// to selectively disable or restore the entries for logical values
// (inline-start and inline-end) in those tables.
static void
FloatLogicalValuesEnabledPrefChangeCallback(const char* aPrefName,
void* aClosure)
{
NS_ASSERTION(strcmp(aPrefName, FLOAT_LOGICAL_VALUES_ENABLED_PREF_NAME) == 0,
"Did you misspell " FLOAT_LOGICAL_VALUES_ENABLED_PREF_NAME " ?");
static bool sIsInitialized;
static int32_t sIndexOfInlineStartInFloatTable;
static int32_t sIndexOfInlineEndInFloatTable;
static int32_t sIndexOfInlineStartInClearTable;
static int32_t sIndexOfInlineEndInClearTable;
bool isFloatLogicalValuesEnabled =
Preferences::GetBool(FLOAT_LOGICAL_VALUES_ENABLED_PREF_NAME, false);
if (!sIsInitialized) {
// First run: find the position of "inline-start" in kFloatKTable.
sIndexOfInlineStartInFloatTable =
nsCSSProps::FindIndexOfKeyword(eCSSKeyword_inline_start,
nsCSSProps::kFloatKTable);
// First run: find the position of "inline-end" in kFloatKTable.
sIndexOfInlineEndInFloatTable =
nsCSSProps::FindIndexOfKeyword(eCSSKeyword_inline_end,
nsCSSProps::kFloatKTable);
// First run: find the position of "inline-start" in kClearKTable.
sIndexOfInlineStartInClearTable =
nsCSSProps::FindIndexOfKeyword(eCSSKeyword_inline_start,
nsCSSProps::kClearKTable);
// First run: find the position of "inline-end" in kClearKTable.
sIndexOfInlineEndInClearTable =
nsCSSProps::FindIndexOfKeyword(eCSSKeyword_inline_end,
nsCSSProps::kClearKTable);
sIsInitialized = true;
}
// OK -- now, stomp on or restore the logical entries in the keyword tables,
// depending on whether the pref is enabled vs. disabled.
MOZ_ASSERT(sIndexOfInlineStartInFloatTable >= 0);
nsCSSProps::kFloatKTable[sIndexOfInlineStartInFloatTable] =
isFloatLogicalValuesEnabled ? eCSSKeyword_inline_start : eCSSKeyword_UNKNOWN;
MOZ_ASSERT(sIndexOfInlineEndInFloatTable >= 0);
nsCSSProps::kFloatKTable[sIndexOfInlineEndInFloatTable] =
isFloatLogicalValuesEnabled ? eCSSKeyword_inline_end : eCSSKeyword_UNKNOWN;
MOZ_ASSERT(sIndexOfInlineStartInClearTable >= 0);
nsCSSProps::kClearKTable[sIndexOfInlineStartInClearTable] =
isFloatLogicalValuesEnabled ? eCSSKeyword_inline_start : eCSSKeyword_UNKNOWN;
MOZ_ASSERT(sIndexOfInlineEndInClearTable >= 0);
nsCSSProps::kClearKTable[sIndexOfInlineEndInClearTable] =
isFloatLogicalValuesEnabled ? eCSSKeyword_inline_end : eCSSKeyword_UNKNOWN;
}
bool
nsLayoutUtils::HasAnimationsForCompositor(const nsIFrame* aFrame,
nsCSSProperty aProperty)
@ -7369,6 +7425,10 @@ nsLayoutUtils::Initialize()
nullptr);
TextAlignTrueEnabledPrefChangeCallback(TEXT_ALIGN_TRUE_ENABLED_PREF_NAME,
nullptr);
Preferences::RegisterCallback(FloatLogicalValuesEnabledPrefChangeCallback,
FLOAT_LOGICAL_VALUES_ENABLED_PREF_NAME);
FloatLogicalValuesEnabledPrefChangeCallback(FLOAT_LOGICAL_VALUES_ENABLED_PREF_NAME,
nullptr);
nsComputedDOMStyle::RegisterPrefChangeCallbacks();
}

View File

@ -90,10 +90,10 @@ fuzzy-if(OSX==1010,26,7) == orthogonal-floats-1b.html orthogonal-floats-1-ref.ht
fuzzy-if(OSX==1010,103,802) fuzzy-if(winWidget,116,700) HTTP(..) == orthogonal-floats-1c.html orthogonal-floats-1-ref.html
fuzzy-if(OSX==1010,103,802) fuzzy-if(winWidget,116,700) HTTP(..) == orthogonal-floats-1d.html orthogonal-floats-1-ref.html
== logical-float-side-1.html logical-float-side-1-ref.html
== logical-float-side-2.html logical-float-side-2-ref.html
== logical-float-side-3.html logical-float-side-3-ref.html
== logical-float-side-4.html logical-float-side-4-ref.html
pref(layout.css.float-logical-values.enabled,true) == logical-float-side-1.html logical-float-side-1-ref.html
pref(layout.css.float-logical-values.enabled,true) == logical-float-side-2.html logical-float-side-2-ref.html
pref(layout.css.float-logical-values.enabled,true) == logical-float-side-3.html logical-float-side-3-ref.html
pref(layout.css.float-logical-values.enabled,true) == logical-float-side-4.html logical-float-side-4-ref.html
== float-in-rtl-slr-1a.html float-in-rtl-slr-1-ref.html
== float-in-rtl-slr-1b.html float-in-rtl-slr-1-ref.html

View File

@ -1004,7 +1004,7 @@ const KTableValue nsCSSProps::kCaptionSideKTable[] = {
eCSSKeyword_UNKNOWN, -1
};
const KTableValue nsCSSProps::kClearKTable[] = {
KTableValue nsCSSProps::kClearKTable[] = {
eCSSKeyword_none, NS_STYLE_CLEAR_NONE,
eCSSKeyword_left, NS_STYLE_CLEAR_LEFT,
eCSSKeyword_right, NS_STYLE_CLEAR_RIGHT,
@ -1354,7 +1354,7 @@ const KTableValue nsCSSProps::kHyphensKTable[] = {
eCSSKeyword_UNKNOWN,-1
};
const KTableValue nsCSSProps::kFloatKTable[] = {
KTableValue nsCSSProps::kFloatKTable[] = {
eCSSKeyword_none, NS_STYLE_FLOAT_NONE,
eCSSKeyword_left, NS_STYLE_FLOAT_LEFT,
eCSSKeyword_right, NS_STYLE_FLOAT_RIGHT,

View File

@ -677,7 +677,9 @@ public:
static const KTableValue kBoxShadowTypeKTable[];
static const KTableValue kBoxSizingKTable[];
static const KTableValue kCaptionSideKTable[];
static const KTableValue kClearKTable[];
// Not const because we modify its entries when the pref
// "layout.css.float-logical-values.enabled" changes:
static KTableValue kClearKTable[];
static const KTableValue kColorKTable[];
static const KTableValue kContentKTable[];
static const KTableValue kControlCharacterVisibilityKTable[];
@ -703,7 +705,9 @@ public:
// ------------------------------------------------------------------
static const KTableValue kFlexDirectionKTable[];
static const KTableValue kFlexWrapKTable[];
static const KTableValue kFloatKTable[];
// Not const because we modify its entries when the pref
// "layout.css.float-logical-values.enabled" changes:
static KTableValue kFloatKTable[];
static const KTableValue kFloatEdgeKTable[];
static const KTableValue kFontKTable[];
static const KTableValue kFontKerningKTable[];

View File

@ -2498,7 +2498,7 @@ var gCSSProperties = {
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: [ "none" ],
other_values: [ "left", "right", "both", "inline-start", "inline-end" ],
other_values: [ "left", "right", "both" ],
invalid_values: []
},
"clip": {
@ -2602,7 +2602,7 @@ var gCSSProperties = {
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: [ "none" ],
other_values: [ "left", "right", "inline-start", "inline-end" ],
other_values: [ "left", "right" ],
invalid_values: []
},
"font": {
@ -6806,6 +6806,18 @@ if (IsCSSPropertyPrefEnabled("layout.css.unset-value.enabled")) {
}
}
if (IsCSSPropertyPrefEnabled("layout.css.float-logical-values.enabled")) {
gCSSProperties["float"].other_values.push("inline-start");
gCSSProperties["float"].other_values.push("inline-end");
gCSSProperties["clear"].other_values.push("inline-start");
gCSSProperties["clear"].other_values.push("inline-end");
} else {
gCSSProperties["float"].invalid_values.push("inline-start");
gCSSProperties["float"].invalid_values.push("inline-end");
gCSSProperties["clear"].invalid_values.push("inline-start");
gCSSProperties["clear"].invalid_values.push("inline-end");
}
// Copy aliased properties' fields from their alias targets.
for (var prop in gCSSProperties) {
var entry = gCSSProperties[prop];

View File

@ -2296,6 +2296,14 @@ pref("layout.css.unicode-range.enabled", true);
// Is support for CSS "text-align: true X" enabled?
pref("layout.css.text-align-true-value.enabled", false);
// Is support for CSS "float: inline-{start,end}" and
// "clear: inline-{start,end}" enabled?
#if defined(MOZ_B2G) || defined(NIGHTLY_BUILD)
pref("layout.css.float-logical-values.enabled", true);
#else
pref("layout.css.float-logical-values.enabled", false);
#endif
// Is support for the CSS4 image-orientation property enabled?
pref("layout.css.image-orientation.enabled", true);