diff --git a/bin/unit_tests/assets/html/reddit_header_icons.html b/bin/unit_tests/assets/html/reddit_header_icons.html new file mode 100644 index 000000000..bd23cdc34 --- /dev/null +++ b/bin/unit_tests/assets/html/reddit_header_icons.html @@ -0,0 +1,62 @@ + + + + + + +
+ messages|notifications|chat messages +
+ + diff --git a/bin/unit_tests/assets/html/sprite-reddit.13AvZYXRW_4.png b/bin/unit_tests/assets/html/sprite-reddit.13AvZYXRW_4.png new file mode 100644 index 000000000..7d7d4d67d Binary files /dev/null and b/bin/unit_tests/assets/html/sprite-reddit.13AvZYXRW_4.png differ diff --git a/src/eepp/ui/uitextspan.cpp b/src/eepp/ui/uitextspan.cpp index a23890d06..ef7222a07 100644 --- a/src/eepp/ui/uitextspan.cpp +++ b/src/eepp/ui/uitextspan.cpp @@ -15,7 +15,8 @@ #define PUGIXML_HEADER_ONLY #include -namespace EE { namespace UI { +namespace EE { +namespace UI { UITextSpan* UITextSpan::New() { return eeNew( UITextSpan, () ); @@ -64,8 +65,14 @@ bool UITextSpan::isType( const Uint32& type ) const { bool UITextSpan::isMergeable() const { if ( mDisplay == CSSDisplay::Inline ) return true; - if ( mDisplay == CSSDisplay::InlineBlock ) - return !getText().empty() && NULL != getFontStyleConfig().Font; + if ( mDisplay == CSSDisplay::InlineBlock ) { + if ( getText().empty() || NULL == getFontStyleConfig().Font ) + return false; + if ( getLayoutWidthPolicy() == SizePolicy::Fixed || + getLayoutHeightPolicy() == SizePolicy::Fixed ) + return false; + return true; + } return false; } @@ -805,4 +812,5 @@ void UILabelSpan::activateTarget() { } } -}} // namespace EE::UI +} +} // namespace EE::UI diff --git a/src/tests/unit_tests/uihtml_tests.cpp b/src/tests/unit_tests/uihtml_tests.cpp index cfae2bdf3..1672556bd 100644 --- a/src/tests/unit_tests/uihtml_tests.cpp +++ b/src/tests/unit_tests/uihtml_tests.cpp @@ -1515,3 +1515,38 @@ UTEST( UIBackground, InlineBlockImageSpans ) { Engine::destroySingleton(); } + +UTEST( UIBackground, InlineBlockImageFixedSize ) { + auto win = Engine::instance()->createWindow( + WindowSettings( 1024, 653, "inline-block image fixed size", WindowStyle::Default, + WindowBackend::Default, 32, {}, 1, false, true ), + ContextSettings( false, 0, 0, GLv_default, true, false ) ); + FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); + + UI::UISceneNode* sceneNode = init_test_inline_block(); + + sceneNode->setURI( "file://" + Sys::getProcessPath() + "assets/html/" ); + + std::string html; + FileSystem::fileGet( "assets/html/reddit_header_icons.html", html ); + sceneNode->loadLayoutFromString( HTMLFormatter::HTMLtoXML( html ) ); + win->setClearColor( Color::White ); + + win->getInput()->update(); + SceneManager::instance()->update(); + + win->clear(); + SceneManager::instance()->draw(); + win->display(); + + auto anchors = sceneNode->getRoot()->findAllByTag( "a" ); + + EXPECT_GT( anchors.size(), (size_t)0 ); + + for ( auto anchor : anchors ) { + EXPECT_EQ( anchor->getPixelsSize().getWidth(), 15 ); + EXPECT_EQ( anchor->getPixelsSize().getHeight(), 12 ); + } + + Engine::destroySingleton(); +}