зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1387594
- Add a chrome-only CSS property called -moz-font-smoothing-background-color. r=dbaron
This property accepts a color. It's inherited and defaults to transparent. Its value is respected on macOS when rendering text into transparent pixels. This property should be used for text that is placed on top of "vibrant" -moz-appearances, in order to achieve high quality text rendering for such text. In most cases, the property should be set to a named system color; an upcoming patch in this patch series will add one such color for each vibrant -moz-appearance value. However, in some cases it can also be useful to use a custom color: If text is rendered into an intermediate surface, for example because a mask is applied to it, and the background color behind that intermediate surface is known, then this property can be set to that background color in order to achieve subpixel AA for the text inside the mask effect. In that case, the font smoothing background color is respected because text is rendered into transparent pixels *inside the intermediate surface*. At the moment, the only example of that use case is the text of the active tab in the state where the text is overflowing. MozReview-Commit-ID: D98qQnxoFaq
This commit is contained in:
Родитель
4d6b93fc29
Коммит
2e951f24c1
|
@ -3013,6 +3013,7 @@ exports.CSS_PROPERTIES = {
|
|||
"font-language-override",
|
||||
"font-size",
|
||||
"font-size-adjust",
|
||||
"-moz-font-smoothing-background-color",
|
||||
"font-stretch",
|
||||
"font-style",
|
||||
"font-synthesis",
|
||||
|
|
|
@ -1951,6 +1951,20 @@ CSS_PROP_FONT(
|
|||
nullptr,
|
||||
offsetof(nsStyleFont, mFont.sizeAdjust),
|
||||
eStyleAnimType_float)
|
||||
#ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL
|
||||
CSS_PROP_USERINTERFACE(
|
||||
-moz-font-smoothing-background-color,
|
||||
_moz_font_smoothing_background_color,
|
||||
CSS_PROP_DOMPROP_PREFIXED(FontSmoothingBackgroundColor),
|
||||
CSS_PROPERTY_INTERNAL |
|
||||
CSS_PROPERTY_PARSE_VALUE |
|
||||
CSS_PROPERTY_ENABLED_IN_UA_SHEETS_AND_CHROME,
|
||||
"",
|
||||
VARIANT_HC,
|
||||
nullptr,
|
||||
offsetof(nsStyleUserInterface, mFontSmoothingBackgroundColor),
|
||||
eStyleAnimType_Color)
|
||||
#endif // CSS_PROP_LIST_EXCLUDE_INTERNAL
|
||||
CSS_PROP_FONT(
|
||||
font-stretch,
|
||||
font_stretch,
|
||||
|
|
|
@ -1766,6 +1766,14 @@ nsComputedDOMStyle::DoGetOsxFontSmoothing()
|
|||
return val.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<CSSValue>
|
||||
nsComputedDOMStyle::DoGetFontSmoothingBackgroundColor()
|
||||
{
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
SetToRGBAColor(val, StyleUserInterface()->mFontSmoothingBackgroundColor);
|
||||
return val.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<CSSValue>
|
||||
nsComputedDOMStyle::DoGetFontStretch()
|
||||
{
|
||||
|
|
|
@ -296,6 +296,7 @@ private:
|
|||
already_AddRefed<CSSValue> DoGetFontSize();
|
||||
already_AddRefed<CSSValue> DoGetFontSizeAdjust();
|
||||
already_AddRefed<CSSValue> DoGetOsxFontSmoothing();
|
||||
already_AddRefed<CSSValue> DoGetFontSmoothingBackgroundColor();
|
||||
already_AddRefed<CSSValue> DoGetFontStretch();
|
||||
already_AddRefed<CSSValue> DoGetFontStyle();
|
||||
already_AddRefed<CSSValue> DoGetFontSynthesis();
|
||||
|
|
|
@ -288,6 +288,7 @@ COMPUTED_STYLE_PROP(_moz_box_orient, BoxOrient)
|
|||
COMPUTED_STYLE_PROP(_moz_box_pack, BoxPack)
|
||||
COMPUTED_STYLE_PROP(_moz_context_properties, ContextProperties)
|
||||
COMPUTED_STYLE_PROP(_moz_float_edge, FloatEdge)
|
||||
COMPUTED_STYLE_PROP(_moz_font_smoothing_background_color, FontSmoothingBackgroundColor)
|
||||
COMPUTED_STYLE_PROP(_moz_force_broken_image_icon, ForceBrokenImageIcon)
|
||||
COMPUTED_STYLE_PROP(_moz_image_region, ImageRegion)
|
||||
COMPUTED_STYLE_PROP(_moz_orient, Orient)
|
||||
|
|
|
@ -5326,6 +5326,18 @@ nsRuleNode::ComputeUserInterfaceData(void* aStartStruct,
|
|||
mPresContext,
|
||||
ui->mCaretColor, conditions);
|
||||
|
||||
// -moz-font-smoothing-background-color:
|
||||
const nsCSSValue* fsbColorValue =
|
||||
aRuleData->ValueForFontSmoothingBackgroundColor();
|
||||
if (eCSSUnit_Initial == fsbColorValue->GetUnit() ||
|
||||
eCSSUnit_Unset == fsbColorValue->GetUnit()) {
|
||||
ui->mFontSmoothingBackgroundColor = NS_RGBA(0, 0, 0, 0);
|
||||
} else {
|
||||
SetColor(*fsbColorValue, parentUI->mFontSmoothingBackgroundColor,
|
||||
mPresContext, aContext, ui->mFontSmoothingBackgroundColor,
|
||||
conditions);
|
||||
}
|
||||
|
||||
COMPUTE_END_INHERITED(UserInterface, ui)
|
||||
}
|
||||
|
||||
|
|
|
@ -4325,6 +4325,7 @@ nsStyleUserInterface::nsStyleUserInterface(const nsPresContext* aContext)
|
|||
, mPointerEvents(NS_STYLE_POINTER_EVENTS_AUTO)
|
||||
, mCursor(NS_STYLE_CURSOR_AUTO)
|
||||
, mCaretColor(StyleComplexColor::Auto())
|
||||
, mFontSmoothingBackgroundColor(NS_RGBA(0, 0, 0, 0))
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
||||
}
|
||||
|
@ -4337,6 +4338,7 @@ nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource)
|
|||
, mCursor(aSource.mCursor)
|
||||
, mCursorImages(aSource.mCursorImages)
|
||||
, mCaretColor(aSource.mCaretColor)
|
||||
, mFontSmoothingBackgroundColor(aSource.mFontSmoothingBackgroundColor)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
||||
}
|
||||
|
@ -4398,7 +4400,8 @@ nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aNewData) const
|
|||
hint |= nsChangeHint_NeutralChange;
|
||||
}
|
||||
|
||||
if (mCaretColor != aNewData.mCaretColor) {
|
||||
if (mCaretColor != aNewData.mCaretColor ||
|
||||
mFontSmoothingBackgroundColor != aNewData.mFontSmoothingBackgroundColor) {
|
||||
hint |= nsChangeHint_RepaintFrame;
|
||||
}
|
||||
|
||||
|
|
|
@ -3319,6 +3319,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUserInterface
|
|||
uint8_t mCursor; // [inherited] See nsStyleConsts.h
|
||||
nsTArray<nsCursorImage> mCursorImages; // [inherited] images and coords
|
||||
mozilla::StyleComplexColor mCaretColor; // [inherited]
|
||||
nscolor mFontSmoothingBackgroundColor; // [inherited]
|
||||
|
||||
inline uint8_t GetEffectivePointerEvents(nsIFrame* aFrame) const;
|
||||
};
|
||||
|
|
|
@ -115,6 +115,7 @@ const char *gInaccessibleProperties[] = {
|
|||
"-moz-math-display", // parsed by UA sheets only
|
||||
"-moz-top-layer", // parsed by UA sheets only
|
||||
"-moz-min-font-size-ratio", // parsed by UA sheets only
|
||||
"-moz-font-smoothing-background-color", // chrome-only internal properties
|
||||
"-moz-window-opacity", // chrome-only internal properties
|
||||
"-moz-window-transform", // chrome-only internal properties
|
||||
"-moz-window-transform-origin", // chrome-only internal properties
|
||||
|
|
|
@ -8291,4 +8291,13 @@ if (false) {
|
|||
other_values: [ "fill", "stroke", "fill, stroke", "fill, stroke, fill", "fill, foo", "foo" ],
|
||||
invalid_values: [ "default", "fill, auto", "all, stroke", "none, fill", "fill, none", "fill, default", "2px" ]
|
||||
};
|
||||
|
||||
gCSSProperties["-moz-font-smoothing-background-color"] = {
|
||||
// domProp: "MozFontSmoothingBackgroundColor",
|
||||
inherited: true,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "transparent" ],
|
||||
other_values: [ "green", "#fc3" ],
|
||||
invalid_values: [ "000000", "ff00ff" ]
|
||||
};
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче