Closed Bug 1198613 Opened 9 years ago Closed 9 years ago

[GTK3] default-styled select element is not tall enough and has text off-center

Categories

(Core :: Widget: Gtk, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox43 --- affected
firefox45 --- fixed

People

(Reporter: dbaron, Assigned: acomminos)

References

(Depends on 1 open bug)

Details

(Whiteboard: [gfx-noted])

Attachments

(5 files, 1 obsolete file)

Since GTK3 was switched on by default, selects on bugzilla (which I believe are default-styled) have been much shorter in height than GTK2 selects, and the text has been a bit off-center.  (This is somewhat similar to bug 1187385 for text inputs.)

I'm running Ubuntu 15.04; I don't think I've changed theme settings much, if at all, although I've upgraded from earlier Ubuntu versions.
Attached image screenshot of bugzilla bug (deleted) —
Blocks: gtk3
Summary: [GTK3] default--styled select element is not tall enough and has text off-center → [GTK3] default-styled select element is not tall enough and has text off-center
Attached image native select, for comparison (deleted) —
(from gnome-terminal comparison)
...er, gnome-terminal preferences
This occurs for me on a 43 nightly, I can confirm.
Whiteboard: [gfx-noted]
Looks like this is caused by an omission of the GTK theme's style padding for dropdown boxes in HTML;

https://dxr.mozilla.org/mozilla-central/rev/c0abc2a6e11f52761366e029eb1bae4c9864a8a3/widget/gtk/gtk3drawing.c#2765

We should probably use it everywhere for consistency and usability's sake.
Assignee: nobody → acomminos
Status: NEW → ASSIGNED
Here's a simple patch to use the style padding in HTML.

This may break some tests that expect the combo box to fit within certain bounds, so depending on this try push there may be followup patches;

https://treeherder.mozilla.org/#/jobs?repo=try&revision=c2ac87bcb689

Thanks!
Attachment #8660193 - Flags: review?(karlt)
Comment on attachment 8660193 [details] [diff] [review]
Use GTK style padding for dropdown boxes in HTML.

This is part of the solution, but the arrow is not positioned correctly.

The drawing code should be consistent, which means calling calculate_button_inner_rect from moz_gtk_combo_box_paint with ignore_focus false, which makes that parameter and the inhtml parameter to moz_gtk_combo_box_paint unnecessary.  I guess we should keep the aWidgetFlags code for NS_THEME_DROPDOWN in nsNativeThemeGTK::GetGtkWidgetAndState() for GTK2 because it means something a little different there.
Attachment #8660193 - Flags: review?(karlt) → review+
Thanks, here's an updated patch with correct inner rect calculation and flag removal.

Try run: https://treeherder.mozilla.org/#/jobs?repo=try&revision=75d9e54c2290
Attachment #8660193 - Attachment is obsolete: true
Attachment #8662691 - Flags: review+
Regarding the vertical off-center issue; the widget code appears to be providing the same (correct) padding for the top and bottom of the <select> tag, so the issue is likely elsewhere. I suspect that it may have something to do with the metrics of the font used (Fira Sans); changing fonts makes the text appear much better centered.
Comment on attachment 8662691 [details] [diff] [review]
Use GTK style padding for dropdown boxes in HTML. Carry r=karlt

This patch makes bugzilla controls extra large on default Gtk3 theme on Fedora. The font approach looks more promising. There's also a bug in gtk - it returns large border/padding values but renders with smaller numbers here:

https://bugzilla.redhat.com/show_bug.cgi?id=1205651#c3
Attached image Adwaita 3.16.6 screenshot with patch (deleted) —
(In reply to Martin Stránský from comment #11)
> Comment on attachment 8662691 [details] [diff] [review]
> This patch makes bugzilla controls extra large on default Gtk3 theme on
> Fedora.

It does make the controls larger, but it seems consistent with native widgets.
(It is still one pixel short, but I don't know what is causing that difference.)

Are you happy with this patch now?
Flags: needinfo?(stransky)
Yes, the patch if fine (although it makes the comboboxes 1 pix. lower than original gtk3 ones). 

IMHO we should match all toolkit elements to the same size, for instance buttons and editable dropdowns are still undersized.
Flags: needinfo?(stransky)
Unfortunately bugzilla is not very good platform for the form testing. Some elements (for instance the summary entry box) are shrink by the html page by some pixels (for instance removed bottom padding) which greatly confused me.

I suggest to test/compare all form sizes on single test page, like this one:
https://www.lehigh.edu/~inwww/form-test.html

and compare those sizes with reference gtk3 application which may be gtk3-demo or gtk3-widget-factory.

For what I see now (with Bug 1187385 fixed) on Fedora/Adwaita with this patch:

Firefox GtkEntry is 27pix high - gtk3 one is 26pix high
Firefox entry is 25pix high - gtk3 one is 26pix high

I'll try to align the sizes with gtk3 and also align the button sizes. I see many elements are modified by forms.css (like checkboxes and so) which may be worth to investigate.
Attached image widget shadows (deleted) —
It appears that Gkt draws a shadow under the widget which we don't draw and the widget looks bigger then.
Depends on: 866955
(In reply to Karl Tomlinson (ni?:karlt) from comment #12)
> It does make the controls larger, but it seems consistent with native
> widgets.
> (It is still one pixel short, but I don't know what is causing that
> difference.)

That's caused by external leading font property. The external leading adds pixels between text rows but Firefox also uses that for single-line elements. When browser.display.normal_lineheight_calc_control is set to 0 the elements match gtk3. 

The external leading is loaded from each font which also explains why different fonts give different results.
https://hg.mozilla.org/mozilla-central/rev/390cb35d9245
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Depends on: 1230065
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: