зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1704332 - Move moz-control-character-visibility out of mako, and remove support for gecko_pref_controlled_initial_value. r=xidorn
No behavior change, just cleanup. Actually seem this technically _adds_ some code even though it's a cleanup, but that's mostly because of the wrapping of the derive list. The resulting code is simpler (more in-line with our usual things, so I think it's an improvement). Differential Revision: https://phabricator.services.mozilla.com/D111551
This commit is contained in:
Родитель
97ec9ca623
Коммит
a4272ff381
|
@ -6792,8 +6792,8 @@ nsIFrame* nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame) {
|
|||
aStyleText->mTextJustify == StyleTextJustify::InterCharacter) {
|
||||
result |= gfx::ShapedTextFlags::TEXT_DISABLE_OPTIONAL_LIGATURES;
|
||||
}
|
||||
if (aStyleText->mControlCharacterVisibility ==
|
||||
StyleControlCharacterVisibility::Hidden) {
|
||||
if (aStyleText->mMozControlCharacterVisibility ==
|
||||
StyleMozControlCharacterVisibility::Hidden) {
|
||||
result |= gfx::ShapedTextFlags::TEXT_HIDE_CONTROL_CHARACTERS;
|
||||
}
|
||||
switch (aComputedStyle->StyleText()->mTextRendering) {
|
||||
|
@ -9424,14 +9424,6 @@ nsPoint nsLayoutUtils::ComputeOffsetToUserSpace(nsDisplayListBuilder* aBuilder,
|
|||
return (offsetToBoundingBox - toUserSpace);
|
||||
}
|
||||
|
||||
/* static */
|
||||
mozilla::StyleControlCharacterVisibility
|
||||
nsLayoutUtils::ControlCharVisibilityDefault() {
|
||||
return StaticPrefs::layout_css_control_characters_visible()
|
||||
? StyleControlCharacterVisibility::Visible
|
||||
: StyleControlCharacterVisibility::Hidden;
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsFontMetrics> nsLayoutUtils::GetMetricsFor(
|
||||
nsPresContext* aPresContext, bool aIsVertical,
|
||||
|
|
|
@ -2883,11 +2883,6 @@ class nsLayoutUtils {
|
|||
static nsPoint ComputeOffsetToUserSpace(nsDisplayListBuilder* aBuilder,
|
||||
nsIFrame* aFrame);
|
||||
|
||||
// Return the default value to be used for -moz-control-character-visibility,
|
||||
// from preferences.
|
||||
static mozilla::StyleControlCharacterVisibility
|
||||
ControlCharVisibilityDefault();
|
||||
|
||||
// Callers are responsible to ensure the user-font-set is up-to-date if
|
||||
// aUseUserFontSet is true.
|
||||
static already_AddRefed<nsFontMetrics> GetMetricsFor(
|
||||
|
|
|
@ -162,7 +162,6 @@ rusty-enums = [
|
|||
"mozilla::StyleBackfaceVisibility",
|
||||
"mozilla::StyleBlend",
|
||||
"mozilla::StyleMaskComposite",
|
||||
"mozilla::StyleControlCharacterVisibility",
|
||||
"mozilla::StyleWritingModeProperty",
|
||||
]
|
||||
whitelist-vars = [
|
||||
|
@ -433,6 +432,7 @@ cbindgen-types = [
|
|||
{ gecko = "StyleOverflowWrap", servo = "crate::values::computed::OverflowWrap" },
|
||||
{ gecko = "StyleWordBreak", servo = "crate::values::computed::WordBreak" },
|
||||
{ gecko = "StyleTextJustify", servo = "crate::values::computed::TextJustify" },
|
||||
{ gecko = "StyleMozControlCharacterVisibility", servo = "crate::values::computed::text::MozControlCharacterVisibility" },
|
||||
{ gecko = "StyleLineBreak", servo = "crate::values::computed::LineBreak" },
|
||||
{ gecko = "StyleUserSelect", servo = "crate::values::computed::UserSelect" },
|
||||
{ gecko = "StyleBreakBetween", servo = "crate::values::computed::BreakBetween" },
|
||||
|
|
|
@ -757,9 +757,6 @@ enum class StyleMaskComposite : uint8_t {
|
|||
Exclude
|
||||
};
|
||||
|
||||
// See nsStyleText::mControlCharacterVisibility
|
||||
enum class StyleControlCharacterVisibility : uint8_t { Hidden = 0, Visible };
|
||||
|
||||
// scroll-behavior
|
||||
enum class StyleScrollBehavior : uint8_t {
|
||||
Auto,
|
||||
|
|
|
@ -2861,8 +2861,10 @@ nsStyleText::nsStyleText(const Document& aDocument)
|
|||
: StyleRubyPosition::Over),
|
||||
mTextSizeAdjust(StyleTextSizeAdjust::Auto),
|
||||
mTextCombineUpright(NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE),
|
||||
mControlCharacterVisibility(
|
||||
nsLayoutUtils::ControlCharVisibilityDefault()),
|
||||
mMozControlCharacterVisibility(
|
||||
StaticPrefs::layout_css_control_characters_visible()
|
||||
? StyleMozControlCharacterVisibility::Visible
|
||||
: StyleMozControlCharacterVisibility::Hidden),
|
||||
mTextRendering(StyleTextRendering::Auto),
|
||||
mTextEmphasisColor(StyleColor::CurrentColor()),
|
||||
mWebkitTextFillColor(StyleColor::CurrentColor()),
|
||||
|
@ -2901,7 +2903,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
|
|||
mRubyPosition(aSource.mRubyPosition),
|
||||
mTextSizeAdjust(aSource.mTextSizeAdjust),
|
||||
mTextCombineUpright(aSource.mTextCombineUpright),
|
||||
mControlCharacterVisibility(aSource.mControlCharacterVisibility),
|
||||
mMozControlCharacterVisibility(aSource.mMozControlCharacterVisibility),
|
||||
mTextEmphasisPosition(aSource.mTextEmphasisPosition),
|
||||
mTextRendering(aSource.mTextRendering),
|
||||
mTextEmphasisColor(aSource.mTextEmphasisColor),
|
||||
|
@ -2931,7 +2933,8 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aNewData) const {
|
|||
}
|
||||
|
||||
if (mTextCombineUpright != aNewData.mTextCombineUpright ||
|
||||
mControlCharacterVisibility != aNewData.mControlCharacterVisibility) {
|
||||
mMozControlCharacterVisibility !=
|
||||
aNewData.mMozControlCharacterVisibility) {
|
||||
return nsChangeHint_ReconstructFrame;
|
||||
}
|
||||
|
||||
|
|
|
@ -908,7 +908,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText {
|
|||
mozilla::StyleRubyPosition mRubyPosition;
|
||||
mozilla::StyleTextSizeAdjust mTextSizeAdjust;
|
||||
uint8_t mTextCombineUpright; // NS_STYLE_TEXT_COMBINE_UPRIGHT_*
|
||||
mozilla::StyleControlCharacterVisibility mControlCharacterVisibility;
|
||||
mozilla::StyleMozControlCharacterVisibility mMozControlCharacterVisibility;
|
||||
uint8_t mTextEmphasisPosition; // NS_STYLE_TEXT_EMPHASIS_POSITION_*
|
||||
mozilla::StyleTextRendering mTextRendering;
|
||||
mozilla::StyleColor mTextEmphasisColor;
|
||||
|
|
|
@ -483,6 +483,7 @@ class Longhand(Property):
|
|||
"LineBreak",
|
||||
"MasonryAutoFlow",
|
||||
"MozForceBrokenImageIcon",
|
||||
"text::MozControlCharacterVisibility",
|
||||
"MozListReversed",
|
||||
"MathDepth",
|
||||
"MozScriptMinSize",
|
||||
|
|
|
@ -707,8 +707,7 @@
|
|||
</%def>
|
||||
|
||||
<%def name="single_keyword(name, values, vector=False,
|
||||
needs_conversion=False, gecko_pref_controlled_initial_value=None,
|
||||
**kwargs)">
|
||||
needs_conversion=False, **kwargs)">
|
||||
<%
|
||||
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
|
||||
'gecko_constant_prefix',
|
||||
|
@ -725,10 +724,13 @@
|
|||
]}
|
||||
%>
|
||||
|
||||
<%def name="inner_body(keyword, needs_conversion=False,
|
||||
gecko_pref_controlled_initial_value=None)">
|
||||
<%def name="variants(variants)">
|
||||
% for variant in variants:
|
||||
<%def name="inner_body(keyword, needs_conversion=False)">
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
pub mod computed_value {
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)]
|
||||
pub enum T {
|
||||
% for variant in keyword.values_for(engine):
|
||||
<%
|
||||
aliases = []
|
||||
for alias, v in keyword.aliases_for(engine).items():
|
||||
|
@ -740,31 +742,14 @@
|
|||
% endif
|
||||
${to_camel_case(variant)},
|
||||
% endfor
|
||||
</%def>
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
pub mod computed_value {
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)]
|
||||
pub enum T {
|
||||
${variants(data.longhands_by_name[name].keyword.values_for(engine))}
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
% if engine == "gecko" and gecko_pref_controlled_initial_value:
|
||||
if static_prefs::pref!("${gecko_pref_controlled_initial_value.split('=')[0]}") {
|
||||
return computed_value::T::${to_camel_case(gecko_pref_controlled_initial_value.split('=')[1])};
|
||||
}
|
||||
% endif
|
||||
computed_value::T::${to_camel_case(values.split()[0])}
|
||||
}
|
||||
#[inline]
|
||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||
% if engine == "gecko" and gecko_pref_controlled_initial_value:
|
||||
if static_prefs::pref!("${gecko_pref_controlled_initial_value.split('=')[0]}") {
|
||||
return SpecifiedValue::${to_camel_case(gecko_pref_controlled_initial_value.split('=')[1])};
|
||||
}
|
||||
% endif
|
||||
SpecifiedValue::${to_camel_case(values.split()[0])}
|
||||
}
|
||||
#[inline]
|
||||
|
@ -790,8 +775,7 @@
|
|||
% else:
|
||||
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
|
||||
${inner_body(Keyword(name, values, **keyword_kwargs),
|
||||
needs_conversion=needs_conversion,
|
||||
gecko_pref_controlled_initial_value=gecko_pref_controlled_initial_value)}
|
||||
needs_conversion=needs_conversion)}
|
||||
% if caller:
|
||||
${caller.body()}
|
||||
% endif
|
||||
|
|
|
@ -332,15 +332,13 @@ ${helpers.single_keyword(
|
|||
servo_restyle_damage="rebuild_and_reflow",
|
||||
)}
|
||||
|
||||
${helpers.single_keyword(
|
||||
${helpers.predefined_type(
|
||||
"-moz-control-character-visibility",
|
||||
"hidden visible",
|
||||
"text::MozControlCharacterVisibility",
|
||||
"Default::default()",
|
||||
engines="gecko",
|
||||
gecko_enum_prefix="StyleControlCharacterVisibility",
|
||||
gecko_pref_controlled_initial_value="layout.css.control-characters.visible=visible",
|
||||
animation_value_type="none",
|
||||
gecko_ffi_name="mControlCharacterVisibility",
|
||||
spec="Nonstandard",
|
||||
spec="Nonstandard"
|
||||
)}
|
||||
|
||||
// text underline offset
|
||||
|
|
|
@ -18,7 +18,7 @@ use crate::Zero;
|
|||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
|
||||
pub use crate::values::specified::text::{TextAlignLast, TextUnderlinePosition};
|
||||
pub use crate::values::specified::text::{TextAlignLast, TextUnderlinePosition, MozControlCharacterVisibility};
|
||||
pub use crate::values::specified::{LineBreak, OverflowWrap, RubyPosition, WordBreak};
|
||||
pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition};
|
||||
pub use crate::values::specified::{TextDecorationSkipInk, TextJustify, TextTransform};
|
||||
|
|
|
@ -1028,6 +1028,39 @@ pub enum TextJustify {
|
|||
InterCharacter,
|
||||
}
|
||||
|
||||
/// Values for the `-moz-control-character-visibility` CSS property.
|
||||
#[repr(u8)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
Parse,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum MozControlCharacterVisibility {
|
||||
Hidden,
|
||||
Visible,
|
||||
}
|
||||
|
||||
impl Default for MozControlCharacterVisibility {
|
||||
fn default() -> Self {
|
||||
if static_prefs::pref!("layout.css.control-characters.visible") {
|
||||
Self::Visible
|
||||
} else {
|
||||
Self::Hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Values for the `line-break` property.
|
||||
#[repr(u8)]
|
||||
#[derive(
|
||||
|
|
|
@ -151,6 +151,7 @@ include = [
|
|||
"TextTransform",
|
||||
"TextJustify",
|
||||
"TextOverflow",
|
||||
"MozControlCharacterVisibility",
|
||||
"RubyPosition",
|
||||
"MozListReversed",
|
||||
"Owned",
|
||||
|
|
Загрузка…
Ссылка в новой задаче