Jelajahi Sumber

Make images specified in @decorator properly load (see #22)

Michael Ragazzon 6 tahun lalu
induk
melakukan
1685de4a59
2 mengubah file dengan 6 tambahan dan 3 penghapusan
  1. 4 2
      Source/Core/StyleSheetParser.cpp
  2. 2 1
      Source/Core/StyleSheetParser.h

+ 4 - 2
Source/Core/StyleSheetParser.cpp

@@ -253,7 +253,7 @@ bool StyleSheetParser::ParseKeyframeBlock(KeyframesMap& keyframes_map, const Str
 	return true;
 }
 
-bool StyleSheetParser::ParseDecoratorBlock(const String& at_name, DecoratorSpecificationMap& decorator_map, const StyleSheet& style_sheet)
+bool StyleSheetParser::ParseDecoratorBlock(const String& at_name, DecoratorSpecificationMap& decorator_map, const StyleSheet& style_sheet, const SharedPtr<const PropertySource>& source)
 {
 	StringList name_type;
 	StringUtilities::ExpandString(name_type, at_name, ':');
@@ -306,6 +306,7 @@ bool StyleSheetParser::ParseDecoratorBlock(const String& at_name, DecoratorSpeci
 
 	// Set non-defined properties to their defaults
 	property_specification.SetPropertyDefaults(properties);
+	properties.SetSourceOfAllProperties(source);
 
 	SharedPtr<Decorator> decorator = decorator_instancer->InstanceDecorator(decorator_type, properties, DecoratorInstancerInterface(style_sheet));
 	if (!decorator)
@@ -392,7 +393,8 @@ int StyleSheetParser::Parse(StyleSheetNode* node, Stream* _stream, const StyleSh
 					}
 					else if (at_rule_identifier == "decorator")
 					{
-						ParseDecoratorBlock(at_rule_name, decorator_map, style_sheet);
+						auto source = std::make_shared<PropertySource>(stream_file_name, line_number, pre_token_str);
+						ParseDecoratorBlock(at_rule_name, decorator_map, style_sheet, source);
 						
 						at_rule_name.clear();
 						state = State::Global;

+ 2 - 1
Source/Core/StyleSheetParser.h

@@ -36,6 +36,7 @@ class PropertyDictionary;
 class Stream;
 class StyleSheetNode;
 class AbstractPropertyParser;
+struct PropertySource;
 
 /**
 	Helper class for parsing a style sheet into its memory representation.
@@ -90,7 +91,7 @@ private:
 	bool ParseKeyframeBlock(KeyframesMap & keyframes_map, const String & identifier, const String & rules, const PropertyDictionary & properties);
 
 	// Attempts to parse a @decorator block
-	bool ParseDecoratorBlock(const String& at_name, DecoratorSpecificationMap& decorator_map, const StyleSheet& style_sheet);
+	bool ParseDecoratorBlock(const String& at_name, DecoratorSpecificationMap& decorator_map, const StyleSheet& style_sheet, const SharedPtr<const PropertySource>& source);
 
 	// Attempts to find one of the given character tokens in the active stream
 	// If it's found, buffer is filled with all content up until the token