StyleSheetSpecification.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #include "../../Include/RmlUi/Core/StyleSheetSpecification.h"
  29. #include "../../Include/RmlUi/Core/PropertyIdSet.h"
  30. #include "../../Include/RmlUi/Core/PropertyDefinition.h"
  31. #include "PropertyParserNumber.h"
  32. #include "PropertyParserAnimation.h"
  33. #include "PropertyParserRatio.h"
  34. #include "PropertyParserColour.h"
  35. #include "PropertyParserDecorator.h"
  36. #include "PropertyParserFontEffect.h"
  37. #include "PropertyParserKeyword.h"
  38. #include "PropertyParserString.h"
  39. #include "PropertyParserTransform.h"
  40. #include "PropertyShorthandDefinition.h"
  41. #include "IdNameMap.h"
  42. namespace Rml {
  43. static StyleSheetSpecification* instance = nullptr;
  44. struct DefaultStyleSheetParsers {
  45. PropertyParserNumber number = PropertyParserNumber(Property::NUMBER);
  46. PropertyParserNumber length = PropertyParserNumber(Property::LENGTH, Property::PX);
  47. PropertyParserNumber length_percent = PropertyParserNumber(Property::LENGTH_PERCENT, Property::PX);
  48. PropertyParserNumber number_length_percent = PropertyParserNumber(Property::NUMBER_LENGTH_PERCENT, Property::PX);
  49. PropertyParserNumber angle = PropertyParserNumber(Property::ANGLE, Property::RAD);
  50. PropertyParserKeyword keyword = PropertyParserKeyword();
  51. PropertyParserString string = PropertyParserString();
  52. PropertyParserAnimation animation = PropertyParserAnimation(PropertyParserAnimation::ANIMATION_PARSER);
  53. PropertyParserAnimation transition = PropertyParserAnimation(PropertyParserAnimation::TRANSITION_PARSER);
  54. PropertyParserColour color = PropertyParserColour();
  55. PropertyParserDecorator decorator = PropertyParserDecorator();
  56. PropertyParserFontEffect font_effect = PropertyParserFontEffect();
  57. PropertyParserTransform transform = PropertyParserTransform();
  58. PropertyParserRatio ratio = PropertyParserRatio();
  59. PropertyParserNumber resolution = PropertyParserNumber(Property::X);
  60. };
  61. StyleSheetSpecification::StyleSheetSpecification() :
  62. // Reserve space for all defined ids and some more for custom properties
  63. properties((size_t)PropertyId::MaxNumIds, 2 * (size_t)ShorthandId::NumDefinedIds)
  64. {
  65. RMLUI_ASSERT(instance == nullptr);
  66. instance = this;
  67. default_parsers.reset(new DefaultStyleSheetParsers);
  68. }
  69. StyleSheetSpecification::~StyleSheetSpecification()
  70. {
  71. RMLUI_ASSERT(instance == this);
  72. instance = nullptr;
  73. }
  74. PropertyDefinition& StyleSheetSpecification::RegisterProperty(PropertyId id, const String& property_name, const String& default_value, bool inherited, bool forces_layout)
  75. {
  76. return properties.RegisterProperty(property_name, default_value, inherited, forces_layout, id);
  77. }
  78. ShorthandId StyleSheetSpecification::RegisterShorthand(ShorthandId id, const String& shorthand_name, const String& property_names, ShorthandType type)
  79. {
  80. return properties.RegisterShorthand(shorthand_name, property_names, type, id);
  81. }
  82. bool StyleSheetSpecification::Initialise()
  83. {
  84. if (instance == nullptr)
  85. {
  86. new StyleSheetSpecification();
  87. instance->RegisterDefaultParsers();
  88. instance->RegisterDefaultProperties();
  89. }
  90. return true;
  91. }
  92. void StyleSheetSpecification::Shutdown()
  93. {
  94. if (instance != nullptr)
  95. {
  96. delete instance;
  97. }
  98. }
  99. // Registers a parser for use in property definitions.
  100. bool StyleSheetSpecification::RegisterParser(const String& parser_name, PropertyParser* parser)
  101. {
  102. ParserMap::iterator iterator = instance->parsers.find(parser_name);
  103. if (iterator != instance->parsers.end())
  104. {
  105. Log::Message(Log::LT_WARNING, "Parser with name %s already exists!", parser_name.c_str());
  106. return false;
  107. }
  108. instance->parsers[parser_name] = parser;
  109. return true;
  110. }
  111. // Returns the parser registered with a specific name.
  112. PropertyParser* StyleSheetSpecification::GetParser(const String& parser_name)
  113. {
  114. ParserMap::iterator iterator = instance->parsers.find(parser_name);
  115. if (iterator == instance->parsers.end())
  116. return nullptr;
  117. return (*iterator).second;
  118. }
  119. // Registers a property with a new definition.
  120. PropertyDefinition& StyleSheetSpecification::RegisterProperty(const String& property_name, const String& default_value, bool inherited, bool forces_layout)
  121. {
  122. RMLUI_ASSERTMSG((size_t)instance->properties.property_map->GetId(property_name) < (size_t)PropertyId::FirstCustomId, "Custom property name matches an internal property, please make a unique name for the given property.");
  123. return instance->RegisterProperty(PropertyId::Invalid, property_name, default_value, inherited, forces_layout);
  124. }
  125. // Returns a property definition.
  126. const PropertyDefinition* StyleSheetSpecification::GetProperty(const String& property_name)
  127. {
  128. return instance->properties.GetProperty(property_name);
  129. }
  130. const PropertyDefinition* StyleSheetSpecification::GetProperty(PropertyId id)
  131. {
  132. return instance->properties.GetProperty(id);
  133. }
  134. const PropertyIdSet& StyleSheetSpecification::GetRegisteredProperties()
  135. {
  136. return instance->properties.GetRegisteredProperties();
  137. }
  138. const PropertyIdSet & StyleSheetSpecification::GetRegisteredInheritedProperties()
  139. {
  140. return instance->properties.GetRegisteredInheritedProperties();
  141. }
  142. const PropertyIdSet& StyleSheetSpecification::GetRegisteredPropertiesForcingLayout()
  143. {
  144. return instance->properties.GetRegisteredPropertiesForcingLayout();
  145. }
  146. // Registers a shorthand property definition.
  147. ShorthandId StyleSheetSpecification::RegisterShorthand(const String& shorthand_name, const String& property_names, ShorthandType type)
  148. {
  149. RMLUI_ASSERTMSG(instance->properties.property_map->GetId(shorthand_name) == PropertyId::Invalid, "Custom shorthand name matches a property name, please make a unique name.");
  150. RMLUI_ASSERTMSG((size_t)instance->properties.shorthand_map->GetId(shorthand_name) < (size_t)ShorthandId::FirstCustomId, "Custom shorthand name matches an internal shorthand, please make a unique name for the given shorthand property.");
  151. return instance->properties.RegisterShorthand(shorthand_name, property_names, type);
  152. }
  153. // Returns a shorthand definition.
  154. const ShorthandDefinition* StyleSheetSpecification::GetShorthand(const String& shorthand_name)
  155. {
  156. return instance->properties.GetShorthand(shorthand_name);
  157. }
  158. const ShorthandDefinition* StyleSheetSpecification::GetShorthand(ShorthandId id)
  159. {
  160. return instance->properties.GetShorthand(id);
  161. }
  162. // Parses a property declaration, setting any parsed and validated properties on the given dictionary.
  163. bool StyleSheetSpecification::ParsePropertyDeclaration(PropertyDictionary& dictionary, const String& property_name, const String& property_value)
  164. {
  165. return instance->properties.ParsePropertyDeclaration(dictionary, property_name, property_value);
  166. }
  167. PropertyId StyleSheetSpecification::GetPropertyId(const String& property_name)
  168. {
  169. return instance->properties.property_map->GetId(property_name);
  170. }
  171. ShorthandId StyleSheetSpecification::GetShorthandId(const String& shorthand_name)
  172. {
  173. return instance->properties.shorthand_map->GetId(shorthand_name);
  174. }
  175. const String& StyleSheetSpecification::GetPropertyName(PropertyId id)
  176. {
  177. return instance->properties.property_map->GetName(id);
  178. }
  179. const String& StyleSheetSpecification::GetShorthandName(ShorthandId id)
  180. {
  181. return instance->properties.shorthand_map->GetName(id);
  182. }
  183. PropertyIdSet StyleSheetSpecification::GetShorthandUnderlyingProperties(ShorthandId id)
  184. {
  185. PropertyIdSet result;
  186. const ShorthandDefinition* shorthand = instance->properties.GetShorthand(id);
  187. if (!shorthand)
  188. return result;
  189. for (auto& item : shorthand->items)
  190. {
  191. if (item.type == ShorthandItemType::Property)
  192. {
  193. result.Insert(item.property_id);
  194. }
  195. else if (item.type == ShorthandItemType::Shorthand)
  196. {
  197. // When we have a shorthand pointing to another shorthands, call us recursively. Add the union of the previous result and new properties.
  198. result |= GetShorthandUnderlyingProperties(item.shorthand_id);
  199. }
  200. }
  201. return result;
  202. }
  203. const PropertySpecification& StyleSheetSpecification::GetPropertySpecification()
  204. {
  205. return instance->properties;
  206. }
  207. // Registers RmlUi's default parsers.
  208. void StyleSheetSpecification::RegisterDefaultParsers()
  209. {
  210. RegisterParser("number", &default_parsers->number);
  211. RegisterParser("length", &default_parsers->length);
  212. RegisterParser("length_percent", &default_parsers->length_percent);
  213. RegisterParser("number_length_percent", &default_parsers->number_length_percent);
  214. RegisterParser("angle", &default_parsers->angle);
  215. RegisterParser("keyword", &default_parsers->keyword);
  216. RegisterParser("string", &default_parsers->string);
  217. RegisterParser("animation", &default_parsers->animation);
  218. RegisterParser("transition", &default_parsers->transition);
  219. RegisterParser("color", &default_parsers->color);
  220. RegisterParser("decorator", &default_parsers->decorator);
  221. RegisterParser("font_effect", &default_parsers->font_effect);
  222. RegisterParser("transform", &default_parsers->transform);
  223. RegisterParser("ratio", &default_parsers->ratio);
  224. RegisterParser("resolution", &default_parsers->resolution);
  225. }
  226. // Registers RmlUi's default style properties.
  227. void StyleSheetSpecification::RegisterDefaultProperties()
  228. {
  229. /*
  230. Style property specifications (ala RCSS).
  231. Note: Whenever keywords or default values are changed, make sure its computed value is
  232. changed correspondingly, see `ComputedValues.h`.
  233. When adding new properties, it may be desirable to add it to the computed values as well.
  234. Then, make sure to resolve it as appropriate in `ElementStyle.cpp`.
  235. */
  236. RegisterProperty(PropertyId::MarginTop, "margin-top", "0px", false, true)
  237. .AddParser("keyword", "auto")
  238. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  239. RegisterProperty(PropertyId::MarginRight, "margin-right", "0px", false, true)
  240. .AddParser("keyword", "auto")
  241. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  242. RegisterProperty(PropertyId::MarginBottom, "margin-bottom", "0px", false, true)
  243. .AddParser("keyword", "auto")
  244. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  245. RegisterProperty(PropertyId::MarginLeft, "margin-left", "0px", false, true)
  246. .AddParser("keyword", "auto")
  247. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  248. RegisterShorthand(ShorthandId::Margin, "margin", "margin-top, margin-right, margin-bottom, margin-left", ShorthandType::Box);
  249. RegisterProperty(PropertyId::PaddingTop, "padding-top", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  250. RegisterProperty(PropertyId::PaddingRight, "padding-right", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  251. RegisterProperty(PropertyId::PaddingBottom, "padding-bottom", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  252. RegisterProperty(PropertyId::PaddingLeft, "padding-left", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  253. RegisterShorthand(ShorthandId::Padding, "padding", "padding-top, padding-right, padding-bottom, padding-left", ShorthandType::Box);
  254. RegisterProperty(PropertyId::BorderTopWidth, "border-top-width", "0px", false, true).AddParser("length");
  255. RegisterProperty(PropertyId::BorderRightWidth, "border-right-width", "0px", false, true).AddParser("length");
  256. RegisterProperty(PropertyId::BorderBottomWidth, "border-bottom-width", "0px", false, true).AddParser("length");
  257. RegisterProperty(PropertyId::BorderLeftWidth, "border-left-width", "0px", false, true).AddParser("length");
  258. RegisterShorthand(ShorthandId::BorderWidth, "border-width", "border-top-width, border-right-width, border-bottom-width, border-left-width", ShorthandType::Box);
  259. RegisterProperty(PropertyId::BorderTopColor, "border-top-color", "black", false, false).AddParser("color");
  260. RegisterProperty(PropertyId::BorderRightColor, "border-right-color", "black", false, false).AddParser("color");
  261. RegisterProperty(PropertyId::BorderBottomColor, "border-bottom-color", "black", false, false).AddParser("color");
  262. RegisterProperty(PropertyId::BorderLeftColor, "border-left-color", "black", false, false).AddParser("color");
  263. RegisterShorthand(ShorthandId::BorderColor, "border-color", "border-top-color, border-right-color, border-bottom-color, border-left-color", ShorthandType::Box);
  264. RegisterShorthand(ShorthandId::BorderTop, "border-top", "border-top-width, border-top-color", ShorthandType::FallThrough);
  265. RegisterShorthand(ShorthandId::BorderRight, "border-right", "border-right-width, border-right-color", ShorthandType::FallThrough);
  266. RegisterShorthand(ShorthandId::BorderBottom, "border-bottom", "border-bottom-width, border-bottom-color", ShorthandType::FallThrough);
  267. RegisterShorthand(ShorthandId::BorderLeft, "border-left", "border-left-width, border-left-color", ShorthandType::FallThrough);
  268. RegisterShorthand(ShorthandId::Border, "border", "border-top, border-right, border-bottom, border-left", ShorthandType::RecursiveRepeat);
  269. RegisterProperty(PropertyId::BorderTopLeftRadius, "border-top-left-radius", "0px", false, false).AddParser("length");
  270. RegisterProperty(PropertyId::BorderTopRightRadius, "border-top-right-radius", "0px", false, false).AddParser("length");
  271. RegisterProperty(PropertyId::BorderBottomRightRadius, "border-bottom-right-radius", "0px", false, false).AddParser("length");
  272. RegisterProperty(PropertyId::BorderBottomLeftRadius, "border-bottom-left-radius", "0px", false, false).AddParser("length");
  273. RegisterShorthand(ShorthandId::BorderRadius, "border-radius", "border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius", ShorthandType::Box);
  274. RegisterProperty(PropertyId::Display, "display", "inline", false, true).AddParser("keyword", "none, block, inline, inline-block, table, table-row, table-row-group, table-column, table-column-group, table-cell");
  275. RegisterProperty(PropertyId::Position, "position", "static", false, true).AddParser("keyword", "static, relative, absolute, fixed");
  276. RegisterProperty(PropertyId::Top, "top", "auto", false, false)
  277. .AddParser("keyword", "auto")
  278. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  279. RegisterProperty(PropertyId::Right, "right", "auto", false, false)
  280. .AddParser("keyword", "auto")
  281. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  282. RegisterProperty(PropertyId::Bottom, "bottom", "auto", false, false)
  283. .AddParser("keyword", "auto")
  284. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  285. RegisterProperty(PropertyId::Left, "left", "auto", false, false)
  286. .AddParser("keyword", "auto")
  287. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  288. RegisterProperty(PropertyId::Float, "float", "none", false, true).AddParser("keyword", "none, left, right");
  289. RegisterProperty(PropertyId::Clear, "clear", "none", false, true).AddParser("keyword", "none, left, right, both");
  290. RegisterProperty(PropertyId::BoxSizing, "box-sizing", "content-box", false, true).AddParser("keyword", "content-box, border-box");
  291. RegisterProperty(PropertyId::ZIndex, "z-index", "auto", false, false)
  292. .AddParser("keyword", "auto")
  293. .AddParser("number");
  294. RegisterProperty(PropertyId::Width, "width", "auto", false, true)
  295. .AddParser("keyword", "auto")
  296. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  297. RegisterProperty(PropertyId::MinWidth, "min-width", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  298. RegisterProperty(PropertyId::MaxWidth, "max-width", "-1px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  299. RegisterProperty(PropertyId::Height, "height", "auto", false, true)
  300. .AddParser("keyword", "auto")
  301. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  302. RegisterProperty(PropertyId::MinHeight, "min-height", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  303. RegisterProperty(PropertyId::MaxHeight, "max-height", "-1px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  304. RegisterProperty(PropertyId::LineHeight, "line-height", "1.2", true, true).AddParser("number_length_percent").SetRelativeTarget(RelativeTarget::FontSize);
  305. RegisterProperty(PropertyId::VerticalAlign, "vertical-align", "baseline", false, true)
  306. .AddParser("keyword", "baseline, middle, sub, super, text-top, text-bottom, top, bottom")
  307. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::LineHeight);
  308. RegisterProperty(PropertyId::OverflowX, "overflow-x", "visible", false, true).AddParser("keyword", "visible, hidden, auto, scroll");
  309. RegisterProperty(PropertyId::OverflowY, "overflow-y", "visible", false, true).AddParser("keyword", "visible, hidden, auto, scroll");
  310. RegisterShorthand(ShorthandId::Overflow, "overflow", "overflow-x, overflow-y", ShorthandType::Replicate);
  311. RegisterProperty(PropertyId::Clip, "clip", "auto", true, false).AddParser("keyword", "auto, none").AddParser("number");
  312. RegisterProperty(PropertyId::Visibility, "visibility", "visible", false, false).AddParser("keyword", "visible, hidden");
  313. // Need some work on this if we are to include images.
  314. RegisterProperty(PropertyId::BackgroundColor, "background-color", "transparent", false, false).AddParser("color");
  315. RegisterShorthand(ShorthandId::Background, "background", "background-color", ShorthandType::FallThrough);
  316. RegisterProperty(PropertyId::Color, "color", "white", true, false).AddParser("color");
  317. RegisterProperty(PropertyId::CaretColor, "caret-color", "auto", true, false).AddParser("keyword", "auto").AddParser("color");
  318. RegisterProperty(PropertyId::ImageColor, "image-color", "white", false, false).AddParser("color");
  319. RegisterProperty(PropertyId::Opacity, "opacity", "1", true, false).AddParser("number");
  320. RegisterProperty(PropertyId::FontFamily, "font-family", "", true, true).AddParser("string");
  321. RegisterProperty(PropertyId::FontStyle, "font-style", "normal", true, true).AddParser("keyword", "normal, italic");
  322. RegisterProperty(PropertyId::FontWeight, "font-weight", "normal", true, true).AddParser("keyword", "normal, bold");
  323. RegisterProperty(PropertyId::FontSize, "font-size", "12px", true, true).AddParser("length").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ParentFontSize);
  324. RegisterShorthand(ShorthandId::Font, "font", "font-style, font-weight, font-size, font-family", ShorthandType::FallThrough);
  325. RegisterProperty(PropertyId::TextAlign, "text-align", "left", true, true).AddParser("keyword", "left, right, center, justify");
  326. RegisterProperty(PropertyId::TextDecoration, "text-decoration", "none", true, false).AddParser("keyword", "none, underline, overline, line-through");
  327. RegisterProperty(PropertyId::TextTransform, "text-transform", "none", true, true).AddParser("keyword", "none, capitalize, uppercase, lowercase");
  328. RegisterProperty(PropertyId::WhiteSpace, "white-space", "normal", true, true).AddParser("keyword", "normal, pre, nowrap, pre-wrap, pre-line");
  329. RegisterProperty(PropertyId::WordBreak, "word-break", "normal", true, true).AddParser("keyword", "normal, break-all, break-word");
  330. RegisterProperty(PropertyId::RowGap, "row-gap", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  331. RegisterProperty(PropertyId::ColumnGap, "column-gap", "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  332. RegisterShorthand(ShorthandId::Gap, "gap", "row-gap, column-gap", ShorthandType::Replicate);
  333. RegisterProperty(PropertyId::Cursor, "cursor", "", true, false).AddParser("string");
  334. // Functional property specifications.
  335. RegisterProperty(PropertyId::Drag, "drag", "none", false, false).AddParser("keyword", "none, drag, drag-drop, block, clone");
  336. RegisterProperty(PropertyId::TabIndex, "tab-index", "none", false, false).AddParser("keyword", "none, auto");
  337. RegisterProperty(PropertyId::Focus, "focus", "auto", true, false).AddParser("keyword", "none, auto");
  338. RegisterProperty(PropertyId::ScrollbarMargin, "scrollbar-margin", "0", false, false).AddParser("length");
  339. RegisterProperty(PropertyId::PointerEvents, "pointer-events", "auto", true, false).AddParser("keyword", "none, auto");
  340. // Perspective and Transform specifications
  341. RegisterProperty(PropertyId::Perspective, "perspective", "none", false, false).AddParser("keyword", "none").AddParser("length");
  342. RegisterProperty(PropertyId::PerspectiveOriginX, "perspective-origin-x", "50%", false, false).AddParser("keyword", "left, center, right").AddParser("length_percent");
  343. RegisterProperty(PropertyId::PerspectiveOriginY, "perspective-origin-y", "50%", false, false).AddParser("keyword", "top, center, bottom").AddParser("length_percent");
  344. RegisterShorthand(ShorthandId::PerspectiveOrigin, "perspective-origin", "perspective-origin-x, perspective-origin-y", ShorthandType::FallThrough);
  345. RegisterProperty(PropertyId::Transform, "transform", "none", false, false).AddParser("transform");
  346. RegisterProperty(PropertyId::TransformOriginX, "transform-origin-x", "50%", false, false).AddParser("keyword", "left, center, right").AddParser("length_percent");
  347. RegisterProperty(PropertyId::TransformOriginY, "transform-origin-y", "50%", false, false).AddParser("keyword", "top, center, bottom").AddParser("length_percent");
  348. RegisterProperty(PropertyId::TransformOriginZ, "transform-origin-z", "0", false, false).AddParser("length");
  349. RegisterShorthand(ShorthandId::TransformOrigin, "transform-origin", "transform-origin-x, transform-origin-y, transform-origin-z", ShorthandType::FallThrough);
  350. RegisterProperty(PropertyId::Transition, "transition", "none", false, false).AddParser("transition");
  351. RegisterProperty(PropertyId::Animation, "animation", "none", false, false).AddParser("animation");
  352. RegisterProperty(PropertyId::Decorator, "decorator", "", false, false).AddParser("decorator");
  353. RegisterProperty(PropertyId::FontEffect, "font-effect", "", true, false).AddParser("font_effect");
  354. // Rare properties (not added to computed values)
  355. RegisterProperty(PropertyId::FillImage, "fill-image", "", false, false).AddParser("string");
  356. RMLUI_ASSERTMSG(instance->properties.shorthand_map->AssertAllInserted(ShorthandId::NumDefinedIds), "Missing specification for one or more Shorthand IDs.");
  357. RMLUI_ASSERTMSG(instance->properties.property_map->AssertAllInserted(PropertyId::NumDefinedIds), "Missing specification for one or more Property IDs.");
  358. }
  359. } // namespace Rml