Skip to content

Commit

Permalink
fix(gui): the block element default width should be 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Aug 5, 2018
1 parent 49e3d8b commit adcb9e7
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/gui/widget_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,8 @@ void Widget_AutoSize(LCUI_Widget w)

static void Widget_ComputeSize(LCUI_Widget w)
{
float width, height, max_width = -1;
float width, height;
float max_width = -1, default_width = -1;

Widget_ComputeLimitSize(w);
width = ComputeXMetric(w, key_width);
Expand All @@ -1249,18 +1250,21 @@ static void Widget_ComputeSize(LCUI_Widget w)
width = ToContentBoxWidth(w, width);
height = ToContentBoxHeight(w, height);
}
if (Widget_HasAutoStyle(w, key_width)) {
if (Widget_HasFillAvailableWidth(w)) {
width = Widget_ComputeFillAvailableWidth(w);
width = ToContentBoxWidth(w, width);
if (!Widget_HasStaticWidthParent(w)) {
max_width = width;
width = 0;
if (Widget_HasAutoStyle(w, key_width) && Widget_HasFillAvailableWidth(w)) {
width = Widget_ComputeFillAvailableWidth(w);
width = ToContentBoxWidth(w, width);
if (!Widget_HasStaticWidthParent(w)) {
default_width = w->parent->box.content.width;
if (w->computed_style.box_sizing == SV_BORDER_BOX) {
default_width = ToContentBoxWidth(w, default_width);
}
max_width = width;
width = 0;
}
Widget_ComputeContentSize(w, &width, &height);
} else {
Widget_ComputeContentSize(w, &width, &height);
}
Widget_ComputeContentSize(w, &width, &height);
if (default_width != -1 && width < default_width) {
width = default_width;
}
if (max_width != -1 && width > max_width) {
width = max_width;
Expand Down

0 comments on commit adcb9e7

Please sign in to comment.