StyleSheetSpecification.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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 "PropertyParserColour.h"
  34. #include "PropertyParserKeyword.h"
  35. #include "PropertyParserString.h"
  36. #include "PropertyParserTransform.h"
  37. #include "PropertyShorthandDefinition.h"
  38. #include "IdNameMap.h"
  39. #include "StringCache.h"
  40. namespace Rml {
  41. namespace Core {
  42. static StyleSheetSpecification* instance = nullptr;
  43. struct DefaultStyleSheetParsers {
  44. PropertyParserNumber number = PropertyParserNumber(Property::NUMBER);
  45. PropertyParserNumber length = PropertyParserNumber(Property::LENGTH, Property::PX);
  46. PropertyParserNumber length_percent = PropertyParserNumber(Property::LENGTH_PERCENT, Property::PX);
  47. PropertyParserNumber number_length_percent = PropertyParserNumber(Property::NUMBER_LENGTH_PERCENT, Property::PX);
  48. PropertyParserNumber angle = PropertyParserNumber(Property::ANGLE, Property::RAD);
  49. PropertyParserKeyword keyword = PropertyParserKeyword();
  50. PropertyParserString string = PropertyParserString();
  51. PropertyParserAnimation animation = PropertyParserAnimation(PropertyParserAnimation::ANIMATION_PARSER);
  52. PropertyParserAnimation transition = PropertyParserAnimation(PropertyParserAnimation::TRANSITION_PARSER);
  53. PropertyParserColour color = PropertyParserColour();
  54. PropertyParserTransform transform = PropertyParserTransform();
  55. };
  56. StyleSheetSpecification::StyleSheetSpecification() :
  57. // Reserve space for all defined ids and some more for custom properties
  58. properties((size_t)PropertyId::MaxNumIds, 2 * (size_t)ShorthandId::NumDefinedIds)
  59. {
  60. RMLUI_ASSERT(instance == nullptr);
  61. instance = this;
  62. default_parsers.reset(new DefaultStyleSheetParsers);
  63. }
  64. StyleSheetSpecification::~StyleSheetSpecification()
  65. {
  66. RMLUI_ASSERT(instance == this);
  67. instance = nullptr;
  68. }
  69. PropertyDefinition& StyleSheetSpecification::RegisterProperty(PropertyId id, const String& property_name, const String& default_value, bool inherited, bool forces_layout)
  70. {
  71. return properties.RegisterProperty(property_name, default_value, inherited, forces_layout, id);
  72. }
  73. ShorthandId StyleSheetSpecification::RegisterShorthand(ShorthandId id, const String& shorthand_name, const String& property_names, ShorthandType type)
  74. {
  75. return properties.RegisterShorthand(shorthand_name, property_names, type, id);
  76. }
  77. bool StyleSheetSpecification::Initialise()
  78. {
  79. if (instance == nullptr)
  80. {
  81. new StyleSheetSpecification();
  82. instance->RegisterDefaultParsers();
  83. instance->RegisterDefaultProperties();
  84. }
  85. return true;
  86. }
  87. void StyleSheetSpecification::Shutdown()
  88. {
  89. if (instance != nullptr)
  90. {
  91. delete instance;
  92. }
  93. }
  94. // Registers a parser for use in property definitions.
  95. bool StyleSheetSpecification::RegisterParser(const String& parser_name, PropertyParser* parser)
  96. {
  97. ParserMap::iterator iterator = instance->parsers.find(parser_name);
  98. if (iterator != instance->parsers.end())
  99. {
  100. Log::Message(Log::LT_WARNING, "Parser with name %s already exists!", parser_name.c_str());
  101. return false;
  102. }
  103. instance->parsers[parser_name] = parser;
  104. return true;
  105. }
  106. // Returns the parser registered with a specific name.
  107. PropertyParser* StyleSheetSpecification::GetParser(const String& parser_name)
  108. {
  109. ParserMap::iterator iterator = instance->parsers.find(parser_name);
  110. if (iterator == instance->parsers.end())
  111. return nullptr;
  112. return (*iterator).second;
  113. }
  114. // Registers a property with a new definition.
  115. PropertyDefinition& StyleSheetSpecification::RegisterProperty(const String& property_name, const String& default_value, bool inherited, bool forces_layout)
  116. {
  117. 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.");
  118. return instance->RegisterProperty(PropertyId::Invalid, property_name, default_value, inherited, forces_layout);
  119. }
  120. // Returns a property definition.
  121. const PropertyDefinition* StyleSheetSpecification::GetProperty(const String& property_name)
  122. {
  123. return instance->properties.GetProperty(property_name);
  124. }
  125. const PropertyDefinition* StyleSheetSpecification::GetProperty(PropertyId id)
  126. {
  127. return instance->properties.GetProperty(id);
  128. }
  129. const PropertyIdSet& StyleSheetSpecification::GetRegisteredProperties()
  130. {
  131. return instance->properties.GetRegisteredProperties();
  132. }
  133. const PropertyIdSet & StyleSheetSpecification::GetRegisteredInheritedProperties()
  134. {
  135. return instance->properties.GetRegisteredInheritedProperties();
  136. }
  137. const PropertyIdSet& StyleSheetSpecification::GetRegisteredPropertiesForcingLayout()
  138. {
  139. return instance->properties.GetRegisteredPropertiesForcingLayout();
  140. }
  141. // Registers a shorthand property definition.
  142. ShorthandId StyleSheetSpecification::RegisterShorthand(const String& shorthand_name, const String& property_names, ShorthandType type)
  143. {
  144. RMLUI_ASSERTMSG(instance->properties.property_map->GetId(shorthand_name) == PropertyId::Invalid, "Custom shorthand name matches a property name, please make a unique name.");
  145. 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.");
  146. return instance->properties.RegisterShorthand(shorthand_name, property_names, type);
  147. }
  148. // Returns a shorthand definition.
  149. const ShorthandDefinition* StyleSheetSpecification::GetShorthand(const String& shorthand_name)
  150. {
  151. return instance->properties.GetShorthand(shorthand_name);
  152. }
  153. const ShorthandDefinition* StyleSheetSpecification::GetShorthand(ShorthandId id)
  154. {
  155. return instance->properties.GetShorthand(id);
  156. }
  157. // Parses a property declaration, setting any parsed and validated properties on the given dictionary.
  158. bool StyleSheetSpecification::ParsePropertyDeclaration(PropertyDictionary& dictionary, const String& property_name, const String& property_value)
  159. {
  160. return instance->properties.ParsePropertyDeclaration(dictionary, property_name, property_value);
  161. }
  162. PropertyId StyleSheetSpecification::GetPropertyId(const String& property_name)
  163. {
  164. return instance->properties.property_map->GetId(property_name);
  165. }
  166. ShorthandId StyleSheetSpecification::GetShorthandId(const String& shorthand_name)
  167. {
  168. return instance->properties.shorthand_map->GetId(shorthand_name);
  169. }
  170. const String& StyleSheetSpecification::GetPropertyName(PropertyId id)
  171. {
  172. return instance->properties.property_map->GetName(id);
  173. }
  174. const String& StyleSheetSpecification::GetShorthandName(ShorthandId id)
  175. {
  176. return instance->properties.shorthand_map->GetName(id);
  177. }
  178. PropertyIdSet StyleSheetSpecification::GetShorthandUnderlyingProperties(ShorthandId id)
  179. {
  180. PropertyIdSet result;
  181. const ShorthandDefinition* shorthand = instance->properties.GetShorthand(id);
  182. if (!shorthand)
  183. return result;
  184. for (auto& item : shorthand->items)
  185. {
  186. if (item.type == ShorthandItemType::Property)
  187. {
  188. result.Insert(item.property_id);
  189. }
  190. else if (item.type == ShorthandItemType::Shorthand)
  191. {
  192. // When we have a shorthand pointing to another shorthands, call us recursively. Add the union of the previous result and new properties.
  193. result |= GetShorthandUnderlyingProperties(item.shorthand_id);
  194. }
  195. }
  196. return result;
  197. }
  198. const PropertySpecification& StyleSheetSpecification::GetPropertySpecification()
  199. {
  200. return instance->properties;
  201. }
  202. // Registers RmlUi's default parsers.
  203. void StyleSheetSpecification::RegisterDefaultParsers()
  204. {
  205. RegisterParser("number", &default_parsers->number);
  206. RegisterParser("length", &default_parsers->length);
  207. RegisterParser("length_percent", &default_parsers->length_percent);
  208. RegisterParser("number_length_percent", &default_parsers->number_length_percent);
  209. RegisterParser("angle", &default_parsers->angle);
  210. RegisterParser("keyword", &default_parsers->keyword);
  211. RegisterParser("string", &default_parsers->string);
  212. RegisterParser("animation", &default_parsers->animation);
  213. RegisterParser("transition", &default_parsers->transition);
  214. RegisterParser("color", &default_parsers->color);
  215. RegisterParser("transform", &default_parsers->transform);
  216. }
  217. // Registers RmlUi's default style properties.
  218. void StyleSheetSpecification::RegisterDefaultProperties()
  219. {
  220. /*
  221. Style property specifications (ala RCSS).
  222. Note: Whenever keywords or default values are changed, make sure its computed value is
  223. changed correspondingly, see `ComputedValues.h`.
  224. When adding new properties, it may be desirable to add it to the computed values as well.
  225. Then, make sure to resolve it as appropriate in `ElementStyle.cpp`.
  226. */
  227. RegisterProperty(PropertyId::MarginTop, MARGIN_TOP, "0px", false, true)
  228. .AddParser("keyword", "auto")
  229. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  230. RegisterProperty(PropertyId::MarginRight, MARGIN_RIGHT, "0px", false, true)
  231. .AddParser("keyword", "auto")
  232. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  233. RegisterProperty(PropertyId::MarginBottom, MARGIN_BOTTOM, "0px", false, true)
  234. .AddParser("keyword", "auto")
  235. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  236. RegisterProperty(PropertyId::MarginLeft, MARGIN_LEFT, "0px", false, true)
  237. .AddParser("keyword", "auto")
  238. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  239. RegisterShorthand(ShorthandId::Margin, MARGIN, "margin-top, margin-right, margin-bottom, margin-left", ShorthandType::Box);
  240. RegisterProperty(PropertyId::PaddingTop, PADDING_TOP, "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  241. RegisterProperty(PropertyId::PaddingRight, PADDING_RIGHT, "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  242. RegisterProperty(PropertyId::PaddingBottom, PADDING_BOTTOM, "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  243. RegisterProperty(PropertyId::PaddingLeft, PADDING_LEFT, "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  244. RegisterShorthand(ShorthandId::Padding, PADDING, "padding-top, padding-right, padding-bottom, padding-left", ShorthandType::Box);
  245. RegisterProperty(PropertyId::BorderTopWidth, BORDER_TOP_WIDTH, "0px", false, true).AddParser("length");
  246. RegisterProperty(PropertyId::BorderRightWidth, BORDER_RIGHT_WIDTH, "0px", false, true).AddParser("length");
  247. RegisterProperty(PropertyId::BorderBottomWidth, BORDER_BOTTOM_WIDTH, "0px", false, true).AddParser("length");
  248. RegisterProperty(PropertyId::BorderLeftWidth, BORDER_LEFT_WIDTH, "0px", false, true).AddParser("length");
  249. RegisterShorthand(ShorthandId::BorderWidth, BORDER_WIDTH, "border-top-width, border-right-width, border-bottom-width, border-left-width", ShorthandType::Box);
  250. RegisterProperty(PropertyId::BorderTopColor, BORDER_TOP_COLOR, "black", false, false).AddParser(COLOR);
  251. RegisterProperty(PropertyId::BorderRightColor, BORDER_RIGHT_COLOR, "black", false, false).AddParser(COLOR);
  252. RegisterProperty(PropertyId::BorderBottomColor, BORDER_BOTTOM_COLOR, "black", false, false).AddParser(COLOR);
  253. RegisterProperty(PropertyId::BorderLeftColor, BORDER_LEFT_COLOR, "black", false, false).AddParser(COLOR);
  254. RegisterShorthand(ShorthandId::BorderColor, BORDER_COLOR, "border-top-color, border-right-color, border-bottom-color, border-left-color", ShorthandType::Box);
  255. RegisterShorthand(ShorthandId::BorderTop, BORDER_TOP, "border-top-width, border-top-color", ShorthandType::FallThrough);
  256. RegisterShorthand(ShorthandId::BorderRight, BORDER_RIGHT, "border-right-width, border-right-color", ShorthandType::FallThrough);
  257. RegisterShorthand(ShorthandId::BorderBottom, BORDER_BOTTOM, "border-bottom-width, border-bottom-color", ShorthandType::FallThrough);
  258. RegisterShorthand(ShorthandId::BorderLeft, BORDER_LEFT, "border-left-width, border-left-color", ShorthandType::FallThrough);
  259. RegisterShorthand(ShorthandId::Border, BORDER, "border-top, border-right, border-bottom, border-left", ShorthandType::RecursiveRepeat);
  260. RegisterProperty(PropertyId::Display, DISPLAY, "inline", false, true).AddParser("keyword", "none, block, inline, inline-block");
  261. RegisterProperty(PropertyId::Position, POSITION, "static", false, true).AddParser("keyword", "static, relative, absolute, fixed");
  262. RegisterProperty(PropertyId::Top, TOP, "auto", false, false)
  263. .AddParser("keyword", "auto")
  264. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  265. RegisterProperty(PropertyId::Right, RIGHT, "auto", false, false)
  266. .AddParser("keyword", "auto")
  267. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  268. RegisterProperty(PropertyId::Bottom, BOTTOM, "auto", false, false)
  269. .AddParser("keyword", "auto")
  270. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  271. RegisterProperty(PropertyId::Left, LEFT, "auto", false, false)
  272. .AddParser("keyword", "auto")
  273. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  274. RegisterProperty(PropertyId::Float, FLOAT, "none", false, true).AddParser("keyword", "none, left, right");
  275. RegisterProperty(PropertyId::Clear, CLEAR, "none", false, true).AddParser("keyword", "none, left, right, both");
  276. RegisterProperty(PropertyId::ZIndex, Z_INDEX, "auto", false, false)
  277. .AddParser("keyword", "auto")
  278. .AddParser("number");
  279. RegisterProperty(PropertyId::Width, WIDTH, "auto", false, true)
  280. .AddParser("keyword", "auto")
  281. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  282. RegisterProperty(PropertyId::MinWidth, MIN_WIDTH, "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  283. RegisterProperty(PropertyId::MaxWidth, MAX_WIDTH, "-1px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockWidth);
  284. RegisterProperty(PropertyId::Height, HEIGHT, "auto", false, true)
  285. .AddParser("keyword", "auto")
  286. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  287. RegisterProperty(PropertyId::MinHeight, MIN_HEIGHT, "0px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  288. RegisterProperty(PropertyId::MaxHeight, MAX_HEIGHT, "-1px", false, true).AddParser("length_percent").SetRelativeTarget(RelativeTarget::ContainingBlockHeight);
  289. RegisterProperty(PropertyId::LineHeight, LINE_HEIGHT, "1.2", true, true).AddParser("number_length_percent").SetRelativeTarget(RelativeTarget::FontSize);
  290. RegisterProperty(PropertyId::VerticalAlign, VERTICAL_ALIGN, "baseline", false, true)
  291. .AddParser("keyword", "baseline, middle, sub, super, text-top, text-bottom, top, bottom")
  292. .AddParser("length_percent").SetRelativeTarget(RelativeTarget::LineHeight);
  293. RegisterProperty(PropertyId::OverflowX, OVERFLOW_X, "visible", false, true).AddParser("keyword", "visible, hidden, auto, scroll");
  294. RegisterProperty(PropertyId::OverflowY, OVERFLOW_Y, "visible", false, true).AddParser("keyword", "visible, hidden, auto, scroll");
  295. RegisterShorthand(ShorthandId::Overflow, "overflow", "overflow-x, overflow-y", ShorthandType::Replicate);
  296. RegisterProperty(PropertyId::Clip, CLIP, "auto", true, false).AddParser("keyword", "auto, none").AddParser("number");
  297. RegisterProperty(PropertyId::Visibility, VISIBILITY, "visible", false, false).AddParser("keyword", "visible, hidden");
  298. // Need some work on this if we are to include images.
  299. RegisterProperty(PropertyId::BackgroundColor, BACKGROUND_COLOR, "transparent", false, false).AddParser(COLOR);
  300. RegisterShorthand(ShorthandId::Background, BACKGROUND, BACKGROUND_COLOR, ShorthandType::FallThrough);
  301. RegisterProperty(PropertyId::Color, COLOR, "white", true, false).AddParser(COLOR);
  302. RegisterProperty(PropertyId::ImageColor, IMAGE_COLOR, "white", false, false).AddParser(COLOR);
  303. RegisterProperty(PropertyId::Opacity, OPACITY, "1", true, false).AddParser("number");
  304. RegisterProperty(PropertyId::FontFamily, FONT_FAMILY, "", true, true).AddParser("string");
  305. RegisterProperty(PropertyId::FontStyle, FONT_STYLE, "normal", true, true).AddParser("keyword", "normal, italic");
  306. RegisterProperty(PropertyId::FontWeight, FONT_WEIGHT, "normal", true, true).AddParser("keyword", "normal, bold");
  307. RegisterProperty(PropertyId::FontSize, FONT_SIZE, "12px", true, true).AddParser("length").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ParentFontSize);
  308. RegisterShorthand(ShorthandId::Font, FONT, "font-style, font-weight, font-size, font-family", ShorthandType::FallThrough);
  309. RegisterProperty(PropertyId::TextAlign, TEXT_ALIGN, LEFT, true, true).AddParser("keyword", "left, right, center, justify");
  310. RegisterProperty(PropertyId::TextDecoration, TEXT_DECORATION, "none", true, false).AddParser("keyword", "none, underline, overline, line-through");
  311. RegisterProperty(PropertyId::TextTransform, TEXT_TRANSFORM, "none", true, true).AddParser("keyword", "none, capitalize, uppercase, lowercase");
  312. RegisterProperty(PropertyId::WhiteSpace, WHITE_SPACE, "normal", true, true).AddParser("keyword", "normal, pre, nowrap, pre-wrap, pre-line");
  313. RegisterProperty(PropertyId::Cursor, CURSOR, "", true, false).AddParser("string");
  314. // Functional property specifications.
  315. RegisterProperty(PropertyId::Drag, DRAG, "none", false, false).AddParser("keyword", "none, drag, drag-drop, block, clone");
  316. RegisterProperty(PropertyId::TabIndex, TAB_INDEX, "none", false, false).AddParser("keyword", "none, auto");
  317. RegisterProperty(PropertyId::Focus, FOCUS, "auto", true, false).AddParser("keyword", "none, auto");
  318. RegisterProperty(PropertyId::ScrollbarMargin, SCROLLBAR_MARGIN, "0", false, false).AddParser("length");
  319. RegisterProperty(PropertyId::PointerEvents, POINTER_EVENTS, "auto", true, false).AddParser("keyword", "none, auto");
  320. // Perspective and Transform specifications
  321. RegisterProperty(PropertyId::Perspective, PERSPECTIVE, "none", false, false).AddParser("keyword", "none").AddParser("length");
  322. RegisterProperty(PropertyId::PerspectiveOriginX, PERSPECTIVE_ORIGIN_X, "50%", false, false).AddParser("keyword", "left, center, right").AddParser("length_percent");
  323. RegisterProperty(PropertyId::PerspectiveOriginY, PERSPECTIVE_ORIGIN_Y, "50%", false, false).AddParser("keyword", "top, center, bottom").AddParser("length_percent");
  324. RegisterShorthand(ShorthandId::PerspectiveOrigin, PERSPECTIVE_ORIGIN, "perspective-origin-x, perspective-origin-y", ShorthandType::FallThrough);
  325. RegisterProperty(PropertyId::Transform, TRANSFORM, "none", false, false).AddParser(TRANSFORM);
  326. RegisterProperty(PropertyId::TransformOriginX, TRANSFORM_ORIGIN_X, "50%", false, false).AddParser("keyword", "left, center, right").AddParser("length_percent");
  327. RegisterProperty(PropertyId::TransformOriginY, TRANSFORM_ORIGIN_Y, "50%", false, false).AddParser("keyword", "top, center, bottom").AddParser("length_percent");
  328. RegisterProperty(PropertyId::TransformOriginZ, TRANSFORM_ORIGIN_Z, "0", false, false).AddParser("length");
  329. RegisterShorthand(ShorthandId::TransformOrigin, TRANSFORM_ORIGIN, "transform-origin-x, transform-origin-y, transform-origin-z", ShorthandType::FallThrough);
  330. RegisterProperty(PropertyId::Transition, TRANSITION, "none", false, false).AddParser(TRANSITION);
  331. RegisterProperty(PropertyId::Animation, ANIMATION, "none", false, false).AddParser(ANIMATION);
  332. RegisterProperty(PropertyId::Decorator, "decorator", "", false, false).AddParser("string");
  333. RegisterProperty(PropertyId::FontEffect, "font-effect", "", true, false).AddParser("string");
  334. // Rare properties (not added to computed values)
  335. RegisterProperty(PropertyId::FillImage, FILL_IMAGE, "", false, false).AddParser("string");
  336. instance->properties.property_map->AssertAllInserted(PropertyId::NumDefinedIds);
  337. instance->properties.shorthand_map->AssertAllInserted(ShorthandId::NumDefinedIds);
  338. }
  339. }
  340. }