Browse Source

Clean up property specification

Michael Ragazzon 6 years ago
parent
commit
0f7ded141e

+ 1 - 0
Cmake/FileList.cmake

@@ -48,6 +48,7 @@ set(Core_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/FontFamily.h
     ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/precompiled.h
     ${PROJECT_SOURCE_DIR}/Source/Core/GeometryDatabase.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/IdNameMap.h
     ${PROJECT_SOURCE_DIR}/Source/Core/LayoutBlockBox.h
     ${PROJECT_SOURCE_DIR}/Source/Core/LayoutBlockBoxSpace.h
     ${PROJECT_SOURCE_DIR}/Source/Core/LayoutEngine.h

+ 12 - 107
Include/RmlUi/Core/PropertySpecification.h

@@ -39,86 +39,10 @@ namespace Core {
 
 class StyleSheetSpecification;
 class PropertyDictionary;
+class PropertyIdNameMap;
+class ShorthandIdNameMap;
 struct ShorthandDefinition;
 
-
-// todo: We probably don't need to expose this in a public header
-template <typename ID>
-class IdNameMap {
-	std::vector<String> name_map;  // IDs are indices into the name_map
-	UnorderedMap<String, ID> reverse_map;
-
-protected:
-	IdNameMap(size_t num_ids_to_reserve) {
-		static_assert((int)ID::Invalid == 0, "Invalid id must be zero");
-		name_map.reserve(num_ids_to_reserve);
-		reverse_map.reserve(num_ids_to_reserve);
-		AddPair(ID::Invalid, "invalid");
-	}
-
-public:
-	void AddPair(ID id, const String& name) {
-		// Should only be used for defined IDs
-		if ((size_t)id >= name_map.size())
-			name_map.resize(1 + (size_t)id);
-		name_map[(size_t)id] = name;
-		bool inserted = reverse_map.emplace(name, id).second;
-		RMLUI_ASSERT(inserted);
-		(void)inserted;
-	}
-
-	void AssertAllInserted(ID last_property_inserted) const {
-		ptrdiff_t cnt = std::count_if(name_map.begin(), name_map.end(), [](const String& name) { return !name.empty(); });
-		RMLUI_ASSERT(cnt == (ptrdiff_t)last_property_inserted && reverse_map.size() == (size_t)last_property_inserted);
-		(void)cnt;
-	}
-
-	ID GetId(const String& name) const
-	{
-		auto it = reverse_map.find(name);
-		if (it != reverse_map.end())
-			return it->second;
-		return ID::Invalid;
-	}
-	const String& GetName(ID id) const
-	{
-		if (static_cast<size_t>(id) < name_map.size())
-			return name_map[static_cast<size_t>(id)];
-		return name_map[static_cast<size_t>(ID::Invalid)];
-	}
-
-	ID GetOrCreateId(const String& name)
-	{
-		// All predefined properties must be set before adding custom properties here
-		RMLUI_ASSERT(name_map.size() == reverse_map.size());
-
-		ID next_id = static_cast<ID>(name_map.size());
-
-		// Only insert if not already in list
-		auto pair = reverse_map.emplace(name, next_id);
-		const auto& it = pair.first;
-		bool inserted = pair.second;
-
-		if (inserted)
-			name_map.push_back(name);
-
-		// Return the property id that already existed, or the new one if inserted
-		return it->second;
-	}
-};
-
-class PropertyIdNameMap : public IdNameMap<PropertyId> {
-public:
-	PropertyIdNameMap(size_t reserve_num_properties) : IdNameMap(reserve_num_properties) {}
-};
-
-class ShorthandIdNameMap : public IdNameMap<ShorthandId> {
-public:
-	ShorthandIdNameMap(size_t reserve_num_shorthands) : IdNameMap(2 * (size_t)ShorthandId::NumDefinedIds) {}
-};
-
-
-
 enum class ShorthandType
 {
 	// Normal; properties that fail to parse fall-through to the next until they parse correctly, and any
@@ -134,19 +58,6 @@ enum class ShorthandType
 	RecursiveCommaSeparated
 };
 
-enum class ShorthandItemType { Invalid, Property, Shorthand };
-struct ShorthandItemId {
-	ShorthandItemId() : type(ShorthandItemType::Invalid) {}
-	ShorthandItemId(PropertyId id) : type(ShorthandItemType::Property), property_id(id) {}
-	ShorthandItemId(ShorthandId id) : type(ShorthandItemType::Shorthand), shorthand_id(id) {}
-
-	ShorthandItemType type;
-	union {
-		PropertyId property_id;
-		ShorthandId shorthand_id;
-	};
-};
-using ShorthandItemIdList = std::vector<ShorthandItemId>;
 
 /**
 	A property specification stores a group of property definitions.
@@ -174,12 +85,10 @@ public:
 	const PropertyDefinition* GetProperty(PropertyId id) const;
 	const PropertyDefinition* GetProperty(const String& property_name) const;
 
-	/// Returns the list of the names of all registered property definitions.
-	/// @return The list with stored property names.
+	/// Returns the id set of all registered property definitions.
 	const PropertyIdSet& GetRegisteredProperties() const;
 
-	/// Returns the list of the names of all registered inherited property definitions.
-	/// @return The list with stored property names.
+	/// Returns the id set of all registered inherited property definitions.
 	const PropertyIdSet& GetRegisteredInheritedProperties() const;
 
 	/// Registers a shorthand property definition.
@@ -197,33 +106,29 @@ public:
 
 	/// Parse declaration by name, whether its a property or shorthand.
 	bool ParsePropertyDeclaration(PropertyDictionary& dictionary, const String& property_name, const String& property_value, const String& source_file = "", int source_line_number = 0) const;
-
+	/// Parse property declaration by ID
 	bool ParsePropertyDeclaration(PropertyDictionary& dictionary, PropertyId property_id, const String& property_value, const String& source_file = "", int source_line_number = 0) const;
-
-	/// Parses a property declaration, setting any parsed and validated properties on the given dictionary.
-	/// @param dictionary The property dictionary which will hold all declared properties.
-	/// @param property_name The name of the declared property.
-	/// @param property_value The values the property is being set to.
+	/// Parses a shorthand declaration, setting any parsed and validated properties on the given dictionary.
 	/// @return True if all properties were parsed successfully, false otherwise.
 	bool ParseShorthandDeclaration(PropertyDictionary& dictionary, ShorthandId shorthand_id, const String& property_value, const String& source_file = "", int source_line_number = 0) const;
+
 	/// Sets all undefined properties in the dictionary to their defaults.
-	/// @param dictionary[in] The dictionary to set the default values on.
+	/// @param dictionary[in-out] The dictionary to set the default values on.
 	void SetPropertyDefaults(PropertyDictionary& dictionary) const;
 
 	/// Returns the properties of dictionary converted to a string.
 	String PropertiesToString(const PropertyDictionary& dictionary) const;
 
 private:
-	typedef std::vector< PropertyDefinition* > Properties;
-	typedef std::vector< ShorthandDefinition* > Shorthands;
+	using Properties = std::vector< UniquePtr<PropertyDefinition> >;
+	using Shorthands = std::vector< UniquePtr<ShorthandDefinition> >;
 
 	Properties properties;
 	Shorthands shorthands;
 
-	PropertyIdNameMap property_map;
-	ShorthandIdNameMap shorthand_map;
+	UniquePtr<PropertyIdNameMap> property_map;
+	UniquePtr<ShorthandIdNameMap> shorthand_map;
 
-	// todo: Do we really need these?
 	PropertyIdSet property_names;
 	PropertyIdSet inherited_property_names;
 

+ 0 - 2
Include/RmlUi/Core/StyleSheetSpecification.h

@@ -107,8 +107,6 @@ public:
 	static ShorthandId GetShorthandId(const String& shorthand_name);
 	static const String& GetPropertyName(PropertyId id);
 	static const String& GetShorthandName(ShorthandId id);
-	// todo: Now, this should be equal to GetRegisteredInheritedProperties():
-	static const PropertyIdSet& GetRegisteredInheritedPropertyBitList();
 
 	// Get the underlying property ids associated by a shorthand.
 	static PropertyIdSet GetShorthandUnderlyingProperties(ShorthandId id);

+ 1 - 1
Source/Core/ElementStyle.cpp

@@ -892,7 +892,7 @@ PropertyIdSet ElementStyle::ComputeValues(Style::ComputedValues& values, const S
 	// Next, pass inheritable dirty properties onto our children
 	// @performance: We might avoid an allocation here in case of dirty non-inherited custom properties. Instead of the initial copy and &=, introduce & operator.
 	PropertyIdSet dirty_inherited_properties = dirty_properties;
-	dirty_inherited_properties &= StyleSheetSpecification::GetRegisteredInheritedPropertyBitList();
+	dirty_inherited_properties &= StyleSheetSpecification::GetRegisteredInheritedProperties();
 
 	if (!dirty_inherited_properties.Empty())
 	{

+ 114 - 0
Source/Core/IdNameMap.h

@@ -0,0 +1,114 @@
+/*
+ * This source file is part of RmlUi, the HTML/CSS Interface Middleware
+ *
+ * For the latest information, see http://github.com/mikke89/RmlUi
+ *
+ * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
+ * Copyright (c) 2019 The RmlUi Team, and contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#ifndef RMLUICOREIDNAMEMAP_H
+#define RMLUICOREIDNAMEMAP_H
+
+#include "../../Include/RmlUi/Core/Header.h"
+
+namespace Rml {
+namespace Core {
+
+template <typename ID>
+class IdNameMap {
+	std::vector<String> name_map;  // IDs are indices into the name_map
+	UnorderedMap<String, ID> reverse_map;
+
+protected:
+	IdNameMap(size_t num_ids_to_reserve) {
+		static_assert((int)ID::Invalid == 0, "Invalid id must be zero");
+		name_map.reserve(num_ids_to_reserve);
+		reverse_map.reserve(num_ids_to_reserve);
+		AddPair(ID::Invalid, "invalid");
+	}
+
+public:
+	void AddPair(ID id, const String& name) {
+		// Should only be used for defined IDs
+		if ((size_t)id >= name_map.size())
+			name_map.resize(1 + (size_t)id);
+		name_map[(size_t)id] = name;
+		bool inserted = reverse_map.emplace(name, id).second;
+		RMLUI_ASSERT(inserted);
+		(void)inserted;
+	}
+
+	void AssertAllInserted(ID number_of_defined_ids) const {
+		ptrdiff_t cnt = std::count_if(name_map.begin(), name_map.end(), [](const String& name) { return !name.empty(); });
+		RMLUI_ASSERT(cnt == (ptrdiff_t)number_of_defined_ids && reverse_map.size() == (size_t)number_of_defined_ids);
+		(void)cnt;
+	}
+
+	ID GetId(const String& name) const
+	{
+		auto it = reverse_map.find(name);
+		if (it != reverse_map.end())
+			return it->second;
+		return ID::Invalid;
+	}
+	const String& GetName(ID id) const
+	{
+		if (static_cast<size_t>(id) < name_map.size())
+			return name_map[static_cast<size_t>(id)];
+		return name_map[static_cast<size_t>(ID::Invalid)];
+	}
+
+	ID GetOrCreateId(const String& name)
+	{
+		// All predefined properties must be set before possibly adding custom properties here
+		RMLUI_ASSERT(name_map.size() == reverse_map.size());
+
+		ID next_id = static_cast<ID>(name_map.size());
+
+		// Only insert if not already in list
+		auto pair = reverse_map.emplace(name, next_id);
+		const auto& it = pair.first;
+		bool inserted = pair.second;
+
+		if (inserted)
+			name_map.push_back(name);
+
+		// Return the property id that already existed, or the new one if inserted
+		return it->second;
+	}
+};
+
+class PropertyIdNameMap : public IdNameMap<PropertyId> {
+public:
+	PropertyIdNameMap(size_t reserve_num_properties) : IdNameMap(reserve_num_properties) {}
+};
+
+class ShorthandIdNameMap : public IdNameMap<ShorthandId> {
+public:
+	ShorthandIdNameMap(size_t reserve_num_shorthands) : IdNameMap(reserve_num_shorthands) {}
+};
+
+}
+}
+
+#endif

+ 11 - 15
Source/Core/PropertyShorthandDefinition.h

@@ -29,19 +29,17 @@
 #ifndef RMLUICOREPROPERTYSHORTHANDDEFINITION_H
 #define RMLUICOREPROPERTYSHORTHANDDEFINITION_H
 
-#include "../../Include/RmlUi/Core/PropertySpecification.h"
+#include "../../Include/RmlUi/Core/ID.h"
 
 namespace Rml {
 namespace Core {
 
+enum class ShorthandType;
 class PropertyDefinition;
 
-/**
-	@author Peter Curry
- */
-
-
+enum class ShorthandItemType { Invalid, Property, Shorthand };
 
+// Each entry in a shorthand points either to another shorthand or a property
 struct ShorthandItem {
 	ShorthandItem() : type(ShorthandItemType::Invalid), property_id(PropertyId::Invalid), property_definition(nullptr) {}
 	ShorthandItem(PropertyId id, const PropertyDefinition* definition) : type(ShorthandItemType::Property), property_id(id), property_definition(definition) {}
@@ -49,19 +47,17 @@ struct ShorthandItem {
 
 	ShorthandItemType type;
 	union {
-		struct {
-			PropertyId property_id;
-			const PropertyDefinition* property_definition;
-		};
-		struct {
-			ShorthandId shorthand_id;
-			const ShorthandDefinition* shorthand_definition;
-		};
+		PropertyId property_id;
+		ShorthandId shorthand_id;
+	};
+	union {
+		const PropertyDefinition* property_definition;
+		const ShorthandDefinition* shorthand_definition;
 	};
 };
 
 // A list of shorthands or properties
-typedef std::vector< ShorthandItem > ShorthandItemList;
+using ShorthandItemList = std::vector< ShorthandItem >;
 
 struct ShorthandDefinition
 {

+ 41 - 57
Source/Core/PropertySpecification.cpp

@@ -28,35 +28,34 @@
 
 #include "precompiled.h"
 #include "../../Include/RmlUi/Core/PropertySpecification.h"
-#include "PropertyShorthandDefinition.h"
 #include "../../Include/RmlUi/Core/Log.h"
 #include "../../Include/RmlUi/Core/PropertyDefinition.h"
 #include "../../Include/RmlUi/Core/PropertyDictionary.h"
+#include "PropertyShorthandDefinition.h"
+#include "IdNameMap.h"
 
 namespace Rml {
 namespace Core {
 
+
 PropertySpecification::PropertySpecification(size_t reserve_num_properties, size_t reserve_num_shorthands) : 
 	// Increment reserve numbers by one because the 'invalid' property occupies the first element
-	properties(reserve_num_properties + 1, nullptr), shorthands(reserve_num_shorthands + 1, nullptr), property_map(reserve_num_properties + 1), shorthand_map(reserve_num_shorthands + 1)
+	properties(reserve_num_properties + 1), shorthands(reserve_num_shorthands + 1),
+	property_map(std::make_unique<PropertyIdNameMap>(reserve_num_properties + 1)), shorthand_map(std::make_unique<ShorthandIdNameMap>(reserve_num_shorthands + 1))
 {
 }
 
 PropertySpecification::~PropertySpecification()
 {
-	for (PropertyDefinition* p : properties)
-		delete p;
-	for (ShorthandDefinition* s : shorthands)
-		delete s;
 }
 
 // Registers a property with a new definition.
 PropertyDefinition& PropertySpecification::RegisterProperty(const String& property_name, const String& default_value, bool inherited, bool forces_layout, PropertyId id)
 {
 	if (id == PropertyId::Invalid)
-		id = property_map.GetOrCreateId(property_name);
+		id = property_map->GetOrCreateId(property_name);
 	else
-		property_map.AddPair(id, property_name);
+		property_map->AddPair(id, property_name);
 
 	size_t index = (size_t)id;
 	RMLUI_ASSERT(index < (size_t)INT16_MAX);
@@ -73,18 +72,16 @@ PropertyDefinition& PropertySpecification::RegisterProperty(const String& proper
 	else
 	{
 		// Resize vector to hold the new index
-		properties.resize((index*3)/2 + 1, nullptr);
+		properties.resize((index*3)/2 + 1);
 	}
 
 	// Create and insert the new property
-	PropertyDefinition* property_definition = new PropertyDefinition(id, default_value, inherited, forces_layout);
-
-	properties[index] = property_definition;
+	properties[index] = std::make_unique<PropertyDefinition>(id, default_value, inherited, forces_layout);
 	property_names.Insert(id);
 	if (inherited)
 		inherited_property_names.Insert(id);
 
-	return *property_definition;
+	return *properties[index];
 }
 
 // Returns a property definition.
@@ -93,12 +90,12 @@ const PropertyDefinition* PropertySpecification::GetProperty(PropertyId id) cons
 	if (id == PropertyId::Invalid || (size_t)id >= properties.size())
 		return nullptr;
 
-	return properties[(size_t)id];
+	return properties[(size_t)id].get();
 }
 
 const PropertyDefinition* PropertySpecification::GetProperty(const String& property_name) const
 {
-	return GetProperty(property_map.GetId(property_name));
+	return GetProperty(property_map->GetId(property_name));
 }
 
 // Fetches a list of the names of all registered property definitions.
@@ -117,56 +114,43 @@ const PropertyIdSet& PropertySpecification::GetRegisteredInheritedProperties(voi
 ShorthandId PropertySpecification::RegisterShorthand(const String& shorthand_name, const String& property_names, ShorthandType type, ShorthandId id)
 {
 	if (id == ShorthandId::Invalid)
-		id = shorthand_map.GetOrCreateId(shorthand_name);
+		id = shorthand_map->GetOrCreateId(shorthand_name);
 	else
-		shorthand_map.AddPair(id, shorthand_name);
+		shorthand_map->AddPair(id, shorthand_name);
 
 	StringList property_list;
 	StringUtilities::ExpandString(property_list, ToLower(property_names));
-	ShorthandItemIdList id_list;
-	id_list.reserve(property_list.size());
-
-	for (auto& name : property_list)
-	{
-		PropertyId property_id = property_map.GetId(name);
-		if (property_id != PropertyId::Invalid)
-			id_list.emplace_back(property_id);
-		else
-		{
-			ShorthandId shorthand_id = shorthand_map.GetId(name);
-			if (shorthand_id != ShorthandId::Invalid)
-				id_list.emplace_back(shorthand_id);
-		}
-	}
-
-	if (id_list.empty() || id_list.size() != property_list.size())
-		return ShorthandId::Invalid;
-
-	if (id_list.empty())
-		return ShorthandId::Invalid;
 
 	// Construct the new shorthand definition and resolve its properties.
 	UniquePtr<ShorthandDefinition> property_shorthand(new ShorthandDefinition());
-	for (size_t i = 0; i < id_list.size(); i++)
+
+	for (const String& name : property_list)
 	{
 		ShorthandItem item;
-		if (id_list[i].type == ShorthandItemType::Property)
+
+		PropertyId property_id = property_map->GetId(name);
+		if (property_id != PropertyId::Invalid)
 		{
-			const PropertyDefinition* property = GetProperty(id_list[i].property_id);
-			if(property)
-				item = ShorthandItem(id_list[i].property_id, property);
+			// We have a valid property
+			if (const PropertyDefinition* property = GetProperty(property_id))
+				item = ShorthandItem(property_id, property);
 		}
-		else if (id_list[i].type == ShorthandItemType::Shorthand && (type == ShorthandType::Recursive || type == ShorthandType::RecursiveCommaSeparated))
+		else
 		{
-			// The recursive types (and only those) can hold other shorthands
-			const ShorthandDefinition* shorthand = GetShorthand(id_list[i].shorthand_id);
-			if (shorthand)
-				item = ShorthandItem(id_list[i].shorthand_id, shorthand);
+			// Otherwise, we must be a shorthand
+			ShorthandId shorthand_id = shorthand_map->GetId(name);
+
+			// Test for valid shorthand id. The recursive types (and only those) can hold other shorthands.
+			if (shorthand_id != ShorthandId::Invalid && (type == ShorthandType::Recursive || type == ShorthandType::RecursiveCommaSeparated))
+			{
+				if (const ShorthandDefinition * shorthand = GetShorthand(shorthand_id))
+					item = ShorthandItem(shorthand_id, shorthand);
+			}
 		}
 
 		if (item.type == ShorthandItemType::Invalid)
 		{
-			Log::Message(Log::LT_ERROR, "Shorthand property '%s' was registered with invalid property '%s'.", shorthand_name.c_str(), property_list[i].c_str());
+			Log::Message(Log::LT_ERROR, "Shorthand property '%s' was registered with invalid property '%s'.", shorthand_name.c_str(), name.c_str());
 			return ShorthandId::Invalid;
 		}
 		property_shorthand->items.push_back(item);
@@ -190,10 +174,10 @@ ShorthandId PropertySpecification::RegisterShorthand(const String& shorthand_nam
 	else
 	{
 		// Resize vector to hold the new index
-		shorthands.resize((index * 3) / 2 + 1, nullptr);
+		shorthands.resize((index * 3) / 2 + 1);
 	}
 
-	shorthands[index] = property_shorthand.release();
+	shorthands[index] = std::move(property_shorthand);
 	return id;
 }
 
@@ -203,23 +187,23 @@ const ShorthandDefinition* PropertySpecification::GetShorthand(ShorthandId id) c
 	if (id == ShorthandId::Invalid || (size_t)id >= shorthands.size())
 		return nullptr;
 
-	return shorthands[(size_t)id];
+	return shorthands[(size_t)id].get();
 }
 
 const ShorthandDefinition* PropertySpecification::GetShorthand(const String& shorthand_name) const
 {
-	return GetShorthand(shorthand_map.GetId(shorthand_name));
+	return GetShorthand(shorthand_map->GetId(shorthand_name));
 }
 
 bool PropertySpecification::ParsePropertyDeclaration(PropertyDictionary& dictionary, const String& property_name, const String& property_value, const String& source_file, int source_line_number) const
 {
 	// Try as a property first
-	PropertyId property_id = property_map.GetId(property_name);
+	PropertyId property_id = property_map->GetId(property_name);
 	if (property_id != PropertyId::Invalid)
 		return ParsePropertyDeclaration(dictionary, property_id, property_value, source_file, source_line_number);
 
 	// Then, as a shorthand
-	ShorthandId shorthand_id = shorthand_map.GetId(property_name);
+	ShorthandId shorthand_id = shorthand_map->GetId(property_name);
 	if (shorthand_id != ShorthandId::Invalid)
 		return ParseShorthandDeclaration(dictionary, shorthand_id, property_value, source_file, source_line_number);
 
@@ -383,7 +367,7 @@ bool PropertySpecification::ParseShorthandDeclaration(PropertyDictionary& dictio
 // Sets all undefined properties in the dictionary to their defaults.
 void PropertySpecification::SetPropertyDefaults(PropertyDictionary& dictionary) const
 {
-	for (PropertyDefinition* property : properties)
+	for (const auto& property : properties)
 	{
 		if (property && dictionary.GetProperty(property->GetId()) == nullptr)
 			dictionary.SetProperty(property->GetId(), *property->GetDefaultValue());
@@ -395,7 +379,7 @@ String PropertySpecification::PropertiesToString(const PropertyDictionary& dicti
 	String result;
 	for (auto& pair : dictionary.GetProperties())
 	{
-		result += property_map.GetName(pair.first) + ": " + pair.second.ToString() + '\n';
+		result += property_map->GetName(pair.first) + ": " + pair.second.ToString() + '\n';
 	}
 	return result;
 }

+ 11 - 23
Source/Core/StyleSheetSpecification.cpp

@@ -26,7 +26,6 @@
  *
  */
 
- 
 #include "precompiled.h"
 #include "../../Include/RmlUi/Core/StyleSheetSpecification.h"
 #include "../../Include/RmlUi/Core/PropertyIdSet.h"
@@ -37,6 +36,7 @@
 #include "PropertyParserString.h"
 #include "PropertyParserTransform.h"
 #include "PropertyShorthandDefinition.h"
+#include "IdNameMap.h"
 
 namespace Rml {
 namespace Core {
@@ -44,16 +44,12 @@ namespace Core {
 
 static StyleSheetSpecification* instance = nullptr;
 
-static PropertyIdSet registered_inherited_properties;
-
-
 StyleSheetSpecification::StyleSheetSpecification() : 
 	// Reserve space for all defined ids and some more for custom properties
 	properties(2 * (size_t)PropertyId::NumDefinedIds, 2 * (size_t)ShorthandId::NumDefinedIds)
 {
 	RMLUI_ASSERT(instance == nullptr);
 	instance = this;
-	registered_inherited_properties.Clear();
 }
 
 StyleSheetSpecification::~StyleSheetSpecification()
@@ -64,10 +60,7 @@ StyleSheetSpecification::~StyleSheetSpecification()
 
 PropertyDefinition& StyleSheetSpecification::RegisterProperty(PropertyId id, const String& property_name, const String& default_value, bool inherited, bool forces_layout)
 {
-	auto& result = properties.RegisterProperty(property_name, default_value, inherited, forces_layout, id);
-	if (inherited)
-		registered_inherited_properties.Insert(result.GetId());
-	return result;
+	return properties.RegisterProperty(property_name, default_value, inherited, forces_layout, id);
 }
 
 ShorthandId StyleSheetSpecification::RegisterShorthand(ShorthandId id, const String& shorthand_name, const String& property_names, ShorthandType type)
@@ -123,7 +116,7 @@ PropertyParser* StyleSheetSpecification::GetParser(const String& parser_name)
 // Registers a property with a new definition.
 PropertyDefinition& StyleSheetSpecification::RegisterProperty(const String& property_name, const String& default_value, bool inherited, bool forces_layout)
 {
-	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.");
+	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.");
 	return instance->RegisterProperty(PropertyId::Invalid, property_name, default_value, inherited, forces_layout); 
 }
 
@@ -152,8 +145,8 @@ const PropertyIdSet & StyleSheetSpecification::GetRegisteredInheritedProperties(
 // Registers a shorthand property definition.
 ShorthandId StyleSheetSpecification::RegisterShorthand(const String& shorthand_name, const String& property_names, ShorthandType type)
 {
-	RMLUI_ASSERTMSG(instance->properties.property_map.GetId(shorthand_name) == PropertyId::Invalid, "Custom shorthand name matches a property name, please make a unique name.");
-	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.");
+	RMLUI_ASSERTMSG(instance->properties.property_map->GetId(shorthand_name) == PropertyId::Invalid, "Custom shorthand name matches a property name, please make a unique name.");
+	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.");
 	return instance->properties.RegisterShorthand(shorthand_name, property_names, type);
 }
 
@@ -176,27 +169,22 @@ bool StyleSheetSpecification::ParsePropertyDeclaration(PropertyDictionary& dicti
 
 PropertyId StyleSheetSpecification::GetPropertyId(const String& property_name)
 {
-	return instance->properties.property_map.GetId(property_name);
+	return instance->properties.property_map->GetId(property_name);
 }
 
 ShorthandId StyleSheetSpecification::GetShorthandId(const String& shorthand_name)
 {
-	return instance->properties.shorthand_map.GetId(shorthand_name);
+	return instance->properties.shorthand_map->GetId(shorthand_name);
 }
 
 const String& StyleSheetSpecification::GetPropertyName(PropertyId id)
 {
-	return instance->properties.property_map.GetName(id);
+	return instance->properties.property_map->GetName(id);
 }
 
 const String& StyleSheetSpecification::GetShorthandName(ShorthandId id)
 {
-	return instance->properties.shorthand_map.GetName(id);
-}
-
-const PropertyIdSet& StyleSheetSpecification::GetRegisteredInheritedPropertyBitList()
-{
-	return registered_inherited_properties;
+	return instance->properties.shorthand_map->GetName(id);
 }
 
 PropertyIdSet StyleSheetSpecification::GetShorthandUnderlyingProperties(ShorthandId id)
@@ -378,8 +366,8 @@ void StyleSheetSpecification::RegisterDefaultProperties()
 	RegisterProperty(PropertyId::Decorator, "decorator", "", false, false).AddParser("string");
 	RegisterProperty(PropertyId::FontEffect, "font-effect", "", true, false).AddParser("string");
 
-	instance->properties.property_map.AssertAllInserted(PropertyId::NumDefinedIds);
-	instance->properties.shorthand_map.AssertAllInserted(ShorthandId::NumDefinedIds);
+	instance->properties.property_map->AssertAllInserted(PropertyId::NumDefinedIds);
+	instance->properties.shorthand_map->AssertAllInserted(ShorthandId::NumDefinedIds);
 }
 
 }