Browse Source

Handle rem units in ElementUtilities::GetLineHeight

Triang3l 9 years ago
parent
commit
1d6cabf434
1 changed files with 8 additions and 2 deletions
  1. 8 2
      Source/Core/ElementUtilities.cpp

+ 8 - 2
Source/Core/ElementUtilities.cpp

@@ -136,13 +136,18 @@ int ElementUtilities::GetFontSize(Element* element)
 // Returns an element's line height, if it has a font defined.
 int ElementUtilities::GetLineHeight(Element* element)
 {
-	FontFaceHandle* font_face_handle = element->GetFontFaceHandle();
+	const Property* line_height_property = element->GetLineHeightProperty();
+
+	Element* font_element = element;
+	if (line_height_property->unit == Property::REM)
+		font_element = element->GetOwnerDocument();
+
+	FontFaceHandle* font_face_handle = font_element->GetFontFaceHandle();
 	if (font_face_handle == NULL)
 		return 0;
 
 	int line_height = font_face_handle->GetLineHeight();
 	float inch = element->GetRenderInterface()->GetPixelsPerInch();
-	const Property* line_height_property = element->GetLineHeightProperty();
 
 	switch (line_height_property->unit)
 	{
@@ -155,6 +160,7 @@ int ElementUtilities::GetLineHeight(Element* element)
 	ROCKET_UNUSED_SWITCH_ENUM(Property::RELATIVE_UNIT);
 	case Property::NUMBER:
 	case Property::EM:
+	case Property::REM:
 		// If the property is a straight number or an em measurement, then it scales the line height.
 		return Math::Round(line_height_property->value.Get< float >() * line_height);
 	case Property::PERCENT: