Fix double background being rendered.

This commit is contained in:
Martín Lucas Golini
2026-06-02 14:51:34 -03:00
parent 5030e392df
commit b97232cecc
4 changed files with 35 additions and 4 deletions

View File

@@ -377,7 +377,7 @@
"working_dir": "${project_root}/bin"
},
{
"args": "https://www.0xsid.com/blog/wont-download-your-app",
"args": "-c system --hn-dark",
"command": "${project_root}/bin/eepp-ui-html-debug",
"name": "eepp-ui-html-debug",
"working_dir": "${project_root}/bin"

View File

@@ -45,6 +45,8 @@ class EE_API UITextSpan : public UIRichText {
virtual bool isInlineBlock() const;
virtual void onDisplayChange();
virtual void draw();
virtual bool applyProperty( const StyleSheetProperty& attribute );

View File

@@ -432,8 +432,13 @@ bool UIRichText::applyProperty( const StyleSheetProperty& attribute ) {
break;
}
case PropertyId::BackgroundColor:
setBackgroundColor( attribute.asColor() );
setFontBackgroundColor( attribute.asColor() );
if ( isInline() ) {
setBackgroundColor( Color::Transparent );
setFontBackgroundColor( attribute.asColor() );
} else {
setFontBackgroundColor( Color::Transparent );
setBackgroundColor( attribute.asColor() );
}
break;
case PropertyId::TextShadowColor:
setFontShadowColor( attribute.asColor() );

View File

@@ -70,6 +70,24 @@ bool UITextSpan::isInlineBlock() const {
return mDisplay == CSSDisplay::InlineBlock && getCSSFloat() == CSSFloat::None && !isOutOfFlow();
}
void UITextSpan::onDisplayChange() {
bool nowInline = isInline();
if ( nowInline && getFontBackgroundColor() == Color::Transparent ) {
const Color& widgetBg = getBackgroundColor();
if ( widgetBg != Color::Transparent ) {
setFontBackgroundColor( widgetBg );
setBackgroundColor( Color::Transparent );
}
} else if ( !nowInline && getBackgroundColor() == Color::Transparent ) {
const Color& fontBg = getFontBackgroundColor();
if ( fontBg != Color::Transparent ) {
setBackgroundColor( fontBg );
setFontBackgroundColor( Color::Transparent );
}
}
UIHTMLWidget::onDisplayChange();
}
void UITextSpan::draw() {
// When a UITextSpan is a flex item it is laid out independently by the
// flex container (blockification per CSS Flexbox §4). In that case the
@@ -100,7 +118,13 @@ bool UITextSpan::applyProperty( const StyleSheetProperty& attribute ) {
break;
}
case PropertyId::BackgroundColor:
setFontBackgroundColor( attribute.asColor() );
if ( isInline() ) {
setBackgroundColor( Color::Transparent );
setFontBackgroundColor( attribute.asColor() );
} else {
setFontBackgroundColor( Color::Transparent );
setBackgroundColor( attribute.asColor() );
}
break;
case PropertyId::TextShadowColor:
setFontShadowColor( attribute.asColor() );