From ee6d1b8fa8477845edc7155709f5e798812bb5d3 Mon Sep 17 00:00:00 2001 From: Jared Date: Sat, 11 Feb 2017 10:43:31 -0800 Subject: [PATCH] Move UIKit.Xaml DependencyProperty registration out of UIKit.Layer's constructor. (#1949) Fixes #1930. --- Frameworks/UIKit.Xaml/Label.xaml.cpp | 1 + Frameworks/UIKit.Xaml/Layer.xaml.cpp | 5 +++++ Frameworks/UIKit.Xaml/Layer.xaml.h | 5 ++++- Frameworks/UIKit.Xaml/ObjCXamlControls.h | 3 +++ Frameworks/UIKit/StarboardXaml/XamlCompositor.cpp | 3 +++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Frameworks/UIKit.Xaml/Label.xaml.cpp b/Frameworks/UIKit.Xaml/Label.xaml.cpp index a53527047f..2c5eb4774d 100644 --- a/Frameworks/UIKit.Xaml/Label.xaml.cpp +++ b/Frameworks/UIKit.Xaml/Label.xaml.cpp @@ -61,6 +61,7 @@ Canvas^ Label::SublayerCanvas::get() { 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. + // TODO: Issue #1946: Do we actually need this call to Measure? TextBlock->Measure(finalSize); if (TextBlock->DesiredSize.Height >= finalSize.Height) { TextBlock->VerticalAlignment = Windows::UI::Xaml::VerticalAlignment::Top; diff --git a/Frameworks/UIKit.Xaml/Layer.xaml.cpp b/Frameworks/UIKit.Xaml/Layer.xaml.cpp index 89307f3868..173a783a48 100644 --- a/Frameworks/UIKit.Xaml/Layer.xaml.cpp +++ b/Frameworks/UIKit.Xaml/Layer.xaml.cpp @@ -105,6 +105,11 @@ void Layer::_RegisterDependencyProperties() { // ObjectiveC Interop //////////////////////////////////////////////////////////////////////////////////// +// Initializes our library for use; registers dependency properties, etc. +UIKIT_XAML_EXPORT void UIKitXamlInitialize() { + UIKit::Xaml::Private::CoreAnimation::Layer::_RegisterDependencyProperties(); +} + // Set one or more layer properties for the specified target xaml element UIKIT_XAML_EXPORT void XamlSetFrameworkElementLayerProperties( const Microsoft::WRL::ComPtr& targetElement, diff --git a/Frameworks/UIKit.Xaml/Layer.xaml.h b/Frameworks/UIKit.Xaml/Layer.xaml.h index 0d7a8bc7f3..76d4a89384 100644 --- a/Frameworks/UIKit.Xaml/Layer.xaml.h +++ b/Frameworks/UIKit.Xaml/Layer.xaml.h @@ -73,12 +73,15 @@ public ref class Layer sealed : public ILayer { Windows::UI::Xaml::DependencyProperty^ get(); } +internal: + // Static entry point to register our dependency properties + static void _RegisterDependencyProperties(); + private: // Layer elements; created on demand Windows::UI::Xaml::Controls::Image^ _content; // Dependency properties for adding layer-like functionality to any FrameworkElement - static void _RegisterDependencyProperties(); static bool s_dependencyPropertiesRegistered; static Windows::UI::Xaml::DependencyProperty^ s_layerContentProperty; static Windows::UI::Xaml::DependencyProperty^ s_sublayerCanvasProperty; diff --git a/Frameworks/UIKit.Xaml/ObjCXamlControls.h b/Frameworks/UIKit.Xaml/ObjCXamlControls.h index 36c5c72d16..0a9eb1e766 100644 --- a/Frameworks/UIKit.Xaml/ObjCXamlControls.h +++ b/Frameworks/UIKit.Xaml/ObjCXamlControls.h @@ -66,6 +66,9 @@ UIKIT_XAML_EXPORT IInspectable* XamlGetLabelTextBox(const Microsoft::WRL::ComPtr // Layer.xaml.cpp //////////////////////////////////////////////////////////////////////////////////// +// Initializes our library for use; registers dependency properties, etc. +UIKIT_XAML_EXPORT void UIKitXamlInitialize(); + // Set one or more layer properties for the specified target xaml element UIKIT_XAML_EXPORT void XamlSetFrameworkElementLayerProperties(const Microsoft::WRL::ComPtr& targetElement, const Microsoft::WRL::ComPtr& sublayerCanvasProperty, diff --git a/Frameworks/UIKit/StarboardXaml/XamlCompositor.cpp b/Frameworks/UIKit/StarboardXaml/XamlCompositor.cpp index 940ca66fa3..0543a61898 100644 --- a/Frameworks/UIKit/StarboardXaml/XamlCompositor.cpp +++ b/Frameworks/UIKit/StarboardXaml/XamlCompositor.cpp @@ -31,6 +31,7 @@ #include "DisplayProperties.h" #include "LayerProxy.h" +#include "../UIKit.Xaml/ObjCXamlControls.h" using namespace Microsoft::WRL; using namespace UIKit::Xaml::Private::CoreAnimation; @@ -69,6 +70,8 @@ void Initialize(Windows::UI::Xaml::Controls::Grid^ rootGrid, ActivationType acti s_rootGrid->InvalidateArrange(); s_rootGrid->SizeChanged += ref new SizeChangedEventHandler(&OnGridSizeChanged); + + UIKitXamlInitialize(); } ComPtr GetRootElement() {