Browse Source

No need to dirty decorators in update definition anymore. Postpone dirty child definitions to update.

Michael Ragazzon 6 years ago
parent
commit
3f17844b7e
2 changed files with 11 additions and 14 deletions
  1. 9 12
      Source/Core/ElementStyle.cpp
  2. 2 2
      Source/Core/ElementStyle.h

+ 9 - 12
Source/Core/ElementStyle.cpp

@@ -179,11 +179,12 @@ void ElementStyle::UpdateDefinition()
 	if (definition_dirty)
 	{
 		definition_dirty = false;
+
+		bool definition_changed = false;
 		
 		ElementDefinition* new_definition = nullptr;
 		
-		const StyleSheet* style_sheet = GetStyleSheet();
-		if (style_sheet)
+		if (const StyleSheet * style_sheet = GetStyleSheet())
 		{
 			new_definition = style_sheet->GetElementDefinition(element);
 		}
@@ -193,12 +194,13 @@ void ElementStyle::UpdateDefinition()
 		{
 			// Since we had no definition before there is a likelihood that everything is dirty.
 			// We could do as in the next else-if block, but this is considerably faster.
+			definition_changed = true;
 			dirty_properties.DirtyAll();
-			element->GetElementDecoration()->DirtyDecorators();
 			definition = new_definition;
 		}
 		else if (new_definition != definition)
 		{
+			definition_changed = true;
 			PropertyNameList properties;
 			
 			if (definition)
@@ -215,20 +217,16 @@ void ElementStyle::UpdateDefinition()
 			definition = new_definition;
 			
 			DirtyProperties(properties);
-			element->GetElementDecoration()->DirtyDecorators();
-		}
-		else if (!new_definition)
-		{
-			// Both definitions empty
-			ROCKET_ASSERT(!definition);
-			// Is this really necessary?
-			element->GetElementDecoration()->DirtyDecorators();
 		}
 		else if (new_definition)
 		{
 			// We got the same definition
+			ROCKET_ASSERT(new_definition == definition);
 			new_definition->RemoveReference();
 		}
+
+		if (definition_changed)
+			DirtyChildDefinitions();
 	}
 }
 
@@ -479,7 +477,6 @@ StyleSheet* ElementStyle::GetStyleSheet() const
 void ElementStyle::DirtyDefinition()
 {
 	definition_dirty = true;
-	DirtyChildDefinitions();
 }
 
 void ElementStyle::DirtyChildDefinitions()

+ 2 - 2
Source/Core/ElementStyle.h

@@ -118,8 +118,6 @@ public:
 
 	/// Mark definition and all children dirty
 	void DirtyDefinition();
-	/// Dirty all child definitions
-	void DirtyChildDefinitions();
 
 	/// Dirties all properties with a given unit on the current element and recursively on all children.
 	void DirtyPropertiesWithUnitRecursive(Property::Unit unit);
@@ -136,6 +134,8 @@ public:
 	PropertiesIterator Iterate() const;
 
 private:
+	// Dirty all child definitions
+	void DirtyChildDefinitions();
 	// Sets a single property as dirty.
 	void DirtyProperty(PropertyId id);
 	// Sets a list of properties as dirty.