diff options
author | Moonchild <moonchild@palemoon.org> | 2021-01-13 00:25:23 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-01-13 00:25:23 +0000 |
commit | 51581427794bb41142285bc837e9cf461d8abe7a (patch) | |
tree | 0be420e6bbd39dbdc889d341fa9a70300b3613c6 /layout/style | |
parent | 7023db88ca13046fda9204b018d8f48f10e44ec4 (diff) | |
parent | 0939fde1a45d757debf36394c5a76bfb0951b8d7 (diff) | |
download | UXP-51581427794bb41142285bc837e9cf461d8abe7a.tar UXP-51581427794bb41142285bc837e9cf461d8abe7a.tar.gz UXP-51581427794bb41142285bc837e9cf461d8abe7a.tar.lz UXP-51581427794bb41142285bc837e9cf461d8abe7a.tar.xz UXP-51581427794bb41142285bc837e9cf461d8abe7a.zip |
Merge pull request 'Add scrollbar-width CSS spec' (#1707) from 1705 into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1707
Diffstat (limited to 'layout/style')
-rw-r--r-- | layout/style/nsCSSKeywordList.h | 1 | ||||
-rw-r--r-- | layout/style/nsCSSPropList.h | 10 | ||||
-rw-r--r-- | layout/style/nsCSSProps.cpp | 6 | ||||
-rw-r--r-- | layout/style/nsCSSProps.h | 1 | ||||
-rw-r--r-- | layout/style/nsComputedDOMStyle.cpp | 10 | ||||
-rw-r--r-- | layout/style/nsComputedDOMStyle.h | 1 | ||||
-rw-r--r-- | layout/style/nsComputedDOMStylePropertyList.h | 1 | ||||
-rw-r--r-- | layout/style/nsRuleNode.cpp | 11 | ||||
-rw-r--r-- | layout/style/nsStyleConsts.h | 7 | ||||
-rw-r--r-- | layout/style/nsStyleStruct.cpp | 11 | ||||
-rw-r--r-- | layout/style/nsStyleStruct.h | 1 | ||||
-rw-r--r-- | layout/style/test/property_database.js | 12 |
12 files changed, 70 insertions, 2 deletions
diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index 86ba59142..689ff47eb 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -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) diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 658ea68d7..e78dafcc5 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -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, diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index e0cda2488..b6ffe7952 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -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 }, diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index 34d457c08..7b8c56860 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -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[]; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 748f990b7..7ac5fa604 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -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) { diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index 35a614268..38a61e23c 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -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(); diff --git a/layout/style/nsComputedDOMStylePropertyList.h b/layout/style/nsComputedDOMStylePropertyList.h index 6a18a7ad0..ec223cda4 100644 --- a/layout/style/nsComputedDOMStylePropertyList.h +++ b/layout/style/nsComputedDOMStylePropertyList.h @@ -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) diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 9721b4bed..04715aa99 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -424,7 +424,7 @@ static nsSize CalcViewportUnitsScale(nsPresContext* aPresContext) nsIScrollableFrame* scrollFrame = aPresContext->PresShell()->GetRootScrollFrameAsScrollable(); if (scrollFrame) { - ScrollbarStyles styles(scrollFrame->GetScrollbarStyles()); + ScrollStyles styles(scrollFrame->GetScrollStyles()); if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL || styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) { @@ -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) } diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index e6a0cc65a..308a66647 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -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, diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 073cfcd5e..acf287ea8 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -3264,7 +3264,7 @@ nsStyleDisplay::CalcDifference(const nsStyleDisplay& aNewData) const if (mOverflowX != aNewData.mOverflowX || mOverflowY != aNewData.mOverflowY) { - hint |= nsChangeHint_CSSOverflowChange; + hint |= nsChangeHint_ScrollbarChange; } /* Note: When mScrollBehavior, mScrollSnapTypeX, mScrollSnapTypeY, @@ -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; } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 831808edf..35ff071a5 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -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; }; diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 635431e8f..1d5dc989f 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -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. |