Use calc() to avoid hard-coded height of Synced Tabs panel

RESOLVED FIXED in Firefox 48

Status

()

Firefox
Sync
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: markh, Assigned: tcsc)

Tracking

Trunk
Firefox 48
Points:
---
Dependency tree / graph
Bug Flags:
firefox-backlog +

Firefox Tracking Flags

(firefox47 affected, firefox48 fixed)

Details

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
In bug 1236372, the SyncedTabs CSS has a work-around for bug 1224412, in which we use a hard-coded min-height declaration to prevent scrollbars in the panel in some cases. In bug 1236372 comment 7, Gijs suggests using calc() to avoid hardcoding px - this bug is to track doing that (but even better would be for bug 1224412 to be fixed so we can remove the workaround completely.
Flags: firefox-backlog+
(Reporter)

Updated

2 years ago
Blocks: 1251842
(Assignee)

Comment 1

2 years ago
Gijs, if I'm understanding correctly, this would require duplicating the 180px right? Is that necessarily a good idea?
(Assignee)

Updated

2 years ago
Flags: needinfo?(gijskruitbosch+bugs)

Comment 2

2 years ago
(In reply to Thom Chiovoloni [:tcsc] from comment #1)
> Gijs, if I'm understanding correctly, this would require duplicating the
> 180px right? Is that necessarily a good idea?

180px is the width, and we're dealing with the height. Is the image in question actually square?

Anyway, you don't need to duplicate the image size - you can use a CSS variable to avoid doing that.
Flags: needinfo?(gijskruitbosch+bugs)
(Assignee)

Comment 3

2 years ago
Ah, yeah, that's right (unfortunately, I didn't look as closely as I should have). The height is 157.5px, and specifying the image size that way, and using it in the calc (with var) would work fine.

So, just to check, you're thinking something like `calc(var(--panel-ui-sync-illustration-height) + 19em)`? I'm not positive this has a huge benefit (other than moving the image size out, which is nice, I guess), since the 19em has most of the same problems as the 33em (e.g. it's dependent on the number of lines of text, is larger than necessary for some languages, etc). 

Computing it based on the number of lines seems like it would be more ideal to me, but it has the downside of requiring the line height and margin sizes be specified in the calc...

Or am I totally confused about this? If you think something like the calc expression above is what we want, I'll absolutely make a patch for it, I'm just not certain it *is* in fact what you mean.
Flags: needinfo?(gijskruitbosch+bugs)

Comment 4

2 years ago
(In reply to Thom Chiovoloni [:tcsc] from comment #3)
> Ah, yeah, that's right (unfortunately, I didn't look as closely as I should
> have). The height is 157.5px, and specifying the image size that way, and
> using it in the calc (with var) would work fine.
> 
> So, just to check, you're thinking something like
> `calc(var(--panel-ui-sync-illustration-height) + 19em)`? I'm not positive
> this has a huge benefit (other than moving the image size out, which is
> nice, I guess), since the 19em has most of the same problems as the 33em
> (e.g. it's dependent on the number of lines of text, is larger than
> necessary for some languages, etc). 

<snip>

> Or am I totally confused about this? If you think something like the calc
> expression above is what we want, I'll absolutely make a patch for it, I'm
> just not certain it *is* in fact what you mean.

Not totally confused, but I think you're missing something (or maybe I am). The benefit of using effectively something like:

calc(157.5px + 19em);

is that it represents the boxes that in the container: one fixed size in pixels, one (kind of) fixed size on text.

I'm not really trying to solve the "German strings are really long" problem. I'm trying to solve the "1em might be different on different machines" problem.

Specifically, if you were to test a German build and used the Windows font settings to make text quite small or quite large, we will mis-size this panel. calc() with a combination of the px-fixed and em-fixed values separately helps avoid that problem, where both a fixed-in-px value (doesn't work with large text) and a fixed-in-em value (doesn't work with small text) would break.

Does that help?

(FWIW, it's true that we don't know the number of lines of text, and can't do without some help from JS or something... I'd like to avoid going down that rabbithole for now unless it becomes necessary. One thing we've done in the past is making the size in question be a localized string that localizers can adjust for their locale, but to a certain degree it's not very fair to shift the burden that way, and it's not often possible for localizers to test all the platforms we ship on...)
Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(tchiovoloni)
(Assignee)

Comment 5

2 years ago
> I'm not really trying to solve the "German strings are really long" 
> problem. I'm trying to solve the "1em might be different on different 
> machines" problem.

Ah, this makes more sense. Although, since the margin sizes are specified in px it's going to be a little more complex than just 157.5px + 19em, but it still should be doable.
Flags: needinfo?(tchiovoloni)
(Assignee)

Comment 6

2 years ago
Created attachment 8738617 [details]
MozReview Request: Bug 1248506 - Replace hardcoded height of synced tab panel with calc expression based on content size r?gijs

Review commit: https://reviewboard.mozilla.org/r/44611/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/44611/
Attachment #8738617 - Flags: review?(gijskruitbosch+bugs)
(Assignee)

Updated

2 years ago
Assignee: nobody → tchiovoloni
Status: NEW → ASSIGNED

Comment 7

2 years ago
Comment on attachment 8738617 [details]
MozReview Request: Bug 1248506 - Replace hardcoded height of synced tab panel with calc expression based on content size r?gijs

https://reviewboard.mozilla.org/r/44611/#review41321

r=me with the extra comment. Your choice about the structure of the calc here, see below.

::: browser/themes/shared/customizableui/panelUIOverlay.inc.css:755
(Diff revision 1)
> +     paddings of the items contained in the panel (that is, of
> +     .PanelUI-remotetabs-instruction-label, .PanelUI-remotetabs-instruction-box,
> +     and .PanelUI-remotetabs-prefs-button).
> +  */
> +  min-height: calc(var(--panel-ui-sync-illustration-height) +
> +                   10px * 2 + 8px * 2 + 15px * 2 + 30px + 15px +

TBH, I would just stick all of these on one line per thing and pre-multiply:

20px /* margin of foobar */ +
16px /* padding of flopsy */ +
30px /* ... */

but I don't really care too much.

I do think it'd make sense to add a comment where we're setting the "original"s of these numbers noting that the min-height here might need updating if they get changed.
Attachment #8738617 - Flags: review?(gijskruitbosch+bugs) → review+
(Assignee)

Comment 8

2 years ago
Comment on attachment 8738617 [details]
MozReview Request: Bug 1248506 - Replace hardcoded height of synced tab panel with calc expression based on content size r?gijs

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/44611/diff/1-2/
(Assignee)

Updated

2 years ago
Keywords: checkin-needed

Comment 10

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/572875411dba
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox48: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 48
You need to log in before you can comment on or make changes to this bug.