Browse Source

Reduce memory footprint of Element

Michael Ragazzon 5 years ago
parent
commit
261d08ce87

+ 6 - 18
Include/RmlUi/Core/Element.h

@@ -236,13 +236,13 @@ public:
 
 
 	/// Returns the size of the containing block. Often percentages are scaled relative to this.
 	/// Returns the size of the containing block. Often percentages are scaled relative to this.
 	Vector2f GetContainingBlock();
 	Vector2f GetContainingBlock();
-	/// Returns 'position' property value from element's style or local cache.
+	/// Returns 'position' property value from element's computed values.
 	Style::Position GetPosition();
 	Style::Position GetPosition();
-	/// Returns 'float' property value from element's style or local cache.
+	/// Returns 'float' property value from element's computed values.
 	Style::Float GetFloat();
 	Style::Float GetFloat();
-	/// Returns 'display' property value from element's style or local cache.
+	/// Returns 'display' property value from element's computed values.
 	Style::Display GetDisplay();
 	Style::Display GetDisplay();
-	/// Returns 'line-height' property value from element's style or local cache.
+	/// Returns 'line-height' property value from element's computed values.
 	float GetLineHeight();
 	float GetLineHeight();
 
 
 	/// Returns this element's TransformState
 	/// Returns this element's TransformState
@@ -672,18 +672,6 @@ private:
 	// The owning document
 	// The owning document
 	ElementDocument* owner_document;
 	ElementDocument* owner_document;
 
 
-	// The event dispatcher for this element.
-	EventDispatcher* event_dispatcher;
-	// Style information for this element.
-	ElementStyle* style;
-	// Background functionality for this element.
-	ElementBackground* background;
-	// Border functionality for this element.
-	ElementBorder* border;
-	// Decorator information for this element.
-	ElementDecoration* decoration;
-	// Scrollbar information for this element.
-	ElementScroll* scroll;
 	// Attributes on this element.
 	// Attributes on this element.
 	ElementAttributes attributes;
 	ElementAttributes attributes;
 
 
@@ -700,7 +688,7 @@ private:
 	Vector2f scroll_offset;
 	Vector2f scroll_offset;
 
 
 	// The size of the element.
 	// The size of the element.
-	typedef std::vector< Box > BoxList;
+	using BoxList = std::vector< Box >;
 	Box main_box;
 	Box main_box;
 	BoxList additional_boxes;
 	BoxList additional_boxes;
 
 
@@ -742,7 +730,7 @@ private:
 	bool dirty_animation;
 	bool dirty_animation;
 	bool dirty_transition;
 	bool dirty_transition;
 
 
-	ElementMeta* element_meta;
+	ElementMeta* meta;
 
 
 	friend class Context;
 	friend class Context;
 	friend class ElementStyle;
 	friend class ElementStyle;

+ 1 - 1
Include/RmlUi/Core/Geometry.h

@@ -93,7 +93,7 @@ private:
 	bool compile_attempted;
 	bool compile_attempted;
 };
 };
 
 
-typedef std::vector< Geometry > GeometryList;
+using GeometryList = std::vector< Geometry >;
 
 
 }
 }
 }
 }

+ 78 - 85
Source/Core/Element.cpp

@@ -96,9 +96,9 @@ public:
 static constexpr int ChildNotifyLevels = 2;
 static constexpr int ChildNotifyLevels = 2;
 
 
 // Meta objects for element collected in a single struct to reduce memory allocations
 // Meta objects for element collected in a single struct to reduce memory allocations
-struct ElementMeta 
+struct ElementMeta
 {
 {
-	ElementMeta(Element* el) : event_dispatcher(el), style(el), background(el), border(el), decoration(el), scroll(el)  {}
+	ElementMeta(Element* el) : event_dispatcher(el), style(el), background(el), border(el), decoration(el), scroll(el) {}
 	EventDispatcher event_dispatcher;
 	EventDispatcher event_dispatcher;
 	ElementStyle style;
 	ElementStyle style;
 	ElementBackground background;
 	ElementBackground background;
@@ -146,14 +146,7 @@ transform_state(), dirty_transform(false), dirty_perspective(false), dirty_anima
 	clipping_enabled = false;
 	clipping_enabled = false;
 	clipping_state_dirty = true;
 	clipping_state_dirty = true;
 
 
-	element_meta = element_meta_chunk_pool.AllocateAndConstruct(this);
-
-	event_dispatcher = &element_meta->event_dispatcher;
-	style = &element_meta->style;
-	background = &element_meta->background;
-	border = &element_meta->border;
-	decoration = &element_meta->decoration;
-	scroll = &element_meta->scroll;
+	meta = element_meta_chunk_pool.AllocateAndConstruct(this);
 }
 }
 
 
 Element::~Element()
 Element::~Element()
@@ -163,7 +156,7 @@ Element::~Element()
 	PluginRegistry::NotifyElementDestroy(this);
 	PluginRegistry::NotifyElementDestroy(this);
 
 
 	// Remove scrollbar elements before we delete the children!
 	// Remove scrollbar elements before we delete the children!
-	scroll->ClearScrollbars();
+	meta->scroll.ClearScrollbars();
 
 
 	// A simplified version of RemoveChild() for destruction.
 	// A simplified version of RemoveChild() for destruction.
 	for (ElementPtr& child : children)
 	for (ElementPtr& child : children)
@@ -178,7 +171,7 @@ Element::~Element()
 	children.clear();
 	children.clear();
 	num_non_dom_children = 0;
 	num_non_dom_children = 0;
 
 
-	element_meta_chunk_pool.DestroyAndDeallocate(element_meta);
+	element_meta_chunk_pool.DestroyAndDeallocate(meta);
 }
 }
 
 
 void Element::Update(float dp_ratio)
 void Element::Update(float dp_ratio)
@@ -193,7 +186,7 @@ void Element::Update(float dp_ratio)
 	HandleAnimationProperty();
 	HandleAnimationProperty();
 	AdvanceAnimations();
 	AdvanceAnimations();
 
 
-	scroll->Update();
+	meta->scroll.Update();
 
 
 	UpdateProperties();
 	UpdateProperties();
 
 
@@ -212,9 +205,9 @@ void Element::Update(float dp_ratio)
 
 
 void Element::UpdateProperties()
 void Element::UpdateProperties()
 {
 {
-	style->UpdateDefinition();
+	meta->style.UpdateDefinition();
 
 
-	if (style->AnyPropertiesDirty())
+	if (meta->style.AnyPropertiesDirty())
 	{
 	{
 		const ComputedValues* parent_values = nullptr;
 		const ComputedValues* parent_values = nullptr;
 		if (parent)
 		if (parent)
@@ -230,7 +223,7 @@ void Element::UpdateProperties()
 		}
 		}
 
 
 		// Compute values and clear dirty properties
 		// Compute values and clear dirty properties
-		PropertyIdSet dirty_properties = style->ComputeValues(element_meta->computed_values, parent_values, document_values, computed_values_are_default_initialized, dp_ratio);
+		PropertyIdSet dirty_properties = meta->style.ComputeValues(meta->computed_values, parent_values, document_values, computed_values_are_default_initialized, dp_ratio);
 
 
 		computed_values_are_default_initialized = false;
 		computed_values_are_default_initialized = false;
 
 
@@ -266,9 +259,9 @@ void Element::Render()
 	// Set up the clipping region for this element.
 	// Set up the clipping region for this element.
 	if (ElementUtilities::SetClippingRegion(this))
 	if (ElementUtilities::SetClippingRegion(this))
 	{
 	{
-		background->RenderBackground();
-		border->RenderBorder();
-		decoration->RenderDecorators();
+		meta->background.RenderBackground();
+		meta->border.RenderBorder();
+		meta->decoration.RenderDecorators();
 
 
 		{
 		{
 			RMLUI_ZoneScopedNC("OnRender", 0x228B22);
 			RMLUI_ZoneScopedNC("OnRender", 0x228B22);
@@ -310,13 +303,13 @@ ElementPtr Element::Clone() const
 // Sets or removes a class on the element.
 // Sets or removes a class on the element.
 void Element::SetClass(const String& class_name, bool activate)
 void Element::SetClass(const String& class_name, bool activate)
 {
 {
-	style->SetClass(class_name, activate);
+	meta->style.SetClass(class_name, activate);
 }
 }
 
 
 // Checks if a class is set on the element.
 // Checks if a class is set on the element.
 bool Element::IsClassSet(const String& class_name) const
 bool Element::IsClassSet(const String& class_name) const
 {
 {
-	return style->IsClassSet(class_name);
+	return meta->style.IsClassSet(class_name);
 }
 }
 
 
 // Specifies the entire list of classes for this element. This will replace any others specified.
 // Specifies the entire list of classes for this element. This will replace any others specified.
@@ -328,7 +321,7 @@ void Element::SetClassNames(const String& class_names)
 /// Return the active class list
 /// Return the active class list
 String Element::GetClassNames() const
 String Element::GetClassNames() const
 {
 {
-	return style->GetClassNames();
+	return meta->style.GetClassNames();
 }
 }
 
 
 // Returns the active style sheet for this element. This may be nullptr.
 // Returns the active style sheet for this element. This may be nullptr.
@@ -343,7 +336,7 @@ const SharedPtr<StyleSheet>& Element::GetStyleSheet() const
 // Returns the element's definition.
 // Returns the element's definition.
 const ElementDefinition* Element::GetDefinition()
 const ElementDefinition* Element::GetDefinition()
 {
 {
-	return style->GetDefinition();
+	return meta->style.GetDefinition();
 }
 }
 
 
 // Fills an String with the full address of this element.
 // Fills an String with the full address of this element.
@@ -359,7 +352,7 @@ String Element::GetAddress(bool include_pseudo_classes, bool include_parents) co
 		address += id;
 		address += id;
 	}
 	}
 
 
-	String classes = style->GetClassNames();
+	String classes = meta->style.GetClassNames();
 	if (!classes.empty())
 	if (!classes.empty())
 	{
 	{
 		classes = StringUtilities::Replace(classes, ' ', '.');
 		classes = StringUtilities::Replace(classes, ' ', '.');
@@ -369,7 +362,7 @@ String Element::GetAddress(bool include_pseudo_classes, bool include_parents) co
 
 
 	if (include_pseudo_classes)
 	if (include_pseudo_classes)
 	{
 	{
-		const PseudoClassList& pseudo_classes = style->GetActivePseudoClasses();		
+		const PseudoClassList& pseudo_classes = meta->style.GetActivePseudoClasses();		
 		for (PseudoClassList::const_iterator i = pseudo_classes.begin(); i != pseudo_classes.end(); ++i)
 		for (PseudoClassList::const_iterator i = pseudo_classes.begin(); i != pseudo_classes.end(); ++i)
 		{
 		{
 			address += ":";
 			address += ":";
@@ -496,9 +489,9 @@ void Element::SetBox(const Box& box)
 
 
 		OnResize();
 		OnResize();
 
 
-		background->DirtyBackground();
-		border->DirtyBorder();
-		decoration->DirtyDecorators();
+		meta->background.DirtyBackground();
+		meta->border.DirtyBorder();
+		meta->decoration.DirtyDecorators();
 	}
 	}
 }
 }
 
 
@@ -509,9 +502,9 @@ void Element::AddBox(const Box& box)
 
 
 	OnResize();
 	OnResize();
 
 
-	background->DirtyBackground();
-	border->DirtyBorder();
-	decoration->DirtyDecorators();
+	meta->background.DirtyBackground();
+	meta->border.DirtyBorder();
+	meta->decoration.DirtyDecorators();
 }
 }
 
 
 // Returns one of the boxes describing the size of the element.
 // Returns one of the boxes describing the size of the element.
@@ -591,7 +584,7 @@ float Element::GetZIndex() const
 // Returns the element's font face handle.
 // Returns the element's font face handle.
 FontFaceHandle Element::GetFontFaceHandle() const
 FontFaceHandle Element::GetFontFaceHandle() const
 {
 {
-	return element_meta->computed_values.font_face_handle;
+	return meta->computed_values.font_face_handle;
 }
 }
 
 
 // Sets a local property override on the element.
 // Sets a local property override on the element.
@@ -606,7 +599,7 @@ bool Element::SetProperty(const String& name, const String& value)
 	}
 	}
 	for (auto& property : properties.GetProperties())
 	for (auto& property : properties.GetProperties())
 	{
 	{
-		if (!style->SetProperty(property.first, property.second))
+		if (!meta->style.SetProperty(property.first, property.second))
 			return false;
 			return false;
 	}
 	}
 	return true;
 	return true;
@@ -615,57 +608,57 @@ bool Element::SetProperty(const String& name, const String& value)
 // Sets a local property override on the element to a pre-parsed value.
 // Sets a local property override on the element to a pre-parsed value.
 bool Element::SetProperty(PropertyId id, const Property& property)
 bool Element::SetProperty(PropertyId id, const Property& property)
 {
 {
-	return style->SetProperty(id, property);
+	return meta->style.SetProperty(id, property);
 }
 }
 
 
 // Removes a local property override on the element.
 // Removes a local property override on the element.
 void Element::RemoveProperty(const String& name)
 void Element::RemoveProperty(const String& name)
 {
 {
-	style->RemoveProperty(StyleSheetSpecification::GetPropertyId(name));
+	meta->style.RemoveProperty(StyleSheetSpecification::GetPropertyId(name));
 }
 }
 
 
 // Removes a local property override on the element.
 // Removes a local property override on the element.
 void Element::RemoveProperty(PropertyId id)
 void Element::RemoveProperty(PropertyId id)
 {
 {
-	style->RemoveProperty(id);
+	meta->style.RemoveProperty(id);
 }
 }
 
 
 // Returns one of this element's properties.
 // Returns one of this element's properties.
 const Property* Element::GetProperty(const String& name)
 const Property* Element::GetProperty(const String& name)
 {
 {
-	return style->GetProperty(StyleSheetSpecification::GetPropertyId(name));
+	return meta->style.GetProperty(StyleSheetSpecification::GetPropertyId(name));
 }
 }
 
 
 // Returns one of this element's properties.
 // Returns one of this element's properties.
 const Property* Element::GetProperty(PropertyId id)
 const Property* Element::GetProperty(PropertyId id)
 {
 {
-	return style->GetProperty(id);
+	return meta->style.GetProperty(id);
 }
 }
 
 
 // Returns one of this element's properties.
 // Returns one of this element's properties.
 const Property* Element::GetLocalProperty(const String& name)
 const Property* Element::GetLocalProperty(const String& name)
 {
 {
-	return style->GetLocalProperty(StyleSheetSpecification::GetPropertyId(name));
+	return meta->style.GetLocalProperty(StyleSheetSpecification::GetPropertyId(name));
 }
 }
 
 
 const Property* Element::GetLocalProperty(PropertyId id)
 const Property* Element::GetLocalProperty(PropertyId id)
 {
 {
-	return style->GetLocalProperty(id);
+	return meta->style.GetLocalProperty(id);
 }
 }
 
 
 const PropertyMap& Element::GetLocalStyleProperties()
 const PropertyMap& Element::GetLocalStyleProperties()
 {
 {
-	return style->GetLocalStyleProperties();
+	return meta->style.GetLocalStyleProperties();
 }
 }
 
 
 float Element::ResolveNumericProperty(const Property *property, float base_value)
 float Element::ResolveNumericProperty(const Property *property, float base_value)
 {
 {
-	return style->ResolveNumericProperty(property, base_value);
+	return meta->style.ResolveNumericProperty(property, base_value);
 }
 }
 
 
 float Element::ResolveNumericProperty(const String& property_name)
 float Element::ResolveNumericProperty(const String& property_name)
 {
 {
-	auto property = style->GetProperty(StyleSheetSpecification::GetPropertyId(property_name));
+	auto property = meta->style.GetProperty(StyleSheetSpecification::GetPropertyId(property_name));
 	if (!property)
 	if (!property)
 		return 0.0f;
 		return 0.0f;
 
 
@@ -676,7 +669,7 @@ float Element::ResolveNumericProperty(const String& property_name)
 	if (property->definition)
 	if (property->definition)
 		relative_target = property->definition->GetRelativeTarget();
 		relative_target = property->definition->GetRelativeTarget();
 
 
-	float result = style->ResolveLength(property, relative_target);
+	float result = meta->style.ResolveLength(property, relative_target);
 	
 	
 	return result;
 	return result;
 }
 }
@@ -700,28 +693,28 @@ Vector2f Element::GetContainingBlock()
 			containing_block = parent_box.GetSize(Box::PADDING);
 			containing_block = parent_box.GetSize(Box::PADDING);
 		}
 		}
 	}
 	}
-
+	
 	return containing_block;
 	return containing_block;
 }
 }
 
 
 Style::Position Element::GetPosition()
 Style::Position Element::GetPosition()
 {
 {
-	return element_meta->computed_values.position;
+	return meta->computed_values.position;
 }
 }
 
 
 Style::Float Element::GetFloat()
 Style::Float Element::GetFloat()
 {
 {
-	return element_meta->computed_values.float_;
+	return meta->computed_values.float_;
 }
 }
 
 
 Style::Display Element::GetDisplay()
 Style::Display Element::GetDisplay()
 {
 {
-	return element_meta->computed_values.display;
+	return meta->computed_values.display;
 }
 }
 
 
 float Element::GetLineHeight()
 float Element::GetLineHeight()
 {
 {
-	return element_meta->computed_values.line_height.value;
+	return meta->computed_values.line_height.value;
 }
 }
 
 
 // Returns this element's TransformState
 // Returns this element's TransformState
@@ -775,20 +768,20 @@ bool Element::Project(Vector2f& point) const noexcept
 
 
 PropertiesIteratorView Element::IterateLocalProperties() const
 PropertiesIteratorView Element::IterateLocalProperties() const
 {
 {
-	return PropertiesIteratorView(std::make_unique<PropertiesIterator>(style->Iterate()));
+	return PropertiesIteratorView(std::make_unique<PropertiesIterator>(meta->style.Iterate()));
 }
 }
 
 
 
 
 // Sets or removes a pseudo-class on the element.
 // Sets or removes a pseudo-class on the element.
 void Element::SetPseudoClass(const String& pseudo_class, bool activate)
 void Element::SetPseudoClass(const String& pseudo_class, bool activate)
 {
 {
-	style->SetPseudoClass(pseudo_class, activate);
+	meta->style.SetPseudoClass(pseudo_class, activate);
 }
 }
 
 
 // Checks if a specific pseudo-class has been set on the element.
 // Checks if a specific pseudo-class has been set on the element.
 bool Element::IsPseudoClassSet(const String& pseudo_class) const
 bool Element::IsPseudoClassSet(const String& pseudo_class) const
 {
 {
-	return style->IsPseudoClassSet(pseudo_class);
+	return meta->style.IsPseudoClassSet(pseudo_class);
 }
 }
 
 
 // Checks if a complete set of pseudo-classes are set on the element.
 // Checks if a complete set of pseudo-classes are set on the element.
@@ -806,7 +799,7 @@ bool Element::ArePseudoClassesSet(const PseudoClassList& pseudo_classes) const
 // Gets a list of the current active pseudo classes
 // Gets a list of the current active pseudo classes
 const PseudoClassList& Element::GetActivePseudoClasses() const
 const PseudoClassList& Element::GetActivePseudoClasses() const
 {
 {
-	return style->GetActivePseudoClasses();
+	return meta->style.GetActivePseudoClasses();
 }
 }
 
 
 /// Get the named attribute
 /// Get the named attribute
@@ -923,13 +916,13 @@ float Element::GetClientTop()
 // Gets the inner width of the element.
 // Gets the inner width of the element.
 float Element::GetClientWidth()
 float Element::GetClientWidth()
 {
 {
-	return GetBox().GetSize(client_area).x - scroll->GetScrollbarSize(ElementScroll::VERTICAL);
+	return GetBox().GetSize(client_area).x - meta->scroll.GetScrollbarSize(ElementScroll::VERTICAL);
 }
 }
 
 
 // Gets the inner height of the element.
 // Gets the inner height of the element.
 float Element::GetClientHeight()
 float Element::GetClientHeight()
 {
 {
-	return GetBox().GetSize(client_area).y - scroll->GetScrollbarSize(ElementScroll::HORIZONTAL);
+	return GetBox().GetSize(client_area).y - meta->scroll.GetScrollbarSize(ElementScroll::HORIZONTAL);
 }
 }
 
 
 // Returns the element from which all offset calculations are currently computed.
 // Returns the element from which all offset calculations are currently computed.
@@ -975,7 +968,7 @@ void Element::SetScrollLeft(float scroll_left)
 	if (new_offset != scroll_offset.x)
 	if (new_offset != scroll_offset.x)
 	{
 	{
 		scroll_offset.x = new_offset;
 		scroll_offset.x = new_offset;
-		scroll->UpdateScrollbar(ElementScroll::HORIZONTAL);
+		meta->scroll.UpdateScrollbar(ElementScroll::HORIZONTAL);
 		DirtyOffset();
 		DirtyOffset();
 
 
 		DispatchEvent(EventId::Scroll, Dictionary());
 		DispatchEvent(EventId::Scroll, Dictionary());
@@ -995,7 +988,7 @@ void Element::SetScrollTop(float scroll_top)
 	if(new_offset != scroll_offset.y)
 	if(new_offset != scroll_offset.y)
 	{
 	{
 		scroll_offset.y = new_offset;
 		scroll_offset.y = new_offset;
-		scroll->UpdateScrollbar(ElementScroll::VERTICAL);
+		meta->scroll.UpdateScrollbar(ElementScroll::VERTICAL);
 		DirtyOffset();
 		DirtyOffset();
 
 
 		DispatchEvent(EventId::Scroll, Dictionary());
 		DispatchEvent(EventId::Scroll, Dictionary());
@@ -1017,7 +1010,7 @@ float Element::GetScrollHeight()
 // Gets the object representing the declarations of an element's style attributes.
 // Gets the object representing the declarations of an element's style attributes.
 ElementStyle* Element::GetStyle() const
 ElementStyle* Element::GetStyle() const
 {
 {
-	return style;
+	return &meta->style;
 }
 }
 
 
 // Gets the document this element belongs to.
 // Gets the document this element belongs to.
@@ -1136,7 +1129,7 @@ void Element::SetInnerRML(const String& rml)
 bool Element::Focus()
 bool Element::Focus()
 {
 {
 	// Are we allowed focus?
 	// Are we allowed focus?
-	Style::Focus focus_property = element_meta->computed_values.focus;
+	Style::Focus focus_property = meta->computed_values.focus;
 	if (focus_property == Style::Focus::None)
 	if (focus_property == Style::Focus::None)
 		return false;
 		return false;
 
 
@@ -1196,26 +1189,26 @@ void Element::Click()
 void Element::AddEventListener(const String& event, EventListener* listener, bool in_capture_phase)
 void Element::AddEventListener(const String& event, EventListener* listener, bool in_capture_phase)
 {
 {
 	EventId id = EventSpecificationInterface::GetIdOrInsert(event);
 	EventId id = EventSpecificationInterface::GetIdOrInsert(event);
-	event_dispatcher->AttachEvent(id, listener, in_capture_phase);
+	meta->event_dispatcher.AttachEvent(id, listener, in_capture_phase);
 }
 }
 
 
 // Adds an event listener
 // Adds an event listener
 void Element::AddEventListener(EventId id, EventListener* listener, bool in_capture_phase)
 void Element::AddEventListener(EventId id, EventListener* listener, bool in_capture_phase)
 {
 {
-	event_dispatcher->AttachEvent(id, listener, in_capture_phase);
+	meta->event_dispatcher.AttachEvent(id, listener, in_capture_phase);
 }
 }
 
 
 // Removes an event listener from this element.
 // Removes an event listener from this element.
 void Element::RemoveEventListener(const String& event, EventListener* listener, bool in_capture_phase)
 void Element::RemoveEventListener(const String& event, EventListener* listener, bool in_capture_phase)
 {
 {
 	EventId id = EventSpecificationInterface::GetIdOrInsert(event);
 	EventId id = EventSpecificationInterface::GetIdOrInsert(event);
-	event_dispatcher->DetachEvent(id, listener, in_capture_phase);
+	meta->event_dispatcher.DetachEvent(id, listener, in_capture_phase);
 }
 }
 
 
 // Removes an event listener from this element.
 // Removes an event listener from this element.
 void Element::RemoveEventListener(EventId id, EventListener* listener, bool in_capture_phase)
 void Element::RemoveEventListener(EventId id, EventListener* listener, bool in_capture_phase)
 {
 {
-	event_dispatcher->DetachEvent(id, listener, in_capture_phase);
+	meta->event_dispatcher.DetachEvent(id, listener, in_capture_phase);
 }
 }
 
 
 
 
@@ -1485,36 +1478,36 @@ void Element::GetElementsByClassName(ElementList& elements, const String& class_
 // Access the event dispatcher
 // Access the event dispatcher
 EventDispatcher* Element::GetEventDispatcher() const
 EventDispatcher* Element::GetEventDispatcher() const
 {
 {
-	return event_dispatcher;
+	return &meta->event_dispatcher;
 }
 }
 
 
 String Element::GetEventDispatcherSummary() const
 String Element::GetEventDispatcherSummary() const
 {
 {
-	return event_dispatcher->ToString();
+	return meta->event_dispatcher.ToString();
 }
 }
 
 
 // Access the element background.
 // Access the element background.
 ElementBackground* Element::GetElementBackground() const
 ElementBackground* Element::GetElementBackground() const
 {
 {
-	return background;
+	return &meta->background;
 }
 }
 
 
 // Access the element border.
 // Access the element border.
 ElementBorder* Element::GetElementBorder() const
 ElementBorder* Element::GetElementBorder() const
 {
 {
-	return border;
+	return &meta->border;
 }
 }
 
 
 // Access the element decorators
 // Access the element decorators
 ElementDecoration* Element::GetElementDecoration() const
 ElementDecoration* Element::GetElementDecoration() const
 {
 {
-	return decoration;
+	return &meta->decoration;
 }
 }
 
 
 // Returns the element's scrollbar functionality.
 // Returns the element's scrollbar functionality.
 ElementScroll* Element::GetElementScroll() const
 ElementScroll* Element::GetElementScroll() const
 {
 {
-	return scroll;
+	return &meta->scroll;
 }
 }
 	
 	
 int Element::GetClippingIgnoreDepth()
 int Element::GetClippingIgnoreDepth()
@@ -1600,13 +1593,13 @@ void Element::OnAttributeChange(const ElementAttributes& changed_attributes)
 	if (it != changed_attributes.end())
 	if (it != changed_attributes.end())
 	{
 	{
 		id = it->second.Get<String>();
 		id = it->second.Get<String>();
-		style->DirtyDefinition();
+		meta->style.DirtyDefinition();
 	}
 	}
 
 
 	it = changed_attributes.find("class");
 	it = changed_attributes.find("class");
 	if (it != changed_attributes.end())
 	if (it != changed_attributes.end())
 	{
 	{
-		style->SetClassNames(it->second.Get<String>());
+		meta->style.SetClassNames(it->second.Get<String>());
 	}
 	}
 
 
 	// Add any inline style declarations.
 	// Add any inline style declarations.
@@ -1620,7 +1613,7 @@ void Element::OnAttributeChange(const ElementAttributes& changed_attributes)
 		Rml::Core::PropertyMap property_map = properties.GetProperties();
 		Rml::Core::PropertyMap property_map = properties.GetProperties();
 		for (Rml::Core::PropertyMap::iterator i = property_map.begin(); i != property_map.end(); ++i)
 		for (Rml::Core::PropertyMap::iterator i = property_map.begin(); i != property_map.end(); ++i)
 		{
 		{
-			style->SetProperty((*i).first, (*i).second);
+			meta->style.SetProperty((*i).first, (*i).second);
 		}
 		}
 	}
 	}
 }
 }
@@ -1644,7 +1637,7 @@ void Element::OnPropertyChange(const PropertyIdSet& changed_properties)
 	if (changed_properties.Contains(PropertyId::Visibility) ||
 	if (changed_properties.Contains(PropertyId::Visibility) ||
 		changed_properties.Contains(PropertyId::Display))
 		changed_properties.Contains(PropertyId::Display))
 	{
 	{
-		bool new_visibility = (element_meta->computed_values.display != Style::Display::None && element_meta->computed_values.visibility == Style::Visibility::Visible);
+		bool new_visibility = (meta->computed_values.display != Style::Display::None && meta->computed_values.visibility == Style::Visibility::Visible);
 			
 			
 		if (visible != new_visibility)
 		if (visible != new_visibility)
 		{
 		{
@@ -1681,7 +1674,7 @@ void Element::OnPropertyChange(const PropertyIdSet& changed_properties)
 	// Update the z-index.
 	// Update the z-index.
 	if (changed_properties.Contains(PropertyId::ZIndex))
 	if (changed_properties.Contains(PropertyId::ZIndex))
 	{
 	{
-		Style::ZIndex z_index_property = element_meta->computed_values.z_index;
+		Style::ZIndex z_index_property = meta->computed_values.z_index;
 
 
 		if (z_index_property.type == Style::ZIndex::Auto)
 		if (z_index_property.type == Style::ZIndex::Auto)
 		{
 		{
@@ -1726,14 +1719,14 @@ void Element::OnPropertyChange(const PropertyIdSet& changed_properties)
     if (changed_properties.Contains(PropertyId::BackgroundColor) ||
     if (changed_properties.Contains(PropertyId::BackgroundColor) ||
 		changed_properties.Contains(PropertyId::Opacity) ||
 		changed_properties.Contains(PropertyId::Opacity) ||
 		changed_properties.Contains(PropertyId::ImageColor)) {
 		changed_properties.Contains(PropertyId::ImageColor)) {
-		background->DirtyBackground();
+		meta->background.DirtyBackground();
     }
     }
 	
 	
 	// Dirty the decoration if it's changed.
 	// Dirty the decoration if it's changed.
 	if (changed_properties.Contains(PropertyId::Decorator) ||
 	if (changed_properties.Contains(PropertyId::Decorator) ||
 		changed_properties.Contains(PropertyId::Opacity) ||
 		changed_properties.Contains(PropertyId::Opacity) ||
 		changed_properties.Contains(PropertyId::ImageColor)) {
 		changed_properties.Contains(PropertyId::ImageColor)) {
-		decoration->DirtyDecorators();
+		meta->decoration.DirtyDecorators();
 	}
 	}
 
 
 	// Dirty the border if it's changed.
 	// Dirty the border if it's changed.
@@ -1746,7 +1739,7 @@ void Element::OnPropertyChange(const PropertyIdSet& changed_properties)
 		changed_properties.Contains(PropertyId::BorderBottomColor) ||
 		changed_properties.Contains(PropertyId::BorderBottomColor) ||
 		changed_properties.Contains(PropertyId::BorderLeftColor) ||
 		changed_properties.Contains(PropertyId::BorderLeftColor) ||
 		changed_properties.Contains(PropertyId::Opacity))
 		changed_properties.Contains(PropertyId::Opacity))
-		border->DirtyBorder();
+		meta->border.DirtyBorder();
 
 
 	
 	
 	// Check for clipping state changes
 	// Check for clipping state changes
@@ -1823,7 +1816,7 @@ void Element::ProcessDefaultAction(Event& event)
 	{
 	{
 		if (GetScrollHeight() > GetClientHeight())
 		if (GetScrollHeight() > GetClientHeight())
 		{
 		{
-			Style::Overflow overflow_property = element_meta->computed_values.overflow_y;
+			Style::Overflow overflow_property = meta->computed_values.overflow_y;
 			if (overflow_property == Style::Overflow::Auto ||
 			if (overflow_property == Style::Overflow::Auto ||
 				overflow_property == Style::Overflow::Scroll)
 				overflow_property == Style::Overflow::Scroll)
 			{
 			{
@@ -1874,7 +1867,7 @@ void Element::ProcessDefaultAction(Event& event)
 
 
 const Style::ComputedValues& Element::GetComputedValues() const
 const Style::ComputedValues& Element::GetComputedValues() const
 {
 {
-	return element_meta->computed_values;
+	return meta->computed_values;
 }
 }
 
 
 void Element::GetRML(String& content)
 void Element::GetRML(String& content)
@@ -1948,8 +1941,8 @@ void Element::SetParent(Element* _parent)
 	if (parent)
 	if (parent)
 	{
 	{
 		// We need to update our definition and make sure we inherit the properties of our new parent.
 		// We need to update our definition and make sure we inherit the properties of our new parent.
-		style->DirtyDefinition();
-		style->DirtyInheritedProperties();
+		meta->style.DirtyDefinition();
+		meta->style.DirtyInheritedProperties();
 	}
 	}
 
 
 	// The transform state may require recalculation.
 	// The transform state may require recalculation.
@@ -1977,7 +1970,7 @@ void Element::DirtyOffset()
 void Element::UpdateOffset()
 void Element::UpdateOffset()
 {
 {
 	using namespace Style;
 	using namespace Style;
-	const auto& computed = element_meta->computed_values;
+	const auto& computed = meta->computed_values;
 	Position position_property = computed.position;
 	Position position_property = computed.position;
 
 
 	if (position_property == Position::Absolute ||
 	if (position_property == Position::Absolute ||
@@ -2206,7 +2199,7 @@ ElementAnimationList::iterator Element::StartAnimation(PropertyId property_id, c
 bool Element::AddAnimationKeyTime(PropertyId property_id, const Property* target_value, float time, Tween tween)
 bool Element::AddAnimationKeyTime(PropertyId property_id, const Property* target_value, float time, Tween tween)
 {
 {
 	if (!target_value)
 	if (!target_value)
-		target_value = style->GetProperty(property_id);
+		target_value = meta->style.GetProperty(property_id);
 	if (!target_value)
 	if (!target_value)
 		return false;
 		return false;
 
 
@@ -2320,7 +2313,7 @@ void Element::HandleAnimationProperty()
 	{
 	{
 		dirty_animation = false;
 		dirty_animation = false;
 
 
-		const AnimationList& animation_list = element_meta->computed_values.animation;
+		const AnimationList& animation_list = meta->computed_values.animation;
 		bool element_has_animations = (!animation_list.empty() || !animations.empty());
 		bool element_has_animations = (!animation_list.empty() || !animations.empty());
 		StyleSheet* stylesheet = nullptr;
 		StyleSheet* stylesheet = nullptr;
 
 
@@ -2432,7 +2425,7 @@ void Element::UpdateTransformState()
 	if (!dirty_perspective && !dirty_transform)
 	if (!dirty_perspective && !dirty_transform)
 		return;
 		return;
 
 
-	const ComputedValues& computed = element_meta->computed_values;
+	const ComputedValues& computed = meta->computed_values;
 
 
 	const Vector2f pos = GetAbsoluteOffset(Box::BORDER);
 	const Vector2f pos = GetAbsoluteOffset(Box::BORDER);
 	const Vector2f size = GetBox().GetSize(Box::BORDER);
 	const Vector2f size = GetBox().GetSize(Box::BORDER);

+ 1 - 1
Source/Core/ElementDecoration.h

@@ -71,7 +71,7 @@ private:
 		DecoratorDataHandle decorator_data;
 		DecoratorDataHandle decorator_data;
 	};
 	};
 
 
-	typedef std::vector< DecoratorHandle > DecoratorHandleList;
+	using DecoratorHandleList = std::vector< DecoratorHandle >;
 
 
 	// The element this decorator belongs to
 	// The element this decorator belongs to
 	Element* element;
 	Element* element;