Browse Source

Remove 'StyleSheetKeywords.h'. Instead, use the Style:: namespace in ComputedValues.h.

Michael Ragazzon 6 years ago
parent
commit
a6d058b58b

+ 0 - 1
Cmake/FileList.cmake

@@ -173,7 +173,6 @@ set(Core_PUB_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StreamMemory.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StringUtilities.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StyleSheet.h
-    ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StyleSheetKeywords.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StyleSheetSpecification.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/SystemInterface.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Texture.h

+ 4 - 4
Include/RmlUi/Core/ComputedValues.h

@@ -100,11 +100,11 @@ struct VerticalAlign {
 
 enum class Overflow : uint8_t { Visible, Hidden, Auto, Scroll };
 struct Clip {
-	// Note, internally Auto is 0 and None is -1, however, the enum must correspond to the keywords in StyleSheetSpec
-	enum Type { Auto, None, Number };
+	enum class Type : uint8_t { Auto, None, Number };
+	// Note, internally 'number' is encoded with Auto as 0 and None as -1. However, the enum must correspond to the keywords in StyleSheetSpec.
 	int number = 0;
 	Clip() {}
-	Clip(Type type, int number = 0) : number(type == Auto ? 0 : (type == None ? -1 : number)) {}
+	Clip(Type type, int number = 0) : number(type == Type::Auto ? 0 : (type == Type::None ? -1 : number)) {}
 };
 
 enum class Visibility : uint8_t { Visible, Hidden };
@@ -113,7 +113,7 @@ enum class FontStyle : uint8_t { Normal, Italic };
 enum class FontWeight : uint8_t { Normal, Bold };
 
 enum class TextAlign : uint8_t { Left, Right, Center, Justify };
-enum class TextDecoration : uint8_t { None, Underline };
+enum class TextDecoration : uint8_t { None, Underline, Overline, LineThrough };
 enum class TextTransform : uint8_t { None, Capitalize, Uppercase, Lowercase };
 enum class WhiteSpace : uint8_t { Normal, Pre, Nowrap, Prewrap, Preline };
 

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

@@ -72,7 +72,6 @@
 #include "Spritesheet.h"
 #include "StringUtilities.h"
 #include "StyleSheet.h"
-#include "StyleSheetKeywords.h"
 #include "StyleSheetSpecification.h"
 #include "SystemInterface.h"
 #include "Texture.h"

+ 0 - 133
Include/RmlUi/Core/StyleSheetKeywords.h

@@ -1,133 +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 RMLUICORESTYLESHEETKEYWORDS_H
-#define RMLUICORESTYLESHEETKEYWORDS_H
-
-namespace Rml {
-namespace Core {
-
-const int POSITION_STATIC = 0;
-const int POSITION_RELATIVE = 1;
-const int POSITION_ABSOLUTE = 2;
-const int POSITION_FIXED = 3;
-
-const int FLOAT_NONE = 0;
-const int FLOAT_LEFT = 1;
-const int FLOAT_RIGHT = 2;
-
-const int DISPLAY_NONE = 0;
-const int DISPLAY_BLOCK = 1;
-const int DISPLAY_INLINE = 2;
-const int DISPLAY_INLINE_BLOCK = 3;
-
-const int VISIBILITY_VISIBLE = 0;
-const int VISIBILITY_HIDDEN = 1;
-
-const int OVERFLOW_VISIBLE = 0;
-const int OVERFLOW_HIDDEN = 1;
-const int OVERFLOW_AUTO = 2;
-const int OVERFLOW_SCROLL = 3;
-
-const int CLIP_AUTO = 0;
-const int CLIP_NONE = 1;
-
-const int FONT_STYLE_NORMAL = 0;
-const int FONT_STYLE_ITALIC = 1;
-
-const int FONT_WEIGHT_NORMAL = 0;
-const int FONT_WEIGHT_BOLD = 1;
-
-const int TEXT_ALIGN_LEFT = 0;
-const int TEXT_ALIGN_RIGHT = 1;
-const int TEXT_ALIGN_CENTER = 2;
-const int TEXT_ALIGN_JUSTIFY = 3;
-
-const int TEXT_DECORATION_NONE = 0;
-const int TEXT_DECORATION_UNDERLINE = 1;
-const int TEXT_DECORATION_OVERLINE = 2;
-const int TEXT_DECORATION_LINE_THROUGH = 3;
-
-const int TEXT_TRANSFORM_NONE = 0;
-const int TEXT_TRANSFORM_CAPITALIZE = 1;
-const int TEXT_TRANSFORM_UPPERCASE = 2;
-const int TEXT_TRANSFORM_LOWERCASE = 3;
-
-const int WHITE_SPACE_NORMAL = 0;
-const int WHITE_SPACE_PRE = 1;
-const int WHITE_SPACE_NOWRAP = 2;
-const int WHITE_SPACE_PRE_WRAP = 3;
-const int WHITE_SPACE_PRE_LINE = 4;
-
-const int VERTICAL_ALIGN_BASELINE = 0;
-const int VERTICAL_ALIGN_MIDDLE = 1;
-const int VERTICAL_ALIGN_SUB = 2;
-const int VERTICAL_ALIGN_SUPER = 3;
-const int VERTICAL_ALIGN_TEXT_TOP = 4;
-const int VERTICAL_ALIGN_TEXT_BOTTOM = 5;
-const int VERTICAL_ALIGN_TOP = 6;
-const int VERTICAL_ALIGN_BOTTOM = 7;
-
-const int DRAG_NONE = 0;
-const int DRAG_DRAG = 1;
-const int DRAG_DRAG_DROP = 2;
-const int DRAG_BLOCK = 3;
-const int DRAG_CLONE = 4;
-
-const int TAB_INDEX_NONE = 0;
-const int TAB_INDEX_AUTO = 1;
-
-const int FOCUS_NONE = 0;
-const int FOCUS_AUTO = 1;
-
-const int POINTER_EVENTS_AUTO = 0;
-const int POINTER_EVENTS_NONE = 1;
-
-const int PERSPECTIVE_NONE = 0;
-
-const int PERSPECTIVE_ORIGIN_X_LEFT = 0;
-const int PERSPECTIVE_ORIGIN_X_CENTER = 1;
-const int PERSPECTIVE_ORIGIN_X_RIGHT = 2;
-
-const int PERSPECTIVE_ORIGIN_Y_TOP = 0;
-const int PERSPECTIVE_ORIGIN_Y_CENTER = 1;
-const int PERSPECTIVE_ORIGIN_Y_BOTTOM = 2;
-
-const int TRANSFORM_NONE = 0;
-
-const int TRANSFORM_ORIGIN_X_LEFT = 0;
-const int TRANSFORM_ORIGIN_X_CENTER = 1;
-const int TRANSFORM_ORIGIN_X_RIGHT = 2;
-
-const int TRANSFORM_ORIGIN_Y_TOP = 0;
-const int TRANSFORM_ORIGIN_Y_CENTER = 1;
-const int TRANSFORM_ORIGIN_Y_BOTTOM = 2;
-}
-}
-
-#endif

+ 2 - 3
Source/Controls/WidgetDropDown.cpp

@@ -33,7 +33,6 @@
 #include "../../Include/RmlUi/Core/Event.h"
 #include "../../Include/RmlUi/Core/Input.h"
 #include "../../Include/RmlUi/Core/Property.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 #include "../../Include/RmlUi/Controls/ElementFormControl.h"
 
 namespace Rml {
@@ -59,7 +58,7 @@ WidgetDropDown::WidgetDropDown(ElementFormControl* element)
 
 	selection_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden));
 	selection_element->SetProperty(Core::PropertyId::ZIndex, Core::Property(1.0f, Core::Property::NUMBER));
-	selection_element->SetProperty(Core::PropertyId::Clip, Core::Property(Core::Style::Clip::None));
+	selection_element->SetProperty(Core::PropertyId::Clip, Core::Property(Core::Style::Clip::Type::None));
 
 	parent_element->AddEventListener(Core::EventId::Click, this, true);
 	parent_element->AddEventListener(Core::EventId::Blur, this);
@@ -233,7 +232,7 @@ int WidgetDropDown::AddOption(Rml::Core::ElementPtr element, const Rml::Core::St
 
 	// Force to block display. Register a click handler so we can be notified of selection.
 	element->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::Block));
-	element->SetProperty(Core::PropertyId::Clip, Core::Property(Core::Style::Clip::Auto));
+	element->SetProperty(Core::PropertyId::Clip, Core::Property(Core::Style::Clip::Type::Auto));
 	element->AddEventListener(Core::EventId::Click, this);
 
 	int option_index;

+ 2 - 2
Source/Core/ComputeProperty.cpp

@@ -193,9 +193,9 @@ Style::Clip ComputeClip(const Property* property)
 {
 	int value = property->Get<int>();
 	if (property->unit == Property::KEYWORD)
-		return Style::Clip(value == CLIP_NONE ? Style::Clip::None : Style::Clip::Auto);
+		return Style::Clip(static_cast<Style::Clip::Type>(value));
 	else if (property->unit == Property::NUMBER)
-		return Style::Clip(Style::Clip::Number, value);
+		return Style::Clip(Style::Clip::Type::Number, value);
 	RMLUI_ERRORMSG("Invalid clip type");
 	return Style::Clip();
 }

+ 8 - 9
Source/Core/ElementTextDefault.cpp

@@ -36,7 +36,6 @@
 #include "../../Include/RmlUi/Core/Event.h"
 #include "../../Include/RmlUi/Core/FontDatabase.h"
 #include "../../Include/RmlUi/Core/Property.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {
@@ -48,8 +47,8 @@ ElementTextDefault::ElementTextDefault(const String& tag) : ElementText(tag), co
 {
 	dirty_layout_on_change = true;
 
-	generated_decoration = TEXT_DECORATION_NONE;
-	decoration_property = TEXT_DECORATION_NONE;
+	generated_decoration = Style::TextDecoration::None;
+	decoration_property = Style::TextDecoration::None;
 
 	geometry_dirty = true;
 
@@ -140,7 +139,7 @@ void ElementTextDefault::OnRender()
 			geometry[i].Render(translation);
 	}
 
-	if (decoration_property != TEXT_DECORATION_NONE)
+	if (decoration_property != Style::TextDecoration::None)
 		decoration.Render(translation);
 }
 
@@ -283,7 +282,7 @@ void ElementTextDefault::AddLine(const Vector2f& line_position, const WString& l
 
 	geometry_dirty = true;
 
-	if (decoration_property != TEXT_DECORATION_NONE)
+	if (decoration_property != Style::TextDecoration::None)
 		GenerateDecoration(font_face_handle, lines.back());
 }
 
@@ -329,8 +328,8 @@ void ElementTextDefault::OnPropertyChange(const PropertyIdSet& changed_propertie
 
 	if (changed_properties.Contains(PropertyId::TextDecoration))
 	{
-		decoration_property = (int)computed.text_decoration;
-		if (decoration_property != TEXT_DECORATION_NONE)
+		decoration_property = computed.text_decoration;
+		if (decoration_property != Style::TextDecoration::None)
 		{
 			if (decoration_property != generated_decoration)
 			{
@@ -432,9 +431,9 @@ void ElementTextDefault::GenerateDecoration(const FontFaceHandle* font_face_hand
 	RMLUI_ZoneScopedC(0xA52A2A);
 	
 	Font::Line line_height;
-	if (decoration_property == TEXT_DECORATION_OVERLINE)
+	if (decoration_property == Style::TextDecoration::Overline)
 		line_height = Font::OVERLINE;
-	else if (decoration_property == TEXT_DECORATION_LINE_THROUGH)
+	else if (decoration_property == Style::TextDecoration::LineThrough)
 		line_height = Font::STRIKE_THROUGH;
 	else
 		line_height = Font::UNDERLINE;

+ 2 - 2
Source/Core/ElementTextDefault.h

@@ -124,11 +124,11 @@ private:
 	// The decoration geometry we've generated for this string.
 	Geometry decoration;
 	// What the decoration type is that we have generated.
-	int generated_decoration;
+	Style::TextDecoration generated_decoration;
 	// What the element's actual text-decoration property is; this may be different from the generated decoration
 	// if it is set to none; this means we can keep generated decoration and simply toggle it on or off as long as
 	// it isn't being changed.
-	int decoration_property;
+	Style::TextDecoration decoration_property;
 
 	int font_configuration;
 	bool font_dirty;

+ 0 - 1
Source/Core/LayoutBlockBox.cpp

@@ -34,7 +34,6 @@
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include "../../Include/RmlUi/Core/ElementScroll.h"
 #include "../../Include/RmlUi/Core/Property.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/LayoutBlockBoxSpace.cpp

@@ -32,7 +32,6 @@
 #include "LayoutEngine.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/ElementScroll.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 2
Source/Core/LayoutBlockBoxSpace.h

@@ -29,8 +29,6 @@
 #ifndef RMLUICORELAYOUTBLOCKBOXSPACE_H
 #define RMLUICORELAYOUTBLOCKBOXSPACE_H
 
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
-
 namespace Rml {
 namespace Core {
 

+ 0 - 1
Source/Core/LayoutEngine.cpp

@@ -37,7 +37,6 @@
 #include "../../Include/RmlUi/Core/ElementText.h"
 #include "../../Include/RmlUi/Core/Property.h"
 #include "../../Include/RmlUi/Core/Types.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 #include <math.h>
 #include <cstddef>
 

+ 0 - 1
Source/Core/LayoutInlineBox.cpp

@@ -34,7 +34,6 @@
 #include "../../Include/RmlUi/Core/ElementText.h"
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include "../../Include/RmlUi/Core/Property.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/LayoutLineBox.cpp

@@ -35,7 +35,6 @@
 #include "../../Include/RmlUi/Core/Property.h"
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 #include <stack>
 
 namespace Rml {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorEmpty.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorEmpty.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorFirstChild.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorFirstChild.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorFirstOfType.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorFirstOfType.h"
 #include "../../Include/RmlUi/Core/Element.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorLastChild.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorLastChild.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorLastOfType.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorLastOfType.h"
 #include "../../Include/RmlUi/Core/Element.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorNthChild.cpp

@@ -30,7 +30,6 @@
 #include "StyleSheetNodeSelectorNthChild.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
 #include "../../Include/RmlUi/Core/Log.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorNthLastChild.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorNthLastChild.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorNthLastOfType.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorNthLastOfType.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorNthOfType.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorNthOfType.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorOnlyChild.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorOnlyChild.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 0 - 1
Source/Core/StyleSheetNodeSelectorOnlyOfType.cpp

@@ -29,7 +29,6 @@
 #include "precompiled.h"
 #include "StyleSheetNodeSelectorOnlyOfType.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
-#include "../../Include/RmlUi/Core/StyleSheetKeywords.h"
 
 namespace Rml {
 namespace Core {

+ 1 - 0
readme.md

@@ -40,6 +40,7 @@ The main effort in RmlUi 3.0 has been on improving the performance of the librar
 - The update loop has been reworked to avoid doing unnecessary, repeated calculations whenever the document or style is changed. Instead of immediately updating properties on any affected elements, most of this work is done during the Context::Update call in a more carefully chosen order. Note that for this reason, when querying the Rocket API for properties such as size or position, this information may not be up-to-date with changes since the last Context::Update, such as newly added elements or classes. If this information is needed immediately, a call to ElementDocument::UpdateDocument can be made before such queries at a performance penalty.
 - Several containers have been replaced, such as std::map to [robin_hood::unordered_flat_map](https://github.com/martinus/robin-hood-hashing).
 - Reduced number of allocations and unnecessary recursive calls.
+- Internally, the concept of computed values has been introduced. Computed values take the properties of an element and computes them as far as possible without introducing the layouting.
 - And many more, smaller optimizations, resulting in about 10x performance increase for creation and destruction of a large number of elements. A benchmark is included with the samples.