Browse Source

Remove lock layout: it already had no effect

Michael Ragazzon 6 years ago
parent
commit
1e41f9a4ef

+ 0 - 3
Include/Rocket/Core/Element.h

@@ -619,9 +619,6 @@ protected:
 	/// Returns true if the element has been marked as needing a re-layout.
 	/// Returns true if the element has been marked as needing a re-layout.
 	virtual bool IsLayoutDirty();
 	virtual bool IsLayoutDirty();
 
 
-	/// Increment/Decrement the layout lock
-	virtual void LockLayout(bool lock);
-
 	/// Forces a reevaluation of applicable font effects.
 	/// Forces a reevaluation of applicable font effects.
 	virtual void DirtyFont();
 	virtual void DirtyFont();
 
 

+ 0 - 4
Include/Rocket/Core/ElementDocument.h

@@ -131,9 +131,6 @@ public:
 	/// already been called after the change. This has a perfomance penalty, only call when strictly necessary.
 	/// already been called after the change. This has a perfomance penalty, only call when strictly necessary.
 	void UpdateDocument();
 	void UpdateDocument();
 	
 	
-	/// Increment/Decrement the layout lock
-	void LockLayout(bool lock);
-	
 protected:
 protected:
 	/// Repositions the document if necessary.
 	/// Repositions the document if necessary.
 	virtual void OnPropertyChange(const PropertyNameList& changed_properties);
 	virtual void OnPropertyChange(const PropertyNameList& changed_properties);
@@ -184,7 +181,6 @@ private:
 
 
 	// Is the layout dirty?
 	// Is the layout dirty?
 	bool layout_dirty;
 	bool layout_dirty;
-	int lock_layout;
 
 
 	bool position_dirty;
 	bool position_dirty;
 
 

+ 0 - 5
Source/Controls/ElementDataGrid.cpp

@@ -222,9 +222,6 @@ ElementDataGridRow* ElementDataGrid::GetRow(int index) const
 
 
 void ElementDataGrid::OnUpdate()
 void ElementDataGrid::OnUpdate()
 {
 {
-	Core::ElementDocument* document = GetOwnerDocument();
-	document->LockLayout(true);
-	
 	if (!new_data_source.empty())
 	if (!new_data_source.empty())
 	{
 	{
 		root->SetDataSource(new_data_source);
 		root->SetDataSource(new_data_source);
@@ -242,8 +239,6 @@ void ElementDataGrid::OnUpdate()
 		body->SetProperty("display", Core::Property(Core::Style::Display::Block));
 		body->SetProperty("display", Core::Property(Core::Style::Display::Block));
 		body_visible = true;
 		body_visible = true;
 	}
 	}
-	
-	document->LockLayout(false);
 }
 }
 
 
 
 

+ 0 - 9
Source/Controls/ElementDataGridRow.cpp

@@ -369,10 +369,6 @@ void ElementDataGridRow::AddChildren(int first_row_added, int num_rows_added)
 		first_row_added = (int)children.size();
 		first_row_added = (int)children.size();
 	}
 	}
 
 
-	// prevent relayout of the document while adding rows
-	Core::ElementDocument* document = parent_grid->GetOwnerDocument();
-	document->LockLayout(true);
-
 	// We need to make a row for each new child, then pass through the cell
 	// We need to make a row for each new child, then pass through the cell
 	// information and the child's data source (if one exists.)
 	// information and the child's data source (if one exists.)
 	if (data_source != NULL)
 	if (data_source != NULL)
@@ -403,8 +399,6 @@ void ElementDataGridRow::AddChildren(int first_row_added, int num_rows_added)
 		}
 		}
 	}
 	}
 
 
-	document->LockLayout(false);
-
 	RefreshChildDependentCells();
 	RefreshChildDependentCells();
 	DirtyRow();
 	DirtyRow();
 
 
@@ -423,7 +417,6 @@ void ElementDataGridRow::RemoveChildren(int first_row_removed, int num_rows_remo
 
 
 	// prevent relayout of the document while removing rows
 	// prevent relayout of the document while removing rows
 	Core::ElementDocument* document = parent_grid->GetOwnerDocument();
 	Core::ElementDocument* document = parent_grid->GetOwnerDocument();
-	document->LockLayout(true);
 
 
 	for (int i = num_rows_removed - 1; i >= 0; i--)
 	for (int i = num_rows_removed - 1; i >= 0; i--)
 	{
 	{
@@ -438,8 +431,6 @@ void ElementDataGridRow::RemoveChildren(int first_row_removed, int num_rows_remo
 		children[i]->DirtyTableRelativeIndex();
 		children[i]->DirtyTableRelativeIndex();
 	}
 	}
 
 
-	document->LockLayout(false);
-
 	Rocket::Core::Dictionary parameters;
 	Rocket::Core::Dictionary parameters;
 	parameters["first_row_removed"] = GetChildTableRelativeIndex(first_row_removed);
 	parameters["first_row_removed"] = GetChildTableRelativeIndex(first_row_removed);
 	parameters["num_rows_removed"] = num_rows_removed;
 	parameters["num_rows_removed"] = num_rows_removed;

+ 0 - 13
Source/Core/Context.cpp

@@ -168,19 +168,6 @@ float Context::GetDensityIndependentPixelRatio() const
 // Updates all elements in the element tree.
 // Updates all elements in the element tree.
 bool Context::Update()
 bool Context::Update()
 {
 {
-#ifdef ROCKET_DEBUG
-	// Look for leaks in layout lock
-	for (int i = 0; i < root->GetNumChildren(); ++i)
-	{
-		ElementDocument* document = root->GetChild(i)->GetOwnerDocument();
-		if (document != NULL && document->lock_layout != 0)
-		{
-			Log::Message(Log::LT_WARNING, "Layout lock leak. Document '%s' had lock layout value: %d", document->title.c_str(), document->lock_layout);
-			document->lock_layout = 0;
-		}
-	}
-#endif
-
 	root->Update();
 	root->Update();
 
 
 	for (int i = 0; i < root->GetNumChildren(); ++i)
 	for (int i = 0; i < root->GetNumChildren(); ++i)

+ 0 - 24
Source/Core/Element.cpp

@@ -1336,8 +1336,6 @@ void Element::ScrollIntoView(bool align_with_top)
 // Appends a child to this element
 // Appends a child to this element
 void Element::AppendChild(Element* child, bool dom_element)
 void Element::AppendChild(Element* child, bool dom_element)
 {
 {
-	LockLayout(true);
-
 	child->AddReference();
 	child->AddReference();
 	child->SetParent(this);
 	child->SetParent(this);
 	if (dom_element)
 	if (dom_element)
@@ -1357,8 +1355,6 @@ void Element::AppendChild(Element* child, bool dom_element)
 
 
 	if (dom_element)
 	if (dom_element)
 		DirtyLayout();
 		DirtyLayout();
-
-	LockLayout(false);
 }
 }
 
 
 // Adds a child to this element, directly after the adjacent element. Inherits
 // Adds a child to this element, directly after the adjacent element. Inherits
@@ -1384,8 +1380,6 @@ void Element::InsertBefore(Element* child, Element* adjacent_element)
 
 
 	if (found_child)
 	if (found_child)
 	{
 	{
-		LockLayout(true);
-
 		child->AddReference();
 		child->AddReference();
 		child->SetParent(this);
 		child->SetParent(this);
 
 
@@ -1402,8 +1396,6 @@ void Element::InsertBefore(Element* child, Element* adjacent_element)
 		child->OnChildAdd(child);
 		child->OnChildAdd(child);
 		DirtyStackingContext();
 		DirtyStackingContext();
 		DirtyStructure();
 		DirtyStructure();
-
-		LockLayout(false);
 	}
 	}
 	else
 	else
 	{
 	{
@@ -1429,8 +1421,6 @@ bool Element::ReplaceChild(Element* inserted_element, Element* replaced_element)
 		return false;
 		return false;
 	}
 	}
 
 
-	LockLayout(true);
-
 	children.insert(insertion_point, inserted_element);
 	children.insert(insertion_point, inserted_element);
 	RemoveChild(replaced_element);
 	RemoveChild(replaced_element);
 
 
@@ -1438,8 +1428,6 @@ bool Element::ReplaceChild(Element* inserted_element, Element* replaced_element)
 	all_properties_dirty = true;
 	all_properties_dirty = true;
 	inserted_element->OnChildAdd(inserted_element);
 	inserted_element->OnChildAdd(inserted_element);
 
 
-	LockLayout(false);
-
 	return true;
 	return true;
 }
 }
 
 
@@ -1453,8 +1441,6 @@ bool Element::RemoveChild(Element* child)
 		// Add the element to the delete list
 		// Add the element to the delete list
 		if ((*itr) == child)
 		if ((*itr) == child)
 		{
 		{
-			LockLayout(true);
-
 			// Inform the context of the element's pending removal (if we have a valid context).
 			// Inform the context of the element's pending removal (if we have a valid context).
 			Context* context = GetContext();
 			Context* context = GetContext();
 			if (context)
 			if (context)
@@ -1496,8 +1482,6 @@ bool Element::RemoveChild(Element* child)
 			DirtyStackingContext();
 			DirtyStackingContext();
 			DirtyStructure();
 			DirtyStructure();
 
 
-			LockLayout(false);
-
 			return true;
 			return true;
 		}
 		}
 
 
@@ -1940,14 +1924,6 @@ void Element::DirtyLayout()
 		document->DirtyLayout();
 		document->DirtyLayout();
 }
 }
 
 
-/// Increment/Decrement the layout lock
-void Element::LockLayout(bool lock)
-{
-	ElementDocument* document = GetOwnerDocument();
-	if (document != NULL)
-		document->LockLayout(lock);
-}
-
 // Forces a re-layout of this element, and any other children required.
 // Forces a re-layout of this element, and any other children required.
 bool Element::IsLayoutDirty()
 bool Element::IsLayoutDirty()
 {
 {

+ 2 - 15
Source/Core/ElementDocument.cpp

@@ -49,7 +49,6 @@ ElementDocument::ElementDocument(const String& tag) : Element(tag)
 
 
 	modal = false;
 	modal = false;
 	layout_dirty = true;
 	layout_dirty = true;
-	lock_layout = 0;
 
 
 	position_dirty = false;
 	position_dirty = false;
 
 
@@ -313,12 +312,11 @@ void ElementDocument::UpdateDocument()
 // Updates the layout if necessary.
 // Updates the layout if necessary.
 void ElementDocument::UpdateLayout()
 void ElementDocument::UpdateLayout()
 {
 {
-	// The lock_layout currently has no effect. Instead, we carefully consider
-	// when we need to call this function.
+	// Note: Carefully consider when to call this function for performance reasons.
+	// Ideally, only called once per update loop.
 	if(layout_dirty)
 	if(layout_dirty)
 	{
 	{
 		layout_dirty = false;
 		layout_dirty = false;
-		lock_layout++;
 
 
 		Vector2f containing_block(0, 0);
 		Vector2f containing_block(0, 0);
 		if (GetParentNode() != NULL)
 		if (GetParentNode() != NULL)
@@ -326,7 +324,6 @@ void ElementDocument::UpdateLayout()
 
 
 		LayoutEngine layout_engine;
 		LayoutEngine layout_engine;
 		layout_engine.FormatElement(this, containing_block);
 		layout_engine.FormatElement(this, containing_block);
-		lock_layout--;
 	}
 	}
 }
 }
 
 
@@ -369,16 +366,6 @@ void ElementDocument::DirtyPosition()
 {
 {
 	position_dirty = true;
 	position_dirty = true;
 }
 }
-	
-void ElementDocument::LockLayout(bool lock)
-{
-	if (lock)
-		lock_layout++;
-	else
-		lock_layout--;
-	
-	ROCKET_ASSERT(lock_layout >= 0);
-}
 
 
 void ElementDocument::DirtyLayout()
 void ElementDocument::DirtyLayout()
 {
 {

+ 0 - 3
Source/Core/Factory.cpp

@@ -320,14 +320,11 @@ ElementDocument* Factory::InstanceDocumentStream(Rocket::Core::Context* context,
 		return NULL;
 		return NULL;
 	}
 	}
 
 
-	document->lock_layout = true;
 	document->context = context;
 	document->context = context;
 
 
 	XMLParser parser(element);
 	XMLParser parser(element);
 	parser.Parse(stream);
 	parser.Parse(stream);
 
 
-	document->lock_layout = false;
-
 	return document;
 	return document;
 }
 }