Ver código fonte

Remove unnecessary references in arguments. Add conversion between vector types.

Michael Ragazzon 5 anos atrás
pai
commit
3877e3dbad
68 arquivos alterados com 262 adições e 384 exclusões
  1. 0 3
      CMake/FileList.cmake
  2. 6 14
      Include/RmlUi/Core/Colour.h
  3. 4 16
      Include/RmlUi/Core/Colour.inl
  4. 5 5
      Include/RmlUi/Core/Context.h
  5. 1 1
      Include/RmlUi/Core/Core.h
  6. 2 2
      Include/RmlUi/Core/Element.h
  7. 1 1
      Include/RmlUi/Core/ElementText.h
  8. 1 1
      Include/RmlUi/Core/Event.h
  9. 2 2
      Include/RmlUi/Core/FontEffect.h
  10. 0 58
      Include/RmlUi/Core/MathTypes.h
  11. 5 5
      Include/RmlUi/Core/Variant.h
  12. 18 13
      Include/RmlUi/Core/Vector2.h
  13. 36 14
      Include/RmlUi/Core/Vector2.inl
  14. 5 0
      Include/RmlUi/Core/Vector3.h
  15. 18 3
      Include/RmlUi/Core/Vector3.inl
  16. 7 2
      Include/RmlUi/Core/Vector4.h
  17. 28 5
      Include/RmlUi/Core/Vector4.inl
  18. 3 3
      Source/Core/ComputeProperty.cpp
  19. 7 9
      Source/Core/Context.cpp
  20. 1 1
      Source/Core/Core.cpp
  21. 1 1
      Source/Core/DecoratorGradient.cpp
  22. 1 1
      Source/Core/DecoratorGradient.h
  23. 1 2
      Source/Core/DecoratorNinePatch.cpp
  24. 2 3
      Source/Core/DecoratorTiled.cpp
  25. 1 1
      Source/Core/DecoratorTiled.h
  26. 7 25
      Source/Core/Element.cpp
  27. 5 3
      Source/Core/ElementDocument.cpp
  28. 1 2
      Source/Core/ElementScroll.cpp
  29. 24 15
      Source/Core/ElementStyle.cpp
  30. 1 1
      Source/Core/ElementText.cpp
  31. 1 1
      Source/Core/Elements/WidgetSlider.cpp
  32. 1 1
      Source/Core/Elements/WidgetSlider.h
  33. 1 1
      Source/Core/Elements/WidgetTextInput.cpp
  34. 1 1
      Source/Core/Elements/WidgetTextInput.h
  35. 1 1
      Source/Core/Event.cpp
  36. 2 2
      Source/Core/FontEffect.cpp
  37. 1 1
      Source/Core/FontEffectShadow.cpp
  38. 1 1
      Source/Core/FontEffectShadow.h
  39. 1 1
      Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp
  40. 1 1
      Source/Core/FontEngineDefault/FontFaceHandleDefault.h
  41. 3 6
      Source/Core/FontEngineDefault/FontFaceLayer.cpp
  42. 2 2
      Source/Core/FontEngineDefault/FontFaceLayer.h
  43. 2 2
      Source/Core/LayoutBlockBox.cpp
  44. 2 2
      Source/Core/LayoutBlockBox.h
  45. 4 4
      Source/Core/LayoutBlockBoxSpace.cpp
  46. 4 4
      Source/Core/LayoutBlockBoxSpace.h
  47. 1 1
      Source/Core/LayoutInlineBox.cpp
  48. 1 1
      Source/Core/LayoutInlineBox.h
  49. 2 2
      Source/Core/LayoutLineBox.cpp
  50. 2 2
      Source/Core/LayoutLineBox.h
  51. 1 1
      Source/Core/TextureLayout.cpp
  52. 1 1
      Source/Core/TextureLayout.h
  53. 4 4
      Source/Core/TextureLayoutRectangle.cpp
  54. 4 4
      Source/Core/TextureLayoutRectangle.h
  55. 1 1
      Source/Core/TextureLayoutTexture.cpp
  56. 1 1
      Source/Core/TextureLayoutTexture.h
  57. 1 1
      Source/Core/TextureResource.cpp
  58. 1 1
      Source/Core/TextureResource.h
  59. 2 2
      Source/Core/TransformUtilities.cpp
  60. 5 5
      Source/Core/Variant.cpp
  61. 0 45
      Source/Core/Vector3.cpp
  62. 0 53
      Source/Core/Vector4.cpp
  63. 2 2
      Source/Core/WidgetScroll.cpp
  64. 2 2
      Source/Core/WidgetScroll.h
  65. 3 3
      Source/Debugger/Geometry.cpp
  66. 3 3
      Source/Debugger/Geometry.h
  67. 1 2
      Source/Lottie/ElementLottie.cpp
  68. 2 4
      Source/Lua/Context.cpp

+ 0 - 3
CMake/FileList.cmake

@@ -181,7 +181,6 @@ set(Core_PUB_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Input.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Log.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Math.h
-    ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/MathTypes.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Matrix4.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Matrix4.inl
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ObserverPtr.h
@@ -394,8 +393,6 @@ set(Core_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/TypeConverter.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/URL.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/Variant.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Vector3.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Vector4.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/WidgetScroll.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/XMLNodeHandler.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/XMLNodeHandlerBody.cpp

+ 6 - 14
Include/RmlUi/Core/Colour.h

@@ -57,15 +57,11 @@ public:
 	/// Returns the sum of this colour and another. This does not saturate the channels.
 	/// @param[in] rhs The colour to add this to.
 	/// @return The sum of the two colours.
-	inline Colour operator+(const Colour& rhs) const;
+	inline Colour operator+(Colour rhs) const;
 	/// Returns the result of subtracting another colour from this colour.
 	/// @param[in] rhs The colour to subtract from this colour.
 	/// @return The result of the subtraction.
-	inline Colour operator-(const Colour& rhs) const;
-	/// Returns the result of multiplying this colour by another.
-	/// @param[in] rhs The colour to multiply by.
-	/// @return The result of the multiplication.
-	Colour operator*(const Colour& rhs) const;
+	inline Colour operator-(Colour rhs) const;
 	/// Returns the result of multiplying this colour component-wise by a scalar.
 	/// @param[in] rhs The scalar value to multiply by.
 	/// @return The result of the scale.
@@ -77,14 +73,10 @@ public:
 
 	/// Adds another colour to this in-place. This does not saturate the channels.
 	/// @param[in] rhs The colour to add.
-	inline void operator+=(const Colour& rhs);
+	inline void operator+=(Colour rhs);
 	/// Subtracts another colour from this in-place.
 	/// @param[in] rhs The colour to subtract.
-	inline void operator-=(const Colour& rhs);
-	/// Multiplies this colour component-wise with another in-place.
-	/// @param[in] rhs The colour to multiply by.
-	/// @return This colour, post-operation.
-	void operator*=(const Colour& rhs);
+	inline void operator-=(Colour rhs);
 	/// Scales this colour component-wise in-place.
 	/// @param[in] rhs The value to scale this colours's components by.
 	inline void operator*=(float rhs);
@@ -95,11 +87,11 @@ public:
 	/// Equality operator.
 	/// @param[in] rhs The colour to compare this against.
 	/// @return True if the two colours are equal, false otherwise.
-	inline bool operator==(const Colour& rhs)	{ return red == rhs.red && green == rhs.green && blue == rhs.blue && alpha == rhs.alpha; }
+	inline bool operator==(Colour rhs) { return red == rhs.red && green == rhs.green && blue == rhs.blue && alpha == rhs.alpha; }
 	/// Inequality operator.
 	/// @param[in] rhs The colour to compare this against.
 	/// @return True if the two colours are not equal, false otherwise.
-	inline bool operator!=(const Colour& rhs)	{ return red != rhs.red || green != rhs.green || blue != rhs.blue || alpha != rhs.alpha; }
+	inline bool operator!=(Colour rhs) { return !(*this == rhs); }
 
 	/// Auto-cast operator.
 	/// @return A pointer to the first value.

+ 4 - 16
Include/RmlUi/Core/Colour.inl

@@ -44,14 +44,14 @@ Colour< ColourType, AlphaDefault >::Colour(ColourType red, ColourType green, Col
 
 // Returns the sum of this colour and another. This does not saturate the channels.
 template < typename ColourType, int AlphaDefault >
-Colour< ColourType, AlphaDefault > Colour< ColourType, AlphaDefault >::operator+(const Colour< ColourType, AlphaDefault >& rhs) const
+Colour< ColourType, AlphaDefault > Colour< ColourType, AlphaDefault >::operator+(const Colour< ColourType, AlphaDefault > rhs) const
 {
 	return Colour< ColourType, AlphaDefault >(red + rhs.red, green + rhs.green, blue + rhs.blue, alpha + rhs.alpha);
 }
 
 // Returns the result of subtracting another colour from this colour.
 template < typename ColourType, int AlphaDefault >
-Colour< ColourType, AlphaDefault > Colour< ColourType, AlphaDefault >::operator-(const Colour< ColourType, AlphaDefault >& rhs) const
+Colour< ColourType, AlphaDefault > Colour< ColourType, AlphaDefault >::operator-(const Colour< ColourType, AlphaDefault > rhs) const
 {
 	return Colour< ColourType, AlphaDefault >(red - rhs.red, green - rhs.green, blue - rhs.blue, alpha - rhs.alpha);
 }
@@ -72,7 +72,7 @@ Colour< ColourType, AlphaDefault > Colour< ColourType, AlphaDefault >::operator/
 
 // Adds another colour to this in-place. This does not saturate the channels.
 template < typename ColourType, int AlphaDefault >
-void Colour< ColourType, AlphaDefault >::operator+=(const Colour& rhs)
+void Colour< ColourType, AlphaDefault >::operator+=(const Colour rhs)
 {
 	red += rhs.red;
 	green += rhs.green;
@@ -82,7 +82,7 @@ void Colour< ColourType, AlphaDefault >::operator+=(const Colour& rhs)
 
 // Subtracts another colour from this in-place.
 template < typename ColourType, int AlphaDefault >
-void Colour< ColourType, AlphaDefault >::operator-=(const Colour& rhs)
+void Colour< ColourType, AlphaDefault >::operator-=(const Colour rhs)
 {
 	red -= rhs.red;
 	green -= rhs.green;
@@ -107,16 +107,4 @@ void Colour< ColourType, AlphaDefault >::operator/=(float rhs)
 	*this *= (1.0f / rhs);
 }
 
-template < >
-Colour< float, 1 > RMLUICORE_API Colour< float, 1 >::operator*(const Colour< float, 1 >& rhs) const;
-
-template < >
-Colour< byte, 255 > RMLUICORE_API Colour< byte, 255 >::operator*(const Colour< byte, 255 >& rhs) const;
-
-template < >
-void RMLUICORE_API Colour< float, 1 >::operator*=(const Colour& rhs);
-
-template < >
-void RMLUICORE_API Colour< byte, 255 >::operator*=(const Colour& rhs);
-
 } // namespace Rml

+ 5 - 5
Include/RmlUi/Core/Context.h

@@ -69,10 +69,10 @@ public:
 
 	/// Changes the dimensions of the context.
 	/// @param[in] dimensions The new dimensions of the context.
-	void SetDimensions(const Vector2i& dimensions);
+	void SetDimensions(Vector2i dimensions);
 	/// Returns the dimensions of the context.
 	/// @return The current dimensions of the context.
-	const Vector2i& GetDimensions() const;
+	Vector2i GetDimensions() const;
 
 	/// Changes the size ratio of 'dp' unit to 'px' unit
 	/// @param[in] dp_ratio The new density-independent pixel ratio of the context.
@@ -223,7 +223,7 @@ public:
 	/// Sets the current clipping region for the render traversal
 	/// @param[out] origin The clipping origin
 	/// @param[out] dimensions The clipping dimensions
-	void SetActiveClipRegion(const Vector2i& origin, const Vector2i& dimensions);
+	void SetActiveClipRegion(Vector2i origin, Vector2i dimensions);
 
 	/// Sets the instancer to use for releasing this object.
 	/// @param[in] instancer The context's instancer.
@@ -339,7 +339,7 @@ private:
 	void GenerateClickEvent(Element* element);
 
 	// Updates the current hover elements, sending required events.
-	void UpdateHoverChain(const Dictionary& parameters, const Dictionary& drag_parameters, const Vector2i& old_mouse_position);
+	void UpdateHoverChain(const Dictionary& parameters, const Dictionary& drag_parameters, Vector2i old_mouse_position);
 
 	// Creates the drag clone from the given element. The old drag clone will be released if necessary.
 	void CreateDragClone(Element* element);
@@ -365,7 +365,7 @@ private:
 	static void SendEvents(const ElementSet& old_items, const ElementSet& new_items, EventId id, const Dictionary& parameters);
 
 	friend class Rml::Element;
-	friend RMLUICORE_API Context* CreateContext(const String&, const Vector2i&, RenderInterface*);
+	friend RMLUICORE_API Context* CreateContext(const String&, Vector2i, RenderInterface*);
 };
 
 } // namespace Rml

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

@@ -98,7 +98,7 @@ RMLUICORE_API FontEngineInterface* GetFontEngineInterface();
 /// @param[in] render_interface The custom render interface to use, or nullptr to use the default.
 /// @lifetime If specified, the render interface must be kept alive until after the context is destroyed or the call to Rml::Shutdown.
 /// @return A non-owning pointer to the new context, or nullptr if the context could not be created.
-RMLUICORE_API Context* CreateContext(const String& name, const Vector2i& dimensions, RenderInterface* render_interface = nullptr);
+RMLUICORE_API Context* CreateContext(const String& name, Vector2i dimensions, RenderInterface* render_interface = nullptr);
 /// Removes and destroys a context.
 /// @param[in] name The name of the context to remove.
 /// @return True if name is a valid context, false otherwise.

+ 2 - 2
Include/RmlUi/Core/Element.h

@@ -175,7 +175,7 @@ public:
 	/// Checks if a given point in screen coordinates lies within the bordered area of this element.
 	/// @param[in] point The point to test.
 	/// @return True if the element is within this element, false otherwise.
-	virtual bool IsPointWithinElement(const Vector2f& point);
+	virtual bool IsPointWithinElement(Vector2f point);
 
 	/// Returns the visibility of the element.
 	/// @return True if the element is visible, false otherwise.
@@ -595,7 +595,7 @@ protected:
 	void Render();
 
 	/// Updates definition, computed values, and runs OnPropertyChange on this element.
-	void UpdateProperties();
+	void UpdateProperties(float dp_ratio, Vector2f vp_dimensions);
 
 	/// Forces the element to generate a local stacking context, regardless of the value of its z-index property.
 	void ForceLocalStackingContext();

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

@@ -74,7 +74,7 @@ public:
 	/// Adds a new line into the text element.
 	/// @param[in] line_position The position of this line, as an offset from the first line.
 	/// @param[in] line The contents of the line.
-	void AddLine(const Vector2f& line_position, const String& line);
+	void AddLine(Vector2f line_position, const String& line);
 
 	/// Prevents the element from dirtying its document's layout when its text is changed.
 	void SuppressAutoLayout();

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

@@ -115,7 +115,7 @@ public:
 
 	/// Return the unprojected mouse screen position.
 	/// Note: Only specified for events with 'mouse_x' and 'mouse_y' parameters.
-	const Vector2f& GetUnprojectedMouseScreenPos() const;
+	Vector2f GetUnprojectedMouseScreenPos() const;
 
 protected:
 	Dictionary parameters;

+ 2 - 2
Include/RmlUi/Core/FontEffect.h

@@ -66,9 +66,9 @@ public:
 	virtual void GenerateGlyphTexture(byte* destination_data, Vector2i destination_dimensions, int destination_stride, const FontGlyph& glyph) const;
 
 	/// Sets the colour of the effect's geometry.
-	void SetColour(const Colourb& colour);
+	void SetColour(Colourb colour);
 	/// Returns the effect's colour.
-	const Colourb& GetColour() const;
+	Colourb GetColour() const;
 
 	Layer GetLayer() const;
 	void SetLayer(Layer layer);

+ 0 - 58
Include/RmlUi/Core/MathTypes.h

@@ -1,58 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef RMLUI_CORE_MATHTYPES_H
-#define RMLUI_CORE_MATHTYPES_H
-
-#include "Header.h"
-#include "Vector2.h"
-#include "Vector3.h"
-#include "Vector4.h"
-
-namespace Rml {
-
-// Define common Vector2 types.
-typedef Vector2< int > Vector2i;
-typedef Vector2< float > Vector2f;
-RMLUICORE_API Vector2i operator*(int lhs, const Vector2i& rhs);
-RMLUICORE_API Vector2f operator*(float lhs, const Vector2f& rhs);
-
-// Define common Vector3 types.
-typedef Vector3< int > Vector3i;
-typedef Vector3< float > Vector3f;
-RMLUICORE_API Vector3i operator*(int lhs, const Vector3i& rhs);
-RMLUICORE_API Vector3f operator*(float lhs, const Vector3f& rhs);
-
-// Define common Vector4 types.
-typedef Vector4< int > Vector4i;
-typedef Vector4< float > Vector4f;
-RMLUICORE_API Vector4i operator*(int lhs, const Vector4i& rhs);
-RMLUICORE_API Vector4f operator*(float lhs, const Vector4f& rhs);
-
-} // namespace Rml
-#endif

+ 5 - 5
Include/RmlUi/Core/Variant.h

@@ -131,11 +131,11 @@ private:
 	void Set(const int64_t value);
 	void Set(const char* value);
 	void Set(void* value);
-	void Set(const Vector2f& value);
-	void Set(const Vector3f& value);
-	void Set(const Vector4f& value);
-	void Set(const Colourf& value);
-	void Set(const Colourb& value);
+	void Set(const Vector2f value);
+	void Set(const Vector3f value);
+	void Set(const Vector4f value);
+	void Set(const Colourf value);
+	void Set(const Colourb value);
 	void Set(ScriptInterface* value);
 
 	void Set(const String& value);

+ 18 - 13
Include/RmlUi/Core/Vector2.h

@@ -67,7 +67,7 @@ class Vector2
 		/// Computes the dot-product between this vector and another.
 		/// @param[in] rhs The other vector to use in the dot-product.
 		/// @return The computed dot-product between the two vectors.
-		inline Type DotProduct(const Vector2& rhs) const;
+		inline Type DotProduct(Vector2 rhs) const;
 
 		/// Returns this vector rotated around the origin.
 		/// @param[in] theta The angle to rotate by, in radians.
@@ -81,11 +81,11 @@ class Vector2
 		/// Returns the sum of this vector and another.
 		/// @param[in] rhs The vector to add this to.
 		/// @return The sum of the two vectors.
-		inline Vector2 operator+(const Vector2& rhs) const;
+		inline Vector2 operator+(Vector2 rhs) const;
 		/// Returns the result of subtracting another vector from this vector.
 		/// @param[in] rhs The vector to subtract from this vector.
 		/// @return The result of the subtraction.
-		inline Vector2 operator-(const Vector2& rhs) const;
+		inline Vector2 operator-(Vector2 rhs) const;
 		/// Returns the result of multiplying this vector by a scalar.
 		/// @param[in] rhs The scalar value to multiply by.
 		/// @return The result of the scale.
@@ -93,7 +93,7 @@ class Vector2
 		/// Returns the result of element-wise multiplication.
 		/// @param[in] rhs The vector to multiply by.
 		/// @return The result of the multiplication.
-		inline Vector2 operator*(const Vector2& rhs) const;
+		inline Vector2 operator*(Vector2 rhs) const;
 		/// Returns the result of dividing this vector by a scalar.
 		/// @param[in] rhs The scalar value to divide by.
 		/// @return The result of the scale.
@@ -101,41 +101,41 @@ class Vector2
 		/// Returns the result of element-wise division.
 		/// @param[in] rhs The vector to divide by.
 		/// @return The result of the division.
-		inline Vector2 operator/(const Vector2& rhs) const;
+		inline Vector2 operator/(Vector2 rhs) const;
 
 		/// Adds another vector to this in-place.
 		/// @param[in] rhs The vector to add.
 		/// @return This vector, post-operation.
-		inline Vector2& operator+=(const Vector2& rhs);
+		inline Vector2& operator+=(Vector2 rhs);
 		/// Subtracts another vector from this in-place.
 		/// @param[in] rhs The vector to subtract.
 		/// @return This vector, post-operation.
-		inline Vector2& operator-=(const Vector2& rhs);
+		inline Vector2& operator-=(Vector2 rhs);
 		/// Scales this vector in-place.
 		/// @param[in] rhs The value to scale this vector's components by.
 		/// @return This vector, post-operation.
-		inline Vector2& operator*=(const Type& rhs);
+		inline Vector2& operator*=(Type rhs);
 		/// Element-wise multiplication in-place.
 		/// @param[in] rhs The vector to multiply.
 		/// @return This vector, post-operation.
-		inline Vector2& operator*=(const Vector2& rhs);
+		inline Vector2& operator*=(Vector2 rhs);
 		/// Scales this vector in-place by the inverse of a value.
 		/// @param[in] rhs The value to divide this vector's components by.
 		/// @return This vector, post-operation.
-		inline Vector2& operator/=(const Type& rhs);
+		inline Vector2& operator/=(Type rhs);
 		/// Element-wise division in-place.
 		/// @param[in] rhs The vector to divide by.
 		/// @return This vector, post-operation.
-		inline Vector2& operator/=(const Vector2& rhs);
+		inline Vector2& operator/=(Vector2 rhs);
 
 		/// Equality operator.
 		/// @param[in] rhs The vector to compare this against.
 		/// @return True if the two vectors are equal, false otherwise.
-		inline bool operator==(const Vector2& rhs) const;
+		inline bool operator==(Vector2 rhs) const;
 		/// Inequality operator.
 		/// @param[in] rhs The vector to compare this against.
 		/// @return True if the two vectors are not equal, false otherwise.
-		inline bool operator!=(const Vector2& rhs) const;
+		inline bool operator!=(Vector2 rhs) const;
 
 		/// Auto-cast operator.
 		/// @return A pointer to the first value.
@@ -144,6 +144,11 @@ class Vector2
 		/// @return A constant pointer to the first value.
 		inline operator Type*();
 
+		/// Underlying type-cast operator.
+		/// @return A copy of the vector with another underlying type.
+		template < typename U >
+		explicit inline operator Vector2<U>() const;
+
 		// The components of the vector.
 		Type x;
 		Type y;

+ 36 - 14
Include/RmlUi/Core/Vector2.inl

@@ -61,7 +61,14 @@ Type Vector2< Type >::SquaredMagnitude() const
 
 // Generates a normalised vector from this vector.
 template < typename Type >
-Vector2< Type > Vector2< Type >::Normalise() const
+inline Vector2< Type > Vector2< Type >::Normalise() const
+{
+	static_assert(std::is_same<Type, float>::value, "Normalise only implemented for Vector<float>.");
+	return *this;
+}
+
+template < >
+inline Vector2< float > Vector2< float >::Normalise() const
 {
 	float magnitude = Magnitude();
 	if (Math::IsZero(magnitude))
@@ -89,7 +96,7 @@ inline Vector2< int > Vector2< int >::Round() const
 
 // Computes the dot-product between this vector and another.
 template < typename Type >
-Type Vector2< Type >::DotProduct(const Vector2< Type >& rhs) const
+Type Vector2< Type >::DotProduct(Vector2 rhs) const
 {
 	return x * rhs.x +
 		y * rhs.y;
@@ -115,14 +122,14 @@ Vector2< Type > Vector2< Type >::operator-() const
 
 // Returns the sum of this vector and another.
 template < typename Type >
-Vector2< Type > Vector2< Type >::operator+(const Vector2< Type > & rhs) const
+Vector2< Type > Vector2< Type >::operator+(Vector2 rhs) const
 {
 	return Vector2< Type >(x + rhs.x, y + rhs.y);
 }
 
 // Returns the result of subtracting another vector from this vector.
 template < typename Type >
-Vector2< Type > Vector2< Type >::operator-(const Vector2< Type > & rhs) const
+Vector2< Type > Vector2< Type >::operator-(Vector2 rhs) const
 {
 	return Vector2(x - rhs.x, y - rhs.y);
 }
@@ -135,7 +142,7 @@ Vector2< Type > Vector2< Type >::operator*(Type rhs) const
 }
 
 template<typename Type>
-Vector2< Type > Vector2<Type>::operator*(const Vector2& rhs) const
+Vector2< Type > Vector2<Type>::operator*(Vector2 rhs) const
 {
 	return Vector2(x * rhs.x, y * rhs.y);
 }
@@ -148,14 +155,14 @@ Vector2< Type > Vector2< Type >::operator/(Type rhs) const
 }
 
 template<typename Type>
-Vector2< Type > Vector2<Type>::operator/(const Vector2& rhs) const
+Vector2< Type > Vector2<Type>::operator/(Vector2 rhs) const
 {
 	return Vector2(x / rhs.x, y / rhs.y);
 }
 
 // Adds another vector to this in-place.
 template < typename Type >
-Vector2< Type >& Vector2< Type >::operator+=(const Vector2 & rhs)
+Vector2< Type >& Vector2< Type >::operator+=(Vector2 rhs)
 {
 	x += rhs.x;
 	y += rhs.y;
@@ -165,7 +172,7 @@ Vector2< Type >& Vector2< Type >::operator+=(const Vector2 & rhs)
 
 // Subtracts another vector from this in-place.
 template < typename Type >
-Vector2< Type >& Vector2< Type >::operator-=(const Vector2 & rhs)
+Vector2< Type >& Vector2< Type >::operator-=(Vector2 rhs)
 {
 	x -= rhs.x;
 	y -= rhs.y;
@@ -175,7 +182,7 @@ Vector2< Type >& Vector2< Type >::operator-=(const Vector2 & rhs)
 
 // Scales this vector in-place.
 template < typename Type >
-Vector2< Type >& Vector2< Type >::operator*=(const Type & rhs)
+Vector2< Type >& Vector2< Type >::operator*=(Type rhs)
 {
 	x *= rhs;
 	y *= rhs;
@@ -184,7 +191,7 @@ Vector2< Type >& Vector2< Type >::operator*=(const Type & rhs)
 }
 
 template<typename Type>
-Vector2< Type >& Vector2<Type>::operator*=(const Vector2& rhs)
+Vector2< Type >& Vector2<Type>::operator*=(Vector2 rhs)
 {
 	x *= rhs.x;
 	y *= rhs.y;
@@ -194,7 +201,7 @@ Vector2< Type >& Vector2<Type>::operator*=(const Vector2& rhs)
 
 // Scales this vector in-place by the inverse of a value.
 template < typename Type >
-Vector2< Type >& Vector2< Type >::operator/=(const Type & rhs)
+Vector2< Type >& Vector2< Type >::operator/=(Type rhs)
 {
 	x /= rhs;
 	y /= rhs;
@@ -203,7 +210,7 @@ Vector2< Type >& Vector2< Type >::operator/=(const Type & rhs)
 }
 
 template<typename Type>
-Vector2< Type >& Vector2<Type>::operator/=(const Vector2& rhs)
+Vector2< Type >& Vector2<Type>::operator/=(Vector2 rhs)
 {
 	x /= rhs.x;
 	y /= rhs.y;
@@ -212,14 +219,14 @@ Vector2< Type >& Vector2<Type>::operator/=(const Vector2& rhs)
 
 // Equality operator.
 template < typename Type >
-bool Vector2< Type >::operator==(const Vector2 & rhs) const
+bool Vector2< Type >::operator==(Vector2 rhs) const
 {
 	return (x == rhs.x && y == rhs.y);
 }
 
 // Inequality operator.
 template < typename Type >
-bool Vector2< Type >::operator!=(const Vector2 & rhs) const
+bool Vector2< Type >::operator!=(Vector2 rhs) const
 {
 	return (x != rhs.x || y != rhs.y);
 }
@@ -238,4 +245,19 @@ Vector2< Type >::operator Type* ()
 	return &x;
 }
 
+// Underlying type-cast operator.
+template < typename Type >
+template < typename U >
+inline Vector2< Type >::operator Vector2<U>() const
+{
+	return Vector2<U>(static_cast<U>(x), static_cast<U>(y));
+}
+
+// Multiply by scalar operator.
+template < typename Type >
+inline Vector2< Type > operator*(Type lhs, Vector2< Type> rhs)
+{
+	return rhs * lhs;
+}
+
 } // namespace Rml

+ 5 - 0
Include/RmlUi/Core/Vector3.h

@@ -126,6 +126,11 @@ class Vector3
 		/// @return A constant pointer to the first value.
 		inline operator Type*();
 
+		/// Underlying type-cast operator.
+		/// @return A copy of the vector with another underlying type.
+		template < typename U >
+		explicit inline operator Vector3<U>() const;
+
 		// Cast to Vector2
 		explicit inline operator Vector2< Type >() const;
 

+ 18 - 3
Include/RmlUi/Core/Vector3.inl

@@ -62,16 +62,16 @@ Type Vector3< Type >::SquaredMagnitude() const
 
 // Generates a normalised vector from this vector.
 template < typename Type >
-Vector3< Type > Vector3< Type >::Normalise() const
+inline Vector3< Type > Vector3< Type >::Normalise() const
 {
-	static_assert(std::is_floating_point< Type >::value, "Invalid operation");
+	static_assert(std::is_same<Type, float>::value, "Normalise only implemented for Vector<float>.");
 	return *this;
 }
 
 template <>
 inline Vector3< float > Vector3< float >::Normalise() const
 {
-	float magnitude = Magnitude();
+	const float magnitude = Magnitude();
 	if (Math::IsZero(magnitude))
 		return *this;
 
@@ -203,10 +203,25 @@ Vector3< Type >::operator Type* ()
 	return &x;
 }
 
+// Underlying type-cast operator.
+template < typename Type >
+template < typename U >
+inline Vector3< Type >::operator Vector3<U>() const
+{
+	return Vector3<U>(static_cast<U>(x), static_cast<U>(y), static_cast<U>(z));
+}
+
 template < typename Type >
 Vector3< Type >::operator Vector2< Type >() const
 {
 	return Vector2< Type >(x, y);
 }
 
+// Multiply by scalar operator.
+template < typename Type >
+inline Vector3< Type > operator*(Type lhs, Vector3< Type > rhs)
+{
+	return rhs * lhs;
+}
+
 } // namespace Rml

+ 7 - 2
Include/RmlUi/Core/Vector4.h

@@ -71,6 +71,9 @@ class Vector4
 		/// @return The computed dot-product between the two vectors.
 		inline Type DotProduct(const Vector4& rhs) const;
 
+		/// Return a Vector3 after perspective divide
+		inline Vector3< Type > PerspectiveDivide() const;
+
 		/// Returns the negation of this vector.
 		/// @return The negation of this vector.
 		inline Vector4 operator-() const;
@@ -125,8 +128,10 @@ class Vector4
 		/// @return A constant pointer to the first value.
 		inline operator Type*();
 
-		/// Return a Vector3 after perspective divide
-		inline Vector3< Type > PerspectiveDivide() const;
+		/// Underlying type-cast operator.
+		/// @return A copy of the vector with another underlying type.
+		template < typename U >
+		explicit inline operator Vector4<U>() const;
 
 		/// Cast to Vector3
 		explicit inline operator Vector3< Type >() const;

+ 28 - 5
Include/RmlUi/Core/Vector4.inl

@@ -71,14 +71,21 @@ Type Vector4< Type >::SquaredMagnitude() const
 
 // Generates a normalised vector from this vector.
 template < typename Type >
-Vector4< Type > Vector4< Type >::Normalise() const
+inline Vector4< Type > Vector4< Type >::Normalise() const
 {
-	static_assert(std::is_floating_point< Type >::value, "Invalid operation");
+	static_assert(std::is_same<Type, float>::value, "Normalise only implemented for Vector<float>.");
 	return *this;
 }
 
 template <>
-RMLUICORE_API Vector4< float > Vector4< float >::Normalise() const;
+inline Vector4< float > Vector4< float >::Normalise() const
+{
+	const float magnitude = Magnitude();
+	if (Math::IsZero(magnitude))
+		return *this;
+
+	return *this / magnitude;
+}
 
 // Computes the dot-product between this vector and another.
 template < typename Type >
@@ -87,6 +94,12 @@ Type Vector4< Type >::DotProduct(const Vector4< Type >& rhs) const
 	return x * rhs.x + y * rhs.y + z * rhs.z + w * rhs.w;
 }
 
+template < typename Type >
+Vector3< Type > Vector4< Type >::PerspectiveDivide() const
+{
+	return Vector3< Type >(x / w, y / w, z / w);
+}
+
 // Returns the negation of this vector.
 template < typename Type >
 Vector4< Type > Vector4< Type >::operator-() const
@@ -198,12 +211,15 @@ Vector4< Type >::operator Type* ()
 	return &x;
 }
 
+// Underlying type-cast operator.
 template < typename Type >
-Vector3< Type > Vector4< Type >::PerspectiveDivide() const
+template < typename U >
+inline Vector4< Type >::operator Vector4<U>() const
 {
-	return Vector3< Type >(x / w, y / w, z / w);
+	return Vector4<U>(static_cast<U>(x), static_cast<U>(y), static_cast<U>(z), static_cast<U>(w));
 }
 
+
 template < typename Type >
 Vector4< Type >::operator Vector3< Type >() const
 {
@@ -216,4 +232,11 @@ Vector4< Type >::operator Vector2< Type >() const
 	return Vector2< Type >(x, y);
 }
 
+// Multiply by scalar operator.
+template < typename Type >
+inline Vector4< Type > operator*(Type lhs, Vector4< Type > rhs)
+{
+	return rhs * lhs;
+}
+
 } // namespace Rml

+ 3 - 3
Source/Core/ComputeProperty.cpp

@@ -121,11 +121,11 @@ float ComputeAbsoluteLength(const Property& property, float dp_ratio, Vector2f v
 	case Property::PX:
 		return property.value.Get< float >();
 	case Property::DP:
-		return property.value.Get< float >()* dp_ratio;
+		return property.value.Get< float >() * dp_ratio;
 	case Property::VW:
-		return property.value.Get< float >()* vp_dimensions.x * 0.01f;
+		return property.value.Get< float >() * vp_dimensions.x * 0.01f;
 	case Property::VH:
-		return property.value.Get< float >()* vp_dimensions.y * 0.01f;
+		return property.value.Get< float >() * vp_dimensions.y * 0.01f;
 	default:
 		// Values based on pixels-per-inch.
 		if (property.unit & Property::PPI_UNIT)

+ 7 - 9
Source/Core/Context.cpp

@@ -112,12 +112,12 @@ const String& Context::GetName() const
 }
 
 // Changes the dimensions of the screen.
-void Context::SetDimensions(const Vector2i& _dimensions)
+void Context::SetDimensions(const Vector2i _dimensions)
 {
 	if (dimensions != _dimensions)
 	{
 		dimensions = _dimensions;
-		root->SetBox(Box(Vector2f((float) dimensions.x, (float) dimensions.y)));
+		root->SetBox(Box(Vector2f(dimensions)));
 		root->DirtyLayout();
 
 		for (int i = 0; i < root->GetNumChildren(); ++i)
@@ -137,7 +137,7 @@ void Context::SetDimensions(const Vector2i& _dimensions)
 }
 
 // Returns the dimensions of the screen.
-const Vector2i& Context::GetDimensions() const
+Vector2i Context::GetDimensions() const
 {
 	return dimensions;
 }
@@ -173,9 +173,7 @@ bool Context::Update()
 	for (auto& data_model : data_models)
 		data_model.second->Update(true);
 
-	Vector2f vp_dimensions((float)dimensions.x, (float)dimensions.y);
-
-	root->Update(density_independent_pixel_ratio, vp_dimensions);
+	root->Update(density_independent_pixel_ratio, Vector2f(dimensions));
 
 	for (int i = 0; i < root->GetNumChildren(); ++i)
 		if (auto doc = root->GetChild(i)->GetOwnerDocument())
@@ -813,7 +811,7 @@ bool Context::GetActiveClipRegion(Vector2i& origin, Vector2i& dimensions) const
 }
 	
 // Sets the current clipping region for the render traversal
-void Context::SetActiveClipRegion(const Vector2i& origin, const Vector2i& dimensions)
+void Context::SetActiveClipRegion(const Vector2i origin, const Vector2i dimensions)
 {
 	clip_origin = origin;
 	clip_dimensions = dimensions;
@@ -1006,9 +1004,9 @@ void Context::GenerateClickEvent(Element* element)
 }
 
 // Updates the current hover elements, sending required events.
-void Context::UpdateHoverChain(const Dictionary& parameters, const Dictionary& drag_parameters, const Vector2i& old_mouse_position)
+void Context::UpdateHoverChain(const Dictionary& parameters, const Dictionary& drag_parameters, const Vector2i old_mouse_position)
 {
-	Vector2f position((float) mouse_position.x, (float) mouse_position.y);
+	const Vector2f position(mouse_position);
 
 	// Send out drag events.
 	if (drag)

+ 1 - 1
Source/Core/Core.cpp

@@ -228,7 +228,7 @@ FontEngineInterface* GetFontEngineInterface()
 }
 
 // Creates a new element context.
-Context* CreateContext(const String& name, const Vector2i& dimensions, RenderInterface* custom_render_interface)
+Context* CreateContext(const String& name, const Vector2i dimensions, RenderInterface* custom_render_interface)
 {
 	if (!initialised)
 		return nullptr;

+ 1 - 1
Source/Core/DecoratorGradient.cpp

@@ -56,7 +56,7 @@ DecoratorGradient::~DecoratorGradient()
 {
 }
 
-bool DecoratorGradient::Initialise(const Direction &dir_, const Colourb &start_, const Colourb & stop_)
+bool DecoratorGradient::Initialise(const Direction dir_, const Colourb start_, const Colourb stop_)
 {
 	dir = dir_;
 	start = start_;

+ 1 - 1
Source/Core/DecoratorGradient.h

@@ -43,7 +43,7 @@ public:
 	DecoratorGradient();
 	virtual ~DecoratorGradient();
 
-	bool Initialise(const Direction &dir_, const Colourb &start_, const Colourb & stop_);
+	bool Initialise(Direction dir_, Colourb start_, Colourb stop_);
 
 	DecoratorDataHandle GenerateElementData(Element* element) const override;
 	void ReleaseElementData(DecoratorDataHandle element_data) const override;

+ 1 - 2
Source/Core/DecoratorNinePatch.cpp

@@ -63,8 +63,7 @@ DecoratorDataHandle DecoratorNinePatch::GenerateElementData(Element* element) co
 
 	const Texture* texture = GetTexture();
 	data->SetTexture(texture);
-	const Vector2i texture_dimensions_i = texture->GetDimensions(render_interface);
-	const Vector2f texture_dimensions = { (float)texture_dimensions_i.x, (float)texture_dimensions_i.y };
+	const Vector2f texture_dimensions(texture->GetDimensions(render_interface));
 
 	const Vector2f surface_dimensions = element->GetBox().GetSize(Box::PADDING);
 

+ 2 - 3
Source/Core/DecoratorTiled.cpp

@@ -65,8 +65,7 @@ void DecoratorTiled::Tile::CalculateDimensions(Element* element, const Texture&
 	if (data_iterator == data.end())
 	{
 		TileData new_data;
-		const Vector2i texture_dimensions_i = texture.GetDimensions(render_interface);
-		const Vector2f texture_dimensions((float)texture_dimensions_i.x, (float)texture_dimensions_i.y);
+		const Vector2f texture_dimensions(texture.GetDimensions(render_interface));
 
 		if (texture_dimensions.x == 0 || texture_dimensions.y == 0)
 		{
@@ -106,7 +105,7 @@ Vector2f DecoratorTiled::Tile::GetDimensions(Element* element) const
 }
 
 // Generates geometry to render this tile across a surface.
-void DecoratorTiled::Tile::GenerateGeometry(Vector< Vertex >& vertices, Vector< int >& indices, Element* element, const Vector2f& surface_origin, const Vector2f& surface_dimensions, const Vector2f& tile_dimensions) const
+void DecoratorTiled::Tile::GenerateGeometry(Vector< Vertex >& vertices, Vector< int >& indices, Element* element, const Vector2f surface_origin, const Vector2f surface_dimensions, const Vector2f tile_dimensions) const
 {
 	if (surface_dimensions.x <= 0 || surface_dimensions.y <= 0)
 		return;

+ 1 - 1
Source/Core/DecoratorTiled.h

@@ -94,7 +94,7 @@ public:
 		/// @param[in] surface_origin The starting point of the first tile to generate.
 		/// @param[in] surface_dimensions The dimensions of the surface to be tiled.
 		/// @param[in] tile_dimensions The dimensions to render this tile at.
-		void GenerateGeometry(Vector< Vertex >& vertices, Vector< int >& indices, Element* element, const Vector2f& surface_origin, const Vector2f& surface_dimensions, const Vector2f& tile_dimensions) const;
+		void GenerateGeometry(Vector< Vertex >& vertices, Vector< int >& indices, Element* element, Vector2f surface_origin, Vector2f surface_dimensions, Vector2f tile_dimensions) const;
 
 		struct TileData
 		{

+ 7 - 25
Source/Core/Element.cpp

@@ -161,46 +161,28 @@ void Element::Update(float dp_ratio, Vector2f vp_dimensions)
 
 	meta->scroll.Update();
 
-	UpdateProperties();
+	UpdateProperties(dp_ratio, vp_dimensions);
 
 	// Do en extra pass over the animations and properties if the 'animation' property was just changed.
 	if (dirty_animation)
 	{
 		HandleAnimationProperty();
 		AdvanceAnimations();
-		UpdateProperties();
+		UpdateProperties(dp_ratio, vp_dimensions);
 	}
 
 	for (size_t i = 0; i < children.size(); i++)
 		children[i]->Update(dp_ratio, vp_dimensions);
 }
 
-
-void Element::UpdateProperties()
+void Element::UpdateProperties(const float dp_ratio, const Vector2f vp_dimensions)
 {
 	meta->style.UpdateDefinition();
 
 	if (meta->style.AnyPropertiesDirty())
 	{
-		const ComputedValues* parent_values = nullptr;
-		if (parent)
-			parent_values = &parent->GetComputedValues();
-
-		const ComputedValues* document_values = nullptr;
-		float dp_ratio = 1.0f;
-		Vector2f vp_dimensions(1.0f);
-		if (auto doc = GetOwnerDocument())
-		{
-			document_values = &doc->GetComputedValues();
-			if (Context * context = doc->GetContext())
-			{
-				dp_ratio = context->GetDensityIndependentPixelRatio();
-				Vector2i dimensions = context->GetDimensions();
-				vp_dimensions.x = (float)dimensions.x;
-				vp_dimensions.y = (float)dimensions.y;
-
-			}
-		}
+		const ComputedValues* parent_values = parent ? &parent->GetComputedValues() : nullptr;
+		const ComputedValues* document_values = owner_document ? &owner_document->GetComputedValues() : nullptr;
 
 		// Compute values and clear dirty properties
 		PropertyIdSet dirty_properties = meta->style.ComputeValues(meta->computed_values, parent_values, document_values, computed_values_are_default_initialized, dp_ratio, vp_dimensions);
@@ -535,9 +517,9 @@ bool Element::GetIntrinsicDimensions(Vector2f& RMLUI_UNUSED_PARAMETER(dimensions
 }
 
 // Checks if a given point in screen coordinates lies within the bordered area of this element.
-bool Element::IsPointWithinElement(const Vector2f& point)
+bool Element::IsPointWithinElement(const Vector2f point)
 {
-	Vector2f position = GetAbsoluteOffset(Box::BORDER);
+	const Vector2f position = GetAbsoluteOffset(Box::BORDER);
 
 	for (int i = 0; i < GetNumBoxes(); ++i)
 	{

+ 5 - 3
Source/Core/ElementDocument.cpp

@@ -159,8 +159,11 @@ void ElementDocument::ProcessHeader(const DocumentHeader* document_header)
 	// Hide this document.
 	SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden));
 
+	const float dp_ratio = (context ? context->GetDensityIndependentPixelRatio() : 1.0f);
+	const Vector2f vp_dimensions = (context ? Vector2f(context->GetDimensions()) : Vector2f(1.0f));
+
 	// Update properties so that e.g. visibility status can be queried properly immediately.
-	UpdateProperties();
+	UpdateProperties(dp_ratio, vp_dimensions);
 }
 
 // Returns the document's context.
@@ -397,8 +400,7 @@ void ElementDocument::LoadExternalScript(const String& RMLUI_UNUSED_PARAMETER(so
 void ElementDocument::UpdateDocument()
 {
 	const float dp_ratio = (context ? context->GetDensityIndependentPixelRatio() : 1.0f);
-	const Vector2i dimensions = (context ? context->GetDimensions() : Vector2i(1));
-	const Vector2f vp_dimensions((float)dimensions.x, (float)dimensions.y);
+	const Vector2f vp_dimensions = (context ? Vector2f(context->GetDimensions()) : Vector2f(1.0f));
 	Update(dp_ratio, vp_dimensions);
 	UpdateLayout();
 	UpdatePosition();

+ 1 - 2
Source/Core/ElementScroll.cpp

@@ -230,8 +230,7 @@ bool ElementScroll::CreateScrollbar(Orientation orientation)
 	Context* context = element->GetContext();
 	
 	const float dp_ratio = (context ? context->GetDensityIndependentPixelRatio() : 1.0f);
-	const Vector2i dimensions = (context ? context->GetDimensions() : Vector2i(1));
-	const Vector2f vp_dimensions((float)dimensions.x, (float)dimensions.y);
+	const Vector2f vp_dimensions = (context ? Vector2f(context->GetDimensions()) : Vector2f(1.0f));
 	child->Update(dp_ratio, vp_dimensions);
 
 	return true;

+ 24 - 15
Source/Core/ElementStyle.cpp

@@ -346,6 +346,28 @@ const PropertyMap& ElementStyle::GetLocalStyleProperties() const
 	return inline_properties.GetProperties();
 }
 
+static float ComputeLength(const Property* property, Element* element)
+{
+	const float font_size = element->GetComputedValues().font_size;
+	float doc_font_size = DefaultComputedValues.font_size;
+	float dp_ratio = 1.0f;
+	Vector2f vp_dimensions(1.0f);
+
+	if (ElementDocument* document = element->GetOwnerDocument())
+	{
+		doc_font_size = document->GetComputedValues().font_size;
+
+		if (Context* context = document->GetContext())
+		{
+			dp_ratio = context->GetDensityIndependentPixelRatio();
+			vp_dimensions = Vector2f(context->GetDimensions());
+		}
+	}
+
+	const float result = ComputeLength(property, font_size, doc_font_size, dp_ratio, vp_dimensions);
+	return result;
+}
+
 float ElementStyle::ResolveNumericProperty(const Property* property, float base_value) const
 {
 	if (!property || !(property->unit & (Property::NUMBER_LENGTH_PERCENT | Property::ANGLE)))
@@ -358,15 +380,7 @@ float ElementStyle::ResolveNumericProperty(const Property* property, float base_
 	else if (property->unit & Property::ANGLE)
 		return ComputeAngle(*property);
 
-	const float dp_ratio = ElementUtilities::GetDensityIndependentPixelRatio(element);
-	Vector2i dimensions = (element->GetContext() ? element->GetContext()->GetDimensions() : Vector2i(1));
-	Vector2f vp_dimensions((float)dimensions.x, (float)dimensions.y);
-	const float font_size = element->GetComputedValues().font_size;
-
-	auto doc = element->GetOwnerDocument();
-	const float doc_font_size = (doc ? doc->GetComputedValues().font_size : DefaultComputedValues.font_size);
-
-	float result = ComputeLength(property, font_size, doc_font_size, dp_ratio, vp_dimensions);
+	const float result = ComputeLength(property, element);
 
 	return result;
 }
@@ -378,12 +392,7 @@ float ElementStyle::ResolveLength(const Property* property, RelativeTarget relat
 	// There is an exception on font-size properties, as 'em' units here refer to parent font size instead
 	if ((property->unit & Property::LENGTH) && !(property->unit == Property::EM && relative_target == RelativeTarget::ParentFontSize))
 	{
-		auto doc = element->GetOwnerDocument();
-		const float doc_font_size = (doc ? doc->GetComputedValues().font_size : DefaultComputedValues.font_size);
-		Vector2i dimensions = (element->GetContext() ? element->GetContext()->GetDimensions() : Vector2i(1));
-		Vector2f vp_dimensions((float)dimensions.x, (float)dimensions.y);
-		float result = ComputeLength(property, element->GetComputedValues().font_size, doc_font_size, ElementUtilities::GetDensityIndependentPixelRatio(element), vp_dimensions);
-
+		const float result = ComputeLength(property, element);
 		return result;
 	}
 

+ 1 - 1
Source/Core/ElementText.cpp

@@ -320,7 +320,7 @@ void ElementText::ClearLines()
 }
 
 // Adds a new line into the text element.
-void ElementText::AddLine(const Vector2f& line_position, const String& line)
+void ElementText::AddLine(Vector2f line_position, const String& line)
 {
 	FontFaceHandle font_face_handle = GetFontFaceHandle();
 

+ 1 - 1
Source/Core/Elements/WidgetSlider.cpp

@@ -245,7 +245,7 @@ void WidgetSlider::FormatElements()
 
 
 // Lays out and resizes the internal elements.
-void WidgetSlider::FormatElements(const Vector2f& containing_block, float slider_length)
+void WidgetSlider::FormatElements(const Vector2f containing_block, float slider_length)
 {
 	int length_axis = orientation == VERTICAL ? 1 : 0;
 

+ 1 - 1
Source/Core/Elements/WidgetSlider.h

@@ -93,7 +93,7 @@ private:
 	/// Lays out and resizes the slider's internal elements.
 	/// @param[in] containing_block The padded box containing the slider. This is used to resolve relative properties.
 	/// @param[in] slider_length The total length, in pixels, of the slider widget.
-	void FormatElements(const Vector2f& containing_block, float slider_length);
+	void FormatElements(Vector2f containing_block, float slider_length);
 	/// Lays out and positions the bar element.
 	void FormatBar();
 

+ 1 - 1
Source/Core/Elements/WidgetTextInput.cpp

@@ -280,7 +280,7 @@ ElementText* WidgetTextInput::GetTextElement()
 }
 
 // Returns the input element's maximum allowed text dimensions.
-const Vector2f& WidgetTextInput::GetTextDimensions() const
+Vector2f WidgetTextInput::GetTextDimensions() const
 {
 	return internal_dimensions;
 }

+ 1 - 1
Source/Core/Elements/WidgetTextInput.h

@@ -80,7 +80,7 @@ public:
 	/// Returns the input element's underlying text element.
 	ElementText* GetTextElement();
 	/// Returns the input element's maximum allowed text dimensions.
-	const Vector2f& GetTextDimensions() const;
+	Vector2f GetTextDimensions() const;
 
 protected:
 	enum class CursorMovement { Begin = -4, BeginLine = -3, PreviousWord = -2, Left = -1, Right = 1, NextWord = 2, EndLine = 3, End = 4 };

+ 1 - 1
Source/Core/Event.cpp

@@ -134,7 +134,7 @@ const Dictionary& Event::GetParameters() const
 	return parameters;
 }
 
-const Vector2f& Event::GetUnprojectedMouseScreenPos() const
+Vector2f Event::GetUnprojectedMouseScreenPos() const
 {
 	return mouse_screen_position;
 }

+ 2 - 2
Source/Core/FontEffect.cpp

@@ -62,12 +62,12 @@ void FontEffect::GenerateGlyphTexture(byte* RMLUI_UNUSED_PARAMETER(destination_d
 	RMLUI_UNUSED(glyph);
 }
 
-void FontEffect::SetColour(const Colourb& _colour)
+void FontEffect::SetColour(const Colourb _colour)
 {
 	colour = _colour;
 }
 
-const Colourb& FontEffect::GetColour() const
+Colourb FontEffect::GetColour() const
 {
 	return colour;
 }

+ 1 - 1
Source/Core/FontEffectShadow.cpp

@@ -40,7 +40,7 @@ FontEffectShadow::~FontEffectShadow()
 {
 }
 
-bool FontEffectShadow::Initialise(const Vector2i& _offset)
+bool FontEffectShadow::Initialise(const Vector2i _offset)
 {
 	offset = _offset;
 	return true;

+ 1 - 1
Source/Core/FontEffectShadow.h

@@ -46,7 +46,7 @@ public:
 	FontEffectShadow();
 	virtual ~FontEffectShadow();
 
-	bool Initialise(const Vector2i& offset);
+	bool Initialise(Vector2i offset);
 
 	bool HasUniqueTexture() const override;
 

+ 1 - 1
Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp

@@ -218,7 +218,7 @@ bool FontFaceHandleDefault::GenerateLayerTexture(UniquePtr<const byte[]>& textur
 }
 
 // Generates the geometry required to render a single line of text.
-int FontFaceHandleDefault::GenerateString(GeometryList& geometry, const String& string, const Vector2f& position, const Colourb& colour, int layer_configuration_index)
+int FontFaceHandleDefault::GenerateString(GeometryList& geometry, const String& string, const Vector2f position, const Colourb colour, int layer_configuration_index)
 {
 	int geometry_index = 0;
 	int line_width = 0;

+ 1 - 1
Source/Core/FontEngineDefault/FontFaceHandleDefault.h

@@ -93,7 +93,7 @@ public:
 	/// @param[in] position The position of the baseline of the first character to render.
 	/// @param[in] colour The colour to render the text.
 	/// @return The width, in pixels, of the string geometry.
-	int GenerateString(GeometryList& geometry, const String& string, const Vector2f& position, const Colourb& colour, int layer_configuration = 0);
+	int GenerateString(GeometryList& geometry, const String& string, Vector2f position, Colourb colour, int layer_configuration = 0);
 
 	/// Version is changed whenever the layers are dirtied, requiring regeneration of string geometry.
 	int GetVersion() const;

+ 3 - 6
Source/Core/FontEngineDefault/FontFaceLayer.cpp

@@ -86,10 +86,7 @@ bool FontFaceLayer::Generate(const FontFaceHandleDefault* handle, const FontFace
 				Vector2i glyph_dimensions(Math::RealToInteger(box.dimensions.x), Math::RealToInteger(box.dimensions.y));
 
 				if (effect->GetGlyphMetrics(glyph_origin, glyph_dimensions, glyph))
-				{
-					box.origin.x = (float)glyph_origin.x;
-					box.origin.y = (float)glyph_origin.y;
-				}
+					box.origin = Vector2f(glyph_origin);
 				else
 					box.texture_index = -1;
 			}
@@ -116,7 +113,7 @@ bool FontFaceLayer::Generate(const FontFaceHandleDefault* handle, const FontFace
 
 			TextureBox box;
 			box.origin = Vector2f(float(glyph_origin.x + glyph.bearing.x), float(glyph_origin.y - glyph.bearing.y));
-			box.dimensions = Vector2f(float(glyph_dimensions.x), float(glyph_dimensions.y));
+			box.dimensions = Vector2f(glyph_dimensions);
 			
 			RMLUI_ASSERT(box.dimensions.x >= 0 && box.dimensions.y >= 0);
 
@@ -253,7 +250,7 @@ int FontFaceLayer::GetNumTextures() const
 }
 
 // Returns the layer's colour.
-const Colourb& FontFaceLayer::GetColour() const
+Colourb FontFaceLayer::GetColour() const
 {
 	return colour;
 }

+ 2 - 2
Source/Core/FontEngineDefault/FontFaceLayer.h

@@ -72,7 +72,7 @@ public:
 	/// @param[in] character_code The character to generate geometry for.
 	/// @param[in] position The position of the baseline.
 	/// @param[in] colour The colour of the string.
-	inline void GenerateGeometry(Geometry* geometry, const Character character_code, const Vector2f& position, const Colourb& colour) const
+	inline void GenerateGeometry(Geometry* geometry, const Character character_code, const Vector2f position, const Colourb colour) const
 	{
 		auto it = character_boxes.find(character_code);
 		if (it == character_boxes.end())
@@ -110,7 +110,7 @@ public:
 	int GetNumTextures() const;
 
 	/// Returns the layer's colour.
-	const Colourb& GetColour() const;
+	Colourb GetColour() const;
 
 private:
 

+ 2 - 2
Source/Core/LayoutBlockBox.cpp

@@ -573,7 +573,7 @@ void LayoutBlockBox::PositionBlockBox(Vector2f& box_position, const Box& box, St
 }
 
 // Returns the offset from the top-left corner of this box for the next line.
-void LayoutBlockBox::PositionLineBox(Vector2f& box_position, float& box_width, bool& _wrap_content, const Vector2f& dimensions) const
+void LayoutBlockBox::PositionLineBox(Vector2f& box_position, float& box_width, bool& _wrap_content, const Vector2f dimensions) const
 {
 	Vector2f cursor;
 	PositionBox(cursor);
@@ -669,7 +669,7 @@ LayoutBlockBox* LayoutBlockBox::GetParent() const
 }
 
 // Returns the position of the block box, relative to its parent's content area.
-const Vector2f& LayoutBlockBox::GetPosition() const
+Vector2f LayoutBlockBox::GetPosition() const
 {
 	return position;
 }

+ 2 - 2
Source/Core/LayoutBlockBox.h

@@ -130,7 +130,7 @@ public:
 	/// @param box_width[out] The available width for the line box.
 	/// @param wrap_content[out] Set to true if the line box should grow to fit inline boxes, false if it should wrap them.
 	/// @param dimensions[in] The minimum dimensions of the line.
-	void PositionLineBox(Vector2f& box_position, float& box_width, bool& wrap_content, const Vector2f& dimensions) const;
+	void PositionLineBox(Vector2f& box_position, float& box_width, bool& wrap_content, Vector2f dimensions) const;
 
 	/// Calculate the dimensions of the box's internal content width; i.e. the size used to calculate the shrink-to-fit width.
 	float GetShrinkToFitWidth() const;
@@ -149,7 +149,7 @@ public:
 
 	/// Returns the position of the block box, relative to its parent's content area.
 	/// @return The relative position of the block box.
-	const Vector2f& GetPosition() const;
+	Vector2f GetPosition() const;
 
 	/// Returns the block box against which all positions of boxes in the hierarchy are set relative to.
 	/// @return This box's offset parent.

+ 4 - 4
Source/Core/LayoutBlockBoxSpace.cpp

@@ -56,7 +56,7 @@ void LayoutBlockBoxSpace::ImportSpace(const LayoutBlockBoxSpace& space)
 }
 
 // Generates the position for a box of a given size within a containing block box.
-void LayoutBlockBoxSpace::PositionBox(Vector2f& box_position, float& box_width, float cursor, const Vector2f& dimensions) const
+void LayoutBlockBoxSpace::PositionBox(Vector2f& box_position, float& box_width, float cursor, const Vector2f dimensions) const
 {
 	box_width = PositionBox(box_position, cursor, dimensions);
 }
@@ -123,7 +123,7 @@ float LayoutBlockBoxSpace::ClearBoxes(float cursor, Style::Clear clear_property)
 }
 
 // Generates the position for an arbitrary box within our space layout, floated against either the left or right edge.
-float LayoutBlockBoxSpace::PositionBox(Vector2f& box_position, float cursor, const Vector2f& dimensions, Style::Float float_property) const
+float LayoutBlockBoxSpace::PositionBox(Vector2f& box_position, float cursor, const Vector2f dimensions, Style::Float float_property) const
 {
 	float parent_scrollbar_width = parent->GetElement()->GetElementScroll()->GetScrollbarSize(ElementScroll::VERTICAL);
 	float parent_origin = parent->GetPosition().x + parent->GetBox().GetPosition(Box::CONTENT).x;
@@ -258,7 +258,7 @@ float LayoutBlockBoxSpace::PositionBox(Vector2f& box_position, float cursor, con
 }
 
 // Returns the top-left offset of the boxes within the space.
-const Vector2f& LayoutBlockBoxSpace::GetOffset() const
+Vector2f LayoutBlockBoxSpace::GetOffset() const
 {
 	return offset;
 }
@@ -283,7 +283,7 @@ LayoutBlockBoxSpace::SpaceBox::SpaceBox() : offset(0, 0), dimensions(0, 0)
 {
 }
 
-LayoutBlockBoxSpace::SpaceBox::SpaceBox(const Vector2f& offset, const Vector2f& dimensions) : offset(offset), dimensions(dimensions)
+LayoutBlockBoxSpace::SpaceBox::SpaceBox(const Vector2f offset, const Vector2f dimensions) : offset(offset), dimensions(dimensions)
 {
 }
 

+ 4 - 4
Source/Core/LayoutBlockBoxSpace.h

@@ -59,7 +59,7 @@ public:
 	/// @param[out] box_width The available width for the box.
 	/// @param[in] cursor The ideal vertical position for the box.
 	/// @param[in] dimensions The minimum available space required for the box.
-	void PositionBox(Vector2f& box_position, float& box_width, float cursor, const Vector2f& dimensions) const;
+	void PositionBox(Vector2f& box_position, float& box_width, float cursor, Vector2f dimensions) const;
 
 	/// Generates and sets the position for a floating box of a given size within our block box. The element's box
 	/// is then added into our list of floating boxes.
@@ -77,7 +77,7 @@ public:
 
 	/// Returns the top-left corner of the boxes within the space.
 	/// @return The space's offset.
-	const Vector2f& GetOffset() const;
+	Vector2f GetOffset() const;
 	/// Returns the dimensions of the boxes within the space.
 	/// @return The space's dimensions.
 	Vector2f GetDimensions() const;
@@ -99,12 +99,12 @@ private:
 	/// @param cursor[in] The ideal vertical position for the box.
 	/// @param dimensions[in] The size of the box to place.
 	/// @return The maximum width at the box position.
-	float PositionBox(Vector2f& box_position, float cursor, const Vector2f& dimensions, Style::Float float_property = Style::Float::None) const;
+	float PositionBox(Vector2f& box_position, float cursor, Vector2f dimensions, Style::Float float_property = Style::Float::None) const;
 
 	struct SpaceBox
 	{
 		SpaceBox();
-		SpaceBox(const Vector2f& offset, const Vector2f& dimensions);
+		SpaceBox(Vector2f offset, Vector2f dimensions);
 
 		Vector2f offset;
 		Vector2f dimensions;

+ 1 - 1
Source/Core/LayoutInlineBox.cpp

@@ -289,7 +289,7 @@ void LayoutInlineBox::OffsetBaseline(float ascender)
 }
 
 // Returns the inline box's offset from its parent's content area.
-const Vector2f& LayoutInlineBox::GetPosition() const
+Vector2f LayoutInlineBox::GetPosition() const
 {
 	return position;
 }

+ 1 - 1
Source/Core/LayoutInlineBox.h

@@ -91,7 +91,7 @@ public:
 
 	/// Returns the inline box's offset from its line.
 	/// @return The box's offset from its line.
-	const Vector2f& GetPosition() const;
+	Vector2f GetPosition() const;
 
 	/// Sets the inline box's horizontal offset from its parent's content area.
 	/// @param position[in] The box's horizontal offset.

+ 2 - 2
Source/Core/LayoutLineBox.cpp

@@ -337,7 +337,7 @@ void LayoutLineBox::AddChainedBox(LayoutInlineBox* chained_box)
 }
 
 // Returns the position of the line box, relative to its parent's block box's content area.
-const Vector2f& LayoutLineBox::GetPosition() const
+Vector2f LayoutLineBox::GetPosition() const
 {
 	return position;
 }
@@ -349,7 +349,7 @@ Vector2f LayoutLineBox::GetRelativePosition() const
 }
 
 // Returns the dimensions of the line box.
-const Vector2f& LayoutLineBox::GetDimensions() const
+Vector2f LayoutLineBox::GetDimensions() const
 {
 	return dimensions;
 }

+ 2 - 2
Source/Core/LayoutLineBox.h

@@ -73,13 +73,13 @@ public:
 
 	/// Returns the position of the line box, relative to its parent's block box's content area.
 	/// @return The position of the line box.
-	const Vector2f& GetPosition() const;
+	Vector2f GetPosition() const;
 	/// Returns the position of the line box, relative to its parent's block box's offset parent.
 	/// @return The relative position of the line box.
 	Vector2f GetRelativePosition() const;
 	/// Returns the dimensions of the line box.
 	/// @return The dimensions of the line box.
-	const Vector2f& GetDimensions() const;
+	Vector2f GetDimensions() const;
 
 	/// Returns the line box's open inline box.
 	/// @return The line's open inline box, or nullptr if it currently has none.

+ 1 - 1
Source/Core/TextureLayout.cpp

@@ -50,7 +50,7 @@ TextureLayout::~TextureLayout()
 }
 
 // Adds a rectangle to the list of rectangles to be laid out.
-void TextureLayout::AddRectangle(int id, const Vector2i& dimensions)
+void TextureLayout::AddRectangle(int id, Vector2i dimensions)
 {
 	rectangles.push_back(TextureLayoutRectangle(id, dimensions));
 }

+ 1 - 1
Source/Core/TextureLayout.h

@@ -51,7 +51,7 @@ public:
 	/// the layout before the layout is generated.
 	/// @param[in] id The id of the rectangle; used to identify the rectangle after it has been positioned.
 	/// @param[in] dimensions The dimensions of the rectangle.
-	void AddRectangle(int id, const Vector2i& dimensions);
+	void AddRectangle(int id, Vector2i dimensions);
 
 	/// Returns one of the layout's rectangles.
 	/// @param[in] index The index of the desired rectangle.

+ 4 - 4
Source/Core/TextureLayoutRectangle.cpp

@@ -30,7 +30,7 @@
 
 namespace Rml {
 
-TextureLayoutRectangle::TextureLayoutRectangle(int _id, const Vector2i& dimensions) : dimensions(dimensions), texture_position(0, 0)
+TextureLayoutRectangle::TextureLayoutRectangle(const int _id, const Vector2i dimensions) : dimensions(dimensions), texture_position(0, 0)
 {
 	id = _id;
 	texture_index = -1;
@@ -50,19 +50,19 @@ int TextureLayoutRectangle::GetId() const
 }
 
 // Returns the rectangle's position; this is only valid if it has been placed.
-const Vector2i& TextureLayoutRectangle::GetPosition() const
+Vector2i TextureLayoutRectangle::GetPosition() const
 {
 	return texture_position;
 }
 
 // Returns the rectangle's dimensions.
-const Vector2i& TextureLayoutRectangle::GetDimensions() const
+Vector2i TextureLayoutRectangle::GetDimensions() const
 {
 	return dimensions;
 }
 
 // Places the rectangle within a texture.
-void TextureLayoutRectangle::Place(int _texture_index, const Vector2i& position)
+void TextureLayoutRectangle::Place(const int _texture_index, const Vector2i position)
 {
 	texture_index = _texture_index;
 	texture_position = position;

+ 4 - 4
Source/Core/TextureLayoutRectangle.h

@@ -42,7 +42,7 @@ namespace Rml {
 class TextureLayoutRectangle
 {
 public:
-	TextureLayoutRectangle(int id, const Vector2i& dimensions);
+	TextureLayoutRectangle(int id, Vector2i dimensions);
 	~TextureLayoutRectangle();
 
 	/// Returns the rectangle's id.
@@ -50,15 +50,15 @@ public:
 	int GetId() const;
 	/// Returns the rectangle's position; this is only valid if it has been placed.
 	/// @return The rectangle's position within its texture.
-	const Vector2i& GetPosition() const;
+	Vector2i GetPosition() const;
 	/// Returns the rectangle's dimensions.
 	/// @return The rectangle's dimensions.
-	const Vector2i& GetDimensions() const;
+	Vector2i GetDimensions() const;
 
 	/// Places the rectangle within a texture.
 	/// @param[in] texture_index The index of the texture this rectangle is placed on.
 	/// @param[in] position The position within the texture of this rectangle's top-left corner.
-	void Place(int texture_index, const Vector2i& position);
+	void Place(int texture_index, Vector2i position);
 	/// Unplaces the rectangle.
 	void Unplace();
 	/// Returns the rectangle's placed state.

+ 1 - 1
Source/Core/TextureLayoutTexture.cpp

@@ -41,7 +41,7 @@ TextureLayoutTexture::~TextureLayoutTexture()
 }
 
 // Returns the texture's dimensions. This is only valid after the texture has been generated.
-const Vector2i& TextureLayoutTexture::GetDimensions() const
+Vector2i TextureLayoutTexture::GetDimensions() const
 {
 	return dimensions;
 }

+ 1 - 1
Source/Core/TextureLayoutTexture.h

@@ -52,7 +52,7 @@ public:
 
 	/// Returns the texture's dimensions. This is only valid after the texture has been generated.
 	/// @return The texture's dimensions.
-	const Vector2i& GetDimensions() const;
+	Vector2i GetDimensions() const;
 
 	/// Attempts to position unplaced rectangles from the layout into this texture. The size of
 	/// this texture will be determined by its contents.

+ 1 - 1
Source/Core/TextureResource.cpp

@@ -84,7 +84,7 @@ TextureHandle TextureResource::GetHandle(RenderInterface* render_interface)
 }
 
 // Returns the dimensions of the resource's texture.
-const Vector2i& TextureResource::GetDimensions(RenderInterface* render_interface)
+Vector2i TextureResource::GetDimensions(RenderInterface* render_interface)
 {
 	auto texture_iterator = texture_data.find(render_interface);
 	if (texture_iterator == texture_data.end())

+ 1 - 1
Source/Core/TextureResource.h

@@ -58,7 +58,7 @@ public:
 	/// Returns the resource's underlying texture handle.
 	TextureHandle GetHandle(RenderInterface* render_interface);
 	/// Returns the dimensions of the resource's texture.
-	const Vector2i& GetDimensions(RenderInterface* render_interface);
+	Vector2i GetDimensions(RenderInterface* render_interface);
 
 	/// Returns the resource's source.
 	const String& GetSource() const;

+ 2 - 2
Source/Core/TransformUtilities.cpp

@@ -34,7 +34,7 @@ namespace Rml {
 
 using namespace Transforms;
 
-static Vector3f Combine(const Vector3f& a, const Vector3f& b, float a_scale, float b_scale)
+static Vector3f Combine(const Vector3f a, const Vector3f b, float a_scale, float b_scale)
 {
 	Vector3f result;
 	result.x = a_scale * a.x + b_scale * b.x;
@@ -45,7 +45,7 @@ static Vector3f Combine(const Vector3f& a, const Vector3f& b, float a_scale, flo
 
 
 // Interpolate two quaternions a, b with weight alpha [0, 1]
-static Vector4f QuaternionSlerp(const Vector4f& a, const Vector4f& b, float alpha)
+static Vector4f QuaternionSlerp(const Vector4f a, const Vector4f b, float alpha)
 {
 	using namespace Math;
 

+ 5 - 5
Source/Core/Variant.cpp

@@ -244,31 +244,31 @@ void Variant::Set(void* voidptr)
 	memcpy(data, &voidptr, sizeof(void*));
 }
 
-void Variant::Set(const Vector2f& value)
+void Variant::Set(const Vector2f value)
 {
 	type = VECTOR2;
 	SET_VARIANT(Vector2f);
 }
 
-void Variant::Set(const Vector3f& value)
+void Variant::Set(const Vector3f value)
 {
 	type = VECTOR3;
 	SET_VARIANT(Vector3f);
 }
 
-void Variant::Set(const Vector4f& value)
+void Variant::Set(const Vector4f value)
 {
 	type = VECTOR4;
 	SET_VARIANT(Vector4f);
 }
 
-void Variant::Set(const Colourf& value)
+void Variant::Set(const Colourf value)
 {
 	type = COLOURF;
 	SET_VARIANT(Colourf);
 }
 
-void Variant::Set(const Colourb& value)
+void Variant::Set(const Colourb value)
 {
 	type = COLOURB;
 	SET_VARIANT(Colourb);

+ 0 - 45
Source/Core/Vector3.cpp

@@ -1,45 +0,0 @@
-/*
- * This source file is part of rmlui, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2014 Markus Schöngart
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "../../Include/RmlUi/Core/Types.h"
-
-namespace Rml {
-
-Vector3i operator*(int lhs, const Vector3i& rhs)
-{
-	return Vector3i(lhs * rhs.x, lhs * rhs.y, lhs * rhs.z);
-}
-
-Vector3f operator*(float lhs, const Vector3f& rhs)
-{
-	return Vector3f(lhs * rhs.x, lhs * rhs.y, lhs * rhs.z);
-}
-
-
-
-} // namespace Rml

+ 0 - 53
Source/Core/Vector4.cpp

@@ -1,53 +0,0 @@
-/*
- * This source file is part of rmlui, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2014 Markus Schöngart
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "../../Include/RmlUi/Core/Types.h"
-
-namespace Rml {
-
-Vector4i operator*(int lhs, const Vector4i& rhs)
-{
-	return Vector4i(lhs * rhs.x, lhs * rhs.y, lhs * rhs.z, lhs * rhs.w);
-}
-
-Vector4f operator*(float lhs, const Vector4f& rhs)
-{
-	return Vector4f(lhs * rhs.x, lhs * rhs.y, lhs * rhs.z, lhs * rhs.w);
-}
-
-template <>
-Vector4< float > Vector4< float >::Normalise() const
-{
-	float magnitude = Magnitude();
-	if (Math::IsZero(magnitude))
-		return *this;
-
-	return *this / magnitude;
-}
-
-} // namespace Rml

+ 2 - 2
Source/Core/WidgetScroll.cpp

@@ -210,7 +210,7 @@ void WidgetScroll::GetDimensions(Vector2f& dimensions) const
 }
 
 // Lays out and resizes the internal elements.
-void WidgetScroll::FormatElements(const Vector2f& containing_block, bool resize_element, float slider_length, float bar_length)
+void WidgetScroll::FormatElements(const Vector2f containing_block, bool resize_element, float slider_length, float bar_length)
 {
 	int length_axis = orientation == VERTICAL ? 1 : 0;
 
@@ -503,7 +503,7 @@ void WidgetScroll::SetLineHeight(float _line_height)
 }
 
 // Lays out and resizes the internal elements.
-void WidgetScroll::FormatElements(const Vector2f& containing_block, float slider_length)
+void WidgetScroll::FormatElements(const Vector2f containing_block, float slider_length)
 {
 	float relative_bar_length;
 

+ 2 - 2
Source/Core/WidgetScroll.h

@@ -94,7 +94,7 @@ public:
 	/// Lays out and resizes the internal elements.
 	/// @param[in] containing_block The padded box containing the slider. This is used to resolve relative properties.
 	/// @param[in] length The total length, in pixels, of the slider widget.
-	void FormatElements(const Vector2f& containing_block, float slider_length);
+	void FormatElements(Vector2f containing_block, float slider_length);
 
 private:
 	/// Handles events coming through from the slider's components.
@@ -105,7 +105,7 @@ private:
 	/// @param[in] resize_element True to resize the parent slider element, false to only resize its components.
 	/// @param[in] slider_length The total length, in pixels, of the slider widget.
 	/// @param[in] bar_length The total length of the bar, as a proportion of the track length. If this is -1, the intrinsic length will be used.
-	void FormatElements(const Vector2f& containing_block, bool resize_element, float slider_length, float bar_length = -1);
+	void FormatElements(Vector2f containing_block, bool resize_element, float slider_length, float bar_length = -1);
 	/// Lays out and positions the bar element.
 	/// @param[in] bar_length The total length of the bar, as a proportion of the track length. If this is -1, the intrinsic length will be used.
 	void FormatBar(float bar_length = -1);

+ 3 - 3
Source/Debugger/Geometry.cpp

@@ -46,7 +46,7 @@ void Geometry::SetContext(Context* _context)
 }
 
 // Renders a one-pixel rectangular outline.
-void Geometry::RenderOutline(const Vector2f& origin, const Vector2f& dimensions, const Colourb& colour, float width)
+void Geometry::RenderOutline(const Vector2f origin, const Vector2f dimensions, const Colourb colour, float width)
 {
 	if (context == nullptr)
 		return;
@@ -65,7 +65,7 @@ void Geometry::RenderOutline(const Vector2f& origin, const Vector2f& dimensions,
 }
 
 // Renders a box.
-void Geometry::RenderBox(const Vector2f& origin, const Vector2f& dimensions, const Colourb& colour)
+void Geometry::RenderBox(const Vector2f origin, const Vector2f dimensions, const Colourb colour)
 {
 	if (context == nullptr)
 		return;
@@ -81,7 +81,7 @@ void Geometry::RenderBox(const Vector2f& origin, const Vector2f& dimensions, con
 }
 
 // Renders a box with a hole in the middle.
-void Geometry::RenderBox(const Vector2f& origin, const Vector2f& dimensions, const Vector2f& hole_origin, const Vector2f& hole_dimensions, const Colourb& colour)
+void Geometry::RenderBox(const Vector2f origin, const Vector2f dimensions, const Vector2f hole_origin, const Vector2f hole_dimensions, const Colourb colour)
 {
 	// Top box.
 	float top_y_dimensions = hole_origin.y - origin.y;

+ 3 - 3
Source/Debugger/Geometry.h

@@ -50,11 +50,11 @@ public:
 	static void SetContext(Context* context);
 
 	// Renders a one-pixel rectangular outline.
-	static void RenderOutline(const Vector2f& origin, const Vector2f& dimensions, const Colourb& colour, float width);
+	static void RenderOutline(Vector2f origin, Vector2f dimensions, Colourb colour, float width);
 	// Renders a box.
-	static void RenderBox(const Vector2f& origin, const Vector2f& dimensions, const Colourb& colour);
+	static void RenderBox(Vector2f origin, Vector2f dimensions, Colourb colour);
 	// Renders a box with a hole in the middle.
-	static void RenderBox(const Vector2f& origin, const Vector2f& dimensions, const Vector2f& hole_origin, const Vector2f& hole_dimensions, const Colourb& colour);
+	static void RenderBox(Vector2f origin, Vector2f dimensions, Vector2f hole_origin, Vector2f hole_dimensions, Colourb colour);
 
 private:
 	Geometry();

+ 1 - 2
Source/Lottie/ElementLottie.cpp

@@ -120,8 +120,7 @@ void ElementLottie::GenerateGeometry()
 	quad_colour.alpha = (byte)(opacity * (float)quad_colour.alpha);
 
 	const Vector2f render_dimensions_f = GetBox().GetSize(Box::CONTENT).Round();
-	render_dimensions.x = int(render_dimensions_f.x);
-	render_dimensions.y = int(render_dimensions_f.y);
+	render_dimensions = Vector2i(render_dimensions_f);
 
 	GeometryUtilities::GenerateQuad(&vertices[0], &indices[0], Vector2f(0, 0), render_dimensions_f, quad_colour, texcoords[0], texcoords[1]);
 

+ 2 - 4
Source/Lua/Context.cpp

@@ -135,10 +135,8 @@ int ContextOpenDataModel(lua_State *L, Context *obj)
 int ContextGetAttrdimensions(lua_State* L)
 {
     Context* cont = LuaType<Context>::check(L,1);
-    const Vector2i* dim = &cont->GetDimensions();
-    //const_cast-ing so that the user can do dimensions.x = 3 and it will actually change the dimensions
-    //of the context
-    LuaType<Vector2i>::push(L,const_cast<Vector2i*>(dim));
+    Vector2i* dim = new Vector2i(cont->GetDimensions());
+    LuaType<Vector2i>::push(L,dim,true);
     return 1;
 }