Skip to content

enable text-overflow property for Servo#270

Open
RichardTjokroutomo wants to merge 2 commits intoservo:mainfrom
RichardTjokroutomo:txt-overflow
Open

enable text-overflow property for Servo#270
RichardTjokroutomo wants to merge 2 commits intoservo:mainfrom
RichardTjokroutomo:txt-overflow

Conversation

@RichardTjokroutomo
Copy link
Contributor

@RichardTjokroutomo RichardTjokroutomo commented Nov 18, 2025

Enable text-overflow for Servo. Companion PR: #40526

Copy link
Collaborator

@Loirooriol Loirooriol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said in the Servo review, since it's not handling strings or 2 values, this should alter the parser to reject these cases for Servo.

Alternatively, you can put this property behind a flag, and then in Servo make it an experimental web platform feature flag. Then it won't be enabled by default, but it will be used in tests.

input: &mut Parser<'i, 't>,
) -> Result<TextOverflow, ParseError<'i>> {
let first = TextOverflowSide::parse(context, input)?;
let first = <TextOverflowSide as Parse>::parse(context, input)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add this?

Copy link
Contributor Author

@RichardTjokroutomo RichardTjokroutomo Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for some reason, stylo now can't correctly decide which Parse to use (or rather, for some reason in the past, it can choose the right one), and so if you don't specify, it will result in a compilation error:

error[E0061]: this function takes 1 argument but 2 arguments were supplied
   --> style\values\specified\text.rs:231:21
    |
231 |         let first = TextOverflowSide::parse(context, input)?;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^ ------- unexpected argument #1 of type `&ParserContext<'_>`
    |
note: associated function defined here
   --> style\values\specified\text.rs:178:5
    |
178 |     Parse,
    |     ^^^^^
    = note: this error originates in the derive macro `Parse` (in Nightly builds, run with -Z macro-backtrace for more info)
help: remove the extra argument
    |
231 -         let first = TextOverflowSide::parse(context, input)?;
231 +         let first = TextOverflowSide::parse(input)?;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo it, no longer needed

first,
second,
sides_are_logical: false,
if let Ok(second) = input.try_parse(|input| <TextOverflowSide as Parse>::parse(context, input)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the other case, the compiler now can't resolve to the correct Parse.

error[E0061]: this function takes 1 argument but 2 arguments were supplied
   --> style\values\specified\text.rs:231:21
    |
231 |         let first = TextOverflowSide::parse(context, input)?;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^ ------- unexpected argument #1 of type `&ParserContext<'_>`
    |
note: associated function defined here
   --> style\values\specified\text.rs:178:5
    |
178 |     Parse,
    |     ^^^^^
    = note: this error originates in the derive macro `Parse` (in Nightly builds, run with -Z macro-backtrace for more info)
help: remove the extra argument
    |
231 -         let first = TextOverflowSide::parse(context, input)?;
231 +         let first = TextOverflowSide::parse(input)?;

@RichardTjokroutomo
Copy link
Contributor Author

@Loirooriol I noticed earlier today that a PR on Stylo has been merged (#271), so I tried to rebase. However, I got some compilation errors.

Copy link
Collaborator

@Loirooriol Loirooriol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since changing the struct affects things more than what I expected, maybe just do something like

        #[cfg(feature = "servo")]
        if matches!(first, TextOverflowSide::String(_)) {
            return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
        }
        #[cfg(feature = "gecko")]
        if let Ok(second) = input.try_parse(|input| TextOverflowSide::parse(context, input)) {
            return Ok(Self {
                first,
                second,
                sides_are_logical: false,
            });
        }
        Ok(Self {
            first: TextOverflowSide::Clip,
            second: first,
            sides_are_logical: true,
        })

Or add support for strings as Nico says in servo/servo#40526 (comment)

Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
@RichardTjokroutomo RichardTjokroutomo force-pushed the txt-overflow branch 2 times, most recently from 18765f5 to f075d49 Compare February 11, 2026 06:40
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants