2
0
Michael Ragazzon 6 жил өмнө
parent
commit
3e7b022409

+ 2 - 0
Source/Core/Element.cpp

@@ -228,6 +228,8 @@ void Element::Update()
 		style->ComputeValues(element_meta->computed_values, parent_values, document_values, dp_ratio, ppi);
 	}
 
+	// Right now we are assuming computed values are calculated before OnPropertyChange
+
 	UpdateDirtyProperties();
 
 	if (box_dirty)

+ 12 - 0
Source/Core/ElementStyle.cpp

@@ -1222,6 +1222,11 @@ void ElementStyle::ComputeValues(Style::ComputedValues& values, const Style::Com
 	else if (parent_values)
 		values.font_weight = parent_values->font_weight;
 
+	if (auto p = GetLocalProperty(TEXT_DECORATION))
+		values.text_decoration = (Style::TextDecoration)p->Get< int >();
+	else if (parent_values)
+		values.text_decoration = parent_values->text_decoration;
+
 
 	if (auto p = GetLocalProperty(OVERFLOW_X))
 		values.overflow_x = (Style::Overflow)p->Get< int >();
@@ -1247,6 +1252,13 @@ void ElementStyle::ComputeValues(Style::ComputedValues& values, const Style::Com
 	if (auto p = GetLocalProperty(IMAGE_COLOR))
 		values.image_color = p->Get<Colourb>();
 
+	if (auto p = GetLocalProperty(COLOR))
+		values.color = p->Get<Colourb>();
+	else if (parent_values)
+		values.color = parent_values->color;
+
+
+
 }
 
 }

+ 5 - 3
Source/Core/ElementTextDefault.cpp

@@ -30,6 +30,7 @@
 #include "ElementDefinition.h"
 #include "ElementStyle.h"
 #include "FontFaceHandle.h"
+#include "RCSS.h"
 #include "../../Include/Rocket/Core/ElementDocument.h"
 #include "../../Include/Rocket/Core/ElementUtilities.h"
 #include "../../Include/Rocket/Core/Event.h"
@@ -285,13 +286,14 @@ void ElementTextDefault::OnPropertyChange(const PropertyNameList& changed_proper
 
 	bool colour_changed = false;
 	bool font_face_changed = false;
+	auto& computed = GetComputedValues();
 
 	if (changed_properties.find(COLOR) != changed_properties.end() || 
 		changed_properties.find(OPACITY) != changed_properties.end())
 	{
 		// Fetch our (potentially) new colour.
-		Colourb new_colour = GetProperty(COLOR)->value.Get< Colourb >();
-		float opacity = GetProperty(OPACITY)->value.Get< float>();
+		Colourb new_colour = computed.color;
+		float opacity = computed.opacity;
 		new_colour.alpha = byte(opacity * float(new_colour.alpha));
 		colour_changed = colour != new_colour;
 		if (colour_changed)
@@ -312,7 +314,7 @@ void ElementTextDefault::OnPropertyChange(const PropertyNameList& changed_proper
 
 	if (changed_properties.find(TEXT_DECORATION) != changed_properties.end())
 	{
-		decoration_property = GetProperty< int >(TEXT_DECORATION);
+		decoration_property = (int)computed.text_decoration;
 		if (decoration_property != TEXT_DECORATION_NONE)
 		{
 			if (decoration_property != generated_decoration)

+ 1 - 1
Source/Core/RCSS.h

@@ -84,7 +84,7 @@ enum class TabIndex { None, Auto };
 enum class Focus { None, Auto };
 enum class PointerEvents { None, Auto };
 
-
+// A computed value is a value resolved as far as possible :before: updating layout. See CSS specs for details of each property.
 struct ComputedValues
 {
 	LengthPercentageAuto margin_top, margin_right, margin_bottom, margin_left;