StyleSheetSpecification.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. #include "../../Include/RmlUi/Core/StyleSheetSpecification.h"
  2. #include "../../Include/RmlUi/Core/PropertyDefinition.h"
  3. #include "../../Include/RmlUi/Core/PropertyIdSet.h"
  4. #include "IdNameMap.h"
  5. #include "PropertyParserAnimation.h"
  6. #include "PropertyParserBoxShadow.h"
  7. #include "PropertyParserColorStopList.h"
  8. #include "PropertyParserColour.h"
  9. #include "PropertyParserDecorator.h"
  10. #include "PropertyParserFilter.h"
  11. #include "PropertyParserFontEffect.h"
  12. #include "PropertyParserKeyword.h"
  13. #include "PropertyParserNumber.h"
  14. #include "PropertyParserRatio.h"
  15. #include "PropertyParserString.h"
  16. #include "PropertyParserTransform.h"
  17. #include "PropertyShorthandDefinition.h"
  18. namespace Rml {
  19. static StyleSheetSpecification* instance = nullptr;
  20. struct DefaultStyleSheetParsers : NonCopyMoveable {
  21. PropertyParserNumber number = PropertyParserNumber(Unit::NUMBER);
  22. PropertyParserNumber length = PropertyParserNumber(Unit::LENGTH, Unit::PX);
  23. PropertyParserNumber length_percent = PropertyParserNumber(Unit::LENGTH_PERCENT, Unit::PX);
  24. PropertyParserNumber number_percent = PropertyParserNumber(Unit::NUMBER_PERCENT);
  25. PropertyParserNumber number_length_percent = PropertyParserNumber(Unit::NUMBER_LENGTH_PERCENT, Unit::PX);
  26. PropertyParserNumber angle = PropertyParserNumber(Unit::ANGLE, Unit::RAD);
  27. PropertyParserKeyword keyword = PropertyParserKeyword();
  28. PropertyParserString string = PropertyParserString();
  29. PropertyParserAnimation animation = PropertyParserAnimation(PropertyParserAnimation::ANIMATION_PARSER);
  30. PropertyParserAnimation transition = PropertyParserAnimation(PropertyParserAnimation::TRANSITION_PARSER);
  31. PropertyParserColour color = PropertyParserColour();
  32. PropertyParserColorStopList color_stop_list = PropertyParserColorStopList(&color);
  33. PropertyParserDecorator decorator = PropertyParserDecorator();
  34. PropertyParserFilter filter = PropertyParserFilter();
  35. PropertyParserFontEffect font_effect = PropertyParserFontEffect();
  36. PropertyParserTransform transform = PropertyParserTransform();
  37. PropertyParserRatio ratio = PropertyParserRatio();
  38. PropertyParserNumber resolution = PropertyParserNumber(Unit::X);
  39. PropertyParserBoxShadow box_shadow = PropertyParserBoxShadow(&color, &length);
  40. };
  41. StyleSheetSpecification::StyleSheetSpecification() :
  42. // Reserve space for all defined ids and some more for custom properties
  43. properties((size_t)PropertyId::MaxNumIds, 2 * (size_t)ShorthandId::NumDefinedIds)
  44. {
  45. RMLUI_ASSERT(instance == nullptr);
  46. instance = this;
  47. default_parsers.reset(new DefaultStyleSheetParsers);
  48. }
  49. StyleSheetSpecification::~StyleSheetSpecification()
  50. {
  51. RMLUI_ASSERT(instance == this);
  52. instance = nullptr;
  53. }
  54. PropertyDefinition& StyleSheetSpecification::RegisterProperty(PropertyId id, const String& property_name, const String& default_value, bool inherited,
  55. bool forces_layout)
  56. {
  57. return properties.RegisterProperty(property_name, default_value, inherited, forces_layout, id);
  58. }
  59. ShorthandId StyleSheetSpecification::RegisterShorthand(ShorthandId id, const String& shorthand_name, const String& property_names, ShorthandType type)
  60. {
  61. return properties.RegisterShorthand(shorthand_name, property_names, type, id);
  62. }
  63. void StyleSheetSpecification::Initialise()
  64. {
  65. RMLUI_ASSERT(!instance);
  66. PropertyParserAnimation::Initialize();
  67. PropertyParserColour::Initialize();
  68. PropertyParserDecorator::Initialize();
  69. PropertyParserNumber::Initialize();
  70. new StyleSheetSpecification();
  71. instance->RegisterDefaultParsers();
  72. instance->RegisterDefaultProperties();
  73. }
  74. void StyleSheetSpecification::Shutdown()
  75. {
  76. RMLUI_ASSERT(instance);
  77. delete instance;
  78. PropertyParserAnimation::Shutdown();
  79. PropertyParserColour::Shutdown();
  80. PropertyParserDecorator::Shutdown();
  81. PropertyParserNumber::Shutdown();
  82. }
  83. bool StyleSheetSpecification::RegisterParser(const String& parser_name, PropertyParser* parser)
  84. {
  85. ParserMap::iterator iterator = instance->parsers.find(parser_name);
  86. if (iterator != instance->parsers.end())
  87. {
  88. Log::Message(Log::LT_WARNING, "Parser with name %s already exists!", parser_name.c_str());
  89. return false;
  90. }
  91. instance->parsers[parser_name] = parser;
  92. return true;
  93. }
  94. PropertyParser* StyleSheetSpecification::GetParser(const String& parser_name)
  95. {
  96. ParserMap::iterator iterator = instance->parsers.find(parser_name);
  97. if (iterator == instance->parsers.end())
  98. return nullptr;
  99. return (*iterator).second;
  100. }
  101. PropertyDefinition& StyleSheetSpecification::RegisterProperty(const String& property_name, const String& default_value, bool inherited,
  102. bool forces_layout)
  103. {
  104. RMLUI_ASSERTMSG((size_t)instance->properties.property_map->GetId(property_name) < (size_t)PropertyId::FirstCustomId,
  105. "Custom property name matches an internal property, please make a unique name for the given property.");
  106. return instance->RegisterProperty(PropertyId::Invalid, property_name, default_value, inherited, forces_layout);
  107. }
  108. const PropertyDefinition* StyleSheetSpecification::GetProperty(const String& property_name)
  109. {
  110. return instance->properties.GetProperty(property_name);
  111. }
  112. const PropertyDefinition* StyleSheetSpecification::GetProperty(PropertyId id)
  113. {
  114. return instance->properties.GetProperty(id);
  115. }
  116. const PropertyIdSet& StyleSheetSpecification::GetRegisteredProperties()
  117. {
  118. return instance->properties.GetRegisteredProperties();
  119. }
  120. const PropertyIdSet& StyleSheetSpecification::GetRegisteredInheritedProperties()
  121. {
  122. return instance->properties.GetRegisteredInheritedProperties();
  123. }
  124. const PropertyIdSet& StyleSheetSpecification::GetRegisteredPropertiesForcingLayout()
  125. {
  126. return instance->properties.GetRegisteredPropertiesForcingLayout();
  127. }
  128. ShorthandId StyleSheetSpecification::RegisterShorthand(const String& shorthand_name, const String& property_names, ShorthandType type)
  129. {
  130. RMLUI_ASSERTMSG(instance->properties.property_map->GetId(shorthand_name) == PropertyId::Invalid,
  131. "Custom shorthand name matches a property name, please make a unique name.");
  132. RMLUI_ASSERTMSG((size_t)instance->properties.shorthand_map->GetId(shorthand_name) < (size_t)ShorthandId::FirstCustomId,
  133. "Custom shorthand name matches an internal shorthand, please make a unique name for the given shorthand property.");
  134. return instance->properties.RegisterShorthand(shorthand_name, property_names, type);
  135. }
  136. const ShorthandDefinition* StyleSheetSpecification::GetShorthand(const String& shorthand_name)
  137. {
  138. return instance->properties.GetShorthand(shorthand_name);
  139. }
  140. const ShorthandDefinition* StyleSheetSpecification::GetShorthand(ShorthandId id)
  141. {
  142. return instance->properties.GetShorthand(id);
  143. }
  144. bool StyleSheetSpecification::ParsePropertyDeclaration(PropertyDictionary& dictionary, const String& property_name, const String& property_value)
  145. {
  146. return instance->properties.ParsePropertyDeclaration(dictionary, property_name, property_value);
  147. }
  148. PropertyId StyleSheetSpecification::GetPropertyId(const String& property_name)
  149. {
  150. return instance->properties.property_map->GetId(property_name);
  151. }
  152. ShorthandId StyleSheetSpecification::GetShorthandId(const String& shorthand_name)
  153. {
  154. return instance->properties.shorthand_map->GetId(shorthand_name);
  155. }
  156. const String& StyleSheetSpecification::GetPropertyName(PropertyId id)
  157. {
  158. return instance->properties.property_map->GetName(id);
  159. }
  160. const String& StyleSheetSpecification::GetShorthandName(ShorthandId id)
  161. {
  162. return instance->properties.shorthand_map->GetName(id);
  163. }
  164. PropertyIdSet StyleSheetSpecification::GetShorthandUnderlyingProperties(ShorthandId id)
  165. {
  166. PropertyIdSet result;
  167. const ShorthandDefinition* shorthand = instance->properties.GetShorthand(id);
  168. if (!shorthand)
  169. return result;
  170. for (auto& item : shorthand->items)
  171. {
  172. if (item.type == ShorthandItemType::Property)
  173. {
  174. result.Insert(item.property_id);
  175. }
  176. else if (item.type == ShorthandItemType::Shorthand)
  177. {
  178. // When we have a shorthand pointing to another shorthands, call us recursively. Add the union of the previous result and new properties.
  179. result |= GetShorthandUnderlyingProperties(item.shorthand_id);
  180. }
  181. }
  182. return result;
  183. }
  184. const PropertySpecification& StyleSheetSpecification::GetPropertySpecification()
  185. {
  186. return instance->properties;
  187. }
  188. void StyleSheetSpecification::RegisterDefaultParsers()
  189. {
  190. RegisterParser("number", &default_parsers->number);
  191. RegisterParser("length", &default_parsers->length);
  192. RegisterParser("length_percent", &default_parsers->length_percent);
  193. RegisterParser("number_percent", &default_parsers->number_percent);
  194. RegisterParser("number_length_percent", &default_parsers->number_length_percent);
  195. RegisterParser("angle", &default_parsers->angle);
  196. RegisterParser("keyword", &default_parsers->keyword);
  197. RegisterParser("string", &default_parsers->string);
  198. RegisterParser("animation", &default_parsers->animation);
  199. RegisterParser("transition", &default_parsers->transition);
  200. RegisterParser("color", &default_parsers->color);
  201. RegisterParser("color_stop_list", &default_parsers->color_stop_list);
  202. RegisterParser("decorator", &default_parsers->decorator);
  203. RegisterParser("filter", &default_parsers->filter);
  204. RegisterParser("font_effect", &default_parsers->font_effect);
  205. RegisterParser("transform", &default_parsers->transform);
  206. RegisterParser("ratio", &default_parsers->ratio);
  207. RegisterParser("resolution", &default_parsers->resolution);
  208. RegisterParser("box_shadow", &default_parsers->box_shadow);
  209. }
  210. void StyleSheetSpecification::RegisterDefaultProperties()
  211. {
  212. /*
  213. Style property specifications (ala RCSS).
  214. Note: Whenever keywords or default values are changed, make sure its computed value is
  215. changed correspondingly, see `ComputedValues.h`.
  216. When adding new properties, it may be desirable to add it to the computed values as well.
  217. Then, make sure to resolve it as appropriate in `ElementStyle.cpp`.
  218. */
  219. // clang-format off
  220. RegisterProperty(PropertyId::MarginTop, "margin-top", "0px", false, true)
  221. .AddParser("keyword", "auto")
  222. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  223. RegisterProperty(PropertyId::MarginRight, "margin-right", "0px", false, true)
  224. .AddParser("keyword", "auto")
  225. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  226. RegisterProperty(PropertyId::MarginBottom, "margin-bottom", "0px", false, true)
  227. .AddParser("keyword", "auto")
  228. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  229. RegisterProperty(PropertyId::MarginLeft, "margin-left", "0px", false, true)
  230. .AddParser("keyword", "auto")
  231. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  232. RegisterShorthand(ShorthandId::Margin, "margin", "margin-top, margin-right, margin-bottom, margin-left", ShorthandType::Box);
  233. RegisterProperty(PropertyId::PaddingTop, "padding-top", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  234. RegisterProperty(PropertyId::PaddingRight, "padding-right", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  235. RegisterProperty(PropertyId::PaddingBottom, "padding-bottom", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  236. RegisterProperty(PropertyId::PaddingLeft, "padding-left", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  237. RegisterShorthand(ShorthandId::Padding, "padding", "padding-top, padding-right, padding-bottom, padding-left", ShorthandType::Box);
  238. RegisterProperty(PropertyId::BorderTopWidth, "border-top-width", "0px", false, true).AddParser("length");
  239. RegisterProperty(PropertyId::BorderRightWidth, "border-right-width", "0px", false, true).AddParser("length");
  240. RegisterProperty(PropertyId::BorderBottomWidth, "border-bottom-width", "0px", false, true).AddParser("length");
  241. RegisterProperty(PropertyId::BorderLeftWidth, "border-left-width", "0px", false, true).AddParser("length");
  242. RegisterShorthand(ShorthandId::BorderWidth, "border-width", "border-top-width, border-right-width, border-bottom-width, border-left-width", ShorthandType::Box);
  243. RegisterProperty(PropertyId::BorderTopColor, "border-top-color", "black", false, false).AddParser("color");
  244. RegisterProperty(PropertyId::BorderRightColor, "border-right-color", "black", false, false).AddParser("color");
  245. RegisterProperty(PropertyId::BorderBottomColor, "border-bottom-color", "black", false, false).AddParser("color");
  246. RegisterProperty(PropertyId::BorderLeftColor, "border-left-color", "black", false, false).AddParser("color");
  247. RegisterShorthand(ShorthandId::BorderColor, "border-color", "border-top-color, border-right-color, border-bottom-color, border-left-color", ShorthandType::Box);
  248. RegisterShorthand(ShorthandId::BorderTop, "border-top", "border-top-width, border-top-color", ShorthandType::FallThrough);
  249. RegisterShorthand(ShorthandId::BorderRight, "border-right", "border-right-width, border-right-color", ShorthandType::FallThrough);
  250. RegisterShorthand(ShorthandId::BorderBottom, "border-bottom", "border-bottom-width, border-bottom-color", ShorthandType::FallThrough);
  251. RegisterShorthand(ShorthandId::BorderLeft, "border-left", "border-left-width, border-left-color", ShorthandType::FallThrough);
  252. RegisterShorthand(ShorthandId::Border, "border", "border-top, border-right, border-bottom, border-left", ShorthandType::RecursiveRepeat);
  253. RegisterProperty(PropertyId::BorderTopLeftRadius, "border-top-left-radius", "0px", false, false).AddParser("length");
  254. RegisterProperty(PropertyId::BorderTopRightRadius, "border-top-right-radius", "0px", false, false).AddParser("length");
  255. RegisterProperty(PropertyId::BorderBottomRightRadius, "border-bottom-right-radius", "0px", false, false).AddParser("length");
  256. RegisterProperty(PropertyId::BorderBottomLeftRadius, "border-bottom-left-radius", "0px", false, false).AddParser("length");
  257. RegisterShorthand(ShorthandId::BorderRadius, "border-radius", "border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius", ShorthandType::Box);
  258. RegisterProperty(PropertyId::Display, "display", "inline", false, true)
  259. .AddParser("keyword", "none, block, inline, inline-block, flow-root, flex, inline-flex, table, inline-table, table-row, table-row-group, table-column, table-column-group, table-cell");
  260. RegisterProperty(PropertyId::Position, "position", "static", false, true).AddParser("keyword", "static, relative, absolute, fixed");
  261. RegisterProperty(PropertyId::Top, "top", "auto", false, false).AddParser("keyword", "auto").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  262. RegisterProperty(PropertyId::Right, "right", "auto", false, false).AddParser("keyword", "auto").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  263. RegisterProperty(PropertyId::Bottom, "bottom", "auto", false, false).AddParser("keyword", "auto").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  264. RegisterProperty(PropertyId::Left, "left", "auto", false, false).AddParser("keyword", "auto").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  265. RegisterShorthand(ShorthandId::Inset, "inset", "top, right, bottom, left", ShorthandType::Box);
  266. RegisterProperty(PropertyId::Float, "float", "none", false, true).AddParser("keyword", "none, left, right");
  267. RegisterProperty(PropertyId::Clear, "clear", "none", false, true).AddParser("keyword", "none, left, right, both");
  268. RegisterProperty(PropertyId::BoxSizing, "box-sizing", "content-box", false, true).AddParser("keyword", "content-box, border-box");
  269. RegisterProperty(PropertyId::ZIndex, "z-index", "auto", false, false).AddParser("keyword", "auto").AddParser("number");
  270. RegisterProperty(PropertyId::Width, "width", "auto", false, true).AddParser("keyword", "auto").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  271. RegisterProperty(PropertyId::MinWidth, "min-width", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  272. RegisterProperty(PropertyId::MaxWidth, "max-width", "none", false, true).AddParser("keyword", "none").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  273. RegisterProperty(PropertyId::Height, "height", "auto", false, true).AddParser("keyword", "auto").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  274. RegisterProperty(PropertyId::MinHeight, "min-height", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  275. RegisterProperty(PropertyId::MaxHeight, "max-height", "none", false, true).AddParser("keyword", "none").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  276. RegisterProperty(PropertyId::LineHeight, "line-height", "1.2", true, true).AddParser("number_length_percent").SetRelativeTarget(RelativeTarget::FontSize);
  277. RegisterProperty(PropertyId::VerticalAlign, "vertical-align", "baseline", false, true)
  278. .AddParser("keyword", "baseline, middle, sub, super, text-top, text-bottom, top, center, bottom")
  279. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::LineHeight);
  280. RegisterProperty(PropertyId::OverflowX, "overflow-x", "visible", false, true).AddParser("keyword", "visible, hidden, auto, scroll");
  281. RegisterProperty(PropertyId::OverflowY, "overflow-y", "visible", false, true).AddParser("keyword", "visible, hidden, auto, scroll");
  282. RegisterShorthand(ShorthandId::Overflow, "overflow", "overflow-x, overflow-y", ShorthandType::Replicate);
  283. RegisterProperty(PropertyId::Clip, "clip", "auto", false, false).AddParser("keyword", "auto, none, always").AddParser("number");
  284. RegisterProperty(PropertyId::Visibility, "visibility", "visible", false, false).AddParser("keyword", "visible, hidden");
  285. RegisterProperty(PropertyId::TextOverflow, "text-overflow", "clip", false, false).AddParser("keyword", "clip, ellipsis").AddParser("string");
  286. // Need some work on this if we are to include images.
  287. RegisterProperty(PropertyId::BackgroundColor, "background-color", "transparent", false, false).AddParser("color");
  288. RegisterShorthand(ShorthandId::Background, "background", "background-color", ShorthandType::FallThrough);
  289. RegisterProperty(PropertyId::Color, "color", "white", true, false).AddParser("color");
  290. RegisterProperty(PropertyId::CaretColor, "caret-color", "auto", true, false).AddParser("keyword", "auto").AddParser("color");
  291. RegisterProperty(PropertyId::ImageColor, "image-color", "white", false, false).AddParser("color");
  292. RegisterProperty(PropertyId::Opacity, "opacity", "1", true, false).AddParser("number");
  293. RegisterProperty(PropertyId::FontFamily, "font-family", "", true, true).AddParser("string");
  294. RegisterProperty(PropertyId::FontStyle, "font-style", "normal", true, true).AddParser("keyword", "normal, italic");
  295. RegisterProperty(PropertyId::FontWeight, "font-weight", "normal", true, true).AddParser("keyword", "normal=400, bold=700").AddParser("number");
  296. RegisterProperty(PropertyId::FontSize, "font-size", "12px", true, true).AddParser("length").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ParentFontSize);
  297. RegisterProperty(PropertyId::FontKerning, "font-kerning", "auto", true, true).AddParser("keyword", "auto, normal, none");
  298. RegisterProperty(PropertyId::LetterSpacing, "letter-spacing", "normal", true, true).AddParser("keyword", "normal").AddParser("length");
  299. RegisterShorthand(ShorthandId::Font, "font", "font-style, font-weight, font-size, font-family", ShorthandType::FallThrough);
  300. RegisterProperty(PropertyId::TextAlign, "text-align", "left", true, true).AddParser("keyword", "left, right, center, justify");
  301. RegisterProperty(PropertyId::TextDecoration, "text-decoration", "none", true, false).AddParser("keyword", "none, underline, overline, line-through");
  302. RegisterProperty(PropertyId::TextTransform, "text-transform", "none", true, true).AddParser("keyword", "none, capitalize, uppercase, lowercase");
  303. RegisterProperty(PropertyId::WhiteSpace, "white-space", "normal", true, true).AddParser("keyword", "normal, pre, nowrap, pre-wrap, pre-line");
  304. RegisterProperty(PropertyId::WordBreak, "word-break", "normal", true, true).AddParser("keyword", "normal, break-all, break-word");
  305. RegisterProperty(PropertyId::RowGap, "row-gap", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  306. RegisterProperty(PropertyId::ColumnGap, "column-gap", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  307. RegisterShorthand(ShorthandId::Gap, "gap", "row-gap, column-gap", ShorthandType::Replicate);
  308. RegisterProperty(PropertyId::Cursor, "cursor", "", true, false).AddParser("string");
  309. // Functional property specifications.
  310. RegisterProperty(PropertyId::Drag, "drag", "none", false, false).AddParser("keyword", "none, drag, drag-drop, block, clone");
  311. RegisterProperty(PropertyId::TabIndex, "tab-index", "none", false, false).AddParser("keyword", "none, auto");
  312. RegisterProperty(PropertyId::Focus, "focus", "auto", true, false).AddParser("keyword", "none, auto");
  313. RegisterProperty(PropertyId::NavUp, "nav-up", "none", false, false).AddParser("keyword", "none, auto, horizontal, vertical").AddParser("string");
  314. RegisterProperty(PropertyId::NavRight, "nav-right", "none", false, false).AddParser("keyword", "none, auto, horizontal, vertical").AddParser("string");
  315. RegisterProperty(PropertyId::NavDown, "nav-down", "none", false, false).AddParser("keyword", "none, auto, horizontal, vertical").AddParser("string");
  316. RegisterProperty(PropertyId::NavLeft, "nav-left", "none", false, false).AddParser("keyword", "none, auto, horizontal, vertical").AddParser("string");
  317. RegisterShorthand(ShorthandId::Nav, "nav", "nav-up, nav-right, nav-down, nav-left", ShorthandType::Box);
  318. RegisterProperty(PropertyId::ScrollbarMargin, "scrollbar-margin", "0", false, false).AddParser("length");
  319. RegisterProperty(PropertyId::OverscrollBehavior, "overscroll-behavior", "auto", false, false).AddParser("keyword", "auto, contain");
  320. RegisterProperty(PropertyId::PointerEvents, "pointer-events", "auto", true, false).AddParser("keyword", "none, auto");
  321. // Perspective and Transform specifications
  322. RegisterProperty(PropertyId::Perspective, "perspective", "none", false, false).AddParser("keyword", "none").AddParser("length");
  323. RegisterProperty(PropertyId::PerspectiveOriginX, "perspective-origin-x", "50%", false, false).AddParser("keyword", "left, center, right").AddParser("length_percent");
  324. RegisterProperty(PropertyId::PerspectiveOriginY, "perspective-origin-y", "50%", false, false).AddParser("keyword", "top, center, bottom").AddParser("length_percent");
  325. RegisterShorthand(ShorthandId::PerspectiveOrigin, "perspective-origin", "perspective-origin-x, perspective-origin-y", ShorthandType::FallThrough);
  326. RegisterProperty(PropertyId::Transform, "transform", "none", false, false).AddParser("transform");
  327. RegisterProperty(PropertyId::TransformOriginX, "transform-origin-x", "50%", false, false).AddParser("keyword", "left, center, right").AddParser("length_percent");
  328. RegisterProperty(PropertyId::TransformOriginY, "transform-origin-y", "50%", false, false).AddParser("keyword", "top, center, bottom").AddParser("length_percent");
  329. RegisterProperty(PropertyId::TransformOriginZ, "transform-origin-z", "0", false, false).AddParser("length");
  330. RegisterShorthand(ShorthandId::TransformOrigin, "transform-origin", "transform-origin-x, transform-origin-y, transform-origin-z", ShorthandType::FallThrough);
  331. RegisterProperty(PropertyId::Transition, "transition", "none", false, false).AddParser("transition");
  332. RegisterProperty(PropertyId::Animation, "animation", "none", false, false).AddParser("animation");
  333. // Decorators and effects
  334. RegisterProperty(PropertyId::Decorator, "decorator", "", false, false).AddParser("decorator");
  335. RegisterProperty(PropertyId::MaskImage, "mask-image", "", false, false).AddParser("decorator");
  336. RegisterProperty(PropertyId::FontEffect, "font-effect", "", true, false).AddParser("font_effect");
  337. RegisterProperty(PropertyId::Filter, "filter", "", false, false).AddParser("filter", "filter");
  338. RegisterProperty(PropertyId::BackdropFilter, "backdrop-filter", "", false, false).AddParser("filter");
  339. RegisterProperty(PropertyId::BoxShadow, "box-shadow", "none", false, false).AddParser("box_shadow");
  340. // Rare properties (not added to computed values)
  341. RegisterProperty(PropertyId::FillImage, "fill-image", "", false, false).AddParser("string");
  342. // Flexbox
  343. RegisterProperty(PropertyId::AlignContent, "align-content", "stretch", false, true).AddParser("keyword", "flex-start, flex-end, center, space-between, space-around, space-evenly, stretch");
  344. RegisterProperty(PropertyId::AlignItems, "align-items", "stretch", false, true).AddParser("keyword", "flex-start, flex-end, center, baseline, stretch");
  345. RegisterProperty(PropertyId::AlignSelf, "align-self", "auto", false, true).AddParser("keyword", "auto, flex-start, flex-end, center, baseline, stretch");
  346. RegisterProperty(PropertyId::FlexBasis, "flex-basis", "auto", false, true).AddParser("keyword", "auto").AddParser("length_percent");
  347. RegisterProperty(PropertyId::FlexDirection, "flex-direction", "row", false, true).AddParser("keyword", "row, row-reverse, column, column-reverse");
  348. RegisterProperty(PropertyId::FlexGrow, "flex-grow", "0", false, true).AddParser("number");
  349. RegisterProperty(PropertyId::FlexShrink, "flex-shrink", "1", false, true).AddParser("number");
  350. RegisterProperty(PropertyId::FlexWrap, "flex-wrap", "nowrap", false, true).AddParser("keyword", "nowrap, wrap, wrap-reverse");
  351. RegisterProperty(PropertyId::JustifyContent, "justify-content", "flex-start", false, true).AddParser("keyword", "flex-start, flex-end, center, space-between, space-around, space-evenly");
  352. RegisterShorthand(ShorthandId::Flex, "flex", "flex-grow, flex-shrink, flex-basis", ShorthandType::Flex);
  353. RegisterShorthand(ShorthandId::FlexFlow, "flex-flow", "flex-direction, flex-wrap", ShorthandType::FallThrough);
  354. // Internationalization properties (internal)
  355. RegisterProperty(PropertyId::RmlUi_Language, "--rmlui-language", "", true, true).AddParser("string");
  356. RegisterProperty(PropertyId::RmlUi_Direction, "--rmlui-direction", "auto", true, true).AddParser("keyword", "auto, ltr, rtl");
  357. RMLUI_ASSERTMSG(instance->properties.shorthand_map->AssertAllInserted(ShorthandId::NumDefinedIds), "Missing specification for one or more Shorthand IDs.");
  358. RMLUI_ASSERTMSG(instance->properties.property_map->AssertAllInserted(PropertyId::NumDefinedIds), "Missing specification for one or more Property IDs.");
  359. // clang-format on
  360. }
  361. } // namespace Rml