Skip to content

Commit

Permalink
Syncing content from committish release/1.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
reunion-maestro-bot committed Feb 26, 2024
1 parent 20dcc18 commit d4c4e53
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 21 deletions.
75 changes: 65 additions & 10 deletions controls/dev/Breadcrumb/BreadcrumbBarItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
#include "BreadcrumbBar.h"
#include "BreadcrumbBarItemAutomationPeer.h"

#include "velocity.h"
#include <FrameworkUdk/Containment.h>

// Bug 48360852: [1.4 servicing] BreadcrumbBar leaks in File Explorer
#define WINAPPSDK_CHANGEID_48360852 48360852
// Bug 48634621: [1.4 servicing] File explorer's popup window is hidden by body (z-order issue?)
#define WINAPPSDK_CHANGEID_48634621 48634621
// Bug 48634543: [1.4 servicing] [Watson Failure] caused by FAIL_FAST_FATAL_APP_EXIT_c0000409_Microsoft.UI.Xaml.Controls.dll!BreadcrumbBarItem::CloneEllipsisItemSource
#define WINAPPSDK_CHANGEID_48634543 48634543

namespace winrt::Microsoft::UI::Xaml::Controls
{
CppWinRTActivatableClassWithBasicFactory(BreadcrumbBarItem)
Expand Down Expand Up @@ -92,6 +102,10 @@ void BreadcrumbBarItem::OnApplyTemplate()
if (m_isEllipsisItem)
{
m_ellipsisFlyout.set(GetTemplateChildT<winrt::Flyout>(s_itemEllipsisFlyoutPartName, controlProtected));
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_48634621>())
{
m_ellipsisFlyout.get().ShouldConstrainToRootBounds(false);
}
}

m_button.set(GetTemplateChildT<winrt::Button>(s_itemButtonPartName, controlProtected));
Expand Down Expand Up @@ -149,7 +163,14 @@ void BreadcrumbBarItem::SetParentBreadcrumb(const winrt::BreadcrumbBar& parent)
{
MUX_ASSERT(!m_isEllipsisDropDownItem);

m_parentBreadcrumb.set(parent);
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_48360852>())
{
m_parentBreadcrumbWeakRef = winrt::make_weak(parent);
}
else
{
m_parentBreadcrumb.set(parent);
}
}

void BreadcrumbBarItem::SetEllipsisDropDownItemDataTemplate(const winrt::IInspectable& newDataTemplate)
Expand Down Expand Up @@ -180,7 +201,17 @@ void BreadcrumbBarItem::SetIsEllipsisDropDownItem(bool isEllipsisDropDownItem)

void BreadcrumbBarItem::RaiseItemClickedEvent(const winrt::IInspectable& content, const uint32_t index)
{
if (const auto& breadcrumb = m_parentBreadcrumb.get())
winrt::BreadcrumbBar breadcrumb;
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_48360852>())
{
breadcrumb = m_parentBreadcrumbWeakRef.get();
}
else
{
breadcrumb = m_parentBreadcrumb.get();
}

if (breadcrumb)
{
auto breadcrumbImpl = winrt::get_self<BreadcrumbBar>(breadcrumb);
breadcrumbImpl->RaiseItemClickedEvent(content, index);
Expand Down Expand Up @@ -287,13 +318,27 @@ winrt::IInspectable BreadcrumbBarItem::CloneEllipsisItemSource(const winrt::Coll
// The new list contains all the elements in reverse order
const int itemsSourceSize = ellipsisItemsSource.Size();

// The itemsSourceSize should always be at least 1 as it must always contain the ellipsis item
assert(itemsSourceSize > 0);

for (int i = itemsSourceSize - 1; i >= 0; --i)
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_48634543>())
{
const auto& item = ellipsisItemsSource.GetAt(i);
newItemsSource.Append(item);
if(itemsSourceSize > 0)
{
for (int i = itemsSourceSize - 1; i >= 0; --i)
{
const auto& item = ellipsisItemsSource.GetAt(i);
newItemsSource.Append(item);
}
}
}
else
{
// The itemsSourceSize should always be at least 1 as it must always contain the ellipsis item
assert(itemsSourceSize > 0);

for (int i = itemsSourceSize - 1; i >= 0; --i)
{
const auto& item = ellipsisItemsSource.GetAt(i);
newItemsSource.Append(item);
}
}

return newItemsSource;
Expand Down Expand Up @@ -431,7 +476,17 @@ void BreadcrumbBarItem::OnEllipsisItemClick(const winrt::IInspectable&, const wi
{
MUX_ASSERT(!m_isEllipsisDropDownItem);

if (const auto& breadcrumb = m_parentBreadcrumb.get())
winrt::BreadcrumbBar breadcrumb;
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_48360852>())
{
breadcrumb = m_parentBreadcrumbWeakRef.get();
}
else
{
breadcrumb = m_parentBreadcrumb.get();
}

if (breadcrumb)
{
if (const auto& breadcrumbImpl = breadcrumb.try_as<BreadcrumbBar>())
{
Expand Down Expand Up @@ -496,7 +551,7 @@ void BreadcrumbBarItem::InstantiateFlyout()
{
if (const auto& ellipsisFlyout = m_ellipsisFlyout.get())
{
// Create ItemsRepeater and set the DataTemplate
// Create ItemsRepeater and set the DataTemplate
const auto& ellipsisItemsRepeater = winrt::ItemsRepeater();
ellipsisItemsRepeater.Name(s_ellipsisItemsRepeaterPartName);
winrt::AutomationProperties::SetName(ellipsisItemsRepeater, s_ellipsisItemsRepeaterAutomationName);
Expand Down
4 changes: 4 additions & 0 deletions controls/dev/Breadcrumb/BreadcrumbBarItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ class BreadcrumbBarItem :

// BreadcrumbBarItem visual representation
tracker_ref<winrt::Button> m_button{ this };

// Parent BreadcrumbBarItem to ask for hidden elements
// Bug 48360852: [1.4 servicing] BreadcrumbBar leaks in File Explorer
// A ref-counted pointer creates a reference cycle and a leak. Switch to the weak pointer when the fix is enabled under containment.
tracker_ref<winrt::BreadcrumbBar> m_parentBreadcrumb{ this };
winrt::weak_ref<winrt::BreadcrumbBar> m_parentBreadcrumbWeakRef{ nullptr };

// Flyout content for ellipsis item
tracker_ref<winrt::Flyout> m_ellipsisFlyout{ this };
Expand Down
32 changes: 28 additions & 4 deletions controls/dev/Breadcrumb/BreadcrumbLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@
#include "BreadcrumbBar.h"
#include "BreadcrumbBarItem.h"

#include "velocity.h"
#include <FrameworkUdk/Containment.h>

// Bug 48360852: [1.4 servicing] BreadcrumbBar leaks in File Explorer
#define WINAPPSDK_CHANGEID_48360852 48360852

BreadcrumbLayout::BreadcrumbLayout()
{
}

BreadcrumbLayout::BreadcrumbLayout(const winrt::BreadcrumbBar& breadcrumb)
{
m_breadcrumb = breadcrumb;
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_48360852>())
{
m_breadcrumbWeakRef = winrt::make_weak(breadcrumb);
}
else
{
m_breadcrumb = breadcrumb;
}
}

BreadcrumbLayout::~BreadcrumbLayout()
Expand Down Expand Up @@ -61,7 +74,7 @@ winrt::Size BreadcrumbLayout::MeasureOverride(winrt::NonVirtualizingLayoutContex

if (accumulatedCrumbsSize.Width > availableSize.Width)
{
m_ellipsisIsRendered = true;
m_ellipsisIsRendered = true;
}
else
{
Expand Down Expand Up @@ -185,9 +198,20 @@ winrt::Size BreadcrumbLayout::ArrangeOverride(winrt::NonVirtualizingLayoutContex
}
}

if (const auto& breadcrumb = m_breadcrumb.try_as<BreadcrumbBar>())
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_48360852>())
{
breadcrumb->ReIndexVisibleElementsForAccessibility();
if (const auto& breadcrumb = m_breadcrumbWeakRef.get())
{
auto breadcrumbImpl = winrt::get_self<BreadcrumbBar>(breadcrumb);
breadcrumbImpl->ReIndexVisibleElementsForAccessibility();
}
}
else
{
if (const auto& breadcrumb = m_breadcrumb.try_as<BreadcrumbBar>())
{
breadcrumb->ReIndexVisibleElementsForAccessibility();
}
}

return finalSize;
Expand Down
4 changes: 4 additions & 0 deletions controls/dev/Breadcrumb/BreadcrumbLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ class BreadcrumbLayout :

winrt::Size m_availableSize{};
winrt::BreadcrumbBarItem m_ellipsisButton{nullptr};

// Bug 48360852: [1.4 servicing] BreadcrumbBar leaks in File Explorer
// A ref-counted pointer creates a reference cycle and a leak. Switch to the weak pointer when the fix is enabled under containment.
winrt::BreadcrumbBar m_breadcrumb{ nullptr };
winrt::weak_ref<winrt::BreadcrumbBar> m_breadcrumbWeakRef{ nullptr }; // weak_ref because the BreadcrumbBar already points to us via m_itemsRepeaterLayout

bool m_ellipsisIsRendered{};
uint32_t m_firstRenderedItemIndexAfterEllipsis{};
Expand Down
12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<!-- Copyright (c) Microsoft Corporation. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.WindowsAppSDK.Foundation.TransportPackage" Version="1.4.0-20231216.0">
<Dependency Name="Microsoft.WindowsAppSDK.Foundation.TransportPackage" Version="1.4.0-20240211.0">
<Uri>https://dev.azure.com/microsoft/ProjectReunion/_git/WindowsAppSDK</Uri>
<Sha>e1e38e7e4df1f862ddaac4f4f9a4e77930c55fee</Sha>
<Sha>7d84b710d4c08dc9b8c5506de07bda50c9439369</Sha>
</Dependency>
<Dependency Name="Microsoft.ProjectReunion.InteractiveExperiences.TransportPackage" Version="1.4.4-CI-22624.1058.231213-1411.1">
<Dependency Name="Microsoft.ProjectReunion.InteractiveExperiences.TransportPackage" Version="1.4.4-CI-22624.1061.240209-1942.0">
<Uri>https://dev.azure.com/microsoft/LiftedIXP/_git/DCPP</Uri>
<Sha>3a7a80cf90baf200787d3ffee0443c6a58aacb1f</Sha>
<Sha>2c479f6a2492832f2078a92c9d0489193ff9edba</Sha>
</Dependency>
<Dependency Name="Microsoft.Internal.InteractiveExperiences" Version="1.4.4-CI-22624.1058.231213-1411.1">
<Dependency Name="Microsoft.Internal.InteractiveExperiences" Version="1.4.4-CI-22624.1061.240209-1942.0">
<Uri>https://dev.azure.com/microsoft/LiftedIXP/_git/DCPP</Uri>
<Sha>3a7a80cf90baf200787d3ffee0443c6a58aacb1f</Sha>
<Sha>2c479f6a2492832f2078a92c9d0489193ff9edba</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
2 changes: 1 addition & 1 deletion packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
so we need to pull down this package so we can deploy it to Helix machines. -->
<package id="Microsoft.VCRTForwarders.140" version="1.0.6" />
<!-- Microsoft-WinUI-SDK repo (MSBuild and Visual Studio extensions for building, deploying, and debugging packaged applications.) -->
<package id="Microsoft.Build.Msix" version="1.4.0-zmain.230310.1" />
<package id="Microsoft.Build.Msix" version="1.4.0-zmain.240202.1" />
<!-- Localized MUI and resw files -->
<package id="Microsoft.Internal.WinUILocalizationResources" version="230926.0.0" />
<!-- Windows SDK build tools (e.g. makeappx.exe) -->
Expand Down

0 comments on commit d4c4e53

Please sign in to comment.