diff --git a/bin/unit_tests/assets/html/eepp-ui-border-rendering-2.webp b/bin/unit_tests/assets/html/eepp-ui-border-rendering-2.webp index 0c47a946f..34d2d0c8a 100644 Binary files a/bin/unit_tests/assets/html/eepp-ui-border-rendering-2.webp and b/bin/unit_tests/assets/html/eepp-ui-border-rendering-2.webp differ diff --git a/bin/unit_tests/assets/html/reddit_header.html b/bin/unit_tests/assets/html/reddit_header.html new file mode 100644 index 000000000..e0e1b4a0d --- /dev/null +++ b/bin/unit_tests/assets/html/reddit_header.html @@ -0,0 +1,3956 @@ + + + +GCC 16.1 released with many new C++26/23 features, C++20 now the default stable language version : cpp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/include/eepp/network.hpp b/include/eepp/network.hpp index 89badc055..b6e58bb26 100644 --- a/include/eepp/network.hpp +++ b/include/eepp/network.hpp @@ -1,6 +1,7 @@ #ifndef EEPP_NETWORK_HPP #define EEPP_NETWORK_HPP +#include #include #include #include diff --git a/include/eepp/ui.hpp b/include/eepp/ui.hpp index 9ef72a46a..c08ed7d85 100644 --- a/include/eepp/ui.hpp +++ b/include/eepp/ui.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -45,10 +47,8 @@ #include #include #include -#include -#include -#include #include +#include #include #include #include @@ -64,7 +64,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -91,13 +93,22 @@ #include #include #include +#include +#include +#include +#include #include +#include +#include +#include #include #include #include #include #include #include +#include +#include #include #include #include @@ -140,6 +151,7 @@ #include #include #include +#include #include #include #include @@ -148,6 +160,7 @@ #include #include #include +#include #include #include #include diff --git a/include/eepp/ui/css/propertydefinition.hpp b/include/eepp/ui/css/propertydefinition.hpp index f7408eaca..49b65b4b3 100644 --- a/include/eepp/ui/css/propertydefinition.hpp +++ b/include/eepp/ui/css/propertydefinition.hpp @@ -254,6 +254,7 @@ enum class PropertyId : Uint32 { Action = String::hash( "action" ), Method = String::hash( "method" ), Enctype = String::hash( "enctype" ), + Overflow = String::hash( "overflow" ), }; enum class PropertyType : Uint32 { diff --git a/include/eepp/ui/htmltextinput.hpp b/include/eepp/ui/uihtmltextinput.hpp similarity index 84% rename from include/eepp/ui/htmltextinput.hpp rename to include/eepp/ui/uihtmltextinput.hpp index 247ed9da0..7241109cf 100644 --- a/include/eepp/ui/htmltextinput.hpp +++ b/include/eepp/ui/uihtmltextinput.hpp @@ -5,11 +5,11 @@ namespace EE { namespace UI { -class EE_API HTMLTextInput : public UITextInput { +class EE_API UIHTMLTextInput : public UITextInput { public: - static HTMLTextInput* New(); + static UIHTMLTextInput* New(); - HTMLTextInput(); + UIHTMLTextInput(); virtual Uint32 getType() const; @@ -33,7 +33,7 @@ class EE_API HTMLTextInput : public UITextInput { void setHtmlSize( Uint32 size ); protected: - HTMLTextInput( const std::string& tag ); + UIHTMLTextInput( const std::string& tag ); Uint32 mHtmlSize{ 20 }; bool mPacking{ false }; diff --git a/src/eepp/graphics/image.cpp b/src/eepp/graphics/image.cpp index 63ee8de58..2539e21fd 100644 --- a/src/eepp/graphics/image.cpp +++ b/src/eepp/graphics/image.cpp @@ -784,13 +784,7 @@ Image::Image( const Uint8* imageData, const unsigned int& imageDataSize, } else if ( webp_test_from_memory( imageData, imageDataSize ) ) { webpLoad( imageData, imageDataSize ); } else { - std::string reason = "."; - - if ( NULL != stbi_failure_reason() ) { - reason = ", reason: " + std::string( stbi_failure_reason() ); - } - - Log::error( "Failed to load image from memory. Reason: %s", reason.c_str() ); + Log::error( "Failed to load image from memory. Reason: %s", stbi_failure_reason() ); } } @@ -1438,7 +1432,7 @@ Graphics::Image* Image::copy() { } Graphics::Image& Image::operator=( const Image& right ) { - if (this == &right) + if ( this == &right ) return *this; mWidth = right.mWidth; diff --git a/src/eepp/ui/css/stylesheetspecification.cpp b/src/eepp/ui/css/stylesheetspecification.cpp index d4365b460..5d67cb5e3 100644 --- a/src/eepp/ui/css/stylesheetspecification.cpp +++ b/src/eepp/ui/css/stylesheetspecification.cpp @@ -171,6 +171,11 @@ void StyleSheetSpecification::registerDefaultProperties() { registerProperty( "layout-to-top-of", "" ).addAlias( "layout_to_top_of" ); registerProperty( "layout-to-bottom-of", "" ).addAlias( "layout_to_bottom_of" ); registerProperty( "clip", "" ).setType( PropertyType::String ); + // TODO: layer implement overflow-x and overflow-y properly + registerProperty( "overflow", "visible" ) + .addAlias( "overflow-x" ) + .addAlias( "overflow-y" ) + .setType( PropertyType::String ); registerProperty( "rotation", "" ).addAlias( "rotate" ).setType( PropertyType::NumberFloat ); registerProperty( "scale", "" ).setType( PropertyType::Vector2 ); registerProperty( "rotation-origin-point-x", "50%" ) diff --git a/src/eepp/ui/uihtmlinput.cpp b/src/eepp/ui/uihtmlinput.cpp index f3bc670f3..d2c300027 100644 --- a/src/eepp/ui/uihtmlinput.cpp +++ b/src/eepp/ui/uihtmlinput.cpp @@ -1,8 +1,8 @@ #include -#include #include #include #include +#include #include #include #include @@ -126,11 +126,11 @@ void UIHTMLInput::createChildWidget() { } else if ( mInputType == "number" ) { mChildWidget = UISpinBox::New(); } else if ( mInputType == "password" ) { - mChildWidget = HTMLTextInput::New()->setMode( UITextInput::TextInputMode::Password ); + mChildWidget = UIHTMLTextInput::New()->setMode( UITextInput::TextInputMode::Password ); } else if ( mInputType == "radio" ) { mChildWidget = UIRadioButton::New(); } else { - mChildWidget = HTMLTextInput::New(); + mChildWidget = UIHTMLTextInput::New(); } if ( mChildWidget == nullptr ) diff --git a/src/eepp/ui/htmltextinput.cpp b/src/eepp/ui/uihtmltextinput.cpp similarity index 63% rename from src/eepp/ui/htmltextinput.cpp rename to src/eepp/ui/uihtmltextinput.cpp index 05a6fd588..404851753 100644 --- a/src/eepp/ui/htmltextinput.cpp +++ b/src/eepp/ui/uihtmltextinput.cpp @@ -1,17 +1,17 @@ #include #include -#include +#include #include namespace EE { namespace UI { -HTMLTextInput* HTMLTextInput::New() { - return eeNew( HTMLTextInput, () ); +UIHTMLTextInput* UIHTMLTextInput::New() { + return eeNew( UIHTMLTextInput, () ); } -HTMLTextInput::HTMLTextInput() : HTMLTextInput( "textinput" ) {} +UIHTMLTextInput::UIHTMLTextInput() : UIHTMLTextInput( "textinput" ) {} -HTMLTextInput::HTMLTextInput( const std::string& tag ) : UITextInput( tag ) { +UIHTMLTextInput::UIHTMLTextInput( const std::string& tag ) : UITextInput( tag ) { mHtmlSize = 20; mWidthPolicy = SizePolicy::WrapContent; mHeightPolicy = SizePolicy::WrapContent; @@ -19,15 +19,15 @@ HTMLTextInput::HTMLTextInput( const std::string& tag ) : UITextInput( tag ) { onAutoSize(); } -Uint32 HTMLTextInput::getType() const { +Uint32 UIHTMLTextInput::getType() const { return UI_TYPE_HTML_TEXTINPUT; } -bool HTMLTextInput::isType( const Uint32& type ) const { - return HTMLTextInput::getType() == type || UITextInput::isType( type ); +bool UIHTMLTextInput::isType( const Uint32& type ) const { + return UIHTMLTextInput::getType() == type || UITextInput::isType( type ); } -bool HTMLTextInput::applyProperty( const StyleSheetProperty& attribute ) { +bool UIHTMLTextInput::applyProperty( const StyleSheetProperty& attribute ) { if ( !attribute.getPropertyDefinition() ) return false; @@ -42,8 +42,8 @@ bool HTMLTextInput::applyProperty( const StyleSheetProperty& attribute ) { return UITextInput::applyProperty( attribute ); } -std::string HTMLTextInput::getPropertyString( const PropertyDefinition* propertyDef, - const Uint32& propertyIndex ) const { +std::string UIHTMLTextInput::getPropertyString( const PropertyDefinition* propertyDef, + const Uint32& propertyIndex ) const { if ( !propertyDef ) return ""; @@ -57,13 +57,13 @@ std::string HTMLTextInput::getPropertyString( const PropertyDefinition* property return UITextInput::getPropertyString( propertyDef, propertyIndex ); } -std::vector HTMLTextInput::getPropertiesImplemented() const { +std::vector UIHTMLTextInput::getPropertiesImplemented() const { auto props = UITextInput::getPropertiesImplemented(); props.push_back( PropertyId::Size ); return props; } -Float HTMLTextInput::getMinIntrinsicWidth() const { +Float UIHTMLTextInput::getMinIntrinsicWidth() const { if ( mHtmlSize > 0 && getFont() ) { Float advance = getFont()->getGlyph( 'M', getFontSize(), false, false ).advance; return mHtmlSize * advance + mPaddingPx.Left + mPaddingPx.Right; @@ -71,11 +71,11 @@ Float HTMLTextInput::getMinIntrinsicWidth() const { return UITextInput::getMinIntrinsicWidth(); } -Float HTMLTextInput::getMaxIntrinsicWidth() const { +Float UIHTMLTextInput::getMaxIntrinsicWidth() const { return getMinIntrinsicWidth(); } -void HTMLTextInput::onAutoSize() { +void UIHTMLTextInput::onAutoSize() { if ( mPacking ) return; mPacking = true; @@ -92,11 +92,11 @@ void HTMLTextInput::onAutoSize() { mPacking = false; } -Uint32 HTMLTextInput::getHtmlSize() const { +Uint32 UIHTMLTextInput::getHtmlSize() const { return mHtmlSize; } -void HTMLTextInput::setHtmlSize( Uint32 size ) { +void UIHTMLTextInput::setHtmlSize( Uint32 size ) { if ( mHtmlSize != size ) { mHtmlSize = size; invalidateIntrinsicSize(); diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 2fdfbfc3e..570ab5edf 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -2213,6 +2213,15 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) { case PropertyId::Clip: setClipType( UIClip::fromString( attribute.asString() ) ); break; + case PropertyId::Overflow: { + std::string val = attribute.asString(); + String::toLowerInPlace( val ); + if ( val == "hidden" || val == "auto" || val == "scroll" ) + setClipType( ClipType::ContentBox ); + else + setClipType( ClipType::None ); + break; + } case PropertyId::Rotation: setRotation( attribute.asFloat() ); break; diff --git a/src/tests/unit_tests/uihtml_tests.cpp b/src/tests/unit_tests/uihtml_tests.cpp index dd191c08d..1468bf5c6 100644 --- a/src/tests/unit_tests/uihtml_tests.cpp +++ b/src/tests/unit_tests/uihtml_tests.cpp @@ -9,13 +9,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -401,9 +401,9 @@ UTEST( UIHTMLInput, sizeAttribute ) { ASSERT_TRUE( cm != nullptr ); ASSERT_TRUE( cc != nullptr ); - auto i1 = c1->getChildWidget()->asType(); - auto i2 = c2->getChildWidget()->asType(); - auto i3 = c3->getChildWidget()->asType(); + auto i1 = c1->getChildWidget()->asType(); + auto i2 = c2->getChildWidget()->asType(); + auto i3 = c3->getChildWidget()->asType(); ASSERT_TRUE( i1 != nullptr ); ASSERT_TRUE( i2 != nullptr );