From f4c735ee4e31e003bdac9a8b45684354da00a53a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 14 Aug 2016 13:09:55 -0700 Subject: [PATCH] UI: Allow scrollviews to wrap content. In the opposing direction, we can't AT_MOST if we don't have a good size and we're wrapping content. This can happen inside a LinearLayout. --- ext/native/ui/viewgroup.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ext/native/ui/viewgroup.cpp b/ext/native/ui/viewgroup.cpp index bf3a5e3645..89d0c2d577 100644 --- a/ext/native/ui/viewgroup.cpp +++ b/ext/native/ui/viewgroup.cpp @@ -639,10 +639,18 @@ void ScrollView::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec ver if (views_.size()) { if (orientation_ == ORIENT_HORIZONTAL) { - views_[0]->Measure(dc, MeasureSpec(UNSPECIFIED, measuredWidth_), MeasureSpec(AT_MOST, measuredHeight_ - margins.vert())); + MeasureSpec v = MeasureSpec(AT_MOST, measuredHeight_ - margins.vert()); + if (measuredHeight_ == 0.0f && layoutParams_->height == WRAP_CONTENT) { + v.type = UNSPECIFIED; + } + views_[0]->Measure(dc, MeasureSpec(UNSPECIFIED, measuredWidth_), v); MeasureBySpec(layoutParams_->height, views_[0]->GetMeasuredHeight(), vert, &measuredHeight_); } else { - views_[0]->Measure(dc, MeasureSpec(AT_MOST, measuredWidth_ - margins.horiz()), MeasureSpec(UNSPECIFIED, measuredHeight_)); + MeasureSpec h = MeasureSpec(AT_MOST, measuredWidth_ - margins.horiz()); + if (measuredWidth_ == 0.0f && layoutParams_->width == WRAP_CONTENT) { + h.type = UNSPECIFIED; + } + views_[0]->Measure(dc, h, MeasureSpec(UNSPECIFIED, measuredHeight_)); MeasureBySpec(layoutParams_->width, views_[0]->GetMeasuredWidth(), horiz, &measuredWidth_); } if (orientation_ == ORIENT_VERTICAL && vert.type != EXACTLY) {