diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp index a8c516aa220..eaa41dc415a 100644 --- a/src/buffer/out/textBuffer.cpp +++ b/src/buffer/out/textBuffer.cpp @@ -1260,6 +1260,94 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters return true; } +// Method Description: +// - Update pos to be the beginning of the current glyph/character. This is used for accessibility +// Arguments: +// - pos - a COORD on the word you are currently on +// Return Value: +// - pos - The COORD for the first cell of the current glyph (inclusive) +const til::point TextBuffer::GetGlyphStart(const til::point pos) const +{ + COORD resultPos = pos; + + const auto bufferSize = GetSize(); + if (resultPos != bufferSize.EndExclusive() && GetCellDataAt(resultPos)->DbcsAttr().IsTrailing()) + { + bufferSize.DecrementInBounds(resultPos, true); + } + + return resultPos; +} + +// Method Description: +// - Update pos to be the end of the current glyph/character. This is used for accessibility +// Arguments: +// - pos - a COORD on the word you are currently on +// Return Value: +// - pos - The COORD for the last cell of the current glyph (exclusive) +const til::point TextBuffer::GetGlyphEnd(const til::point pos) const +{ + COORD resultPos = pos; + + const auto bufferSize = GetSize(); + if (resultPos != bufferSize.EndExclusive() && GetCellDataAt(resultPos)->DbcsAttr().IsLeading()) + { + bufferSize.IncrementInBounds(resultPos, true); + } + + // increment one more time to become exclusive + bufferSize.IncrementInBounds(resultPos, true); + return resultPos; +} + +// Method Description: +// - Update pos to be the beginning of the next glyph/character. This is used for accessibility +// Arguments: +// - pos - a COORD on the word you are currently on +// - allowBottomExclusive - allow the nonexistent end-of-buffer cell to be encountered +// Return Value: +// - true, if successfully updated pos. False, if we are unable to move (usually due to a buffer boundary) +// - pos - The COORD for the first cell of the current glyph (inclusive) +bool TextBuffer::MoveToNextGlyph(til::point& pos, bool allowBottomExclusive) const +{ + COORD resultPos = pos; + + // try to move. If we can't, we're done. + const auto bufferSize = GetSize(); + const bool success = bufferSize.IncrementInBounds(resultPos, allowBottomExclusive); + if (resultPos != bufferSize.EndExclusive() && GetCellDataAt(resultPos)->DbcsAttr().IsTrailing()) + { + bufferSize.IncrementInBounds(resultPos, allowBottomExclusive); + } + + pos = resultPos; + return success; +} + +// Method Description: +// - Update pos to be the beginning of the previous glyph/character. This is used for accessibility +// Arguments: +// - pos - a COORD on the word you are currently on +// - allowBottomExclusive - allow the nonexistent end-of-buffer cell to be encountered +// Return Value: +// - true, if successfully updated pos. False, if we are unable to move (usually due to a buffer boundary) +// - pos - The COORD for the first cell of the previous glyph (inclusive) +bool TextBuffer::MoveToPreviousGlyph(til::point& pos, bool allowBottomExclusive) const +{ + COORD resultPos = pos; + + // try to move. If we can't, we're done. + const auto bufferSize = GetSize(); + const bool success = bufferSize.DecrementInBounds(resultPos, allowBottomExclusive); + if (resultPos != bufferSize.EndExclusive() && GetCellDataAt(resultPos)->DbcsAttr().IsLeading()) + { + bufferSize.DecrementInBounds(resultPos, allowBottomExclusive); + } + + pos = resultPos; + return success; +} + // Method Description: // - Determines the line-by-line rectangles based on two COORDs // - expands the rectangles to support wide glyphs diff --git a/src/buffer/out/textBuffer.hpp b/src/buffer/out/textBuffer.hpp index 086eea214d6..351444820ba 100644 --- a/src/buffer/out/textBuffer.hpp +++ b/src/buffer/out/textBuffer.hpp @@ -134,6 +134,11 @@ class TextBuffer final bool MoveToNextWord(COORD& pos, const std::wstring_view wordDelimiters, COORD lastCharPos) const; bool MoveToPreviousWord(COORD& pos, const std::wstring_view wordDelimiters) const; + const til::point GetGlyphStart(const til::point pos) const; + const til::point GetGlyphEnd(const til::point pos) const; + bool MoveToNextGlyph(til::point& pos, bool allowBottomExclusive = false) const; + bool MoveToPreviousGlyph(til::point& pos, bool allowBottomExclusive = false) const; + const std::vector GetTextRects(COORD start, COORD end, bool blockSelection = false) const; class TextAndColor diff --git a/src/host/ut_host/TextBufferTests.cpp b/src/host/ut_host/TextBufferTests.cpp index 4cde9b055e0..563b73e71c3 100644 --- a/src/host/ut_host/TextBufferTests.cpp +++ b/src/host/ut_host/TextBufferTests.cpp @@ -148,6 +148,7 @@ class TextBufferTests void WriteLinesToBuffer(const std::vector& text, TextBuffer& buffer); TEST_METHOD(GetWordBoundaries); + TEST_METHOD(GetGlyphBoundaries); TEST_METHOD(GetTextRects); TEST_METHOD(GetText); @@ -2153,6 +2154,59 @@ void TextBufferTests::GetWordBoundaries() } } +void TextBufferTests::GetGlyphBoundaries() +{ + struct ExpectedResult + { + std::wstring name; + til::point start; + til::point wideGlyphEnd; + til::point normalEnd; + }; + + // clang-format off + const std::vector expected = { + { L"Buffer Start", { 0, 0 }, { 2, 0 }, { 1, 0 } }, + { L"Line Start", { 0, 1 }, { 2, 1 }, { 1, 1 } }, + { L"General Case", { 1, 1 }, { 3, 1 }, { 2, 1 } }, + { L"Line End", { 9, 1 }, { 0, 2 }, { 0, 2 } }, + { L"Buffer End", { 9, 9 }, { 0, 10 }, { 0, 10 } }, + }; + // clang-format on + + BEGIN_TEST_METHOD_PROPERTIES() + TEST_METHOD_PROPERTY(L"Data:wideGlyph", L"{false, true}") + END_TEST_METHOD_PROPERTIES(); + + bool wideGlyph; + VERIFY_SUCCEEDED(TestData::TryGetValue(L"wideGlyph", wideGlyph), L"Get wide glyph variant"); + + COORD bufferSize{ 10, 10 }; + UINT cursorSize = 12; + TextAttribute attr{ 0x7f }; + auto _buffer = std::make_unique(bufferSize, attr, cursorSize, _renderTarget); + + // This is the burrito emoji: 🌯 + // It's encoded in UTF-16, as needed by the buffer. + const auto burrito = L"\xD83C\xDF2F"; + const wchar_t* const output = wideGlyph ? burrito : L"X"; + + const OutputCellIterator iter{ output }; + + for (const auto& test : expected) + { + Log::Comment(test.name.c_str()); + auto target = test.start; + _buffer->Write(iter, target); + + auto start = _buffer->GetGlyphStart(target); + auto end = _buffer->GetGlyphEnd(target); + + VERIFY_ARE_EQUAL(test.start, start); + VERIFY_ARE_EQUAL(wideGlyph ? test.wideGlyphEnd : test.normalEnd, end); + } +} + void TextBufferTests::GetTextRects() { // GetTextRects() is used to... diff --git a/src/types/ScreenInfoUiaProviderBase.cpp b/src/types/ScreenInfoUiaProviderBase.cpp index 831a50382cf..4140059e218 100644 --- a/src/types/ScreenInfoUiaProviderBase.cpp +++ b/src/types/ScreenInfoUiaProviderBase.cpp @@ -256,6 +256,8 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetSelection(_Outptr_result_maybenull_ return hr; } + UiaTracing::TextProvider::GetSelection(*this, *range.Get()); + LONG currentIndex = 0; hr = SafeArrayPutElement(*ppRetVal, ¤tIndex, range.Detach()); if (FAILED(hr)) @@ -265,7 +267,6 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetSelection(_Outptr_result_maybenull_ return hr; } - UiaTracing::TextProvider::GetSelection(*this, *range.Get()); return S_OK; } diff --git a/src/types/UiaTextRangeBase.cpp b/src/types/UiaTextRangeBase.cpp index 5b66d739052..5872cb54365 100644 --- a/src/types/UiaTextRangeBase.cpp +++ b/src/types/UiaTextRangeBase.cpp @@ -263,8 +263,8 @@ IFACEMETHODIMP UiaTextRangeBase::ExpandToEnclosingUnit(_In_ TextUnit unit) noexc if (unit == TextUnit_Character) { - _end = _start; - bufferSize.IncrementInBounds(_end, true); + _start = buffer.GetGlyphStart(_start); + _end = buffer.GetGlyphEnd(_start); } else if (unit <= TextUnit_Word) { @@ -526,7 +526,7 @@ try const auto bufferSize = buffer.GetSize(); // convert _end to be inclusive - auto inclusiveEnd{ _end }; + auto inclusiveEnd = _end; bufferSize.DecrementInBounds(inclusiveEnd, true); const auto textRects = buffer.GetTextRects(_start, inclusiveEnd, _blockRange); @@ -687,9 +687,9 @@ try } else { - auto temp = _end; - _pData->GetTextBuffer().GetSize().DecrementInBounds(temp); - _pData->SelectNewRegion(_start, temp); + auto inclusiveEnd = _end; + _pData->GetTextBuffer().GetSize().DecrementInBounds(inclusiveEnd); + _pData->SelectNewRegion(_start, inclusiveEnd); } UiaTracing::TextRange::Select(*this); @@ -897,7 +897,7 @@ void UiaTextRangeBase::_getBoundingRect(const til::rectangle textRect, _Inout_ s void UiaTextRangeBase::_moveEndpointByUnitCharacter(_In_ const int moveCount, _In_ const TextPatternRangeEndpoint endpoint, _Out_ gsl::not_null const pAmountMoved, - _In_ const bool preventBufferEnd) noexcept + _In_ const bool preventBufferEnd) { *pAmountMoved = 0; @@ -908,23 +908,23 @@ void UiaTextRangeBase::_moveEndpointByUnitCharacter(_In_ const int moveCount, const bool allowBottomExclusive = !preventBufferEnd; const MovementDirection moveDirection = (moveCount > 0) ? MovementDirection::Forward : MovementDirection::Backward; - const auto bufferSize = _getBufferSize(); + const auto& buffer = _pData->GetTextBuffer(); bool success = true; - auto target = GetEndpoint(endpoint); + til::point target = GetEndpoint(endpoint); while (std::abs(*pAmountMoved) < std::abs(moveCount) && success) { switch (moveDirection) { case MovementDirection::Forward: - success = bufferSize.IncrementInBounds(target, allowBottomExclusive); + success = buffer.MoveToNextGlyph(target, allowBottomExclusive); if (success) { (*pAmountMoved)++; } break; case MovementDirection::Backward: - success = bufferSize.DecrementInBounds(target, allowBottomExclusive); + success = buffer.MoveToPreviousGlyph(target, allowBottomExclusive); if (success) { (*pAmountMoved)--; diff --git a/src/types/UiaTextRangeBase.hpp b/src/types/UiaTextRangeBase.hpp index da49d038668..d119d7fd368 100644 --- a/src/types/UiaTextRangeBase.hpp +++ b/src/types/UiaTextRangeBase.hpp @@ -170,7 +170,7 @@ namespace Microsoft::Console::Types _moveEndpointByUnitCharacter(_In_ const int moveCount, _In_ const TextPatternRangeEndpoint endpoint, gsl::not_null const pAmountMoved, - _In_ const bool preventBufferEnd = false) noexcept; + _In_ const bool preventBufferEnd = false); void _moveEndpointByUnitWord(_In_ const int moveCount, diff --git a/src/types/UiaTracing.cpp b/src/types/UiaTracing.cpp index 34b7fbbf346..058404f881e 100644 --- a/src/types/UiaTracing.cpp +++ b/src/types/UiaTracing.cpp @@ -88,9 +88,9 @@ inline std::wstring UiaTracing::_getValue(const TextUnit unit) noexcept void UiaTracing::TextRange::Constructor(const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::Constructor", @@ -101,9 +101,9 @@ void UiaTracing::TextRange::Constructor(const UiaTextRangeBase& result) noexcept void UiaTracing::TextRange::Clone(const UiaTextRangeBase& utr, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::Clone", @@ -115,9 +115,9 @@ void UiaTracing::TextRange::Clone(const UiaTextRangeBase& utr, const UiaTextRang void UiaTracing::TextRange::Compare(const UiaTextRangeBase& utr, const UiaTextRangeBase& other, bool result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::Compare", @@ -130,9 +130,9 @@ void UiaTracing::TextRange::Compare(const UiaTextRangeBase& utr, const UiaTextRa void UiaTracing::TextRange::CompareEndpoints(const UiaTextRangeBase& utr, const TextPatternRangeEndpoint endpoint, const UiaTextRangeBase& other, TextPatternRangeEndpoint otherEndpoint, int result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::CompareEndpoints", @@ -147,9 +147,9 @@ void UiaTracing::TextRange::CompareEndpoints(const UiaTextRangeBase& utr, const void UiaTracing::TextRange::ExpandToEnclosingUnit(TextUnit unit, const UiaTextRangeBase& utr) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::ExpandToEnclosingUnit", @@ -161,9 +161,9 @@ void UiaTracing::TextRange::ExpandToEnclosingUnit(TextUnit unit, const UiaTextRa void UiaTracing::TextRange::FindAttribute(const UiaTextRangeBase& utr) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::FindAttribute (UNSUPPORTED)", @@ -174,9 +174,9 @@ void UiaTracing::TextRange::FindAttribute(const UiaTextRangeBase& utr) noexcept void UiaTracing::TextRange::FindText(const UiaTextRangeBase& base, std::wstring text, bool searchBackward, bool ignoreCase, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::FindText", @@ -191,9 +191,9 @@ void UiaTracing::TextRange::FindText(const UiaTextRangeBase& base, std::wstring void UiaTracing::TextRange::GetAttributeValue(const UiaTextRangeBase& base, TEXTATTRIBUTEID id, VARIANT result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::GetAttributeValue", @@ -206,9 +206,9 @@ void UiaTracing::TextRange::GetAttributeValue(const UiaTextRangeBase& base, TEXT void UiaTracing::TextRange::GetBoundingRectangles(const UiaTextRangeBase& utr) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::GetBoundingRectangles", @@ -219,9 +219,9 @@ void UiaTracing::TextRange::GetBoundingRectangles(const UiaTextRangeBase& utr) n void UiaTracing::TextRange::GetEnclosingElement(const UiaTextRangeBase& utr) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::GetEnclosingElement", @@ -232,9 +232,9 @@ void UiaTracing::TextRange::GetEnclosingElement(const UiaTextRangeBase& utr) noe void UiaTracing::TextRange::GetText(const UiaTextRangeBase& utr, int maxLength, std::wstring result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::GetText", @@ -247,9 +247,9 @@ void UiaTracing::TextRange::GetText(const UiaTextRangeBase& utr, int maxLength, void UiaTracing::TextRange::Move(TextUnit unit, int count, int resultCount, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::Move", @@ -263,9 +263,9 @@ void UiaTracing::TextRange::Move(TextUnit unit, int count, int resultCount, cons void UiaTracing::TextRange::MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count, int resultCount, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::MoveEndpointByUnit", @@ -280,9 +280,9 @@ void UiaTracing::TextRange::MoveEndpointByUnit(TextPatternRangeEndpoint endpoint void UiaTracing::TextRange::MoveEndpointByRange(TextPatternRangeEndpoint endpoint, const UiaTextRangeBase& other, TextPatternRangeEndpoint otherEndpoint, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::MoveEndpointByRange", @@ -296,9 +296,9 @@ void UiaTracing::TextRange::MoveEndpointByRange(TextPatternRangeEndpoint endpoin void UiaTracing::TextRange::Select(const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::Select", @@ -309,9 +309,9 @@ void UiaTracing::TextRange::Select(const UiaTextRangeBase& result) noexcept void UiaTracing::TextRange::AddToSelection(const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::AddToSelection (UNSUPPORTED)", @@ -322,9 +322,9 @@ void UiaTracing::TextRange::AddToSelection(const UiaTextRangeBase& result) noexc void UiaTracing::TextRange::RemoveFromSelection(const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::RemoveFromSelection (UNSUPPORTED)", @@ -335,9 +335,9 @@ void UiaTracing::TextRange::RemoveFromSelection(const UiaTextRangeBase& result) void UiaTracing::TextRange::ScrollIntoView(bool alignToTop, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::ScrollIntoView", @@ -349,9 +349,9 @@ void UiaTracing::TextRange::ScrollIntoView(bool alignToTop, const UiaTextRangeBa void UiaTracing::TextRange::GetChildren(const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "UiaTextRange::AddToSelection (UNSUPPORTED)", @@ -362,9 +362,9 @@ void UiaTracing::TextRange::GetChildren(const UiaTextRangeBase& result) noexcept void UiaTracing::TextProvider::Constructor(const ScreenInfoUiaProviderBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::Constructor", @@ -375,6 +375,7 @@ void UiaTracing::TextProvider::Constructor(const ScreenInfoUiaProviderBase& resu void UiaTracing::TextProvider::get_ProviderOptions(const ScreenInfoUiaProviderBase& siup, ProviderOptions options) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { auto getOptions = [options]() { @@ -387,7 +388,6 @@ void UiaTracing::TextProvider::get_ProviderOptions(const ScreenInfoUiaProviderBa } }; - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::get_ProviderOptions", @@ -399,6 +399,7 @@ void UiaTracing::TextProvider::get_ProviderOptions(const ScreenInfoUiaProviderBa void UiaTracing::TextProvider::GetPatternProvider(const ScreenInfoUiaProviderBase& siup, PATTERNID patternId) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { auto getPattern = [patternId]() { @@ -411,7 +412,6 @@ void UiaTracing::TextProvider::GetPatternProvider(const ScreenInfoUiaProviderBas } }; - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::get_ProviderOptions", @@ -423,6 +423,7 @@ void UiaTracing::TextProvider::GetPatternProvider(const ScreenInfoUiaProviderBas void UiaTracing::TextProvider::GetPropertyValue(const ScreenInfoUiaProviderBase& siup, PROPERTYID propertyId) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { auto getProperty = [propertyId]() { @@ -451,7 +452,6 @@ void UiaTracing::TextProvider::GetPropertyValue(const ScreenInfoUiaProviderBase& } }; - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::GetPropertyValue", @@ -463,9 +463,9 @@ void UiaTracing::TextProvider::GetPropertyValue(const ScreenInfoUiaProviderBase& void UiaTracing::TextProvider::get_HostRawElementProvider(const ScreenInfoUiaProviderBase& siup) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::get_HostRawElementProvider (UNSUPPORTED)", @@ -476,9 +476,9 @@ void UiaTracing::TextProvider::get_HostRawElementProvider(const ScreenInfoUiaPro void UiaTracing::TextProvider::GetRuntimeId(const ScreenInfoUiaProviderBase& siup) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::GetRuntimeId", @@ -489,9 +489,9 @@ void UiaTracing::TextProvider::GetRuntimeId(const ScreenInfoUiaProviderBase& siu void UiaTracing::TextProvider::GetEmbeddedFragmentRoots(const ScreenInfoUiaProviderBase& siup) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::GetEmbeddedFragmentRoots (UNSUPPORTED)", @@ -502,9 +502,9 @@ void UiaTracing::TextProvider::GetEmbeddedFragmentRoots(const ScreenInfoUiaProvi void UiaTracing::TextProvider::SetFocus(const ScreenInfoUiaProviderBase& siup) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::SetFocus", @@ -515,9 +515,9 @@ void UiaTracing::TextProvider::SetFocus(const ScreenInfoUiaProviderBase& siup) n void UiaTracing::TextProvider::GetSelection(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::GetSelection", @@ -529,9 +529,9 @@ void UiaTracing::TextProvider::GetSelection(const ScreenInfoUiaProviderBase& siu void UiaTracing::TextProvider::GetVisibleRanges(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::GetVisibleRanges", @@ -543,9 +543,9 @@ void UiaTracing::TextProvider::GetVisibleRanges(const ScreenInfoUiaProviderBase& void UiaTracing::TextProvider::RangeFromChild(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::GetVisibleRanges", @@ -557,6 +557,7 @@ void UiaTracing::TextProvider::RangeFromChild(const ScreenInfoUiaProviderBase& s void UiaTracing::TextProvider::RangeFromPoint(const ScreenInfoUiaProviderBase& siup, UiaPoint point, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { auto getPoint = [point]() { @@ -565,7 +566,6 @@ void UiaTracing::TextProvider::RangeFromPoint(const ScreenInfoUiaProviderBase& s return stream.str(); }; - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::RangeFromPoint", @@ -578,9 +578,9 @@ void UiaTracing::TextProvider::RangeFromPoint(const ScreenInfoUiaProviderBase& s void UiaTracing::TextProvider::get_DocumentRange(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::GetVisibleRanges", @@ -592,6 +592,7 @@ void UiaTracing::TextProvider::get_DocumentRange(const ScreenInfoUiaProviderBase void UiaTracing::TextProvider::get_SupportedTextSelection(const ScreenInfoUiaProviderBase& siup, SupportedTextSelection result) noexcept { + EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) { auto getResult = [result]() { @@ -604,7 +605,6 @@ void UiaTracing::TextProvider::get_SupportedTextSelection(const ScreenInfoUiaPro } }; - EnsureRegistration(); TraceLoggingWrite( g_UiaProviderTraceProvider, "ScreenInfoUiaProvider::get_SupportedTextSelection",