Merge branch 'develop' into feature/uiwebview

This commit is contained in:
Martín Lucas Golini
2026-07-03 13:27:51 -03:00
6 changed files with 178 additions and 12 deletions

View File

@@ -257,9 +257,9 @@ class EE_API UIHTMLBody : public UIRichText {
UIHTMLBody( const std::string& tag = "body" );
Float getLocalMinHeight() const;
void setDocumentContentMinHeight( const Float& height );
void updateDocumentMinHeight();
void updateDocumentContentMinHeightFromChildren();
bool setDocumentContentMinHeight( const Float& height );
bool updateDocumentMinHeight();
bool updateDocumentContentMinHeightFromChildren();
virtual Uint32 onMessage( const NodeMessage* Msg );
};

View File

@@ -296,27 +296,33 @@ Float UIHTMLBody::getLocalMinHeight() const {
return convertLengthAsDp( mMinHeightLocal, parentHeight );
}
void UIHTMLBody::setDocumentContentMinHeight( const Float& height ) {
bool UIHTMLBody::setDocumentContentMinHeight( const Float& height ) {
if ( mDocumentContentMinHeight == height )
return;
return false;
mDocumentContentMinHeight = height;
updateDocumentMinHeight();
return updateDocumentMinHeight();
}
void UIHTMLBody::updateDocumentMinHeight() {
bool UIHTMLBody::updateDocumentMinHeight() {
const Float oldMinHeight = getCurMinSize().getHeight();
Float minHeight =
std::max( { getLocalMinHeight(), mDocumentViewportMinHeight, mDocumentContentMinHeight } );
setMinHeight( minHeight );
bool minHeightChanged = minHeight != oldMinHeight;
bool sizeForced = false;
if ( minHeight < oldMinHeight &&
getPixelsSize().getHeight() > PixelDensity::dpToPx( minHeight ) )
getPixelsSize().getHeight() > PixelDensity::dpToPx( minHeight ) ) {
// Lowering min-height does not shrink the current box by itself. Reapply size through
// min/max fitting so the body can settle at the new floor.
setPixelsSize( { getPixelsSize().getWidth(), 0 } );
sizeForced = true;
}
return minHeightChanged || sizeForced;
}
void UIHTMLBody::updateDocumentContentMinHeightFromChildren() {
bool UIHTMLBody::updateDocumentContentMinHeightFromChildren() {
Float maxH = 0;
Node* child = mChild;
@@ -336,7 +342,7 @@ void UIHTMLBody::updateDocumentContentMinHeightFromChildren() {
child = child->getNextNode();
}
setDocumentContentMinHeight( maxH > 0 ? std::trunc( PixelDensity::pxToDp( maxH ) ) : 0 );
return setDocumentContentMinHeight( maxH > 0 ? std::trunc( PixelDensity::pxToDp( maxH ) ) : 0 );
}
Uint32 UIHTMLBody::onMessage( const NodeMessage* Msg ) {
@@ -345,10 +351,10 @@ Uint32 UIHTMLBody::onMessage( const NodeMessage* Msg ) {
if ( Msg->getMsg() == NodeMessage::LayoutAttributeChange && Msg->getSender() != this &&
!mSettingBodyHeight ) {
mSettingBodyHeight = true;
updateDocumentContentMinHeightFromChildren();
bool documentMinHeightChanged = updateDocumentContentMinHeightFromChildren();
mSettingBodyHeight = false;
if ( getParent() && getParent()->isType( UI_TYPE_HTML_HTML ) )
if ( documentMinHeightChanged && getParent() && getParent()->isType( UI_TYPE_HTML_HTML ) )
getParent()->asType<UIHTMLHtml>()->setLayoutDirty( LayoutInvalidation::Document );
}

View File

@@ -0,0 +1,91 @@
#include <eepp/ui/doc/languages/gemini.hpp>
#include <eepp/ui/doc/syntaxdefinitionmanager.hpp>
namespace EE { namespace UI { namespace Doc { namespace Language {
SyntaxDefinition& addGemini() {
return SyntaxDefinitionManager::instance()
->add(
{ "Gemini",
{ "%.gmi$" },
{
{ { "include", "#headings" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
{ { "include", "#links" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
{ { "include", "#quote" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
{ { "include", "#raw" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
{ { "include", "#unorderedLists" },
"normal",
"",
SyntaxPatternMatchType::LuaPattern },
},
{
},
"",
{}
} )
.addRepositories( {
{ "unorderedLists",
{
{ { "^(\\*)[ \t]+.+\n" },
{ "normal", "operator" },
{},
"",
SyntaxPatternMatchType::RegEx },
} },
{ "raw",
{
{ { "^```.*\n", "^```.*\n" },
{ "normal" },
{},
"",
SyntaxPatternMatchType::RegEx },
} },
{ "quote",
{
{ { "^(>).*$" },
{ "string", "operator" },
{},
"",
SyntaxPatternMatchType::RegEx },
} },
{ "links",
{
{ { "^=>[ \t]+([^ \t]+)(?:[ \t]+(.*))?" },
{ "normal", "link", "string" },
{},
"",
SyntaxPatternMatchType::RegEx },
} },
{ "headings",
{
{ { "^(#)(?:[^#].*)?\n" },
{ "keyword", "operator" },
{},
"",
SyntaxPatternMatchType::RegEx },
{ { "^(##)(?:[^#].*)?\n" },
{ "keyword", "operator" },
{},
"",
SyntaxPatternMatchType::RegEx },
{ { "^(###)(?:[^#].*)?\n" },
{ "keyword", "operator" },
{},
"",
SyntaxPatternMatchType::RegEx },
} },
} );
}
}}}} // namespace EE::UI::Doc::Language

View File

@@ -0,0 +1,11 @@
#ifndef EE_UI_DOC_Gemini
#define EE_UI_DOC_Gemini
#include <eepp/ui/doc/syntaxdefinition.hpp>
namespace EE { namespace UI { namespace Doc { namespace Language {
extern SyntaxDefinition& addGemini();
}}}} // namespace EE::UI::Doc::Language
#endif

View File

@@ -38,6 +38,7 @@
#include <eepp/ui/doc/languages/freebasic.hpp>
#include <eepp/ui/doc/languages/fstab.hpp>
#include <eepp/ui/doc/languages/gdscript.hpp>
#include <eepp/ui/doc/languages/gemini.hpp>
#include <eepp/ui/doc/languages/gleam.hpp>
#include <eepp/ui/doc/languages/glsl.hpp>
#include <eepp/ui/doc/languages/gn.hpp>
@@ -359,6 +360,9 @@ static void preDefinitionLangsChunk1( SyntaxDefinitionManager* sdm ) {
{ "%.gd$" },
} );
sdm->addPreDefinition(
{ "Gemini", []() -> SyntaxDefinition& { return addGemini(); }, { "%.gmi$" } } );
sdm->addPreDefinition(
{ "Gleam", []() -> SyntaxDefinition& { return addGleam(); }, { "%.gleam$" } } );

View File

@@ -4223,6 +4223,60 @@ UTEST( UIHTML, BodyDocumentContentMinHeightCanShrink ) {
Engine::destroySingleton();
}
UTEST( UIHTML, BodyNoOpContentHeightChangeDoesNotDirtyHtml ) {
auto win = Engine::instance()->createWindow(
WindowSettings( 800, 600, "body no-op content height change", WindowStyle::Default,
WindowBackend::Default, 32, {}, 1, false, true ),
ContextSettings( false, 0, 0, GLv_default, true, false ) );
UISceneNode* sceneNode = init_test_inline_block();
UIWebView* webView = UIWebView::New();
webView->setParent( sceneNode->getRoot() );
webView->setPixelsSize( win->getWidth(), win->getHeight() );
webView->setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::Fixed );
std::string html = R"html(
<!doctype html>
<html>
<body style="margin: 0;">
<div id="spacer" style="display: block; width: 100px; height: 900px;"></div>
</body>
</html>
)html";
sceneNode->setURI( "file://body-no-op-content-height-change.html" );
sceneNode->loadLayoutFromString( HTMLFormatter::HTMLtoXML( html ),
webView->getDocumentContainer(),
String::hash( "body-no-op-content-height-change" ) );
webView->refreshDocumentLayout();
win->getInput()->update();
SceneManager::instance()->update();
sceneNode->updateDirtyLayouts();
win->getInput()->update();
SceneManager::instance()->update();
sceneNode->updateDirtyLayouts();
auto* htmlNode = sceneNode->getRoot()->findByType( UI_TYPE_HTML_HTML )->asType<UILayout>();
auto* body = sceneNode->getRoot()->findByType( UI_TYPE_HTML_BODY )->asType<UIWidget>();
auto* spacer = sceneNode->getRoot()->find( "spacer" )->asType<UIWidget>();
ASSERT_TRUE( htmlNode != nullptr );
ASSERT_TRUE( body != nullptr );
ASSERT_TRUE( spacer != nullptr );
ASSERT_GT( body->getPixelsSize().getHeight(), 850.f );
ASSERT_FALSE( htmlNode->isLayoutDirty() );
spacer->setPixelsSize(
{ spacer->getPixelsSize().getWidth() + 25.f, spacer->getPixelsSize().getHeight() } );
EXPECT_FALSE( htmlNode->isLayoutDirty() );
win->getInput()->update();
SceneManager::instance()->update();
sceneNode->updateDirtyLayouts();
Engine::destroySingleton();
}
UTEST( UIHTML, DeferredCSSKeepsTableHeightStableAfterViewportResize ) {
std::shared_ptr<ThreadPool> threadPool(
ThreadPool::createShared( eemax<int>( 4, Sys::getCPUCount() ) ) );