Issue #1705 - Part 4: Add scrollbar-width CSS keyword to CSS parser.

This should be all parts needed to add a brand new enum keyword including
getting the computed style from it...
This commit is contained in:
Moonchild 2021-01-06 23:57:26 +00:00 • committed by roytam1
commit 8e08d8bfd3
14 changed files with 72 additions and 0 deletions

View file

@ -3038,6 +3038,7 @@ exports.CSS_PROPERTIES = {
"scroll-snap-points-y", "scroll-snap-points-y",
"scroll-snap-type-x", "scroll-snap-type-x",
"scroll-snap-type-y", "scroll-snap-type-y",
"scrollbar-width",
"shape-outside", "shape-outside",
"shape-rendering", "shape-rendering",
"-moz-stack-sizing", "-moz-stack-sizing",

View file

@ -509,6 +509,7 @@ CSS_KEY(scrollbar, scrollbar)
CSS_KEY(scrollbar-small, scrollbar_small) CSS_KEY(scrollbar-small, scrollbar_small)
CSS_KEY(scrollbar-horizontal, scrollbar_horizontal) CSS_KEY(scrollbar-horizontal, scrollbar_horizontal)
CSS_KEY(scrollbar-vertical, scrollbar_vertical) CSS_KEY(scrollbar-vertical, scrollbar_vertical)
CSS_KEY(scrollbar-width, scrollbar_width)
CSS_KEY(se-resize, se_resize) CSS_KEY(se-resize, se_resize)
CSS_KEY(select-after, select_after) CSS_KEY(select-after, select_after)
CSS_KEY(select-all, select_all) CSS_KEY(select-all, select_all)

View file

@ -3709,6 +3709,16 @@ CSS_PROP_DISPLAY(
kScrollSnapTypeKTable, kScrollSnapTypeKTable,
CSS_PROP_NO_OFFSET, CSS_PROP_NO_OFFSET,
eStyleAnimType_Discrete) eStyleAnimType_Discrete)
CSS_PROP_USERINTERFACE(
scrollbar-width,
scrollbar_width,
ScrollbarWidth,
CSS_PROPERTY_PARSE_VALUE,
"layout.css.scrollbar-width.enabled",
VARIANT_HK,
kScrollbarWidthKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Discrete)
CSS_PROP_DISPLAY( CSS_PROP_DISPLAY(
shape-outside, shape-outside,
shape_outside, shape_outside,

View file

@ -2009,6 +2009,12 @@ const KTableEntry nsCSSProps::kScrollSnapTypeKTable[] = {
{ eCSSKeyword_UNKNOWN, -1 } { eCSSKeyword_UNKNOWN, -1 }
}; };
const KTableEntry nsCSSProps::kScrollbarWidthKTable[] = {
{ eCSSKeyword_auto, StyleScrollbarWidth::Auto },
{ eCSSKeyword_thin, StyleScrollbarWidth::Thin },
{ eCSSKeyword_none, StyleScrollbarWidth::None }
};
const KTableEntry nsCSSProps::kStackSizingKTable[] = { const KTableEntry nsCSSProps::kStackSizingKTable[] = {
{ eCSSKeyword_ignore, NS_STYLE_STACK_SIZING_IGNORE }, { eCSSKeyword_ignore, NS_STYLE_STACK_SIZING_IGNORE },
{ eCSSKeyword_stretch_to_fit, NS_STYLE_STACK_SIZING_STRETCH_TO_FIT }, { eCSSKeyword_stretch_to_fit, NS_STYLE_STACK_SIZING_STRETCH_TO_FIT },

View file

@ -856,6 +856,7 @@ public:
static const KTableEntry kRubyPositionKTable[]; static const KTableEntry kRubyPositionKTable[];
static const KTableEntry kScrollBehaviorKTable[]; static const KTableEntry kScrollBehaviorKTable[];
static const KTableEntry kScrollSnapTypeKTable[]; static const KTableEntry kScrollSnapTypeKTable[];
static const KTableEntry kScrollbarWidthKTable[];
static const KTableEntry kSpeakKTable[]; static const KTableEntry kSpeakKTable[];
static const KTableEntry kSpeakHeaderKTable[]; static const KTableEntry kSpeakHeaderKTable[];
static const KTableEntry kSpeakNumeralKTable[]; static const KTableEntry kSpeakNumeralKTable[];

View file

@ -3305,6 +3305,16 @@ nsComputedDOMStyle::DoGetScrollSnapTypeY()
return val.forget(); return val.forget();
} }
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetScrollbarWidth()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleUserInterface()->mScrollbarWidth,
nsCSSProps::kScrollbarWidthKTable));
return val.forget();
}
already_AddRefed<CSSValue> already_AddRefed<CSSValue>
nsComputedDOMStyle::GetScrollSnapPoints(const nsStyleCoord& aCoord) nsComputedDOMStyle::GetScrollSnapPoints(const nsStyleCoord& aCoord)
{ {

View file

@ -492,6 +492,7 @@ private:
already_AddRefed<CSSValue> DoGetCursor(); already_AddRefed<CSSValue> DoGetCursor();
already_AddRefed<CSSValue> DoGetForceBrokenImageIcon(); already_AddRefed<CSSValue> DoGetForceBrokenImageIcon();
already_AddRefed<CSSValue> DoGetIMEMode(); already_AddRefed<CSSValue> DoGetIMEMode();
already_AddRefed<CSSValue> DoGetScrollbarWidth();
already_AddRefed<CSSValue> DoGetUserFocus(); already_AddRefed<CSSValue> DoGetUserFocus();
already_AddRefed<CSSValue> DoGetUserInput(); already_AddRefed<CSSValue> DoGetUserInput();
already_AddRefed<CSSValue> DoGetUserModify(); already_AddRefed<CSSValue> DoGetUserModify();

View file

@ -226,6 +226,7 @@ COMPUTED_STYLE_PROP(scroll_snap_points_x, ScrollSnapPointsX)
COMPUTED_STYLE_PROP(scroll_snap_points_y, ScrollSnapPointsY) COMPUTED_STYLE_PROP(scroll_snap_points_y, ScrollSnapPointsY)
COMPUTED_STYLE_PROP(scroll_snap_type_x, ScrollSnapTypeX) COMPUTED_STYLE_PROP(scroll_snap_type_x, ScrollSnapTypeX)
COMPUTED_STYLE_PROP(scroll_snap_type_y, ScrollSnapTypeY) COMPUTED_STYLE_PROP(scroll_snap_type_y, ScrollSnapTypeY)
COMPUTED_STYLE_PROP(scrollbar_width, ScrollbarWidth)
COMPUTED_STYLE_PROP(shape_outside, ShapeOutside) COMPUTED_STYLE_PROP(shape_outside, ShapeOutside)
//// COMPUTED_STYLE_PROP(size, Size) //// COMPUTED_STYLE_PROP(size, Size)
COMPUTED_STYLE_PROP(tab_size, TabSize) COMPUTED_STYLE_PROP(tab_size, TabSize)

View file

@ -1394,6 +1394,7 @@ struct SetEnumValueHelper
DEFINE_ENUM_CLASS_SETTER(StyleFillRule, Nonzero, Evenodd) DEFINE_ENUM_CLASS_SETTER(StyleFillRule, Nonzero, Evenodd)
DEFINE_ENUM_CLASS_SETTER(StyleFloat, None, InlineEnd) DEFINE_ENUM_CLASS_SETTER(StyleFloat, None, InlineEnd)
DEFINE_ENUM_CLASS_SETTER(StyleFloatEdge, ContentBox, MarginBox) DEFINE_ENUM_CLASS_SETTER(StyleFloatEdge, ContentBox, MarginBox)
DEFINE_ENUM_CLASS_SETTER(StyleScrollbarWidth, Auto, None)
DEFINE_ENUM_CLASS_SETTER(StyleTextJustify, None, InterCharacter) DEFINE_ENUM_CLASS_SETTER(StyleTextJustify, None, InterCharacter)
DEFINE_ENUM_CLASS_SETTER(StyleUserFocus, None, SelectMenu) DEFINE_ENUM_CLASS_SETTER(StyleUserFocus, None, SelectMenu)
DEFINE_ENUM_CLASS_SETTER(StyleUserSelect, None, MozText) DEFINE_ENUM_CLASS_SETTER(StyleUserSelect, None, MozText)
@ -5236,6 +5237,14 @@ nsRuleNode::ComputeUserInterfaceData(void* aStartStruct,
setComplexColor(aRuleData->ValueForCaretColor(), setComplexColor(aRuleData->ValueForCaretColor(),
&nsStyleUserInterface::mCaretColor); &nsStyleUserInterface::mCaretColor);
// scrollbar-width: auto, thin, none
SetValue(*aRuleData->ValueForScrollbarWidth(),
ui->mScrollbarWidth,
conditions,
SETVAL_ENUMERATED,
parentUI->mScrollbarWidth,
StyleScrollbarWidth::Auto);
COMPUTE_END_INHERITED(UserInterface, ui) COMPUTE_END_INHERITED(UserInterface, ui)
} }

View file

@ -187,6 +187,13 @@ enum class StyleFloatEdge : uint8_t {
MarginBox, MarginBox,
}; };
// scrollbar-width
enum class StyleScrollbarWidth : uint8_t {
Auto,
Thin,
None,
};
// shape-box for shape-outside // shape-box for shape-outside
enum class StyleShapeOutsideShapeBox : uint8_t { enum class StyleShapeOutsideShapeBox : uint8_t {
NoBox, NoBox,

View file

@ -4024,6 +4024,7 @@ nsStyleUserInterface::nsStyleUserInterface(StyleStructContext aContext)
, mPointerEvents(NS_STYLE_POINTER_EVENTS_AUTO) , mPointerEvents(NS_STYLE_POINTER_EVENTS_AUTO)
, mCursor(NS_STYLE_CURSOR_AUTO) , mCursor(NS_STYLE_CURSOR_AUTO)
, mCaretColor(StyleComplexColor::Auto()) , mCaretColor(StyleComplexColor::Auto())
, mScrollbarWidth(StyleScrollbarWidth::Auto)
{ {
MOZ_COUNT_CTOR(nsStyleUserInterface); MOZ_COUNT_CTOR(nsStyleUserInterface);
} }
@ -4036,6 +4037,7 @@ nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource)
, mCursor(aSource.mCursor) , mCursor(aSource.mCursor)
, mCursorImages(aSource.mCursorImages) , mCursorImages(aSource.mCursorImages)
, mCaretColor(aSource.mCaretColor) , mCaretColor(aSource.mCaretColor)
, mScrollbarWidth(aSource.mScrollbarWidth)
{ {
MOZ_COUNT_CTOR(nsStyleUserInterface); MOZ_COUNT_CTOR(nsStyleUserInterface);
} }
@ -4088,6 +4090,13 @@ nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aNewData) const
hint |= nsChangeHint_RepaintFrame; hint |= nsChangeHint_RepaintFrame;
} }
if (mScrollbarWidth != aNewData.mScrollbarWidth) {
// For scrollbar-width change, we need some special handling similar
// to overflow properties. Specifically, we may need to reconstruct
// the scrollbar or force reflow of the viewport scrollbar.
hint |= nsChangeHint_ScrollbarChange;
}
return hint; return hint;
} }

View file

@ -3417,6 +3417,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUserInterface
uint8_t mCursor; // [inherited] See nsStyleConsts.h uint8_t mCursor; // [inherited] See nsStyleConsts.h
nsTArray<nsCursorImage> mCursorImages; // [inherited] images and coords nsTArray<nsCursorImage> mCursorImages; // [inherited] images and coords
mozilla::StyleComplexColor mCaretColor; // [inherited] mozilla::StyleComplexColor mCaretColor; // [inherited]
mozilla::StyleScrollbarWidth mScrollbarWidth;
inline uint8_t GetEffectivePointerEvents(nsIFrame* aFrame) const; inline uint8_t GetEffectivePointerEvents(nsIFrame* aFrame) const;
}; };

View file

@ -7944,6 +7944,18 @@ for (var prop in gCSSProperties) {
} }
} }
if (IsCSSPropertyPrefEnabled("layout.css.scrollbar-width.enabled")) {
gCSSProperties["scrollbar-width"] = {
domProp: "scrollbarWidth",
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: [ "auto" ],
other_values: [ "none", "thin" ],
invalid_values: [ "1px" ]
};
}
if (false) { if (false) {
// TODO These properties are chrome-only, and are not exposed via CSSOM. // TODO These properties are chrome-only, and are not exposed via CSSOM.
// We may still want to find a way to test them. See bug 1206999. // We may still want to find a way to test them. See bug 1206999.

View file

@ -2483,6 +2483,9 @@ pref("layout.css.isolation.enabled", true);
// Is support for CSS Filters enabled? // Is support for CSS Filters enabled?
pref("layout.css.filters.enabled", true); pref("layout.css.filters.enabled", true);
// Is support for scrollbar-width property enabled?
pref("layout.css.scrollbar-width.enabled", false);
// Set the threshold distance in CSS pixels below which scrolling will snap to // Set the threshold distance in CSS pixels below which scrolling will snap to
// an edge, when scroll snapping is set to "proximity". // an edge, when scroll snapping is set to "proximity".
pref("layout.css.scroll-snap.proximity-threshold", 200); pref("layout.css.scroll-snap.proximity-threshold", 200);