mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Body height miscalculation fix.
This commit is contained in:
3196
bin/unit_tests/assets/html/body_height_miscalculation.css
Normal file
3196
bin/unit_tests/assets/html/body_height_miscalculation.css
Normal file
File diff suppressed because it is too large
Load Diff
466
bin/unit_tests/assets/html/body_height_miscalculation.html
Normal file
466
bin/unit_tests/assets/html/body_height_miscalculation.html
Normal file
File diff suppressed because one or more lines are too long
@@ -46,6 +46,8 @@ class EE_API UIHTMLWidget : public UILayout {
|
||||
|
||||
void setCSSClear( CSSClear cssClear );
|
||||
|
||||
Rectf getNormalFlowLayoutPixelsMargin() const;
|
||||
|
||||
const CSSBaselineAlignValue& getBaselineAlign() const { return mBaselineAlign; }
|
||||
|
||||
void setBaselineAlign( const CSSBaselineAlignValue& baselineAlign );
|
||||
|
||||
@@ -435,7 +435,10 @@ void BlockLayouter::positionRichTextChildren( Graphics::RichText* rt ) {
|
||||
curCharIdx += 1;
|
||||
Rectf atomicBounds( maxF, maxF, lowF, lowF );
|
||||
if ( getAtomicWidgetFragmentBounds( widget, atomicBounds ) ) {
|
||||
Rectf margin = widget->getLayoutPixelsMargin();
|
||||
Rectf margin =
|
||||
widget->isType( UI_TYPE_HTML_WIDGET )
|
||||
? widget->asType<UIHTMLWidget>()->getNormalFlowLayoutPixelsMargin()
|
||||
: widget->getLayoutPixelsMargin();
|
||||
Vector2f targetPos( atomicBounds.Left + margin.Left,
|
||||
atomicBounds.Top + margin.Top );
|
||||
|
||||
@@ -459,7 +462,10 @@ void BlockLayouter::positionRichTextChildren( Graphics::RichText* rt ) {
|
||||
|
||||
size_t lineIdx = currentSpan > 0 ? currentLine : currentLine - 1;
|
||||
Float lineY = lines[lineIdx].y;
|
||||
Rectf margin = widget->getLayoutPixelsMargin();
|
||||
Rectf margin =
|
||||
widget->isType( UI_TYPE_HTML_WIDGET )
|
||||
? widget->asType<UIHTMLWidget>()->getNormalFlowLayoutPixelsMargin()
|
||||
: widget->getLayoutPixelsMargin();
|
||||
|
||||
Vector2f targetPos( contentOffset.Left + span->position.x + margin.Left,
|
||||
contentOffset.Top + lineY + span->position.y + margin.Top );
|
||||
|
||||
@@ -154,6 +154,15 @@ void UIHTMLWidget::setCSSClear( CSSClear cssClear ) {
|
||||
}
|
||||
}
|
||||
|
||||
Rectf UIHTMLWidget::getNormalFlowLayoutPixelsMargin() const {
|
||||
Rectf margin = getLayoutPixelsMargin();
|
||||
if ( hasLayoutMarginTopAuto() )
|
||||
margin.Top = 0.f;
|
||||
if ( hasLayoutMarginBottomAuto() )
|
||||
margin.Bottom = 0.f;
|
||||
return margin;
|
||||
}
|
||||
|
||||
void UIHTMLWidget::setBaselineAlign( const CSSBaselineAlignValue& baselineAlign ) {
|
||||
if ( mBaselineAlign != baselineAlign ) {
|
||||
mBaselineAlign = baselineAlign;
|
||||
|
||||
@@ -1331,7 +1331,10 @@ void UIRichText::rebuildRichText( UILayout* container, RichText& richText, Intri
|
||||
"\n", widget->asType<UILineBreak>()->getRichText().getFontStyleConfig() );
|
||||
lastSpanEndsWithSpace = false;
|
||||
} else {
|
||||
Rectf margin = widget->getLayoutPixelsMargin();
|
||||
Rectf margin =
|
||||
widget->isType( UI_TYPE_HTML_WIDGET )
|
||||
? widget->asType<UIHTMLWidget>()->getNormalFlowLayoutPixelsMargin()
|
||||
: widget->getLayoutPixelsMargin();
|
||||
bool isBlock = widget->getLayoutWidthPolicy() == SizePolicy::MatchParent;
|
||||
if ( widget->isType( UI_TYPE_HTML_WIDGET ) ) {
|
||||
CSSDisplay display = widget->asType<UIHTMLWidget>()->getDisplay();
|
||||
|
||||
@@ -1650,6 +1650,8 @@ static UISceneNode* init_test_inline_block() {
|
||||
font = FontTrueType::New( "NotoSans-Regular" );
|
||||
font->loadFromFile( "../assets/fonts/NotoSans-Regular.ttf" );
|
||||
FontFamily::loadFromRegular( font );
|
||||
FontTrueType* monoFont = FontTrueType::New( "monospace" );
|
||||
monoFont->loadFromFile( "../assets/fonts/NotoSans-Regular.ttf" );
|
||||
UISceneNode* sceneNode = UISceneNode::New();
|
||||
SceneManager::instance()->add( sceneNode );
|
||||
SceneManager::instance()->setCurrentUISceneNode( sceneNode );
|
||||
@@ -2002,6 +2004,33 @@ UTEST( UIHTML, HeightExpansion_FixedDoesNotExpand ) {
|
||||
Engine::destroySingleton();
|
||||
}
|
||||
|
||||
UTEST( UIHTML, BodyHeightMiscalculationFixture ) {
|
||||
Engine::instance()->createWindow( WindowSettings( 1024, 653, "Body Height Miscalculation Test",
|
||||
WindowStyle::Default, WindowBackend::Default,
|
||||
32, {}, 1, false, true ),
|
||||
ContextSettings( false, 0, 0, GLv_default, true, false ) );
|
||||
|
||||
UI::UISceneNode* sceneNode = init_test_inline_block();
|
||||
sceneNode->setURI( "file://" + Sys::getProcessPath() + "assets/html/" );
|
||||
|
||||
std::string html;
|
||||
FileSystem::fileGet( "assets/html/body_height_miscalculation.html", html );
|
||||
|
||||
sceneNode->loadLayoutFromString( HTMLFormatter::HTMLtoXML( html ) );
|
||||
sceneNode->update( Seconds( 1 ) );
|
||||
sceneNode->updateDirtyLayouts();
|
||||
|
||||
auto bodyNode = sceneNode->getRoot()->findByType( UI_TYPE_HTML_BODY );
|
||||
ASSERT_TRUE( bodyNode != nullptr );
|
||||
|
||||
auto bodyWidget = bodyNode->asType<UIWidget>();
|
||||
|
||||
EXPECT_GT( bodyWidget->getPixelsSize().getHeight(), 3000.f );
|
||||
EXPECT_LT( bodyWidget->getPixelsSize().getHeight(), 6000.f );
|
||||
|
||||
Engine::destroySingleton();
|
||||
}
|
||||
|
||||
UTEST( UIHTML, ContactFormLayout ) {
|
||||
Engine::instance()->createWindow( WindowSettings( 1024, 653, "Contact Form Layout Test",
|
||||
WindowStyle::Default, WindowBackend::Default,
|
||||
|
||||
Reference in New Issue
Block a user