Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avm2: Implement line-related methods of TextField #16904

Merged
merged 9 commits into from
Jun 27, 2024

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented Jun 27, 2024

Thanks to #16784, this PR (except bringing some more refactors) implements TextField.getLineLength(), TextField.getLineOffset(), and fixes TextField.getLineText().

A test is added which covers all three methods, and avm2/textfield_getlinetext is removed, because it had a funny mistake that badly influenced the implementation.

@kjarosh kjarosh added text Issues relating to text rendering/input A-avm2 Area: AVM2 (ActionScript 3) labels Jun 27, 2024
@kjarosh kjarosh force-pushed the textfield-line-methods branch 2 times, most recently from 323f472 to cb4b489 Compare June 27, 2024 14:48
@kjarosh kjarosh added the waiting-on-review Waiting on review from a Ruffle team member label Jun 27, 2024
@kjarosh kjarosh force-pushed the textfield-line-methods branch from cb4b489 to 16d8f45 Compare June 27, 2024 18:58
@Dinnerbone Dinnerbone enabled auto-merge (rebase) June 27, 2024 19:22
kjarosh added 9 commits June 27, 2024 21:50
This refactor adds positions to all layout boxes, not only texts.
Positions for bullets and drawings are used only for obtaining
information about their location relative to other layout boxes,
so that searching and other various operations on boxes are easier.
After some past refactors, it's true now that during layout there's
at least one text span, which is ensured by the span normalization.
This refactor simplifies code.
By adding start and end positions to LayoutLine, it's now easy to
calculate the line length, get its text, or search through lines.
The output.txt of this test was invalid,
because it skipped a carriage return after one of the lines.
This has of course something to do with the whole CR/LF/CRLF newline
madness, as the trailing CR formed a CRLF with the "real" newline
character LF, and (I suspect) git replaced it with LF ignoring
CR completely, which badly influenced the current implementation.

This test will be replaced with a proper test when
the implementation is fixed.
This patch makes the implementation more performant, simpler, and
fixes its behavior related to returning the line delimiter and tabs.
This test verifies the behavior of line-related methods of TextField:
* getLineLength(),
* getLineOffset(), and
* getLineText().
@Dinnerbone Dinnerbone force-pushed the textfield-line-methods branch from 16d8f45 to bc89545 Compare June 27, 2024 19:50
@Dinnerbone Dinnerbone merged commit 1d41d23 into ruffle-rs:master Jun 27, 2024
17 checks passed
@kjarosh kjarosh deleted the textfield-line-methods branch June 27, 2024 20:13
@kjarosh kjarosh removed the waiting-on-review Waiting on review from a Ruffle team member label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-avm2 Area: AVM2 (ActionScript 3) newsworthy text Issues relating to text rendering/input
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants