Browse Source

Replace style cache by computed values

Michael Ragazzon 6 years ago
parent
commit
cfbf05d038
38 changed files with 155 additions and 1105 deletions
  1. 0 2
      Build/cmake/FileList.cmake
  2. 3 2
      Include/Rocket/Core/ComputedValues.h
  3. 6 45
      Include/Rocket/Core/Element.h
  4. 0 21
      Include/Rocket/Core/ElementUtilities.h
  5. 1 0
      Samples/basic/benchmark/src/main.cpp
  6. 1 1
      Source/Controls/ElementFormControlTextArea.cpp
  7. 1 1
      Source/Controls/InputTypeText.cpp
  8. 6 6
      Source/Controls/WidgetTextInput.cpp
  9. 1 1
      Source/Core/Context.cpp
  10. 42 146
      Source/Core/Element.cpp
  11. 6 6
      Source/Core/ElementHandle.cpp
  12. 1 1
      Source/Core/ElementScroll.cpp
  13. 8 142
      Source/Core/ElementStyle.cpp
  14. 0 57
      Source/Core/ElementStyle.h
  15. 0 393
      Source/Core/ElementStyleCache.cpp
  16. 0 138
      Source/Core/ElementStyleCache.h
  17. 1 54
      Source/Core/ElementUtilities.cpp
  18. 14 13
      Source/Core/LayoutBlockBox.cpp
  19. 2 2
      Source/Core/LayoutBlockBox.h
  20. 4 4
      Source/Core/LayoutBlockBoxSpace.cpp
  21. 1 1
      Source/Core/LayoutBlockBoxSpace.h
  22. 2 2
      Source/Core/LayoutEngine.cpp
  23. 20 31
      Source/Core/LayoutInlineBox.cpp
  24. 2 5
      Source/Core/LayoutInlineBox.h
  25. 1 1
      Source/Core/LayoutInlineBoxText.cpp
  26. 10 10
      Source/Core/LayoutLineBox.cpp
  27. 1 1
      Source/Core/StyleSheetNodeSelectorEmpty.cpp
  28. 1 1
      Source/Core/StyleSheetNodeSelectorFirstChild.cpp
  29. 1 1
      Source/Core/StyleSheetNodeSelectorFirstOfType.cpp
  30. 1 1
      Source/Core/StyleSheetNodeSelectorLastChild.cpp
  31. 1 1
      Source/Core/StyleSheetNodeSelectorLastOfType.cpp
  32. 1 1
      Source/Core/StyleSheetNodeSelectorNthChild.cpp
  33. 1 1
      Source/Core/StyleSheetNodeSelectorNthLastChild.cpp
  34. 1 1
      Source/Core/StyleSheetNodeSelectorNthLastOfType.cpp
  35. 1 1
      Source/Core/StyleSheetNodeSelectorNthOfType.cpp
  36. 1 1
      Source/Core/StyleSheetNodeSelectorOnlyChild.cpp
  37. 1 1
      Source/Core/StyleSheetNodeSelectorOnlyOfType.cpp
  38. 11 9
      Source/Core/WidgetSlider.cpp

+ 0 - 2
Build/cmake/FileList.cmake

@@ -25,7 +25,6 @@ set(Core_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementHandle.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementImage.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementStyle.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/ElementStyleCache.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementTextDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/EventDispatcher.h
     ${PROJECT_SOURCE_DIR}/Source/Core/EventInstancerDefault.h
@@ -238,7 +237,6 @@ set(Core_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementReference.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementScroll.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementStyle.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/ElementStyleCache.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementText.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementTextDefault.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementUtilities.cpp

+ 3 - 2
Include/Rocket/Core/ComputedValues.h

@@ -28,11 +28,12 @@
 #ifndef ROCKETCORERCSS_H
 #define ROCKETCORERCSS_H
 
+#include "Types.h"
+#include "Animation.h"
+
 namespace Rocket {
 namespace Core {
 
-#include "Types.h"
-
 struct LengthPercentageAuto {
 	enum Type { Length, Percentage, Auto } type = Length;
 	float value = 0;

+ 6 - 45
Include/Rocket/Core/Element.h

@@ -32,6 +32,7 @@
 #include "ScriptInterface.h"
 #include "Header.h"
 #include "Box.h"
+#include "ComputedValues.h"
 #include "Event.h"
 #include "Property.h"
 #include "Types.h"
@@ -231,57 +232,17 @@ public:
 	/// @return The value of this property for this element.
 	float ResolveProperty(const Property *property, float base_value);
 
-	/// Returns 'top', 'bottom', 'left' and 'right' properties from element's style or local cache.
-	void GetOffsetProperties(const Property **top, const Property **bottom, const Property **left, const Property **right );
-	/// Returns 'border-width' properties from element's style or local cache.
-	void GetBorderWidthProperties(const Property **border_top_width, const Property **border_bottom_width, const Property **border_left_width, const Property **border_right_width);
-	/// Returns 'margin' properties from element's style or local cache.
-	void GetMarginProperties(const Property **margin_top, const Property **margin_bottom, const Property **margin_left, const Property **margin_right);
-	/// Returns 'padding' properties from element's style or local cache.
-	void GetPaddingProperties(const Property **padding_top, const Property **padding_bottom, const Property **padding_left, const Property **padding_right);
-	/// Returns 'width' and 'height' properties from element's style or local cache.
-	void GetDimensionProperties(const Property **width, const Property **height);
-	/// Returns local 'width' and 'height' properties from element's style or local cache,
-	/// ignoring default values.
-	void GetLocalDimensionProperties(const Property **width, const Property **height);
 	/// Returns the size of the containing block. Often percentages are scaled relative to this.
 	Vector2f GetContainingBlock();
-	/// Returns 'overflow' properties' values from element's style or local cache.
-	void GetOverflow(int *overflow_x, int *overflow_y);
 	/// Returns 'position' property value from element's style or local cache.
-	int GetPosition();
+	Style::Position GetPosition();
 	/// Returns 'float' property value from element's style or local cache.
-	int GetFloat();
+	Style::Float GetFloat();
 	/// Returns 'display' property value from element's style or local cache.
-	int GetDisplay();
-	/// Returns 'white-space' property value from element's style or local cache.
-	int GetWhitespace();
-	/// Returns 'pointer-events' property value from element's style or local cache.
-	int GetPointerEvents();
-
+	Style::Display GetDisplay();
 	/// Returns 'line-height' property value from element's style or local cache.
-	const Property *GetLineHeightProperty();
-	/// Returns 'text-align' property value from element's style or local cache.
-	int GetTextAlign();
-	/// Returns 'text-transform' property value from element's style or local cache.
-	int GetTextTransform();
-	/// Returns 'vertical-align' property value from element's style or local cache.
-	const Property *GetVerticalAlignProperty();
-
-	/// Returns 'perspective' property value from element's style or local cache.
-	const Property *GetPerspective();
-	/// Returns 'perspective-origin-x' property value from element's style or local cache.
-	const Property *GetPerspectiveOriginX();
-	/// Returns 'perspective-origin-y' property value from element's style or local cache.
-	const Property *GetPerspectiveOriginY();
-	/// Returns 'transform' property value from element's style or local cache.
-	const Property *GetTransform();
-	/// Returns 'transform-origin-x' property value from element's style or local cache.
-	const Property *GetTransformOriginX();
-	/// Returns 'transform-origin-y' property value from element's style or local cache.
-	const Property *GetTransformOriginY();
-	/// Returns 'transform-origin-z' property value from element's style or local cache.
-	const Property *GetTransformOriginZ();
+	float GetLineHeight();
+
 	/// Returns this element's TransformState
 	const TransformState *GetTransformState() const noexcept;
 	/// Returns the TransformStates that are effective for this element.

+ 0 - 21
Include/Rocket/Core/ElementUtilities.h

@@ -87,14 +87,6 @@ public:
 	/// @param[in] element The element to determine the density-independent pixel ratio for.
 	/// @return The density-independent pixel ratio of the context, or 1.0 if no context assigned.
 	static float GetDensityIndependentPixelRatio(Element* element);
-	/// Returns an element's font size, if it has a font defined.
-	/// @param[in] element The element to determine the font size for.
-	/// @return The font size as determined by the element's font, or 0 if it has no font specified.
-	static int GetFontSize(Element* element);
-	/// Returns an element's line height, if it has a font defined.
-	/// @param[in] element The element to determine the line height for.
-	/// @return The line height as specified by the element's font and line height styles.
-	static int GetLineHeight(Element* element);
 	/// Returns the width of a string rendered within the context of the given element.
 	/// @param[in] element The element to measure the string from.
 	/// @param[in] string The string to measure.
@@ -134,11 +126,6 @@ public:
 	/// @param[in] inline_element True if the element is placed in an inline context, false if not.
 	static void BuildBox(Box& box, const Vector2f& containing_block, Element* element, bool inline_element = false);
 
-	/// Sizes and positions an element within its parent. Any relative values will be evaluated against the size of the
-	/// element parent's content area.
-	/// @param element[in] The element to size and position.
-	/// @param offset[in] The offset of the element inside its parent's content area.
-	static bool PositionElement(Element* element, const Vector2f& offset);
 	/// Sizes an element, and positions it within its parent offset from the borders of its content area. Any relative
 	/// values will be evaluated against the size of the element parent's content area.
 	/// @param element[in] The element to size and position.
@@ -155,14 +142,6 @@ public:
 	/// @param[in] element		The element whose transform to unapply.
 	/// @return true if the element has a transform and it could be unapplied.
 	static bool UnapplyTransform(Element &element);
-
-	/// Projects the mouse cursor coordinates into a transformed element's plane.
-	/// @param[in/out] dict		The dictionary with the projected mouse coordinates.
-	/// @param[in] old_dict		The dictionary with the original mouse coordinates.
-	/// @param[in] element		The element to project the mouse coordinates into.
-	/// @param[in] view		The current global projection and view matrices.
-	/// @return true, if the mouse coordinates could be updated.
-	static bool ProjectMouse(Dictionary &dict, const Dictionary &old_dict, Element &element, const ViewState *view = 0);
 };
 
 }

+ 1 - 0
Samples/basic/benchmark/src/main.cpp

@@ -94,6 +94,7 @@ public:
 		  Computing all the values (only using a few of them yet): 83.0  [9fe9bdf]
 		  Computed transform and other optimizations: 86.0  [654fa09]
 		  Computed layout engine: 90.0   [e18ac30]
+		  Replace style cache by computed values: 96.0
 		
 		*/
 

+ 1 - 1
Source/Controls/ElementFormControlTextArea.cpp

@@ -120,7 +120,7 @@ bool ElementFormControlTextArea::GetWordWrap()
 bool ElementFormControlTextArea::GetIntrinsicDimensions(Rocket::Core::Vector2f& dimensions)
 {
 	dimensions.x = (float) (GetNumColumns() * Core::ElementUtilities::GetStringWidth(this, L"m"));
-	dimensions.y = (float) (GetNumRows() * Core::ElementUtilities::GetLineHeight(this));
+	dimensions.y = (float)GetNumRows() * GetLineHeight();
 
 	return true;
 }

+ 1 - 1
Source/Controls/InputTypeText.cpp

@@ -110,7 +110,7 @@ void InputTypeText::ProcessEvent(Core::Event& ROCKET_UNUSED_PARAMETER(event))
 bool InputTypeText::GetIntrinsicDimensions(Rocket::Core::Vector2f& dimensions)
 {
 	dimensions.x = (float) (size * Core::ElementUtilities::GetStringWidth(element, L"m"));
-	dimensions.y = (float) Core::ElementUtilities::GetLineHeight(element) + 2;
+	dimensions.y = element->GetLineHeight() + 2.0f;
 
 	return true;
 }

+ 6 - 6
Source/Controls/WidgetTextInput.cpp

@@ -598,7 +598,7 @@ void WidgetTextInput::UpdateRelativeCursor()
 // Calculates the line index under a specific vertical position.
 int WidgetTextInput::CalculateLineIndex(float position)
 {
-	float line_height = (float) Core::ElementUtilities::GetLineHeight(parent);
+	float line_height = parent->GetLineHeight();
 	int line_index = Rocket::Core::Math::RealToInteger(position / line_height);
 	return Rocket::Core::Math::Clamp(line_index, 0, (int) (lines.size() - 1));
 }
@@ -739,7 +739,7 @@ Rocket::Core::Vector2f WidgetTextInput::FormatText()
 	std::vector< int >& selection_indices = selection_geometry.GetIndices();
 
 	// Determine the line-height of the text element.
-	int line_height = Rocket::Core::ElementUtilities::GetLineHeight(parent);
+	float line_height = parent->GetLineHeight();
 
 	int line_begin = 0;
 	Rocket::Core::Vector2f line_position(0, 0);
@@ -818,7 +818,7 @@ Rocket::Core::Vector2f WidgetTextInput::FormatText()
 
 			selection_vertices.resize(selection_vertices.size() + 4);
 			selection_indices.resize(selection_indices.size() + 6);
-			Core::GeometryUtilities::GenerateQuad(&selection_vertices[selection_vertices.size() - 4], &selection_indices[selection_indices.size() - 6], line_position, Rocket::Core::Vector2f((float)selection_width, (float)line_height), selection_colour, (int)selection_vertices.size() - 4);
+			Core::GeometryUtilities::GenerateQuad(&selection_vertices[selection_vertices.size() - 4], &selection_indices[selection_indices.size() - 6], line_position, Rocket::Core::Vector2f((float)selection_width, line_height), selection_colour, (int)selection_vertices.size() - 4);
 
 			line_position.x += selection_width;
 		}
@@ -873,8 +873,8 @@ void WidgetTextInput::GenerateCursor()
 	std::vector< int >& indices = cursor_geometry.GetIndices();
 	indices.resize(6);
 
-	cursor_size.x = 1;
-	cursor_size.y = (float) Core::ElementUtilities::GetLineHeight(text_element) + 2;
+	cursor_size.x = Core::ElementUtilities::GetDensityIndependentPixelRatio(text_element);
+	cursor_size.y = text_element->GetLineHeight() + 2.0f;
 	Core::GeometryUtilities::GenerateQuad(&vertices[0], &indices[0], Rocket::Core::Vector2f(0, 0), cursor_size, parent->GetProperty< Rocket::Core::Colourb >("color"));
 }
 
@@ -884,7 +884,7 @@ void WidgetTextInput::UpdateCursorPosition()
 		return;
 
 	cursor_position.x = (float) Core::ElementUtilities::GetStringWidth(text_element, lines[cursor_line_index].content.substr(0, cursor_character_index));
-	cursor_position.y = -1 + cursor_line_index * (float) Core::ElementUtilities::GetLineHeight(text_element);
+	cursor_position.y = -1.f + (float)cursor_line_index * text_element->GetLineHeight();
 }
 
 // Expand the text selection to the position of the cursor.

+ 1 - 1
Source/Core/Context.cpp

@@ -1072,7 +1072,7 @@ Element* Context::GetElementAtPoint(const Vector2f& point, const Element* ignore
 	}
 
 	// Ignore elements whose pointer events are disabled
-	if (element->GetPointerEvents() == POINTER_EVENTS_NONE)
+	if (element->GetComputedValues().pointer_events == Style::PointerEvents::None)
 		return NULL;
 
 	Vector2f projected_point = element->Project(point);

+ 42 - 146
Source/Core/Element.cpp

@@ -382,7 +382,7 @@ String Element::GetAddress(bool include_pseudo_classes) const
 // Sets the position of this element, as a two-dimensional offset from another element.
 void Element::SetOffset(const Vector2f& offset, Element* _offset_parent, bool _offset_fixed)
 {
-	_offset_fixed |= GetPosition() == POSITION_FIXED;
+	_offset_fixed |= GetPosition() == Style::Position::Fixed;
 
 	// If our offset has definitely changed, or any of our parenting has, then these are set and
 	// updated based on our left / right / top / bottom properties.
@@ -632,50 +632,21 @@ float Element::ResolveProperty(const Property *property, float base_value)
 	return style->ResolveProperty(property, base_value);
 }
 
-void Element::GetOffsetProperties(const Property **top, const Property **bottom, const Property **left, const Property **right )
-{
-	style->GetOffsetProperties(top, bottom, left, right);
-}
-
-void Element::GetBorderWidthProperties(const Property **border_top, const Property **border_bottom, const Property **border_left, const Property **bottom_right)
-{
-	style->GetBorderWidthProperties(border_top, border_bottom, border_left, bottom_right);
-}
-
-void Element::GetMarginProperties(const Property **margin_top, const Property **margin_bottom, const Property **margin_left, const Property **margin_right)
-{
-	style->GetMarginProperties(margin_top, margin_bottom, margin_left, margin_right);
-}
-
-void Element::GetPaddingProperties(const Property **padding_top, const Property **padding_bottom, const Property **padding_left, const Property **padding_right)
-{
-	style->GetPaddingProperties(padding_top, padding_bottom, padding_left, padding_right);
-}
-
-void Element::GetDimensionProperties(const Property **width, const Property **height)
-{
-	style->GetDimensionProperties(width, height);
-}
-
-void Element::GetLocalDimensionProperties(const Property **width, const Property **height)
-{
-	style->GetLocalDimensionProperties(width, height);
-}
-
 Vector2f Element::GetContainingBlock()
 {
 	Vector2f containing_block(0, 0);
 
 	if (offset_parent != NULL)
 	{
-		int position_property = GetPosition();
+		using namespace Style;
+		Position position_property = GetPosition();
 		const Box& parent_box = offset_parent->GetBox();
 
-		if (position_property == POSITION_STATIC || position_property == POSITION_RELATIVE)
+		if (position_property == Position::Static || position_property == Position::Relative)
 		{
 			containing_block = parent_box.GetSize();
 		}
-		else if(position_property == POSITION_ABSOLUTE || position_property == POSITION_FIXED)
+		else if(position_property == Position::Absolute || position_property == Position::Fixed)
 		{
 			containing_block = parent_box.GetSize(Box::PADDING);
 		}
@@ -684,96 +655,24 @@ Vector2f Element::GetContainingBlock()
 	return containing_block;
 }
 
-void Element::GetOverflow(int *overflow_x, int *overflow_y)
-{
-	style->GetOverflow(overflow_x, overflow_y);
-}
-
-int Element::GetPosition()
-{
-	return style->GetPosition();
-}
-
-int Element::GetFloat()
-{
-	return style->GetFloat();
-}
-
-int Element::GetDisplay()
-{
-	return style->GetDisplay();
-}
-
-int Element::GetWhitespace()
+Style::Position Element::GetPosition()
 {
-	return style->GetWhitespace();
+	return element_meta->computed_values.position;
 }
 
-int Element::GetPointerEvents()
+Style::Float Element::GetFloat()
 {
-	return style->GetPointerEvents();
+	return element_meta->computed_values.float_;
 }
 
-const Property *Element::GetLineHeightProperty()
+Style::Display Element::GetDisplay()
 {
-	return style->GetLineHeightProperty();
+	return element_meta->computed_values.display;
 }
 
-int Element::GetTextAlign()
+float Element::GetLineHeight()
 {
-	return style->GetTextAlign();
-}
-
-int Element::GetTextTransform()
-{
-	return style->GetTextTransform();
-}
-
-const Property *Element::GetVerticalAlignProperty()
-{
-	return style->GetVerticalAlignProperty();
-}
-
-// Returns 'perspective' property value from element's style or local cache.
-const Property *Element::GetPerspective()
-{
-	return style->GetPerspective();
-}
-
-// Returns 'perspective-origin-x' property value from element's style or local cache.
-const Property *Element::GetPerspectiveOriginX()
-{
-	return style->GetPerspectiveOriginX();
-}
-
-// Returns 'perspective-origin-y' property value from element's style or local cache.
-const Property *Element::GetPerspectiveOriginY()
-{
-	return style->GetPerspectiveOriginY();
-}
-
-// Returns 'transform' property value from element's style or local cache.
-const Property *Element::GetTransform()
-{
-	return style->GetTransform();
-}
-
-// Returns 'transform-origin-x' property value from element's style or local cache.
-const Property *Element::GetTransformOriginX()
-{
-	return style->GetTransformOriginX();
-}
-
-// Returns 'transform-origin-y' property value from element's style or local cache.
-const Property *Element::GetTransformOriginY()
-{
-	return style->GetTransformOriginY();
-}
-
-// Returns 'transform-origin-z' property value from element's style or local cache.
-const Property *Element::GetTransformOriginZ()
-{
-	return style->GetTransformOriginZ();
+	return element_meta->computed_values.line_height.value;
 }
 
 // Returns this element's TransformState
@@ -2109,7 +2008,7 @@ void Element::ProcessEvent(Event& event)
 				if ((wheel_delta < 0 && GetScrollTop() > 0) ||
 					(wheel_delta > 0 && GetScrollHeight() > GetScrollTop() + GetClientHeight()))
 				{
-					SetScrollTop(GetScrollTop() + wheel_delta * (GetFontFaceHandle() ? ElementUtilities::GetLineHeight(this) : 0));
+					SetScrollTop(GetScrollTop() + wheel_delta * GetLineHeight());
 				}
 			}
 		}
@@ -2225,60 +2124,57 @@ void Element::DirtyOffset()
 
 void Element::UpdateOffset()
 {
-	int position_property = GetPosition();
-	if (position_property == POSITION_ABSOLUTE ||
-		position_property == POSITION_FIXED)
+	using namespace Style;
+	const auto& computed = element_meta->computed_values;
+	Position position_property = computed.position;
+
+	if (position_property == Position::Absolute ||
+		position_property == Position::Fixed)
 	{
 		if (offset_parent != NULL)
 		{
 			const Box& parent_box = offset_parent->GetBox();
 			Vector2f containing_block = parent_box.GetSize(Box::PADDING);
 
-			const Property *left = GetLocalProperty(LEFT);
-			const Property *right = GetLocalProperty(RIGHT);
 			// If the element is anchored left, then the position is offset by that resolved value.
-			if (left != NULL && left->unit != Property::KEYWORD)
-				relative_offset_base.x = parent_box.GetEdge(Box::BORDER, Box::LEFT) + (ResolveProperty(LEFT, containing_block.x) + GetBox().GetEdge(Box::MARGIN, Box::LEFT));
+			if (computed.left.type != LengthPercentageAuto::Auto)
+				relative_offset_base.x = parent_box.GetEdge(Box::BORDER, Box::LEFT) + (::Rocket::Core::ResolveProperty(computed.left, containing_block.x) + GetBox().GetEdge(Box::MARGIN, Box::LEFT));
+
 			// If the element is anchored right, then the position is set first so the element's right-most edge
 			// (including margins) will render up against the containing box's right-most content edge, and then
 			// offset by the resolved value.
-			else if (right != NULL && right->unit != Property::KEYWORD)
-				relative_offset_base.x = containing_block.x + parent_box.GetEdge(Box::BORDER, Box::LEFT) - (ResolveProperty(RIGHT, containing_block.x) + GetBox().GetSize(Box::BORDER).x + GetBox().GetEdge(Box::MARGIN, Box::RIGHT));
+			else if (computed.right.type != LengthPercentageAuto::Auto)
+				relative_offset_base.x = containing_block.x + parent_box.GetEdge(Box::BORDER, Box::LEFT) - (::Rocket::Core::ResolveProperty(computed.right, containing_block.x) + GetBox().GetSize(Box::BORDER).x + GetBox().GetEdge(Box::MARGIN, Box::RIGHT));
 
-			const Property *top = GetLocalProperty(TOP);
-			const Property *bottom = GetLocalProperty(BOTTOM);
 			// If the element is anchored top, then the position is offset by that resolved value.
-			if (top != NULL && top->unit != Property::KEYWORD)
-				relative_offset_base.y = parent_box.GetEdge(Box::BORDER, Box::TOP) + (ResolveProperty(TOP, containing_block.y) + GetBox().GetEdge(Box::MARGIN, Box::TOP));
+			if (computed.top.type != LengthPercentageAuto::Auto)
+				relative_offset_base.y = parent_box.GetEdge(Box::BORDER, Box::TOP) + (::Rocket::Core::ResolveProperty(computed.top, containing_block.y) + GetBox().GetEdge(Box::MARGIN, Box::TOP));
+
 			// If the element is anchored bottom, then the position is set first so the element's right-most edge
 			// (including margins) will render up against the containing box's right-most content edge, and then
 			// offset by the resolved value.
-			else if (bottom != NULL && bottom->unit != Property::KEYWORD)
-				relative_offset_base.y = containing_block.y + parent_box.GetEdge(Box::BORDER, Box::TOP) - (ResolveProperty(BOTTOM, containing_block.y) + GetBox().GetSize(Box::BORDER).y + GetBox().GetEdge(Box::MARGIN, Box::BOTTOM));
+			else if (computed.bottom.type != LengthPercentageAuto::Auto)
+				relative_offset_base.y = containing_block.y + parent_box.GetEdge(Box::BORDER, Box::TOP) - (::Rocket::Core::ResolveProperty(computed.bottom, containing_block.y) + GetBox().GetSize(Box::BORDER).y + GetBox().GetEdge(Box::MARGIN, Box::BOTTOM));
 		}
 	}
-	else if (position_property == POSITION_RELATIVE)
+	else if (position_property == Position::Relative)
 	{
 		if (offset_parent != NULL)
 		{
 			const Box& parent_box = offset_parent->GetBox();
 			Vector2f containing_block = parent_box.GetSize();
 
-			const Property *left = GetLocalProperty(LEFT);
-			const Property *right = GetLocalProperty(RIGHT);
-			if (left != NULL && left->unit != Property::KEYWORD)
-				relative_offset_position.x = ResolveProperty(LEFT, containing_block.x);
-			else if (right != NULL && right->unit != Property::KEYWORD)
-				relative_offset_position.x = -1 * ResolveProperty(RIGHT, containing_block.x);
+			if (computed.left.type != LengthPercentageAuto::Auto)
+				relative_offset_position.x = ::Rocket::Core::ResolveProperty(computed.left, containing_block.x);
+			else if (computed.right.type != LengthPercentageAuto::Auto)
+				relative_offset_position.x = -1 * ::Rocket::Core::ResolveProperty(computed.right, containing_block.x);
 			else
 				relative_offset_position.x = 0;
 
-			const Property *top = GetLocalProperty(TOP);
-			const Property *bottom = GetLocalProperty(BOTTOM);
-			if (top != NULL && top->unit != Property::KEYWORD)
-				relative_offset_position.y = ResolveProperty(TOP, containing_block.y);
-			else if (bottom != NULL && bottom->unit != Property::KEYWORD)
-				relative_offset_position.y = -1 * ResolveProperty(BOTTOM, containing_block.y);
+			if (computed.top.type != LengthPercentageAuto::Auto)
+				relative_offset_position.y = ::Rocket::Core::ResolveProperty(computed.top, containing_block.y);
+			else if (computed.bottom.type != LengthPercentageAuto::Auto)
+				relative_offset_position.y = -1 * ::Rocket::Core::ResolveProperty(computed.bottom, containing_block.y);
 			else
 				relative_offset_position.y = 0;
 		}
@@ -2315,11 +2211,11 @@ void Element::BuildStackingContext(ElementList* new_stacking_context)
 		std::pair< Element*, float > ordered_child;
 		ordered_child.first = child;
 
-		if (child->GetPosition() != POSITION_STATIC)
+		if (child->GetPosition() != Style::Position::Static)
 			ordered_child.second = 3;
-		else if (child->GetFloat() != FLOAT_NONE)
+		else if (child->GetFloat() != Style::Float::None)
 			ordered_child.second = 1;
-		else if (child->GetDisplay() == DISPLAY_BLOCK)
+		else if (child->GetDisplay() == Style::Display::Block)
 			ordered_child.second = 0;
 		else
 			ordered_child.second = 2;

+ 6 - 6
Source/Core/ElementHandle.cpp

@@ -113,17 +113,17 @@ void ElementHandle::ProcessEvent(Event& event)
 
 			if (size_target)
 			{
-				const Property *margin_top, *margin_bottom, *margin_left, *margin_right;
-				size_target->GetMarginProperties(&margin_top, &margin_bottom, &margin_left, &margin_right);
+				using namespace Style;
+				const auto& computed = GetComputedValues();
 
 				// Check if we have auto-margins; if so, they have to be set to the current margins.
-				if (margin_top->unit == Property::KEYWORD)
+				if (computed.margin_top.type == LengthPercentageAuto::Auto)
 					size_target->SetProperty(MARGIN_TOP, Property((float) Math::RealToInteger(size_target->GetBox().GetEdge(Box::MARGIN, Box::TOP)), Property::PX));
-				if (margin_right->unit == Property::KEYWORD)
+				if (computed.margin_right.type == LengthPercentageAuto::Auto)
 					size_target->SetProperty(MARGIN_RIGHT, Property((float) Math::RealToInteger(size_target->GetBox().GetEdge(Box::MARGIN, Box::RIGHT)), Property::PX));
-				if (margin_bottom->unit == Property::KEYWORD)
+				if (computed.margin_bottom.type == LengthPercentageAuto::Auto)
 					size_target->SetProperty(MARGIN_BOTTOM, Property((float) Math::RealToInteger(size_target->GetBox().GetEdge(Box::MARGIN, Box::BOTTOM)), Property::PX));
-				if (margin_left->unit == Property::KEYWORD)
+				if (computed.margin_left.type == LengthPercentageAuto::Auto)
 					size_target->SetProperty(MARGIN_LEFT, Property((float) Math::RealToInteger(size_target->GetBox().GetEdge(Box::MARGIN, Box::LEFT)), Property::PX));
 
 				int new_x = Math::RealToInteger(size_original_size.x + x);

+ 1 - 1
Source/Core/ElementScroll.cpp

@@ -197,7 +197,7 @@ void ElementScroll::FormatScrollbars()
 		slider_length -= Math::Max(user_scrollbar_margin, min_scrollbar_margin);
 
 		scrollbars[i].widget->FormatElements(containing_block, slider_length);
-		scrollbars[i].widget->SetLineHeight((float) ElementUtilities::GetLineHeight(element));
+		scrollbars[i].widget->SetLineHeight(element->GetLineHeight());
 
 		int variable_axis = i == VERTICAL ? 0 : 1;
 		Vector2f offset = element->GetBox().GetPosition(Box::PADDING);

+ 8 - 142
Source/Core/ElementStyle.cpp

@@ -27,7 +27,6 @@
 
 #include "precompiled.h"
 #include "ElementStyle.h"
-#include "ElementStyleCache.h"
 #include <algorithm>
 #include "../../Include/Rocket/Core/ElementDocument.h"
 #include "../../Include/Rocket/Core/ElementUtilities.h"
@@ -57,7 +56,6 @@ ElementStyle::ElementStyle(Element* _element)
 	em_properties = NULL;
 	definition = NULL;
 	element = _element;
-	cache = new ElementStyleCache(this);
 
 	definition_dirty = true;
 }
@@ -71,8 +69,6 @@ ElementStyle::~ElementStyle()
 
 	if (definition != NULL)
 		definition->RemoveReference();
-
-	delete cache;
 }
 
 
@@ -433,9 +429,9 @@ float ElementStyle::ResolveLength(const Property * property)
 	case Property::PX:
 		return property->value.Get< float >();
 	case Property::EM:
-		return property->value.Get< float >() * ElementUtilities::GetFontSize(element);
+		return property->value.Get< float >()* element->GetComputedValues().font_size;
 	case Property::REM:
-		return property->value.Get< float >() * ElementUtilities::GetFontSize(element->GetOwnerDocument());
+		return property->value.Get< float >()* element->GetOwnerDocument()->GetComputedValues().font_size;
 	case Property::DP:
 		return property->value.Get< float >() * ElementUtilities::GetDensityIndependentPixelRatio(element);
 	}
@@ -518,13 +514,13 @@ float ElementStyle::ResolveNumericProperty(const Property * property, RelativeTa
 		base_value = element->GetContainingBlock().y;
 		break;
 	case RelativeTarget::FontSize:
-		base_value = (float)ElementUtilities::GetFontSize(element);
+		base_value = element->GetComputedValues().font_size;
 		break;
 	case RelativeTarget::ParentFontSize:
-		base_value = (float)ElementUtilities::GetFontSize(element->GetParentNode());
+		base_value = element->GetParentNode()->GetComputedValues().font_size;
 		break;
 	case RelativeTarget::LineHeight:
-		base_value = (float)ElementUtilities::GetLineHeight(element);
+		base_value = element->GetLineHeight();
 		break;
 	default:
 		break;
@@ -566,9 +562,9 @@ float ElementStyle::ResolveProperty(const Property* property, float base_value)
 			return base_value * property->value.Get< float >() * 0.01f;
 
 		case Property::EM:
-			return property->value.Get< float >() * (float)ElementUtilities::GetFontSize(element);
+			return property->value.Get< float >() * element->GetComputedValues().font_size;
 		case Property::REM:
-			return property->value.Get< float >() * (float)ElementUtilities::GetFontSize(element->GetOwnerDocument());
+			return property->value.Get< float >() * element->GetOwnerDocument()->GetComputedValues().font_size;
 		case Property::DP:
 			return property->value.Get< float >() * ElementUtilities::GetDensityIndependentPixelRatio(element);
 
@@ -648,7 +644,7 @@ float ElementStyle::ResolveProperty(const String& name, float base_value)
 			case Property::REM:
 				// If an rem-relative font size is specified, it is expressed relative to the document's
 				// font height.
-				return property->value.Get< float >() * ElementUtilities::GetFontSize(element->GetOwnerDocument());
+				return property->value.Get< float >() * element->GetOwnerDocument()->GetComputedValues().font_size;
 		}
 	}
 
@@ -869,10 +865,6 @@ void ElementStyle::DirtyProperties(const PropertyNameList& properties, bool clea
 		}
 	}
 
-	// Clear all cached properties.
-	cache->Clear();
-	cache->ClearInherited();
-
 	// clear the list of EM-properties, we will refill it in DirtyEmProperties
 	if (clear_em_properties && em_properties != NULL)
 	{
@@ -912,9 +904,6 @@ void ElementStyle::DirtyInheritedProperties(const PropertyNameList& properties)
 		em_properties = NULL;
 	}
 
-	// Clear cached inherited properties.
-	cache->ClearInherited();
-
 	// Pass the list of those properties that this element doesn't override onto our children.
 	for (int i = 0; i < element->GetNumChildren(true); i++)
 		element->GetChild(i)->GetStyle()->DirtyInheritedProperties(inherited_properties);
@@ -922,129 +911,6 @@ void ElementStyle::DirtyInheritedProperties(const PropertyNameList& properties)
 	element->DirtyProperties(properties);
 }
 
-void ElementStyle::GetOffsetProperties(const Property **top, const Property **bottom, const Property **left, const Property **right )
-{
-	cache->GetOffsetProperties(top, bottom, left, right);
-}
-
-void ElementStyle::GetBorderWidthProperties(const Property **border_top_width, const Property **border_bottom_width, const Property **border_left_width, const Property **bottom_right_width)
-{
-	cache->GetBorderWidthProperties(border_top_width, border_bottom_width, border_left_width, bottom_right_width);
-}
-
-void ElementStyle::GetMarginProperties(const Property **margin_top, const Property **margin_bottom, const Property **margin_left, const Property **margin_right)
-{
-	cache->GetMarginProperties(margin_top, margin_bottom, margin_left, margin_right);
-}
-
-void ElementStyle::GetPaddingProperties(const Property **padding_top, const Property **padding_bottom, const Property **padding_left, const Property **padding_right)
-{
-	cache->GetPaddingProperties(padding_top, padding_bottom, padding_left, padding_right);
-}
-
-void ElementStyle::GetDimensionProperties(const Property **width, const Property **height)
-{
-	cache->GetDimensionProperties(width, height);
-}
-
-void ElementStyle::GetLocalDimensionProperties(const Property **width, const Property **height)
-{
-	cache->GetLocalDimensionProperties(width, height);
-}
-
-void ElementStyle::GetOverflow(int *overflow_x, int *overflow_y)
-{
-	cache->GetOverflow(overflow_x, overflow_y);
-}
-
-int ElementStyle::GetPosition()
-{
-	return cache->GetPosition();
-}
-
-int ElementStyle::GetFloat()
-{
-	return cache->GetFloat();
-}
-
-int ElementStyle::GetDisplay()
-{
-	return cache->GetDisplay();
-}
-
-int ElementStyle::GetWhitespace()
-{
-	return cache->GetWhitespace();
-}
-
-int ElementStyle::GetPointerEvents()
-{
-	return cache->GetPointerEvents();
-}
-
-const Property *ElementStyle::GetLineHeightProperty()
-{
-	return cache->GetLineHeightProperty();
-}
-
-int ElementStyle::GetTextAlign()
-{
-	return cache->GetTextAlign();
-}
-
-int ElementStyle::GetTextTransform()
-{
-	return cache->GetTextTransform();
-}
-
-const Property *ElementStyle::GetVerticalAlignProperty()
-{
-	return cache->GetVerticalAlignProperty();
-}
-
-// Returns 'perspective' property value from element's style or local cache.
-const Property *ElementStyle::GetPerspective()
-{
-	return element->GetProperty(PERSPECTIVE);
-}
-
-// Returns 'perspective-origin-x' property value from element's style or local cache.
-const Property *ElementStyle::GetPerspectiveOriginX()
-{
-	return element->GetProperty(PERSPECTIVE_ORIGIN_X);
-}
-
-// Returns 'perspective-origin-y' property value from element's style or local cache.
-const Property *ElementStyle::GetPerspectiveOriginY()
-{
-	return element->GetProperty(PERSPECTIVE_ORIGIN_Y);
-}
-
-// Returns 'transform' property value from element's style or local cache.
-const Property *ElementStyle::GetTransform()
-{
-	return element->GetProperty(TRANSFORM);
-}
-
-// Returns 'transform-origin-x' property value from element's style or local cache.
-const Property *ElementStyle::GetTransformOriginX()
-{
-	return element->GetProperty(TRANSFORM_ORIGIN_X);
-}
-
-// Returns 'transform-origin-y' property value from element's style or local cache.
-const Property *ElementStyle::GetTransformOriginY()
-{
-	return element->GetProperty(TRANSFORM_ORIGIN_Y);
-}
-
-// Returns 'transform-origin-z' property value from element's style or local cache.
-const Property *ElementStyle::GetTransformOriginZ()
-{
-	return element->GetProperty(TRANSFORM_ORIGIN_Z);
-}
-
-
 
 static float ComputeLength(const Property* property, float font_size, float document_font_size, float dp_ratio, float pixels_per_inch)
 {

+ 0 - 57
Source/Core/ElementStyle.h

@@ -34,10 +34,6 @@
 namespace Rocket {
 namespace Core {
 
-namespace Style { struct ComputedValues; }
-
-class ElementStyleCache;
-
 /**
 	Manages an element's style and property information.
 	@author Lloyd Weehuizen
@@ -165,57 +161,6 @@ public:
 	// Dirties dp properties.
 	void DirtyDpProperties();
 
-	/// Returns 'top', 'bottom', 'left' and 'right' properties from element's style or local cache.
-	void GetOffsetProperties(const Property **top, const Property **bottom, const Property **left, const Property **right );	
-	/// Returns 'border-width' properties from element's style or local cache.
-	void GetBorderWidthProperties(const Property **border_top_width, const Property **border_bottom_width, const Property **border_left_width, const Property **border_right_width);
-	/// Returns 'margin' properties from element's style or local cache.
-	void GetMarginProperties(const Property **margin_top, const Property **margin_bottom, const Property **margin_left, const Property **margin_right);
-	/// Returns 'padding' properties from element's style or local cache.
-	void GetPaddingProperties(const Property **padding_top, const Property **padding_bottom, const Property **padding_left, const Property **padding_right);
-	/// Returns 'width' and 'height' properties from element's style or local cache.
-	void GetDimensionProperties(const Property **width, const Property **height);
-	/// Returns local 'width' and 'height' properties from element's style or local cache,
-	/// ignoring default values.
-	void GetLocalDimensionProperties(const Property **width, const Property **height);
-	/// Returns 'overflow' properties' values from element's style or local cache.
-	void GetOverflow(int *overflow_x, int *overflow_y);
-	/// Returns 'position' property value from element's style or local cache.
-	int GetPosition();
-	/// Returns 'float' property value from element's style or local cache.
-	int GetFloat();
-	/// Returns 'display' property value from element's style or local cache.
-	int GetDisplay();
-	/// Returns 'white-space' property value from element's style or local cache.
-	int GetWhitespace();
-	/// Returns 'pointer-events' property value from element's style or local cache.
-	int GetPointerEvents();
-
-	/// Returns 'line-height' property value from element's style or local cache.
-	const Property *GetLineHeightProperty();
-	/// Returns 'text-align' property value from element's style or local cache.
-	int GetTextAlign();
-	/// Returns 'text-transform' property value from element's style or local cache.
-	int GetTextTransform();
-	/// Returns 'vertical-align' property value from element's style or local cache.
-	const Property *GetVerticalAlignProperty();
-
-	/// Returns 'perspective' property value from element's style or local cache.
-	const Property *GetPerspective();
-	/// Returns 'perspective-origin-x' property value from element's style or local cache.
-	const Property *GetPerspectiveOriginX();
-	/// Returns 'perspective-origin-y' property value from element's style or local cache.
-	const Property *GetPerspectiveOriginY();
-	/// Returns 'transform' property value from element's style or local cache.
-	const Property *GetTransform();
-	/// Returns 'transform-origin-x' property value from element's style or local cache.
-	const Property *GetTransformOriginX();
-	/// Returns 'transform-origin-y' property value from element's style or local cache.
-	const Property *GetTransformOriginY();
-	/// Returns 'transform-origin-z' property value from element's style or local cache.
-	const Property *GetTransformOriginZ();
-
-
 	void ComputeValues(Style::ComputedValues& values, const Style::ComputedValues* parent_values, const Style::ComputedValues* document_values, bool values_are_defaulted, float dp_ratio, float pixels_per_inch);
 
 private:
@@ -247,8 +192,6 @@ private:
 	ElementDefinition* definition;
 	// Set if a new element definition should be fetched from the style.
 	bool definition_dirty;
-	// cached non-inherited properties
-	ElementStyleCache *cache;
 };
 
 }

+ 0 - 393
Source/Core/ElementStyleCache.cpp

@@ -1,393 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "precompiled.h"
-#include "ElementStyle.h"
-#include "ElementStyleCache.h"
-
-namespace Rocket {
-namespace Core {
-
-ElementStyleCache::ElementStyleCache(ElementStyle *style) : style(style), 
-	top(NULL), bottom(NULL), left(NULL), right(NULL),
-	border_top_width(NULL), border_bottom_width(NULL), border_left_width(NULL), border_right_width(NULL),
-	margin_top(NULL), margin_bottom(NULL), margin_left(NULL), margin_right(NULL),
-	padding_top(NULL), padding_bottom(NULL), padding_left(NULL), padding_right(NULL),
-	width(NULL), height(NULL),
-	local_width(NULL), local_height(NULL), have_local_width(false), have_local_height(false),
-	overflow_x(-1), overflow_y(-1),
-	position(-1), float_(-1), display(-1), whitespace(-1),
-	line_height(NULL), text_align(-1), text_transform(-1), vertical_align(NULL),
-	pointer_events(-1)
-{
-}
-
-void ElementStyleCache::Clear()
-{
-	ClearOffset();
-	ClearBorder();
-	ClearMargin();
-	ClearPadding();
-	ClearDimensions();
-	ClearOverflow();
-	ClearPosition();
-	ClearFloat();
-	ClearDisplay();
-	ClearWhitespace();
-}
-
-void ElementStyleCache::ClearInherited()
-{
-	ClearLineHeight();
-	ClearTextAlign();
-	ClearTextTransform();
-	ClearVerticalAlign();
-	ClearPointerEvents();
-}
-
-void ElementStyleCache::ClearOffset()
-{
-	top = bottom = left = right = NULL;
-}
-
-void ElementStyleCache::ClearBorder()
-{
-	border_top_width = border_bottom_width = border_left_width = border_right_width = NULL;
-}
-
-void ElementStyleCache::ClearMargin()
-{
-	margin_top = margin_bottom = margin_left = margin_right = NULL;
-}
-
-void ElementStyleCache::ClearPadding()
-{
-	padding_top = padding_bottom = padding_left = padding_right = NULL;
-}
-
-void ElementStyleCache::ClearDimensions()
-{
-	width = height = NULL;
-	have_local_width = have_local_height = false;
-}
-
-void ElementStyleCache::ClearOverflow()
-{
-	overflow_x = overflow_y = -1;
-}
-
-void ElementStyleCache::ClearPosition()
-{
-	position = -1;
-}
-
-void ElementStyleCache::ClearFloat()
-{
-	float_ = -1;
-}
-
-void ElementStyleCache::ClearDisplay()
-{
-	display = -1;
-}
-
-void ElementStyleCache::ClearWhitespace()
-{
-	whitespace = -1;
-}
-
-void ElementStyleCache::ClearLineHeight()
-{
-	line_height = NULL;
-}
-
-void ElementStyleCache::ClearTextAlign()
-{
-	text_align = -1;
-}
-
-void ElementStyleCache::ClearTextTransform()
-{
-	text_transform = -1;
-}
-
-void ElementStyleCache::ClearVerticalAlign()
-{
-	vertical_align = NULL;
-}
-
-void ElementStyleCache::ClearPointerEvents()
-{
-	pointer_events = -1;
-}
-
-void ElementStyleCache::GetOffsetProperties(const Property **o_top, const Property **o_bottom, const Property **o_left, const Property **o_right )
-{
-	if (o_top)
-	{
-		if (!top)
-			top = style->GetProperty(TOP);
-		*o_top = top;
-	}
-
-	if (o_bottom)
-	{
-		if (!bottom)
-			bottom = style->GetProperty(BOTTOM);
-		*o_bottom = bottom;
-	}
-
-	if (o_left)
-	{
-		if (!left)
-			left = style->GetProperty(LEFT);
-		*o_left = left;
-	}
-
-	if (o_right)
-	{
-		if (!right)
-			right = style->GetProperty(RIGHT);
-		*o_right = right;
-	}
-}
-
-void ElementStyleCache::GetBorderWidthProperties(const Property **o_border_top_width, const Property **o_border_bottom_width, const Property **o_border_left_width, const Property **o_border_right_width)
-{
-	if (o_border_top_width)
-	{
-		if (!border_top_width)
-			border_top_width = style->GetProperty(BORDER_TOP_WIDTH);
-		*o_border_top_width = border_top_width;
-	}
-
-	if (o_border_bottom_width)
-	{
-		if (!border_bottom_width)
-			border_bottom_width = style->GetProperty(BORDER_BOTTOM_WIDTH);
-		*o_border_bottom_width = border_bottom_width;
-	}
-
-	if (o_border_left_width)
-	{
-		if (!border_left_width)
-			border_left_width = style->GetProperty(BORDER_LEFT_WIDTH);
-		*o_border_left_width = border_left_width;
-	}
-
-	if (o_border_right_width)
-	{
-		if (!border_right_width)
-			border_right_width = style->GetProperty(BORDER_RIGHT_WIDTH);
-		*o_border_right_width = border_right_width;
-	}
-}
-
-void ElementStyleCache::GetMarginProperties(const Property **o_margin_top, const Property **o_margin_bottom, const Property **o_margin_left, const Property **o_margin_right)
-{
-	if (o_margin_top)
-	{
-		if (!margin_top)
-			margin_top = style->GetProperty(MARGIN_TOP);
-		*o_margin_top = margin_top;
-	}
-
-	if (o_margin_bottom)
-	{
-		if (!margin_bottom)
-			margin_bottom = style->GetProperty(MARGIN_BOTTOM);
-		*o_margin_bottom = margin_bottom;
-	}
-
-	if (o_margin_left)
-	{
-		if (!margin_left)
-			margin_left = style->GetProperty(MARGIN_LEFT);
-		*o_margin_left = margin_left;
-	}
-
-	if (o_margin_right)
-	{
-		if (!margin_right)
-			margin_right = style->GetProperty(MARGIN_RIGHT);
-		*o_margin_right = margin_right;
-	}
-}
-
-void ElementStyleCache::GetPaddingProperties(const Property **o_padding_top, const Property **o_padding_bottom, const Property **o_padding_left, const Property **o_padding_right)
-{
-	if (o_padding_top)
-	{
-		if (!padding_top)
-			padding_top = style->GetProperty(PADDING_TOP);
-		*o_padding_top = padding_top;
-	}
-
-	if (o_padding_bottom)
-	{
-		if (!padding_bottom)
-			padding_bottom = style->GetProperty(PADDING_BOTTOM);
-		*o_padding_bottom = padding_bottom;
-	}
-
-	if (o_padding_left)
-	{
-		if (!padding_left)
-			padding_left = style->GetProperty(PADDING_LEFT);
-		*o_padding_left = padding_left;
-	}
-
-	if (o_padding_right)
-	{
-		if (!padding_right)
-			padding_right = style->GetProperty(PADDING_RIGHT);
-		*o_padding_right = padding_right;
-	}
-}
-
-void ElementStyleCache::GetDimensionProperties(const Property **o_width, const Property **o_height)
-{
-	if (o_width)
-	{
-		if (!width)
-			width = style->GetProperty(WIDTH);
-		*o_width = width;
-	}
-
-	if (o_height)
-	{
-		if (!height)
-			height = style->GetProperty(HEIGHT);
-		*o_height = height;
-	}
-}
-
-void ElementStyleCache::GetLocalDimensionProperties(const Property **o_width, const Property **o_height)
-{
-	if (o_width)
-	{
-		if (!have_local_width)
-		{
-			have_local_width = true;
-			local_width = style->GetLocalProperty(WIDTH);
-		}
-		*o_width = local_width;
-	}
-
-	if (o_height)
-	{
-		if (!have_local_height)
-		{
-			have_local_height = true;
-			local_height = style->GetLocalProperty(HEIGHT);
-		}
-		*o_height = local_height;
-	}
-}
-
-void ElementStyleCache::GetOverflow(int *o_overflow_x, int *o_overflow_y)
-{
-	if (o_overflow_x)
-	{
-		if (overflow_x < 0)
-			overflow_x = style->GetProperty(OVERFLOW_X)->Get< int >();
-		*o_overflow_x = overflow_x;
-	}
-
-	if (o_overflow_y)
-	{
-		if (overflow_y < 0)
-			overflow_y = style->GetProperty(OVERFLOW_Y)->Get< int >();
-		*o_overflow_y = overflow_y;
-	}
-}
-
-int ElementStyleCache::GetPosition()
-{
-	if (position < 0)
-		position = style->GetProperty(POSITION)->Get< int >();
-	return position;
-}
-
-int ElementStyleCache::GetFloat()
-{
-	if (float_ < 0)
-		float_ = style->GetProperty(FLOAT)->Get< int >();
-	return float_;
-}
-
-int ElementStyleCache::GetDisplay()
-{
-	if (display < 0)
-		display = style->GetProperty(DISPLAY)->Get< int >();
-	return display;
-}
-
-int ElementStyleCache::GetWhitespace()
-{
-	if (whitespace < 0)
-		whitespace = style->GetProperty(WHITE_SPACE)->Get< int >();
-	return whitespace;
-}
-
-int ElementStyleCache::GetPointerEvents()
-{
-	if (pointer_events < 0)
-		pointer_events = style->GetProperty(POINTER_EVENTS)->Get< int >();
-	return pointer_events;
-}
-
-const Property *ElementStyleCache::GetLineHeightProperty()
-{
-	if (!line_height)
-		line_height = style->GetProperty(LINE_HEIGHT);
-	return line_height;
-}
-
-int ElementStyleCache::GetTextAlign()
-{
-	if (text_align < 0)
-		text_align = style->GetProperty(TEXT_ALIGN)->Get< int >();
-	return text_align;
-}
-
-int ElementStyleCache::GetTextTransform()
-{
-	if (text_transform < 0)
-		text_transform = style->GetProperty(TEXT_TRANSFORM)->Get< int >();
-	return text_transform;
-}
-
-const Property *ElementStyleCache::GetVerticalAlignProperty()
-{
-	if (!vertical_align)
-		vertical_align = style->GetProperty(VERTICAL_ALIGN);
-	return vertical_align;
-}
-
-}
-}

+ 0 - 138
Source/Core/ElementStyleCache.h

@@ -1,138 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef ROCKETCOREELEMENTSTYLECACHE_H
-#define ROCKETCOREELEMENTSTYLECACHE_H
-
-#include "ElementDefinition.h"
-#include "../../Include/Rocket/Core/Types.h"
-
-namespace Rocket {
-namespace Core {
-
-class ElementStyle;
-
-/**
-	Manages caching of layout-important properties and provides
-	O(1) access to them (note that for invalidated cache, the access
-	time is still O(log(N)) as per standard std::map).
-	@author Victor Luchits
- */
-
-class ElementStyleCache
-{
-public:
-	ElementStyleCache(ElementStyle *style);
-
-	/// Invalidation function for all non-inherited properties
-	void Clear();
-
-	/// Invalidation function for all inherited properties
-	void ClearInherited();
-
-	/// Invalidation functions for individual and grouped non-inherited properties
-	void ClearOffset();
-	void ClearBorder();
-	void ClearMargin();
-	void ClearPadding();
-	void ClearDimensions();
-	void ClearPosition();
-	void ClearFloat();
-	void ClearDisplay();
-	void ClearWhitespace();
-	void ClearOverflow();
-
-	/// Invalidation functions for individual and grouped inherited properties
-	void ClearLineHeight();
-	void ClearTextAlign();
-	void ClearTextTransform();
-	void ClearVerticalAlign();
-	void ClearPointerEvents();
-
-	/// Returns 'top', 'bottom', 'left' and 'right' properties from element's style or local cache.
-	void GetOffsetProperties(const Property **top, const Property **bottom, const Property **left, const Property **right );
-	/// Returns 'border-width' properties from element's style or local cache.
-	void GetBorderWidthProperties(const Property **border_top_width, const Property **border_bottom_width, const Property **border_left_width, const Property **border_right_width);
-	/// Returns 'margin' properties from element's style or local cache.
-	void GetMarginProperties(const Property **margin_top, const Property **margin_bottom, const Property **margin_left, const Property **margin_right);
-	/// Returns 'padding' properties from element's style or local cache.
-	void GetPaddingProperties(const Property **padding_top, const Property **padding_bottom, const Property **padding_left, const Property **padding_right);
-	/// Returns 'width' and 'height' properties from element's style or local cache.
-	void GetDimensionProperties(const Property **width, const Property **height);
-	/// Returns local 'width' and 'height' properties from element's style or local cache,
-	/// ignoring default values.
-	void GetLocalDimensionProperties(const Property **width, const Property **height);
-	/// Returns 'overflow' properties' values from element's style or local cache.
-	void GetOverflow(int *overflow_x, int *overflow_y);
-	/// Returns 'position' property value from element's style or local cache.
-	int GetPosition();
-	/// Returns 'float' property value from element's style or local cache.
-	int GetFloat();
-	/// Returns 'display' property value from element's style or local cache.
-	int GetDisplay();
-	/// Returns 'white-space' property value from element's style or local cache.
-	int GetWhitespace();
-	/// Returns 'pointer-events' property value from element's style or local cache.
-	int GetPointerEvents();
-
-	/// Returns 'line-height' property value from element's style or local cache.
-	const Property *GetLineHeightProperty();
-	/// Returns 'text-align' property value from element's style or local cache.
-	int GetTextAlign();
-	/// Returns 'text-transform' property value from element's style or local cache.
-	int GetTextTransform();
-	/// Returns 'vertical-align' property value from element's style or local cache.
-	const Property *GetVerticalAlignProperty();
-
-private:
-	/// Element style that owns this cache instance.
-	ElementStyle *style;
-
-	/// Cached properties.
-	const Property *top, *bottom, *left, *right;
-	const Property *border_top_width, *border_bottom_width, *border_left_width, *border_right_width;
-	const Property *margin_top, *margin_bottom, *margin_left, *margin_right;
-	const Property *padding_top, *padding_bottom, *padding_left, *padding_right;
-	const Property *width, *height;
-	const Property *local_width, *local_height;
-	bool have_local_width, have_local_height;
-	int overflow_x, overflow_y;
-	int position;
-	int float_;
-	int display;
-	int whitespace;
-	const Property *line_height;
-	int text_align;
-	int text_transform;
-	const Property *vertical_align;
-	int pointer_events;
-};
-
-}
-}
-
-#endif

+ 1 - 54
Source/Core/ElementUtilities.cpp

@@ -134,45 +134,6 @@ float ElementUtilities::GetDensityIndependentPixelRatio(Element * element)
 	return context->GetDensityIndependentPixelRatio();
 }
 
-// Returns an element's font size, if it has a font defined.
-int ElementUtilities::GetFontSize(Element* element)
-{
-	FontFaceHandle* font_face_handle = element->GetFontFaceHandle();
-	if (font_face_handle == NULL)
-		return 0;
-	
-	return font_face_handle->GetSize();
-}
-
-// Returns an element's line height, if it has a font defined.
-int ElementUtilities::GetLineHeight(Element* element)
-{
-	const Property* line_height_property = element->GetLineHeightProperty();
-
-	if (line_height_property->unit & Property::LENGTH)
-	{
-		float value = element->GetStyle()->ResolveLength(line_height_property);
-		return Math::RoundToInteger(value);
-	}
-
-	float scale_factor = 1.0f;
-
-	switch (line_height_property->unit)
-	{
-	case Property::NUMBER:
-		scale_factor = line_height_property->value.Get< float >();
-		break;
-	case Property::PERCENT:
-		scale_factor = line_height_property->value.Get< float >() * 0.01f;
-		break;
-	}
-
-	float font_size = (float)GetFontSize(element);
-	float value = font_size * scale_factor;
-
-	return Math::RoundToInteger(value);
-}
-
 // Returns the width of a string rendered within the context of the given element.
 int ElementUtilities::GetStringWidth(Element* element, const WString& string)
 {
@@ -333,19 +294,6 @@ void ElementUtilities::BuildBox(Box& box, const Vector2f& containing_block, Elem
 	LayoutEngine::BuildBox(box, containing_block, element, inline_element);
 }
 
-// Sizes and positions an element within its parent.
-bool ElementUtilities::PositionElement(Element* element, const Vector2f& offset)
-{
-	Element* parent = element->GetParentNode();
-	if (parent == NULL)
-		return false;
-
-	SetBox(element);
-	SetElementOffset(element, offset);
-
-	return true;
-}
-
 // Sizes an element, and positions it within its parent offset from the borders of its content area.
 bool ElementUtilities::PositionElement(Element* element, const Vector2f& offset, PositionAnchor anchor)
 {
@@ -384,8 +332,7 @@ static void SetBox(Element* element)
 	Box box;
 	LayoutEngine::BuildBox(box, containing_block, element);
 
-	const Property *local_height;
-	element->GetLocalDimensionProperties(NULL, &local_height);
+	const Property *local_height = element->GetLocalProperty(HEIGHT);
 	if (local_height == NULL)
 		box.SetContent(Vector2f(box.GetSize().x, containing_block.y));
 

+ 14 - 13
Source/Core/LayoutBlockBox.cpp

@@ -71,7 +71,7 @@ LayoutBlockBox::LayoutBlockBox(LayoutEngine* _layout_engine, LayoutBlockBox* _pa
 	// Determine the offset parent for our children.
 	if (parent != NULL &&
 		parent->offset_parent->GetElement() != NULL &&
-		(element == NULL || element->GetPosition() == POSITION_STATIC))
+		(element == NULL || element->GetPosition() == Style::Position::Static))
 		offset_parent = parent->offset_parent;
 	else
 		offset_parent = this;
@@ -100,17 +100,19 @@ LayoutBlockBox::LayoutBlockBox(LayoutEngine* _layout_engine, LayoutBlockBox* _pa
 
 	if (element != NULL)
 	{
-		wrap_content = element->GetWhitespace() != WHITE_SPACE_NOWRAP;
+		const auto& computed = element->GetComputedValues();
+		wrap_content = computed.white_space != Style::WhiteSpace::Nowrap;
 
 		// Determine if this element should have scrollbars or not, and create them if so.
-		element->GetOverflow(&overflow_x_property, &overflow_y_property);
+		overflow_x_property = computed.overflow_x;
+		overflow_y_property = computed.overflow_y;
 
-		if (overflow_x_property == OVERFLOW_SCROLL)
+		if (overflow_x_property == Style::Overflow::Scroll)
 			element->GetElementScroll()->EnableScrollbar(ElementScroll::HORIZONTAL, box.GetSize(Box::PADDING).x);
 		else
 			element->GetElementScroll()->DisableScrollbar(ElementScroll::HORIZONTAL);
 
-		if (overflow_y_property == OVERFLOW_SCROLL)
+		if (overflow_y_property == Style::Overflow::Scroll)
 			element->GetElementScroll()->EnableScrollbar(ElementScroll::VERTICAL, box.GetSize(Box::PADDING).x);
 		else
 			element->GetElementScroll()->DisableScrollbar(ElementScroll::VERTICAL);
@@ -118,8 +120,8 @@ LayoutBlockBox::LayoutBlockBox(LayoutEngine* _layout_engine, LayoutBlockBox* _pa
 	else
 	{
 		wrap_content = true;
-		overflow_x_property = OVERFLOW_VISIBLE;
-		overflow_y_property = OVERFLOW_VISIBLE;
+		overflow_x_property = Style::Overflow::Visible;
+		overflow_y_property = Style::Overflow::Visible;
 	}
 }
 
@@ -223,7 +225,7 @@ LayoutBlockBox::CloseResult LayoutBlockBox::Close()
 			{
 				if (!wrap_content)
 					box.SetContent(Vector2f(content_box.x, box.GetSize().y));
-				else if (overflow_x_property == OVERFLOW_AUTO)
+				else if (overflow_x_property == Style::Overflow::Auto)
 				{
 					element->GetElementScroll()->EnableScrollbar(ElementScroll::HORIZONTAL, box.GetSize(Box::PADDING).x);
 
@@ -265,7 +267,7 @@ LayoutBlockBox::CloseResult LayoutBlockBox::Close()
 	if (context == BLOCK &&
 		element != NULL)
 	{
-		if (element->GetPosition() != POSITION_STATIC)
+		if (element->GetPosition() != Style::Position::Static)
 			CloseAbsoluteElements();
 	}
 
@@ -383,7 +385,7 @@ LayoutInlineBox* LayoutBlockBox::AddInlineElement(Element* element, const Box& b
 // Adds a line-break to this block box.
 void LayoutBlockBox::AddBreak()
 {
-	int line_height = ElementUtilities::GetLineHeight(element);
+	float line_height = element->GetLineHeight();
 
 	// Check for an inline box as our last child; if so, we can simply end its line and bail.
 	if (!block_boxes.empty())
@@ -543,10 +545,9 @@ float LayoutBlockBox::InternalContentWidth() const
 		//  Alternative solution: Add some 'intrinsic_width' property to  every 'LayoutBlockBox' and have that propagate up to the nearest 'inline-block'.
 		if (element)
 		{
-			const Property* width = nullptr;
+			const Property* width = element->GetLocalProperty(WIDTH);
 			const Property* min_width = element->GetLocalProperty("min-width");
 			const Property* max_width = element->GetLocalProperty("max-width");
-			element->GetLocalDimensionProperties(&width, nullptr);
 			if(width)
 			{
 				float w_value = element->ResolveProperty(width, box.GetSize(Box::CONTENT).x);
@@ -670,7 +671,7 @@ bool LayoutBlockBox::CatchVerticalOverflow(float cursor)
 	// If we're auto-scrolling and our height is fixed, we have to check if this box has exceeded our client height.
 	if (!vertical_overflow &&
 		box_height >= 0 &&
-		overflow_y_property == OVERFLOW_AUTO)
+		overflow_y_property == Style::Overflow::Auto)
 	{
 		if (cursor > box_height - element->GetElementScroll()->GetScrollbarSize(ElementScroll::HORIZONTAL))
 		{

+ 2 - 2
Source/Core/LayoutBlockBox.h

@@ -222,8 +222,8 @@ private:
 	// The hierarchy will be resumed in an inline-context box once the intervening block box is completed.
 	LayoutInlineBox* interrupted_chain;
 	// Used by block contexts only; stores the value of the overflow property for the element.
-	int overflow_x_property;
-	int overflow_y_property;
+	Style::Overflow overflow_x_property;
+	Style::Overflow overflow_y_property;
 	// Used by block contexts only; if true, we've enabled our vertical scrollbar.
 	bool vertical_overflow;
 

+ 4 - 4
Source/Core/LayoutBlockBoxSpace.cpp

@@ -66,7 +66,7 @@ void LayoutBlockBoxSpace::PositionBox(Vector2f& box_position, float& box_width,
 float LayoutBlockBoxSpace::PositionBox(float cursor, Element* element)
 {
 	Vector2f element_size = element->GetBox().GetSize(Box::MARGIN);
-	int float_property = element->GetFloat();
+	Style::Float float_property = element->GetComputedValues().float_;
 
 	// Shift the cursor down (if necessary) so it isn't placed any higher than a previously-floated box.
 	for (int i = 0; i < NUM_ANCHOR_EDGES; ++i)
@@ -83,7 +83,7 @@ float LayoutBlockBoxSpace::PositionBox(float cursor, Element* element)
 	PositionBox(element_offset, cursor, element_size, float_property);
 
 	// It's been placed, so we can now add it to our list of floating boxes.
-	boxes[float_property == FLOAT_LEFT ? LEFT : RIGHT].push_back(SpaceBox(element_offset, element_size));
+	boxes[float_property == Style::Float::Left ? LEFT : RIGHT].push_back(SpaceBox(element_offset, element_size));
 
 	// Set our offset and dimensions (if necessary) so they enclose the new box.
 	Vector2f normalised_offset = element_offset - (parent->GetPosition() + parent->GetBox().GetPosition());
@@ -124,13 +124,13 @@ float LayoutBlockBoxSpace::ClearBoxes(float cursor, Style::Clear clear_property)
 }
 
 // Generates the position for an arbitrary box within our space layout, floated against either the left or right edge.
-float LayoutBlockBoxSpace::PositionBox(Vector2f& box_position, float cursor, const Vector2f& dimensions, int float_property) const
+float LayoutBlockBoxSpace::PositionBox(Vector2f& box_position, float cursor, const Vector2f& dimensions, Style::Float float_property) const
 {
 	float parent_scrollbar_width = parent->GetElement()->GetElementScroll()->GetScrollbarSize(ElementScroll::VERTICAL);
 	float parent_origin = parent->GetPosition().x + parent->GetBox().GetPosition(Box::CONTENT).x;
 	float parent_edge = parent->GetBox().GetSize().x + parent_origin - parent_scrollbar_width;
 
-	AnchorEdge box_edge = float_property == FLOAT_RIGHT ? RIGHT : LEFT;
+	AnchorEdge box_edge = float_property == Style::Float::Right ? RIGHT : LEFT;
 
 	box_position.y = cursor;
 	box_position.x = box_edge == LEFT ? 0 : (parent->GetBox().GetSize().x - dimensions.x) - parent_scrollbar_width;

+ 1 - 1
Source/Core/LayoutBlockBoxSpace.h

@@ -98,7 +98,7 @@ private:
 	/// @param cursor[in] The ideal vertical position for the box.
 	/// @param dimensions[in] The size of the box to place.
 	/// @return The maximum width at the box position.
-	float PositionBox(Vector2f& box_position, float cursor, const Vector2f& dimensions, int float_property = FLOAT_NONE) const;
+	float PositionBox(Vector2f& box_position, float cursor, const Vector2f& dimensions, Style::Float float_property = Style::Float::None) const;
 
 	struct SpaceBox
 	{

+ 2 - 2
Source/Core/LayoutEngine.cpp

@@ -293,8 +293,8 @@ bool LayoutEngine::FormatElement(Element* element)
 	}
 
 	// If the element is floating, we remove it from the flow.
-	int float_property = element->GetFloat();
-	if (float_property != FLOAT_NONE)
+	Style::Float float_property = element->GetFloat();
+	if (float_property != Style::Float::None)
 	{
 		// Format the element as a block element.
 		LayoutEngine layout_engine;

+ 20 - 31
Source/Core/LayoutInlineBox.cpp

@@ -60,7 +60,7 @@ LayoutInlineBox::LayoutInlineBox(Element* _element, const Box& _box) : position(
 		FontFaceHandle* font_face = element->GetFontFaceHandle();
 		if (font_face != NULL)
 		{
-			height = (float) ElementUtilities::GetLineHeight(element);
+			height = element->GetLineHeight();
 			baseline = (height - font_face->GetLineHeight()) * 0.5f + font_face->GetBaseline();
 		}
 		else
@@ -70,11 +70,7 @@ LayoutInlineBox::LayoutInlineBox(Element* _element, const Box& _box) : position(
 		}
 	}
 
-	const Property* property = element->GetVerticalAlignProperty();
-	if (property->unit == Property::KEYWORD)
-		vertical_align_property = property->value.Get< int >();
-	else
-		vertical_align_property = -1;
+	vertical_align_property = element->GetComputedValues().vertical_align;
 
 	chained = false;
 	chain = NULL;
@@ -169,18 +165,19 @@ LayoutInlineBox* LayoutInlineBox::FlowContent(bool ROCKET_UNUSED_PARAMETER(first
 // Computes and sets the vertical position of this element, relative to its parent box.
 void LayoutInlineBox::CalculateBaseline(float& ascender, float& descender)
 {
+	using namespace Style;
 	// We're vertically-aligned with one of the standard types.
-	switch (vertical_align_property)
+	switch (vertical_align_property.type)
 	{
 		// Aligned with our parent box's baseline, our relative vertical position is set to 0.
-		case VERTICAL_ALIGN_BASELINE:
+		case VerticalAlign::Baseline:
 		{
 			SetVerticalPosition(0);
 		}
 		break;
 
 		// The middle of this box is aligned with the baseline of its parent's plus half an ex.
-		case VERTICAL_ALIGN_MIDDLE:
+		case VerticalAlign::Middle:
 		{
 			FontFaceHandle* parent_font = GetParentFont();
 			int x_height = 0;
@@ -192,7 +189,7 @@ void LayoutInlineBox::CalculateBaseline(float& ascender, float& descender)
 		break;
 
 		// This box's baseline is offset from its parent's so it is appropriate for rendering subscript.
-		case VERTICAL_ALIGN_SUB:
+		case VerticalAlign::Sub:
 		{
 			FontFaceHandle* parent_font = GetParentFont();
 			if (parent_font == NULL)
@@ -203,7 +200,7 @@ void LayoutInlineBox::CalculateBaseline(float& ascender, float& descender)
 		break;
 
 		// This box's baseline is offset from its parent's so it is appropriate for rendering superscript.
-		case VERTICAL_ALIGN_SUPER:
+		case VerticalAlign::Super:
 		{
 			FontFaceHandle* parent_font = GetParentFont();
 			if (parent_font == NULL)
@@ -214,7 +211,7 @@ void LayoutInlineBox::CalculateBaseline(float& ascender, float& descender)
 		break;
 
 		// The top of this box is aligned to the top of its parent's font.
-		case VERTICAL_ALIGN_TEXT_TOP:
+		case VerticalAlign::TextTop:
 		{
 			FontFaceHandle* parent_font = GetParentFont();
 			if (parent_font == NULL)
@@ -225,7 +222,7 @@ void LayoutInlineBox::CalculateBaseline(float& ascender, float& descender)
 		break;
 
 		// The bottom of this box is aligned to the bottom of its parent's font (not the baseline).
-		case VERTICAL_ALIGN_TEXT_BOTTOM:
+		case VerticalAlign::TextBottom:
 		{
 			FontFaceHandle* parent_font = GetParentFont();
 			if (parent_font == NULL)
@@ -236,14 +233,15 @@ void LayoutInlineBox::CalculateBaseline(float& ascender, float& descender)
 		break;
 
 		// This box is aligned with the line box, not an inline box, so we can't position it yet.
-		case VERTICAL_ALIGN_TOP:
-		case VERTICAL_ALIGN_BOTTOM:
+		case VerticalAlign::Top:
+		case VerticalAlign::Bottom:
 			break;
 
 		// The baseline of this box is offset by a fixed amount from its parent's baseline.
+		case VerticalAlign::Length:
 		default:
 		{
-			SetVerticalPosition(-1 * element->ResolveProperty(element->GetVerticalAlignProperty(), GetParentLineHeight()));
+			SetVerticalPosition(-1.f * vertical_align_property.Length);
 		}
 		break;
 	}
@@ -265,8 +263,8 @@ void LayoutInlineBox::CalculateBaseline(float& ascender, float& descender)
 	{
 		// Don't include any of our children that are aligned relative to the line box; the line box treats them
 		// separately.
-		if (children[i]->GetVerticalAlignProperty() != VERTICAL_ALIGN_TOP &&
-			children[i]->GetVerticalAlignProperty() != VERTICAL_ALIGN_BOTTOM)
+		if (children[i]->GetVerticalAlignProperty().type != Style::VerticalAlign::Top &&
+			children[i]->GetVerticalAlignProperty().type != Style::VerticalAlign::Bottom)
 		{
 			float child_ascender, child_descender;
 			children[i]->CalculateBaseline(child_ascender, child_descender);
@@ -284,8 +282,8 @@ void LayoutInlineBox::OffsetBaseline(float ascender)
 	{
 		// Don't offset any of our children that are aligned relative to the line box; the line box will take care of
 		// them separately.
-		if (children[i]->GetVerticalAlignProperty() != VERTICAL_ALIGN_TOP &&
-			children[i]->GetVerticalAlignProperty() != VERTICAL_ALIGN_BOTTOM)
+		if (children[i]->GetVerticalAlignProperty().type != Style::VerticalAlign::Top &&
+			children[i]->GetVerticalAlignProperty().type != Style::VerticalAlign::Bottom)
 			children[i]->OffsetBaseline(ascender + position.y);
 	}
 
@@ -333,7 +331,7 @@ void LayoutInlineBox::SizeElement(bool split)
 	// Resize the box for an unsized inline element.
 	if (box.GetSize() == Vector2f(-1, -1))
 	{
-		box.SetContent(Vector2f(width, (float) ElementUtilities::GetLineHeight(element)));
+		box.SetContent(Vector2f(width, element->GetLineHeight()));
 		if (parent != NULL)
 			parent->width += width;
 	}
@@ -363,7 +361,7 @@ void LayoutInlineBox::SizeElement(bool split)
 }
 
 // Returns the vertical align property of the box's element.
-int LayoutInlineBox::GetVerticalAlignProperty() const
+Style::VerticalAlign LayoutInlineBox::GetVerticalAlignProperty() const
 {
 	return vertical_align_property;
 }
@@ -417,14 +415,5 @@ FontFaceHandle* LayoutInlineBox::GetParentFont() const
 		return parent->GetElement()->GetFontFaceHandle();
 }
 
-// Returns our parent box's line height.
-float LayoutInlineBox::GetParentLineHeight() const
-{
-	if (parent == NULL)
-		return (float) ElementUtilities::GetLineHeight(line->GetBlockBox()->GetParent()->GetElement());
-	else
-		return (float) ElementUtilities::GetLineHeight(parent->GetElement());
-}
-
 }
 }

+ 2 - 5
Source/Core/LayoutInlineBox.h

@@ -109,7 +109,7 @@ public:
 
 	/// Returns the vertical align property of the box's element.
 	/// @return the vertical align property, or -1 if it is set to a numerical value.
-	int GetVerticalAlignProperty() const;
+	Style::VerticalAlign GetVerticalAlignProperty() const;
 
 	/// Returns the inline box's element.
 	/// @return The inline box's element.
@@ -140,9 +140,6 @@ protected:
 	/// Returns our parent box's font face handle.
 	/// @return The font face handle of our parent box.
 	FontFaceHandle* GetParentFont() const;
-	/// Returns our parent box's line height.
-	/// @return The line height of our parent box.
-	float GetParentLineHeight() const;
 
 	// The box's element.
 	Element* element;
@@ -159,7 +156,7 @@ protected:
 	float height;
 
 	// The value of this box's element's vertical-align property.
-	int vertical_align_property;
+	Style::VerticalAlign vertical_align_property;
 	// The baseline of the inline element.
 	float baseline;
 

+ 1 - 1
Source/Core/LayoutInlineBoxText.cpp

@@ -159,7 +159,7 @@ void LayoutInlineBoxText::BuildWordBox()
 
 	Vector2f content_area;
 	line_segmented = !text_element->GenerateToken(content_area.x, line_begin);
-	content_area.y = (float) ElementUtilities::GetLineHeight(element);
+	content_area.y = element->GetLineHeight();
 	box.SetContent(content_area);
 }
 

+ 10 - 10
Source/Core/LayoutLineBox.cpp

@@ -93,8 +93,8 @@ LayoutInlineBox* LayoutLineBox::Close(LayoutInlineBox* overflow)
 		LayoutInlineBox* inline_box = inline_boxes[i];
 
 		// Check if we've got an element aligned to the line box rather than a baseline.
-		if (inline_box->GetVerticalAlignProperty() == VERTICAL_ALIGN_TOP ||
-			inline_box->GetVerticalAlignProperty() == VERTICAL_ALIGN_BOTTOM)
+		if (inline_box->GetVerticalAlignProperty().type == Style::VerticalAlign::Top ||
+			inline_box->GetVerticalAlignProperty().type == Style::VerticalAlign::Bottom)
 		{
 			// Get this element to calculate the baseline offsets of its children; it can't calculate its own baseline
 			// because we don't know the height of the line box yet. We don't actually care about its ascender or
@@ -125,10 +125,10 @@ LayoutInlineBox* LayoutLineBox::Close(LayoutInlineBox* overflow)
 
 		// Check again if this element is aligned to the line box. We don't need to worry about offsetting an element
 		// tied to the top of the line box, as its position will always stay at exactly 0.
-		if (inline_box->GetVerticalAlignProperty() == VERTICAL_ALIGN_TOP ||
-			inline_box->GetVerticalAlignProperty() == VERTICAL_ALIGN_BOTTOM)
+		if (inline_box->GetVerticalAlignProperty().type == Style::VerticalAlign::Top||
+			inline_box->GetVerticalAlignProperty().type == Style::VerticalAlign::Bottom)
 		{
-			if (inline_box->GetVerticalAlignProperty() == VERTICAL_ALIGN_TOP)
+			if (inline_box->GetVerticalAlignProperty().type == Style::VerticalAlign::Top)
 				inline_box->OffsetBaseline(inline_box->GetHeight() - inline_box->GetBaseline());
 			else
 				inline_box->OffsetBaseline(dimensions.y - inline_box->GetBaseline());
@@ -140,15 +140,15 @@ LayoutInlineBox* LayoutLineBox::Close(LayoutInlineBox* overflow)
 
 	// Position all the boxes horizontally in the line. We only need to reposition the elements if they're set to
 	// centre or right; the element are already placed left-aligned, and justification occurs at the text level.
-	int text_align_property = parent->GetParent()->GetElement()->GetTextAlign();
-	if (text_align_property == TEXT_ALIGN_CENTER ||
-		text_align_property == TEXT_ALIGN_RIGHT)
+	Style::TextAlign text_align_property = parent->GetParent()->GetElement()->GetComputedValues().text_align;
+	if (text_align_property == Style::TextAlign::Center ||
+		text_align_property == Style::TextAlign::Right)
 	{
 		float element_offset = 0;
 		switch (text_align_property)
 		{
-			case TEXT_ALIGN_CENTER:		element_offset = (dimensions.x - box_cursor) * 0.5f; break;
-			case TEXT_ALIGN_RIGHT:		element_offset = (dimensions.x - box_cursor); break;
+			case Style::TextAlign::Center:  element_offset = (dimensions.x - box_cursor) * 0.5f; break;
+			case Style::TextAlign::Right:   element_offset = (dimensions.x - box_cursor); break;
 		}
 
 		if (element_offset != 0)

+ 1 - 1
Source/Core/StyleSheetNodeSelectorEmpty.cpp

@@ -49,7 +49,7 @@ bool StyleSheetNodeSelectorEmpty::IsApplicable(const Element* element, int ROCKE
 
 	for (int i = 0; i < element->GetNumChildren(); ++i)
 	{
-		if (element->GetChild(i)->GetDisplay() != DISPLAY_NONE)
+		if (element->GetChild(i)->GetDisplay() != Style::Display::None)
 			return false;
 	}
 

+ 1 - 1
Source/Core/StyleSheetNodeSelectorFirstChild.cpp

@@ -61,7 +61,7 @@ bool StyleSheetNodeSelectorFirstChild::IsApplicable(const Element* element, int
 
 		// If this child is not a text element, then the selector fails; this element is non-trivial.
 		if (dynamic_cast< ElementText* >(child) == NULL &&
-			child->GetDisplay() != DISPLAY_NONE)
+			child->GetDisplay() != Style::Display::None)
 			return false;
 
 		// Otherwise, skip over the text element to find the last non-trivial element.

+ 1 - 1
Source/Core/StyleSheetNodeSelectorFirstOfType.cpp

@@ -62,7 +62,7 @@ bool StyleSheetNodeSelectorFirstOfType::IsApplicable(const Element* element, int
 		// Otherwise, if this child shares our element's tag, then our element is not the first tagged child; the
 		// selector fails.
 		if (child->GetTagName() == element->GetTagName() &&
-			child->GetDisplay() != DISPLAY_NONE)
+			child->GetDisplay() != Style::Display::None)
 			return false;
 
 		child_index++;

+ 1 - 1
Source/Core/StyleSheetNodeSelectorLastChild.cpp

@@ -61,7 +61,7 @@ bool StyleSheetNodeSelectorLastChild::IsApplicable(const Element* element, int R
 
 		// If this child is not a text element, then the selector fails; this element is non-trivial.
 		if (dynamic_cast< ElementText* >(child) == NULL &&
-			child->GetDisplay() != DISPLAY_NONE)
+			child->GetDisplay() != Style::Display::None)
 			return false;
 
 		// Otherwise, skip over the text element to find the last non-trivial element.

+ 1 - 1
Source/Core/StyleSheetNodeSelectorLastOfType.cpp

@@ -62,7 +62,7 @@ bool StyleSheetNodeSelectorLastOfType::IsApplicable(const Element* element, int
 		// Otherwise, if this child shares our element's tag, then our element is not the first tagged child; the
 		// selector fails.
 		if (child->GetTagName() == element->GetTagName() &&
-			child->GetDisplay() != DISPLAY_NONE)
+			child->GetDisplay() != Style::Display::None)
 			return false;
 
 		child_index--;

+ 1 - 1
Source/Core/StyleSheetNodeSelectorNthChild.cpp

@@ -64,7 +64,7 @@ bool StyleSheetNodeSelectorNthChild::IsApplicable(const Element* element, int a,
 			break;
 
 		// Skip nodes without a display type.
-		if (child->GetDisplay() == DISPLAY_NONE)
+		if (child->GetDisplay() == Style::Display::None)
 			continue;
 
 		element_index++;

+ 1 - 1
Source/Core/StyleSheetNodeSelectorNthLastChild.cpp

@@ -62,7 +62,7 @@ bool StyleSheetNodeSelectorNthLastChild::IsApplicable(const Element* element, in
 		if (child == element)
 			break;
 
-		if (child->GetDisplay() == DISPLAY_NONE)
+		if (child->GetDisplay() == Style::Display::None)
 			continue;
 
 		element_index++;

+ 1 - 1
Source/Core/StyleSheetNodeSelectorNthLastOfType.cpp

@@ -60,7 +60,7 @@ bool StyleSheetNodeSelectorNthLastOfType::IsApplicable(const Element* element, i
 
 		// Skip nodes that don't share our tag.
 		if (child->GetTagName() != element->GetTagName() ||
-			child->GetDisplay() == DISPLAY_NONE)
+			child->GetDisplay() == Style::Display::None)
 			continue;
 
 		element_index++;

+ 1 - 1
Source/Core/StyleSheetNodeSelectorNthOfType.cpp

@@ -60,7 +60,7 @@ bool StyleSheetNodeSelectorNthOfType::IsApplicable(const Element* element, int a
 
 		// Skip nodes that don't share our tag.
 		if (child->GetTagName() != element->GetTagName() ||
-			child->GetDisplay() == DISPLAY_NONE)
+			child->GetDisplay() == Style::Display::None)
 			continue;
 
 		element_index++;

+ 1 - 1
Source/Core/StyleSheetNodeSelectorOnlyChild.cpp

@@ -61,7 +61,7 @@ bool StyleSheetNodeSelectorOnlyChild::IsApplicable(const Element* element, int R
 
 		// Skip the child if it is trivial.
 		if (dynamic_cast< const ElementText* >(element) != NULL ||
-			child->GetDisplay() == DISPLAY_NONE)
+			child->GetDisplay() == Style::Display::None)
 			continue;
 
 		return false;

+ 1 - 1
Source/Core/StyleSheetNodeSelectorOnlyOfType.cpp

@@ -61,7 +61,7 @@ bool StyleSheetNodeSelectorOnlyOfType::IsApplicable(const Element* element, int
 
 		// Skip the child if it does not share our tag.
 		if (child->GetTagName() != element->GetTagName() ||
-			child->GetDisplay() == DISPLAY_NONE)
+			child->GetDisplay() == Style::Display::None)
 			continue;
 
 		// We've found a similarly-tagged child to our element; selector fails.

+ 11 - 9
Source/Core/WidgetSlider.cpp

@@ -308,13 +308,15 @@ void WidgetSlider::FormatBar(float bar_length)
 	Box bar_box;
 	LayoutEngine::BuildBox(bar_box, parent->GetBox().GetSize(), bar);
 
-	const Property *local_width, *local_height;
-	bar->GetLocalDimensionProperties(&local_width, &local_height);
+	const auto& computed = bar->GetComputedValues();
+
+	const LengthPercentageAuto& width = computed.width;
+	const LengthPercentageAuto& height = computed.height;
 
 	Vector2f bar_box_content = bar_box.GetSize();
 	if (orientation == HORIZONTAL)
 	{
-		if (local_height == NULL)
+		if (height.type == height.Auto)
 			bar_box_content.y = parent->GetBox().GetSize().y;
 	}
 
@@ -326,16 +328,16 @@ void WidgetSlider::FormatBar(float bar_length)
 		{
 			float track_length = track_size.y - (bar_box.GetCumulativeEdge(Box::CONTENT, Box::TOP) + bar_box.GetCumulativeEdge(Box::CONTENT, Box::BOTTOM));
 
-			if (local_height == NULL)
+			if (height.type == height.Auto)
 			{
 				bar_box_content.y = track_length * bar_length;
 
 				// Check for 'min-height' restrictions.
-				float min_track_length = bar->ResolveProperty(MIN_HEIGHT, track_length);
+				float min_track_length = ResolveProperty(computed.min_height, track_length);
 				bar_box_content.y = Math::Max(min_track_length, bar_box_content.y);
 
 				// Check for 'max-height' restrictions.
-				float max_track_length = bar->ResolveProperty(MAX_HEIGHT, track_length);
+				float max_track_length = ResolveProperty(computed.max_height, track_length);
 				if (max_track_length > 0)
 					bar_box_content.y = Math::Min(max_track_length, bar_box_content.y);
 			}
@@ -347,16 +349,16 @@ void WidgetSlider::FormatBar(float bar_length)
 		{
 			float track_length = track_size.x - (bar_box.GetCumulativeEdge(Box::CONTENT, Box::LEFT) + bar_box.GetCumulativeEdge(Box::CONTENT, Box::RIGHT));
 
-			if (local_width == NULL)
+			if (width.type == width.Auto)
 			{
 				bar_box_content.x = track_length * bar_length;
 
 				// Check for 'min-width' restrictions.
-				float min_track_length = bar->ResolveProperty(MIN_WIDTH, track_length);
+				float min_track_length = ResolveProperty(computed.min_width, track_length);
 				bar_box_content.x = Math::Max(min_track_length, bar_box_content.x);
 
 				// Check for 'max-width' restrictions.
-				float max_track_length = bar->ResolveProperty(MAX_WIDTH, track_length);
+				float max_track_length = ResolveProperty(computed.max_width, track_length);
 				if (max_track_length > 0)
 					bar_box_content.x = Math::Min(max_track_length, bar_box_content.x);
 			}