Browse Source

Minor cleanup

Michael Ragazzon 6 years ago
parent
commit
b7f84b1e1a

+ 1 - 1
Include/Rocket/Core/Element.h

@@ -742,7 +742,7 @@ private:
 
 	PropertyNameList dirty_properties;
 	bool all_properties_dirty;
-	bool computed_values_are_default;
+	bool computed_values_are_default_initialized;
 	bool box_dirty;
 
 	// The element's font face; used to render text and resolve em / ex properties.

+ 3 - 3
Source/Core/Element.cpp

@@ -144,7 +144,7 @@ transform_state(), transform_state_perspective_dirty(true), transform_state_tran
 	parent_structure_dirty = false;
 
 	all_properties_dirty = true;
-	computed_values_are_default = true;
+	computed_values_are_default_initialized = true;
 	box_dirty = false;
 
 	font_face_handle = NULL;
@@ -224,9 +224,9 @@ void Element::Update()
 			if (auto context = doc->GetContext())
 				dp_ratio = context->GetDensityIndependentPixelRatio();
 		}
-		style->ComputeValues(element_meta->computed_values, parent_values, document_values, computed_values_are_default, dp_ratio);
+		style->ComputeValues(element_meta->computed_values, parent_values, document_values, computed_values_are_default_initialized, dp_ratio);
 
-		computed_values_are_default = false;
+		computed_values_are_default_initialized = false;
 	}
 
 	// Right now we are assuming computed values are calculated before OnPropertyChange

+ 2 - 2
Source/Core/ElementAnimation.cpp

@@ -96,8 +96,8 @@ static Property InterpolateProperties(const Property & p0, const Property& p1, f
 		else
 		{
 			// Otherwise, convert units to pixels.
-			float f0 = element.GetStyle()->ResolveLengthPercentage(&p0, definition->GetRelativeTarget());
-			float f1 = element.GetStyle()->ResolveLengthPercentage(&p1, definition->GetRelativeTarget());
+			float f0 = element.GetStyle()->ResolveNumberLengthPercentage(&p0, definition->GetRelativeTarget());
+			float f1 = element.GetStyle()->ResolveNumberLengthPercentage(&p1, definition->GetRelativeTarget());
 			float f = (1.0f - alpha) * f0 + alpha * f1;
 			return Property{ f, Property::PX };
 		}

+ 3 - 3
Source/Core/ElementStyle.cpp

@@ -410,7 +410,7 @@ const PropertyMap * ElementStyle::GetLocalProperties() const
 	return NULL;
 }
 
-float ElementStyle::ResolveLengthPercentage(const Property * property, RelativeTarget relative_target)
+float ElementStyle::ResolveNumberLengthPercentage(const Property * property, RelativeTarget relative_target)
 {
 	// There is an exception on font-size properties, as 'em' units here refer to parent font size instead
 	if ((property->unit & Property::LENGTH) && !(property->unit == Property::EM && relative_target == RelativeTarget::ParentFontSize))
@@ -746,7 +746,7 @@ void ElementStyle::DirtyInheritedProperties(const PropertyNameList& properties)
 
 
 // Must be called in correct order, from document root to children elements.
-void ElementStyle::ComputeValues(Style::ComputedValues& values, const Style::ComputedValues* parent_values, const Style::ComputedValues* document_values, bool values_are_defaulted, float dp_ratio)
+void ElementStyle::ComputeValues(Style::ComputedValues& values, const Style::ComputedValues* parent_values, const Style::ComputedValues* document_values, bool values_are_default_initialized, float dp_ratio)
 {
 	// Generally, this is how it works (for now, we can probably be smarter about this):
 	//   1. Assign default values (clears any newly dirtied properties)
@@ -755,7 +755,7 @@ void ElementStyle::ComputeValues(Style::ComputedValues& values, const Style::Com
 
 
 	// The next flag is just a small optimization, if the element was just created we don't need to copy all the default values.
-	if (!values_are_defaulted)
+	if (!values_are_default_initialized)
 	{
 		values = DefaultComputedValues;
 	}

+ 4 - 4
Source/Core/ElementStyle.h

@@ -110,9 +110,9 @@ public:
 	/// @param[in] base_value The value that is scaled by the percentage value, if it is a percentage.
 	/// @return The resolved value in 'px' unit.
 	float ResolveLengthPercentage(const Property *property, float base_value);
-	/// Resolves a property with units of length or percentage to 'px'. Percentages are resolved by scaling by the size of the specified target.
-	/// 'percentage' and 'number' are multiplied by the size of the specified relative reference.
-	float ResolveLengthPercentage(const Property* property, RelativeTarget relative_target);
+	/// Resolves a property with units of number, length or percentage. Lengths are resolved to 'px'. 
+	/// Number and percentages are resolved by scaling by the size of the specified target.
+	float ResolveNumberLengthPercentage(const Property* property, RelativeTarget relative_target);
 
 	/// Iterates over the properties defined on the element.
 	/// @param[inout] index Index of the property to fetch. This is incremented to the next valid index after the fetch. Indices are not necessarily incremental.
@@ -141,7 +141,7 @@ public:
 	// Dirties dp properties.
 	void DirtyDpProperties();
 
-	void ComputeValues(Style::ComputedValues& values, const Style::ComputedValues* parent_values, const Style::ComputedValues* document_values, bool values_are_defaulted, float dp_ratio);
+	void ComputeValues(Style::ComputedValues& values, const Style::ComputedValues* parent_values, const Style::ComputedValues* document_values, bool values_are_default_initialized, float dp_ratio);
 
 private:
 	// Sets a single property as dirty.

+ 1 - 0
readme.md

@@ -17,6 +17,7 @@ If upgrading from the original libRocket branch, some breaking changes should be
 - Rocket::Core::String has been replaced by std::string, thus, interfacing with the library now requires you to change your string types. This change was motivated by a small performance gain, additionally, it should make it easier to interface with the library especially for users already using std::string in their codebase.
 - Querying the property of an element for size, position and similar may not work as expected right after changes to the document or style. This change is made for performance reasons, see the note below for reasoning and a workaround.
 - The Controls::DataGrid "min-rows" property has been replaced by an attribute of the same name.
+- Removed RenderInterface::GetPixelsPerInch, instead the pixels per inch value has been fixed to 96 PPI, as per CSS specs. To achieve a scalable user interface, instead use the 'dp' unit.
 
 ## Performance