Browse Source

Add `overscroll-behavior` RCSS property

Michael Ragazzon 2 years ago
parent
commit
1410d5146d

+ 4 - 1
Include/RmlUi/Core/ComputedValues.h

@@ -154,7 +154,7 @@ namespace Style {
 
 
 			flex_basis_type(LengthPercentageAuto::Auto), row_gap_type(LengthPercentage::Length), column_gap_type(LengthPercentage::Length),
 			flex_basis_type(LengthPercentageAuto::Auto), row_gap_type(LengthPercentage::Length), column_gap_type(LengthPercentage::Length),
 
 
-			vertical_align_type(VerticalAlign::Baseline), drag(Drag::None), tab_index(TabIndex::None)
+			vertical_align_type(VerticalAlign::Baseline), drag(Drag::None), tab_index(TabIndex::None), overscroll_behavior(OverscrollBehavior::Auto)
 		{}
 		{}
 
 
 		LengthPercentage::Type min_width_type : 1, max_width_type : 1;
 		LengthPercentage::Type min_width_type : 1, max_width_type : 1;
@@ -169,6 +169,7 @@ namespace Style {
 		VerticalAlign::Type vertical_align_type : 4;
 		VerticalAlign::Type vertical_align_type : 4;
 		Drag drag : 3;
 		Drag drag : 3;
 		TabIndex tab_index : 1;
 		TabIndex tab_index : 1;
+		OverscrollBehavior overscroll_behavior : 1;
 
 
 		Clip clip;
 		Clip clip;
 
 
@@ -286,6 +287,7 @@ namespace Style {
 		Colourb           image_color()                const { return rare.image_color; }
 		Colourb           image_color()                const { return rare.image_color; }
 		LengthPercentage  row_gap()                    const { return LengthPercentage(rare.row_gap_type, rare.row_gap); }
 		LengthPercentage  row_gap()                    const { return LengthPercentage(rare.row_gap_type, rare.row_gap); }
 		LengthPercentage  column_gap()                 const { return LengthPercentage(rare.column_gap_type, rare.column_gap); }
 		LengthPercentage  column_gap()                 const { return LengthPercentage(rare.column_gap_type, rare.column_gap); }
+		OverscrollBehavior overscroll_behavior()       const { return rare.overscroll_behavior; }
 		float             scrollbar_margin()           const { return rare.scrollbar_margin; }
 		float             scrollbar_margin()           const { return rare.scrollbar_margin; }
 		
 		
 		// -- Assignment --
 		// -- Assignment --
@@ -362,6 +364,7 @@ namespace Style {
 		void drag                      (Drag value)              { rare.drag                       = value; }
 		void drag                      (Drag value)              { rare.drag                       = value; }
 		void tab_index                 (TabIndex value)          { rare.tab_index                  = value; }
 		void tab_index                 (TabIndex value)          { rare.tab_index                  = value; }
 		void image_color               (Colourb value)           { rare.image_color                = value; }
 		void image_color               (Colourb value)           { rare.image_color                = value; }
+		void overscroll_behavior       (OverscrollBehavior value){ rare.overscroll_behavior        = value; }
 		void scrollbar_margin          (float value)             { rare.scrollbar_margin           = value; }
 		void scrollbar_margin          (float value)             { rare.scrollbar_margin           = value; }
 
 
 		// clang-format on
 		// clang-format on

+ 1 - 0
Include/RmlUi/Core/ID.h

@@ -140,6 +140,7 @@ enum class PropertyId : uint8_t
 	Drag,
 	Drag,
 	TabIndex,
 	TabIndex,
 	ScrollbarMargin,
 	ScrollbarMargin,
+	OverscrollBehavior,
 
 
 	Perspective,
 	Perspective,
 	PerspectiveOriginX,
 	PerspectiveOriginX,

+ 1 - 0
Include/RmlUi/Core/StyleTypes.h

@@ -126,6 +126,7 @@ namespace Style {
 	enum class Drag : uint8_t { None, Drag, DragDrop, Block, Clone };
 	enum class Drag : uint8_t { None, Drag, DragDrop, Block, Clone };
 	enum class TabIndex : uint8_t { None, Auto };
 	enum class TabIndex : uint8_t { None, Auto };
 	enum class Focus : uint8_t { None, Auto };
 	enum class Focus : uint8_t { None, Auto };
+	enum class OverscrollBehavior : uint8_t { Auto, Contain };
 	enum class PointerEvents : uint8_t { None, Auto };
 	enum class PointerEvents : uint8_t { None, Auto };
 
 
 	using PerspectiveOrigin = LengthPercentage;
 	using PerspectiveOrigin = LengthPercentage;

+ 3 - 0
Source/Core/ElementStyle.cpp

@@ -820,6 +820,9 @@ PropertyIdSet ElementStyle::ComputeValues(Style::ComputedValues& values, const S
 		case PropertyId::ScrollbarMargin:
 		case PropertyId::ScrollbarMargin:
 			values.scrollbar_margin(ComputeLength(p, font_size, document_font_size, dp_ratio, vp_dimensions));
 			values.scrollbar_margin(ComputeLength(p, font_size, document_font_size, dp_ratio, vp_dimensions));
 			break;
 			break;
+		case PropertyId::OverscrollBehavior:
+			values.overscroll_behavior((OverscrollBehavior)p->Get<int>());
+			break;
 		case PropertyId::PointerEvents:
 		case PropertyId::PointerEvents:
 			values.pointer_events((PointerEvents)p->Get<int>());
 			values.pointer_events((PointerEvents)p->Get<int>());
 			break;
 			break;

+ 2 - 0
Source/Core/StyleSheetSpecification.cpp

@@ -395,7 +395,9 @@ void StyleSheetSpecification::RegisterDefaultProperties()
 	RegisterProperty(PropertyId::Drag, "drag", "none", false, false).AddParser("keyword", "none, drag, drag-drop, block, clone");
 	RegisterProperty(PropertyId::Drag, "drag", "none", false, false).AddParser("keyword", "none, drag, drag-drop, block, clone");
 	RegisterProperty(PropertyId::TabIndex, "tab-index", "none", false, false).AddParser("keyword", "none, auto");
 	RegisterProperty(PropertyId::TabIndex, "tab-index", "none", false, false).AddParser("keyword", "none, auto");
 	RegisterProperty(PropertyId::Focus, "focus", "auto", true, false).AddParser("keyword", "none, auto");
 	RegisterProperty(PropertyId::Focus, "focus", "auto", true, false).AddParser("keyword", "none, auto");
+
 	RegisterProperty(PropertyId::ScrollbarMargin, "scrollbar-margin", "0", false, false).AddParser("length");
 	RegisterProperty(PropertyId::ScrollbarMargin, "scrollbar-margin", "0", false, false).AddParser("length");
+	RegisterProperty(PropertyId::OverscrollBehavior, "overscroll-behavior", "auto", false, false).AddParser("keyword", "auto, contain");
 	RegisterProperty(PropertyId::PointerEvents, "pointer-events", "auto", true, false).AddParser("keyword", "none, auto");
 	RegisterProperty(PropertyId::PointerEvents, "pointer-events", "auto", true, false).AddParser("keyword", "none, auto");
 
 
 	// Perspective and Transform specifications
 	// Perspective and Transform specifications