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

Don't scale single-char text divs. #5221

Merged

Conversation

nnethercote
Copy link
Contributor

This change makes scrolling noticeably smoother on files with many
single-char text divs, such as the one in #1045. The trade-off is that
the visual appearance of text selection in such documents is slightly
worse, because more text divs overlap.

This change also uses scaleX(N) instead of scale(N, 1). This might
be marginally more efficient in terms of JS string concatenation.

Here's a screenshot showing text selection and search selection prior to my change:

genre-old

Here's the equivalent screenshot after my change:

genre-new

The old code gave very little overlap, but some gaps. The new code gives more overlap, but no gaps. Neither of them look great!

This change makes scrolling noticeably smoother on files with many
single-char text divs, such as the one in mozilla#1045. The trade-off is that
the visual appearance of text selection in such documents is slightly
worse, because more text divs overlap.

This change also uses `scaleX(N)` instead of `scale(N, 1)`. This might
be marginally more efficient in terms of JS string concatenation.
@Snuffleupagus
Copy link
Collaborator

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.22.172.223:8877/482b3ad87107556/output.txt

yurydelendik added a commit that referenced this pull request Sep 8, 2014
…-divs

Don't scale single-char text divs.
@yurydelendik yurydelendik merged commit b3be74d into mozilla:master Sep 8, 2014
@yurydelendik
Copy link
Contributor

Thank you

@CodingFabian
Copy link
Contributor

I just saw i forgot to comment on this issue. Now that yury merged it, i got reminded. Wouldn't it be possible to tweak the css, so that the overlapping sections do not look darker?

@rocallahan
Copy link

If you give the text a solid selection color, but wrap all the text in a container element with "opacity", the selection will not get darker where it overlaps.

@CodingFabian
Copy link
Contributor

i assume it also would lighten the load on the renderer

CodingFabian added a commit to CodingFabian/pdf.js that referenced this pull request Sep 9, 2014
As a consequence of merging mozilla#5221 it is more likely to have multiple
overlapping selection divs inside the text layer. Because each individual
element gets the selection style applied, the 30%opacity stacks, making a
60% bar visible where the overlap happens.

As proposed by @rocallahan, this can be fixed by making the selection
style solid and setting opacity for the overall layer.

I assume also that this should make the work for the renderer easier, but
was unable to bench it.
CodingFabian added a commit to CodingFabian/pdf.js that referenced this pull request Sep 9, 2014
As a consequence of merging mozilla#5221 it is more likely to have multiple
overlapping selection divs inside the text layer. Because each individual
element gets the selection style applied, the 30%opacity stacks, making a
60% bar visible where the overlap happens.

As proposed by @rocallahan, this can be fixed by making the selection
style solid and setting opacity for the overall layer.

I assume also that this should make the work for the renderer easier, but
was unable to bench it.
CodingFabian added a commit to CodingFabian/pdf.js that referenced this pull request Sep 9, 2014
As a consequence of merging mozilla#5221 it is more likely to have multiple
overlapping selection divs inside the text layer. Because each individual
element gets the selection style applied, the 30%opacity stacks, making a
60% bar visible where the overlap happens.

As proposed by @rocallahan, this can be fixed by making the selection
style solid and setting opacity for the overall layer.

I assume also that this should make the work for the renderer easier, but
was unable to bench it.
CodingFabian added a commit to CodingFabian/pdf.js that referenced this pull request Sep 9, 2014
As a consequence of merging mozilla#5221 it is more likely to have multiple
overlapping selection divs inside the text layer. Because each individual
element gets the selection style applied, the 30%opacity stacks, making a
60% bar visible where the overlap happens.

As proposed by @rocallahan, this can be fixed by making the selection
style solid and setting opacity for the overall layer.

I assume also that this should make the work for the renderer easier, but
was unable to bench it.
@nnethercote nnethercote deleted the dont-scale-single-char-text-divs branch March 24, 2015 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants