diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index f09b0b987a13..b99c8d28412b 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -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) diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index a53a38c7e14d..c0253df47615 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -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, diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index 012171eeec26..e52e897933ad 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -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 }, diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index af096af57367..7f22b1a90dd0 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -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[]; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 0e55896f1e71..fc023db662f3 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -979,6 +979,16 @@ nsComputedDOMStyle::DoGetColor() return val.forget(); } +already_AddRefed +nsComputedDOMStyle::DoGetColorAdjust() +{ + RefPtr val = new nsROCSSPrimitiveValue; + val->SetIdent( + nsCSSProps::ValueToKeywordEnum(StyleVisibility()->mColorAdjust, + nsCSSProps::kColorAdjustKTable)); + return val.forget(); +} + already_AddRefed nsComputedDOMStyle::DoGetOpacity() { diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index dbd1a89a1043..f12bfc528079 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -428,6 +428,7 @@ private: already_AddRefed DoGetWebkitTextFillColor(); /* Visibility properties */ + already_AddRefed DoGetColorAdjust(); already_AddRefed DoGetOpacity(); already_AddRefed DoGetPointerEvents(); already_AddRefed DoGetVisibility(); diff --git a/layout/style/nsComputedDOMStylePropertyList.h b/layout/style/nsComputedDOMStylePropertyList.h index bb9773bcf449..e2b8b73ffa5b 100644 --- a/layout/style/nsComputedDOMStylePropertyList.h +++ b/layout/style/nsComputedDOMStylePropertyList.h @@ -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) diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index db114ef5dda2..4dbdec3a3a2f 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -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) } diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index fab8bc9d3607..c684007b9bd9 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -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 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 93e489b69782..72ca77c6395d 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -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; } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index bc545aa34102..49349db3e127 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -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); diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index e1ad7078b0ba..1909997b086c 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -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, diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index edb8cbcad44a..b92d0d42d6a7 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -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);