Fix bug in CSS id selectors not working properly because we were lower-casing them for no reason.

This commit is contained in:
Martín Lucas Golini
2026-05-22 01:11:39 -03:00
parent ba3576aa8c
commit 428cd55c48
3 changed files with 12 additions and 8 deletions

View File

@@ -8,10 +8,7 @@ StyleSheetSelector::StyleSheetSelector() : mName( "*" ), mSpecificity( 0 ), mCac
}
StyleSheetSelector::StyleSheetSelector( const std::string& selectorName ) :
mName( String::toLower( selectorName ) ),
mSpecificity( 0 ),
mCacheable( true ),
mStructurallyVolatile( false ) {
mName( selectorName ), mSpecificity( 0 ), mCacheable( true ), mStructurallyVolatile( false ) {
parseSelector( mName );
}

View File

@@ -87,19 +87,21 @@ void StyleSheetSelectorRule::pushSelectorTypeIdentifier( TypeIdentifier selector
std::string name ) {
switch ( selectorTypeIdentifier ) {
case GLOBAL:
mTagName = name;
String::toLowerInPlace( name );
mTagName = std::move( name );
mSpecificity += SpecificityGlobal;
break;
case TAG:
mTagName = name;
String::toLowerInPlace( name );
mTagName = std::move( name );
mSpecificity += SpecificityTag;
break;
case CLASS:
mClasses.push_back( name );
mClasses.push_back( std::move( name ) );
mSpecificity += SpecificityClass;
break;
case ID:
mId = name;
mId = std::move( name );
mSpecificity += SpecificityId;
break;
default:

View File

@@ -2234,14 +2234,19 @@ UTEST( UIHTML, RedditHeaderPagenameBottomAlign ) {
auto* headerLeft = sceneNode->getRoot()->find( "header-bottom-left" )->asType<UIHTMLWidget>();
auto* logo = sceneNode->getRoot()->find( "header-img" )->asType<UIHTMLWidget>();
auto* page = sceneNode->getRoot()->querySelector( ".pagename" )->asType<UIHTMLWidget>();
auto* jumpToContent = sceneNode->getRoot()->find( "jumpToContent" )->asType<UIHTMLWidget>();
ASSERT_TRUE( headerLeft != nullptr );
ASSERT_TRUE( logo != nullptr );
ASSERT_TRUE( page != nullptr );
ASSERT_TRUE( jumpToContent != nullptr );
EXPECT_EQ( logo->getBaselineAlign().type, CSSBaselineAlignment::Bottom );
EXPECT_EQ( page->getBaselineAlign().type, CSSBaselineAlignment::Bottom );
EXPECT_NEAR( headerLeft->getPixelsSize().getHeight(),
page->getPixelsPosition().y + page->getPixelsSize().getHeight(), 0.5f );
EXPECT_EQ( CSSPosition::Absolute, jumpToContent->getCSSPosition() );
EXPECT_NEAR( -865.f, jumpToContent->convertToWorldSpace( { 0, 0 } ).x, 1.f );
EXPECT_NEAR( 25.f, jumpToContent->convertToWorldSpace( { 0, 0 } ).y, 1.f );
Engine::destroySingleton();
}