Skip to content

UILabel: Investigate removing the Textblock->Measure call from UIKit.Label::ArangeOverride #1946

Open

Description

It's unclear whether or not we actually need this call to Measure. While adding border support to UILabel, I found that it can lead to layout cycles if our root Grid passes a different size value into Measure than it does into arrange.

In order to replicate how text is vertically aligned on the reference platform, we do the following in our ArrangeOverride:

Windows::Foundation::Size Label::ArrangeOverride(Windows::Foundation::Size finalSize) {
    // Make sure we render vertically-centered text if possible, else cap at the containing layer's height.
    TextBlock->Measure(finalSize);
    if (TextBlock->DesiredSize.Height >= finalSize.Height) {
        TextBlock->VerticalAlignment = Windows::UI::Xaml::VerticalAlignment::Top;
    } else {
        TextBlock->VerticalAlignment = Windows::UI::Xaml::VerticalAlignment::Center;
    }

    return __super::ArrangeOverride(finalSize);
}

However, the Xaml team says we probably don't need the extra call to TextBlock->Measure. If we can get rid of the call, we should, but doing so will require quite a bit of scrutiny and regression testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions