Browse Source

Keep the list of inherited properties in a separate set for quicker access

Victor Luchitz 13 years ago
parent
commit
1347239034

+ 9 - 3
Include/Rocket/Core/PropertySpecification.h

@@ -75,9 +75,13 @@ public:
 	/// @return The appropriate property definition if it could be found, NULL otherwise.
 	/// @return The appropriate property definition if it could be found, NULL otherwise.
 	const PropertyDefinition* GetProperty(const String& property_name) const;
 	const PropertyDefinition* GetProperty(const String& property_name) const;
 
 
-	/// Fetches a list of the names of all registered property definitions.
-	/// @param properties[in] The list to store the property names.
-	void GetRegisteredProperties(PropertyNameList& properties) const;
+	/// Returns the list of the names of all registered property definitions.
+	/// @return The list with stored property names.
+	const PropertyNameList& GetRegisteredProperties() const;
+
+	/// Returns the list of the names of all registered inherited property definitions.
+	/// @return The list with stored property names.
+	const PropertyNameList& GetRegisteredInheritedProperties() const;
 
 
 	/// Registers a shorthand property definition.
 	/// Registers a shorthand property definition.
 	/// @param[in] shorthand_name The name to register the new shorthand property under.
 	/// @param[in] shorthand_name The name to register the new shorthand property under.
@@ -106,6 +110,8 @@ private:
 
 
 	PropertyMap properties;
 	PropertyMap properties;
 	ShorthandMap shorthands;
 	ShorthandMap shorthands;
+	PropertyNameList property_names;
+	PropertyNameList inherited_property_names;
 
 
 	bool ParsePropertyValues(StringList& values_list, const String& values, bool split_values) const;
 	bool ParsePropertyValues(StringList& values_list, const String& values, bool split_values) const;
 };
 };

+ 7 - 3
Include/Rocket/Core/StyleSheetSpecification.h

@@ -72,9 +72,13 @@ public:
 	/// @return The appropriate property definition if it could be found, NULL otherwise.
 	/// @return The appropriate property definition if it could be found, NULL otherwise.
 	static const PropertyDefinition* GetProperty(const String& property_name);
 	static const PropertyDefinition* GetProperty(const String& property_name);
 
 
-	/// Fetches a list of the names of all registered property definitions.
-	/// @param properties[in] The list to store the property names.
-	static void GetRegisteredProperties(PropertyNameList& properties);
+	/// Returns the list of the names of all registered property definitions.
+	/// @return The list with stored property names.
+	static const PropertyNameList & GetRegisteredProperties();
+
+	/// Returns the list of the names of all registered inherited property definitions.
+	/// @return The list with stored property names.
+	static const PropertyNameList & GetRegisteredInheritedProperties();
 
 
 	/// Registers a shorthand property definition.
 	/// Registers a shorthand property definition.
 	/// @param[in] shorthand_name The name to register the new shorthand property under.
 	/// @param[in] shorthand_name The name to register the new shorthand property under.

+ 18 - 3
Source/Core/PropertySpecification.cpp

@@ -60,7 +60,17 @@ PropertyDefinition& PropertySpecification::RegisterProperty(const String& proper
 	// Delete any existing property.
 	// Delete any existing property.
 	PropertyMap::iterator iterator = properties.find(lower_case_name);
 	PropertyMap::iterator iterator = properties.find(lower_case_name);
 	if (iterator != properties.end())
 	if (iterator != properties.end())
+	{
 		delete (*iterator).second;
 		delete (*iterator).second;
+	}
+	else
+	{
+		property_names.insert(lower_case_name);
+		if (inherited)
+		{
+			inherited_property_names.insert(lower_case_name);
+		}
+	}
 
 
 	properties[lower_case_name] = property_definition;
 	properties[lower_case_name] = property_definition;
 	return *property_definition;
 	return *property_definition;
@@ -77,10 +87,15 @@ const PropertyDefinition* PropertySpecification::GetProperty(const String& prope
 }
 }
 
 
 // Fetches a list of the names of all registered property definitions.
 // Fetches a list of the names of all registered property definitions.
-void PropertySpecification::GetRegisteredProperties(PropertyNameList& _properties) const
+const PropertyNameList& PropertySpecification::GetRegisteredProperties(void) const
 {
 {
-	for (PropertyMap::const_iterator i = properties.begin(); i != properties.end(); ++i)
-		_properties.insert((*i).first);
+	return property_names;
+}
+
+// Fetches a list of the names of all registered property definitions.
+const PropertyNameList& PropertySpecification::GetRegisteredInheritedProperties(void) const
+{
+	return inherited_property_names;
 }
 }
 
 
 // Registers a shorthand property definition.
 // Registers a shorthand property definition.

+ 7 - 2
Source/Core/StyleSheetSpecification.cpp

@@ -107,9 +107,14 @@ const PropertyDefinition* StyleSheetSpecification::GetProperty(const String& pro
 }
 }
 
 
 // Fetches a list of the names of all registered property definitions.
 // Fetches a list of the names of all registered property definitions.
-void StyleSheetSpecification::GetRegisteredProperties(PropertyNameList& properties)
+const PropertyNameList& StyleSheetSpecification::GetRegisteredProperties()
 {
 {
-	instance->properties.GetRegisteredProperties(properties);
+	return instance->properties.GetRegisteredProperties();
+}
+
+const PropertyNameList & StyleSheetSpecification::GetRegisteredInheritedProperties()
+{
+	return instance->properties.GetRegisteredInheritedProperties();
 }
 }
 
 
 // Registers a shorthand property definition.
 // Registers a shorthand property definition.