Closed Bug 1837424 Opened 2 years ago Closed 1 year ago

Use the computed style to determine inline vs block elements in the TranslationsDocument

Categories

(Firefox :: Translations, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
122 Branch
Tracking Status
relnote-firefox --- 122+
firefox122 --- fixed

People

(Reporter: gregtatum, Assigned: gregtatum)

References

Details

Attachments

(1 file, 2 obsolete files)

Right now there is a bunch of complicated heuristic-based code to determine if elements are block elements, or inline elements. This is something the browser engine can provide with the computed style. This would mean that we could simplify the code, and provide higher quality translations.

These heuristics are easy to get wrong, since it's ultimately the style, not the tag type, that determines if an element is block or inline. I'm not sure the overall cost for computing the style for each element we walk, but it's something that is worth experimenting with and measuring to see if it's feasible to do.

Summary: Consider using the computed style to determine inline vs block elements in the TranslationDocument → Consider using the computed style to determine inline vs block elements in the TranslationsDocument
No longer blocks: fx-translation
Blocks: 1843914

I just wrote a really bad version of this to measure the performance, and on elpais.com getComputedStyle was called 551 times, and it didn't show up in the profile, so it should be fast.

Blocks: 1849975
Summary: Consider using the computed style to determine inline vs block elements in the TranslationsDocument → Use the computed style to determine inline vs block elements in the TranslationsDocument
Blocks: 1852379

(In reply to Greg Tatum [:gregtatum] from comment #1)

I just wrote a really bad version of this to measure the performance, and on elpais.com getComputedStyle was called 551 times, and it didn't show up in the profile, so it should be fast.

Could you attach the patch here if it is not too dirty so somebody else could finish it up?

Flags: needinfo?(gtatum)

Removing from blocking bug 1838721, since it is already blocking bug 1837421, which in turn blocks bug 1838721.

No longer blocks: 1838721
Attached file example.patch (obsolete) —
> Could you attach the patch here if it is not too dirty so somebody else could finish it up? I can't seem to find it locally. I must have deleted it since it was a fairly trivial change: ```
Attached patch patch (obsolete) — Splinter Review

I can't find the patch I wrote, I must have deleted it. It was a pretty small one, something like this.

Flags: needinfo?(gtatum)
No longer blocks: 1849975
Blocks: 1852062
Attachment #9357666 - Attachment is obsolete: true
Attachment #9357667 - Attachment is obsolete: true
Blocks: 1836117
Blocks: 1839668
Blocks: 1840126
Blocks: 1840913
Blocks: 1849553
Blocks: 1858400
Blocks: 1862339
Blocks: 1863025
Blocks: 1867787

getIsInline took 15ms and nodeNeedsSubdividing took 20ms on a very heavy page with lots of nodes: https://share.firefox.dev/3RDIClz

On the main branch nodeNeedsSubdividing took 13ms took https://share.firefox.dev/48c8sTb

It's a very minimal impact for the benefit it brings.

It had no real impact on my benchmark: https://gregtatum.github.io/taskcluster-tools/benchmark.html

Assignee: nobody → gtatum
Status: NEW → ASSIGNED
Pushed by gtatum@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/be323c04c7dd Change the TranslationsDocument to use computed inline values r=translations-reviewers,nordzilla
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 122 Branch

Release Note Request
[Why is this notable]:

This improved the translations algorithm in a way that closed 12 bugs about broken translations. The results were really noticeably better.

[Suggested wording]:

The translations feature received an improvement to the quality of translated webpages. The results should be much more stable. This fixes issues where the content of a page could disappear when translated, or interactive widgets could break.

[Links (documentation, blog post, etc)]:

The translation feature is documented here: https://support.mozilla.org/en-US/kb/website-translation

relnote-firefox: --- → ?

Thanks, added to the Fx122 nightly release notes, please allow 30 minutes for the site to update.
Keeping the relnote-firefox flag as ? to keep it on the radar for inclusion in the final Fx122 release notes

Duplicate of this bug: 1875232

(In reply to Greg Tatum [:gregtatum] from comment #11)

This improved the translations algorithm in a way that closed 12 bugs about broken translations. The results were really noticeably better.

13 ;)

Regressions: 1909632
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: