зеркало из https://github.com/mozilla/gecko-dev.git
bug 1343802 consider scrollbar trough min-width/min-height properties r=jhorak+328198
in determining breadth of trough and scrollbar. MozReview-Commit-ID: 3orNXdv6uZh
This commit is contained in:
Родитель
e9f17ddd35
Коммит
a230b9ad53
|
@ -437,6 +437,18 @@ calculate_arrow_rect(GtkWidget* arrow, GdkRectangle* rect,
|
||||||
return MOZ_GTK_SUCCESS;
|
return MOZ_GTK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MozGtkSize
|
||||||
|
GetMinContentBox(GtkStyleContext* style)
|
||||||
|
{
|
||||||
|
GtkStateFlags state_flags = gtk_style_context_get_state(style);
|
||||||
|
gint width, height;
|
||||||
|
gtk_style_context_get(style, state_flags,
|
||||||
|
"min-width", &width,
|
||||||
|
"min-height", &height,
|
||||||
|
nullptr);
|
||||||
|
return {width, height};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get minimum widget size as sum of margin, padding, border and
|
* Get minimum widget size as sum of margin, padding, border and
|
||||||
* min-width/min-height.
|
* min-width/min-height.
|
||||||
|
@ -2639,34 +2651,42 @@ GetScrollbarMetrics(GtkOrientation aOrientation)
|
||||||
// track
|
// track
|
||||||
style = ClaimStyleContext(track);
|
style = ClaimStyleContext(track);
|
||||||
metrics->border.track = GetMarginBorderPadding(style);
|
metrics->border.track = GetMarginBorderPadding(style);
|
||||||
|
MozGtkSize trackMinSize = GetMinContentBox(style) + metrics->border.track;
|
||||||
ReleaseStyleContext(style);
|
ReleaseStyleContext(style);
|
||||||
MozGtkSize trackSizeForThumb = metrics->size.thumb + metrics->border.track;
|
MozGtkSize trackSizeForThumb = metrics->size.thumb + metrics->border.track;
|
||||||
// button
|
// button
|
||||||
if (hasButtons) {
|
if (hasButtons) {
|
||||||
metrics->size.button = GetMinMarginBox(MOZ_GTK_SCROLLBAR_BUTTON);
|
metrics->size.button = GetMinMarginBox(MOZ_GTK_SCROLLBAR_BUTTON);
|
||||||
if (aOrientation == GTK_ORIENTATION_HORIZONTAL) {
|
} else {
|
||||||
metrics->size.button.Rotate();
|
metrics->size.button = {0, 0};
|
||||||
// If the buttons will cause Gecko to expand the track to fill
|
}
|
||||||
// available breadth, then add to the track border to prevent Gecko
|
if (aOrientation == GTK_ORIENTATION_HORIZONTAL) {
|
||||||
// from expanding the thumb to fill available breadth.
|
metrics->size.button.Rotate();
|
||||||
gint extra = metrics->size.button.height - trackSizeForThumb.height;
|
// If the track is wider than necessary for the thumb, including when
|
||||||
if (extra > 0) {
|
// the buttons will cause Gecko to expand the track to fill
|
||||||
// If extra is odd, then the thumb is 0.5 pixels above
|
// available breadth, then add to the track border to prevent Gecko
|
||||||
// center as in gtk_range_compute_slider_position().
|
// from expanding the thumb to fill available breadth.
|
||||||
metrics->border.track.top += extra / 2;
|
gint extra =
|
||||||
metrics->border.track.bottom += extra - extra / 2;
|
std::max(trackMinSize.height,
|
||||||
// Update size for change in border.
|
metrics->size.button.height) - trackSizeForThumb.height;
|
||||||
trackSizeForThumb.height += extra;
|
if (extra > 0) {
|
||||||
}
|
// If extra is odd, then the thumb is 0.5 pixels above
|
||||||
} else {
|
// center as in gtk_range_compute_slider_position().
|
||||||
gint extra = metrics->size.button.width - trackSizeForThumb.width;
|
metrics->border.track.top += extra / 2;
|
||||||
if (extra > 0) {
|
metrics->border.track.bottom += extra - extra / 2;
|
||||||
// If extra is odd, then the thumb is 0.5 pixels to the left
|
// Update size for change in border.
|
||||||
// of center as in gtk_range_compute_slider_position().
|
trackSizeForThumb.height += extra;
|
||||||
metrics->border.track.left += extra / 2;
|
}
|
||||||
metrics->border.track.right += extra - extra / 2;
|
} else {
|
||||||
trackSizeForThumb.width += extra;
|
gint extra =
|
||||||
}
|
std::max(trackMinSize.width,
|
||||||
|
metrics->size.button.width) - trackSizeForThumb.width;
|
||||||
|
if (extra > 0) {
|
||||||
|
// If extra is odd, then the thumb is 0.5 pixels to the left
|
||||||
|
// of center as in gtk_range_compute_slider_position().
|
||||||
|
metrics->border.track.left += extra / 2;
|
||||||
|
metrics->border.track.right += extra - extra / 2;
|
||||||
|
trackSizeForThumb.width += extra;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче