Bläddra i källkod

Fix font size with relative sizes

Michael 7 år sedan
förälder
incheckning
cbd72371ae
2 ändrade filer med 4 tillägg och 6 borttagningar
  1. 3 5
      Source/Core/ElementStyle.cpp
  2. 1 1
      Source/Core/StyleSheetSpecification.cpp

+ 3 - 5
Source/Core/ElementStyle.cpp

@@ -407,11 +407,6 @@ float ElementStyle::ResolveProperty(const String& name, float base_value)
 		return 0.0f;
 	}
 
-	if (property->unit & Property::DP)
-	{
-		return property->value.Get< float >() * ElementUtilities::GetDensityIndependentPixelRatio(element);
-	}
-
 	// The calculated value of the font-size property is inherited, so we need to check if this
 	// is an inherited property. If so, then we return our parent's font size instead.
 	if (name == FONT_SIZE && property->unit & Property::RELATIVE_UNIT)
@@ -447,6 +442,9 @@ float ElementStyle::ResolveProperty(const String& name, float base_value)
 			case Property::EM:
 				return property->value.Get< float >() * base_value;
 
+			case Property::DP:
+				return property->value.Get< float >() * ElementUtilities::GetDensityIndependentPixelRatio(element);
+
 			case Property::REM:
 				// If an rem-relative font size is specified, it is expressed relative to the document's
 				// font height.

+ 1 - 1
Source/Core/StyleSheetSpecification.cpp

@@ -250,7 +250,7 @@ void StyleSheetSpecification::RegisterDefaultProperties()
 	RegisterProperty(FONT_CHARSET, "U+0020-007E", true, false).AddParser("string");
 	RegisterProperty(FONT_STYLE, "normal", true, true).AddParser("keyword", "normal, italic");
 	RegisterProperty(FONT_WEIGHT, "normal", true, true).AddParser("keyword", "normal, bold");
-	RegisterProperty(FONT_SIZE, "12", true, true).AddParser("number");
+	RegisterProperty(FONT_SIZE, "12", true, true).AddParser("length");
 	RegisterShorthand(FONT, "font-style, font-weight, font-size, font-family, font-charset");
 
 	RegisterProperty(TEXT_ALIGN, LEFT, true, true).AddParser("keyword", "left, right, center, justify");