Bug 1209273 - Part 1 - Support for color-adjust CSS property. r=dbaron

This commit is contained in:
Tobias Schneider 2016-03-10 10:51:00 +01:00
Родитель 885e886b1e
Коммит 54290c6564
13 изменённых файлов: 60 добавлений и 1 удалений

Просмотреть файл

@ -248,6 +248,7 @@ CSS_KEY(ease, ease)
CSS_KEY(ease-in, ease_in)
CSS_KEY(ease-in-out, ease_in_out)
CSS_KEY(ease-out, ease_out)
CSS_KEY(economy, economy)
CSS_KEY(element, element)
CSS_KEY(elements, elements)
CSS_KEY(ellipse, ellipse)
@ -258,6 +259,7 @@ CSS_KEY(enabled, enabled)
CSS_KEY(end, end)
CSS_KEY(ethiopic-numeric, ethiopic_numeric)
CSS_KEY(ex, ex)
CSS_KEY(exact, exact)
CSS_KEY(exclude, exclude)
CSS_KEY(exclusion, exclusion)
CSS_KEY(expanded, expanded)

Просмотреть файл

@ -1388,6 +1388,16 @@ CSS_PROP_COLOR(
nullptr,
offsetof(nsStyleColor, mColor),
eStyleAnimType_Color)
CSS_PROP_VISIBILITY(
color-adjust,
color_adjust,
ColorAdjust,
CSS_PROPERTY_PARSE_VALUE,
"layout.css.color-adjust.enabled",
VARIANT_HK,
kColorAdjustKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
CSS_PROP_SHORTHAND(
-moz-columns,
_moz_columns,

Просмотреть файл

@ -2366,6 +2366,12 @@ const KTableEntry nsCSSProps::kVectorEffectKTable[] = {
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kColorAdjustKTable[] = {
{ eCSSKeyword_economy, NS_STYLE_COLOR_ADJUST_ECONOMY },
{ eCSSKeyword_exact, NS_STYLE_COLOR_ADJUST_EXACT },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kColorInterpolationKTable[] = {
{ eCSSKeyword_auto, NS_STYLE_COLOR_INTERPOLATION_AUTO },
{ eCSSKeyword_srgb, NS_STYLE_COLOR_INTERPOLATION_SRGB },

Просмотреть файл

@ -707,6 +707,7 @@ public:
static const KTableEntry kVectorEffectKTable[];
static const KTableEntry kTextAnchorKTable[];
static const KTableEntry kTextRenderingKTable[];
static const KTableEntry kColorAdjustKTable[];
static const KTableEntry kColorInterpolationKTable[];
static const KTableEntry kColumnFillKTable[];
static const KTableEntry kBoxPropSourceKTable[];

Просмотреть файл

@ -979,6 +979,16 @@ nsComputedDOMStyle::DoGetColor()
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetColorAdjust()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleVisibility()->mColorAdjust,
nsCSSProps::kColorAdjustKTable));
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetOpacity()
{

Просмотреть файл

@ -428,6 +428,7 @@ private:
already_AddRefed<CSSValue> DoGetWebkitTextFillColor();
/* Visibility properties */
already_AddRefed<CSSValue> DoGetColorAdjust();
already_AddRefed<CSSValue> DoGetOpacity();
already_AddRefed<CSSValue> DoGetPointerEvents();
already_AddRefed<CSSValue> DoGetVisibility();

Просмотреть файл

@ -102,6 +102,7 @@ COMPUTED_STYLE_PROP(caption_side, CaptionSide)
COMPUTED_STYLE_PROP(clear, Clear)
COMPUTED_STYLE_PROP(clip, Clip)
COMPUTED_STYLE_PROP(color, Color)
COMPUTED_STYLE_PROP(color_adjust, ColorAdjust)
COMPUTED_STYLE_PROP(contain, Contain)
COMPUTED_STYLE_PROP(content, Content)
COMPUTED_STYLE_PROP(counter_increment, CounterIncrement)

Просмотреть файл

@ -6461,6 +6461,12 @@ nsRuleNode::ComputeVisibilityData(void* aStartStruct,
MOZ_ASSERT(orientation->GetUnit() == eCSSUnit_Null, "Should be null unit");
}
SetDiscrete(*aRuleData->ValueForColorAdjust(), visibility->mColorAdjust,
conditions,
SETDSC_ENUMERATED | SETDSC_UNSET_INHERIT,
parentVisibility->mColorAdjust,
NS_STYLE_COLOR_ADJUST_ECONOMY, 0, 0, 0, 0);
COMPUTE_END_INHERITED(Visibility, visibility)
}

Просмотреть файл

@ -1121,6 +1121,10 @@ enum class FillMode : uint32_t;
#define NS_STYLE_TEXT_RENDERING_OPTIMIZELEGIBILITY 2
#define NS_STYLE_TEXT_RENDERING_GEOMETRICPRECISION 3
// adjust-color
#define NS_STYLE_COLOR_ADJUST_ECONOMY 0
#define NS_STYLE_COLOR_ADJUST_EXACT 1
// color-interpolation and color-interpolation-filters
#define NS_STYLE_COLOR_INTERPOLATION_AUTO 0
#define NS_STYLE_COLOR_INTERPOLATION_SRGB 1

Просмотреть файл

@ -3172,6 +3172,7 @@ nsStyleVisibility::nsStyleVisibility(nsPresContext* aPresContext)
mPointerEvents = NS_STYLE_POINTER_EVENTS_AUTO;
mWritingMode = NS_STYLE_WRITING_MODE_HORIZONTAL_TB;
mTextOrientation = NS_STYLE_TEXT_ORIENTATION_MIXED;
mColorAdjust = NS_STYLE_COLOR_ADJUST_ECONOMY;
}
nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
@ -3183,6 +3184,7 @@ nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
mPointerEvents = aSource.mPointerEvents;
mWritingMode = aSource.mWritingMode;
mTextOrientation = aSource.mTextOrientation;
mColorAdjust = aSource.mColorAdjust;
}
nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther) const
@ -3217,6 +3219,10 @@ nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther)
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
NS_UpdateHint(hint, nsChangeHint_NeedDirtyReflow); // XXX remove me: bug 876085
}
if (mColorAdjust != aOther.mColorAdjust) {
// color-adjust only affects media where dynamic changes can't happen.
NS_UpdateHint(hint, nsChangeHint_NeutralChange);
}
}
return hint;
}

Просмотреть файл

@ -2109,7 +2109,8 @@ struct nsStyleVisibility
nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
return NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_NeutralChange;
}
static nsChangeHint DifferenceAlwaysHandledForDescendants() {
// CalcDifference never returns the reflow hints that are sometimes
@ -2125,6 +2126,7 @@ struct nsStyleVisibility
uint8_t mPointerEvents; // [inherited] see nsStyleConsts.h
uint8_t mWritingMode; // [inherited] see nsStyleConsts.h
uint8_t mTextOrientation; // [inherited] see nsStyleConsts.h
uint8_t mColorAdjust; // [inherited] see nsStyleConsts.h
bool IsVisible() const {
return (mVisible == NS_STYLE_VISIBILITY_VISIBLE);

Просмотреть файл

@ -1368,6 +1368,14 @@ var gCSSProperties = {
alias_for: "box-sizing",
subproperties: [ "box-sizing" ],
},
"color-adjust": {
domProp: "colorAdjust",
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "economy" ],
other_values: [ "exact" ],
invalid_values: []
},
"-moz-columns": {
domProp: "MozColumns",
inherited: false,

Просмотреть файл

@ -5261,5 +5261,7 @@ pref("dom.input.fallbackUploadDir", "");
// Turn rewriting of youtube embeds on/off
pref("plugins.rewrite_youtube_embeds", true);
// Is support for 'color-adjust' CSS property enabled?
pref("layout.css.color-adjust.enabled", true);
// Disable browser frames by default
pref("dom.mozBrowserFramesEnabled", false);