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
parent 21f707390d
commit 8e08d8bfd3
14 changed files with 72 additions and 0 deletions
@@ -3038,6 +3038,7 @@ exports.CSS_PROPERTIES = {
"scroll-snap-points-y",
"scroll-snap-type-x",
"scroll-snap-type-y",
"scrollbar-width",
"shape-outside",
"shape-rendering",
"-moz-stack-sizing",
+1
View File
@@ -509,6 +509,7 @@ CSS_KEY(scrollbar, scrollbar)
CSS_KEY(scrollbar-small, scrollbar_small)
CSS_KEY(scrollbar-horizontal, scrollbar_horizontal)
CSS_KEY(scrollbar-vertical, scrollbar_vertical)
CSS_KEY(scrollbar-width, scrollbar_width)
CSS_KEY(se-resize, se_resize)
CSS_KEY(select-after, select_after)
CSS_KEY(select-all, select_all)
+10
View File
@@ -3709,6 +3709,16 @@ CSS_PROP_DISPLAY(
kScrollSnapTypeKTable,
CSS_PROP_NO_OFFSET,
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(
shape-outside,
shape_outside,
+6
View File
@@ -2009,6 +2009,12 @@ const KTableEntry nsCSSProps::kScrollSnapTypeKTable[] = {
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kScrollbarWidthKTable[] = {
{ eCSSKeyword_auto, StyleScrollbarWidth::Auto },
{ eCSSKeyword_thin, StyleScrollbarWidth::Thin },
{ eCSSKeyword_none, StyleScrollbarWidth::None }
};
const KTableEntry nsCSSProps::kStackSizingKTable[] = {
{ eCSSKeyword_ignore, NS_STYLE_STACK_SIZING_IGNORE },
{ eCSSKeyword_stretch_to_fit, NS_STYLE_STACK_SIZING_STRETCH_TO_FIT },
+1
View File
@@ -856,6 +856,7 @@ public:
static const KTableEntry kRubyPositionKTable[];
static const KTableEntry kScrollBehaviorKTable[];
static const KTableEntry kScrollSnapTypeKTable[];
static const KTableEntry kScrollbarWidthKTable[];
static const KTableEntry kSpeakKTable[];
static const KTableEntry kSpeakHeaderKTable[];
static const KTableEntry kSpeakNumeralKTable[];
+10
View File
@@ -3305,6 +3305,16 @@ nsComputedDOMStyle::DoGetScrollSnapTypeY()
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>
nsComputedDOMStyle::GetScrollSnapPoints(const nsStyleCoord& aCoord)
{
+1
View File
@@ -492,6 +492,7 @@ private:
already_AddRefed<CSSValue> DoGetCursor();
already_AddRefed<CSSValue> DoGetForceBrokenImageIcon();
already_AddRefed<CSSValue> DoGetIMEMode();
already_AddRefed<CSSValue> DoGetScrollbarWidth();
already_AddRefed<CSSValue> DoGetUserFocus();
already_AddRefed<CSSValue> DoGetUserInput();
already_AddRefed<CSSValue> DoGetUserModify();
@@ -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_type_x, ScrollSnapTypeX)
COMPUTED_STYLE_PROP(scroll_snap_type_y, ScrollSnapTypeY)
COMPUTED_STYLE_PROP(scrollbar_width, ScrollbarWidth)
COMPUTED_STYLE_PROP(shape_outside, ShapeOutside)
//// COMPUTED_STYLE_PROP(size, Size)
COMPUTED_STYLE_PROP(tab_size, TabSize)
+9
View File
@@ -1394,6 +1394,7 @@ struct SetEnumValueHelper
DEFINE_ENUM_CLASS_SETTER(StyleFillRule, Nonzero, Evenodd)
DEFINE_ENUM_CLASS_SETTER(StyleFloat, None, InlineEnd)
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(StyleUserFocus, None, SelectMenu)
DEFINE_ENUM_CLASS_SETTER(StyleUserSelect, None, MozText)
@@ -5235,6 +5236,14 @@ nsRuleNode::ComputeUserInterfaceData(void* aStartStruct,
// caret-color: auto, color, inherit
setComplexColor(aRuleData->ValueForCaretColor(),
&nsStyleUserInterface::mCaretColor);
// scrollbar-width: auto, thin, none
SetValue(*aRuleData->ValueForScrollbarWidth(),
ui->mScrollbarWidth,
conditions,
SETVAL_ENUMERATED,
parentUI->mScrollbarWidth,
StyleScrollbarWidth::Auto);
COMPUTE_END_INHERITED(UserInterface, ui)
}
+7
View File
@@ -187,6 +187,13 @@ enum class StyleFloatEdge : uint8_t {
MarginBox,
};
// scrollbar-width
enum class StyleScrollbarWidth : uint8_t {
Auto,
Thin,
None,
};
// shape-box for shape-outside
enum class StyleShapeOutsideShapeBox : uint8_t {
NoBox,
+9
View File
@@ -4024,6 +4024,7 @@ nsStyleUserInterface::nsStyleUserInterface(StyleStructContext aContext)
, mPointerEvents(NS_STYLE_POINTER_EVENTS_AUTO)
, mCursor(NS_STYLE_CURSOR_AUTO)
, mCaretColor(StyleComplexColor::Auto())
, mScrollbarWidth(StyleScrollbarWidth::Auto)
{
MOZ_COUNT_CTOR(nsStyleUserInterface);
}
@@ -4036,6 +4037,7 @@ nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource)
, mCursor(aSource.mCursor)
, mCursorImages(aSource.mCursorImages)
, mCaretColor(aSource.mCaretColor)
, mScrollbarWidth(aSource.mScrollbarWidth)
{
MOZ_COUNT_CTOR(nsStyleUserInterface);
}
@@ -4087,6 +4089,13 @@ nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aNewData) const
if (mCaretColor != aNewData.mCaretColor) {
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;
}
+1
View File
@@ -3417,6 +3417,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]
mozilla::StyleScrollbarWidth mScrollbarWidth;
inline uint8_t GetEffectivePointerEvents(nsIFrame* aFrame) const;
};
+12
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) {
// 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.
+3
View File
@@ -2483,6 +2483,9 @@ pref("layout.css.isolation.enabled", true);
// Is support for CSS Filters enabled?
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
// an edge, when scroll snapping is set to "proximity".
pref("layout.css.scroll-snap.proximity-threshold", 200);