Browse Source

Some more

Michael Ragazzon 6 years ago
parent
commit
92dd7364f9

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

@@ -92,7 +92,8 @@ public:
 		  Computed values, background-color, image-color, opacity: 77.0
 		  Computed values, padding, margin border++: 81.0  [bb70d38]
 		  Computing all the values (only using a few of them yet): 83.0  [9fe9bdf]
-		  Computed transform and other optimizations: 88.0  [654fa09]
+		  Computed transform and other optimizations: 86.0  [654fa09]
+		  Computed layout engine: 90.0   [e18ac30]
 		
 		*/
 

+ 28 - 24
Source/Core/ElementTextDefault.cpp

@@ -40,7 +40,7 @@
 namespace Rocket {
 namespace Core {
 
-static bool BuildToken(WString& token, const word*& token_begin, const word* string_end, bool first_token, bool collapse_white_space, bool break_at_endline, int text_transformation);
+static bool BuildToken(WString& token, const word*& token_begin, const word* string_end, bool first_token, bool collapse_white_space, bool break_at_endline, Style::TextTransform text_transformation);
 static bool LastToken(const word* token_begin, const word* string_end, bool collapse_white_space, bool break_at_endline);
 
 ElementTextDefault::ElementTextDefault(const String& tag) : ElementText(tag), colour(255, 255, 255), decoration(this)
@@ -151,18 +151,20 @@ bool ElementTextDefault::GenerateToken(float& token_width, int line_begin)
 		return 0;
 
 	// Determine how we are processing white-space while formatting the text.
-	int white_space_property = GetWhitespace();
-	bool collapse_white_space = white_space_property == WHITE_SPACE_NORMAL ||
-								white_space_property == WHITE_SPACE_NOWRAP ||
-								white_space_property == WHITE_SPACE_PRE_LINE;
-	bool break_at_endline = white_space_property == WHITE_SPACE_PRE ||
-							white_space_property == WHITE_SPACE_PRE_WRAP ||
-							white_space_property == WHITE_SPACE_PRE_LINE;
+	using namespace Style;
+	auto& computed = GetComputedValues();
+	WhiteSpace white_space_property = computed.white_space;
+	bool collapse_white_space = white_space_property == WhiteSpace::Normal ||
+								white_space_property == WhiteSpace::Nowrap ||
+								white_space_property == WhiteSpace::Preline;
+	bool break_at_endline = white_space_property == WhiteSpace::Pre ||
+							white_space_property == WhiteSpace::Prewrap ||
+							white_space_property == WhiteSpace::Preline;
 
 	const word* token_begin = text.c_str() + line_begin;
 	WString token;
 
-	BuildToken(token, token_begin, text.c_str() + text.size(), true, collapse_white_space, break_at_endline, GetTextTransform());
+	BuildToken(token, token_begin, text.c_str() + text.size(), true, collapse_white_space, break_at_endline, computed.text_transform);
 	token_width = (float) font_face_handle->GetStringWidth(token, 0);
 
 	return LastToken(token_begin, text.c_str() + text.size(), collapse_white_space, break_at_endline);
@@ -183,20 +185,22 @@ bool ElementTextDefault::GenerateLine(WString& line, int& line_length, float& li
 		return true;
 
 	// Determine how we are processing white-space while formatting the text.
-	int white_space_property = GetWhitespace();
-	bool collapse_white_space = white_space_property == WHITE_SPACE_NORMAL ||
-								white_space_property == WHITE_SPACE_NOWRAP ||
-								white_space_property == WHITE_SPACE_PRE_LINE;
-	bool break_at_line = maximum_line_width >= 0 &&
-						 (white_space_property == WHITE_SPACE_NORMAL ||
-						  white_space_property == WHITE_SPACE_PRE_WRAP ||
-						  white_space_property == WHITE_SPACE_PRE_LINE);
-	bool break_at_endline = white_space_property == WHITE_SPACE_PRE ||
-							white_space_property == WHITE_SPACE_PRE_WRAP ||
-							white_space_property == WHITE_SPACE_PRE_LINE;
+	using namespace Style;
+	auto& computed = GetComputedValues();
+	WhiteSpace white_space_property = computed.white_space;
+	bool collapse_white_space = white_space_property == WhiteSpace::Normal ||
+								white_space_property == WhiteSpace::Nowrap ||
+								white_space_property == WhiteSpace::Preline;
+	bool break_at_line = maximum_line_width >= 0 && 
+		                   (white_space_property == WhiteSpace::Normal ||
+							white_space_property == WhiteSpace::Prewrap ||
+							white_space_property == WhiteSpace::Preline);
+	bool break_at_endline = white_space_property == WhiteSpace::Pre ||
+							white_space_property == WhiteSpace::Prewrap ||
+							white_space_property == WhiteSpace::Preline;
 
 	// Determine what (if any) text transformation we are putting the characters through.
-	int text_transform_property = GetTextTransform();
+	TextTransform text_transform_property = computed.text_transform;
 
 	// Starting at the line_begin character, we generate sections of the text (we'll call them tokens) depending on the
 	// white-space parsing parameters. Each section is then appended to the line if it can fit. If not, or if an
@@ -431,7 +435,7 @@ void ElementTextDefault::GenerateDecoration(FontFaceHandle* font_face_handle, co
 	font_face_handle->GenerateLine(&decoration, line.position, line.width, line_height, colour);
 }
 
-static bool BuildToken(WString& token, const word*& token_begin, const word* string_end, bool first_token, bool collapse_white_space, bool break_at_endline, int text_transformation)
+static bool BuildToken(WString& token, const word*& token_begin, const word* string_end, bool first_token, bool collapse_white_space, bool break_at_endline, Style::TextTransform text_transformation)
 {
 	ROCKET_ASSERT(token_begin != string_end);
 
@@ -543,12 +547,12 @@ static bool BuildToken(WString& token, const word*& token_begin, const word* str
 		}
 		else
 		{
-			if (text_transformation == TEXT_TRANSFORM_UPPERCASE)
+			if (text_transformation == Style::TextTransform::Uppercase)
 			{
 				if (character >= 'a' && character <= 'z')
 					character += (Rocket::Core::word)('A' - 'a');
 			}
-			else if (text_transformation == TEXT_TRANSFORM_LOWERCASE)
+			else if (text_transformation == Style::TextTransform::Lowercase)
 			{
 				if (character >= 'A' && character <= 'Z')
 					character -= (Rocket::Core::word)('A' - 'a');

+ 0 - 1
Source/Core/LayoutEngine.cpp

@@ -445,7 +445,6 @@ Vector2f LayoutEngine::GetContainingBlock(const LayoutBlockBox* containing_box)
 }
 
 // Builds the block-specific width and horizontal margins of a Box.
-// OK
 void LayoutEngine::BuildBoxWidth(Box& box, const ComputedValues& computed, float containing_block_width)
 {
 	Vector2f content_area = box.GetSize();