diff --git a/src/buffer/out/CharRow.cpp b/src/buffer/out/CharRow.cpp index 8ac4ea217..07a66bb92 100644 --- a/src/buffer/out/CharRow.cpp +++ b/src/buffer/out/CharRow.cpp @@ -269,6 +269,33 @@ std::wstring CharRow::GetText() const return wstr; } +// Method Description: +// - get delimiter class for a position in the char row +// - used for double click selection and uia word navigation +// Arguments: +// - column: column to get text data for +// - wordDelimiters: the delimiters defined as a part of the DelimiterClass::DelimiterChar +// Return Value: +// - the delimiter class for the given char +const DelimiterClass CharRow::DelimiterClassAt(const size_t column, const std::wstring_view wordDelimiters) const +{ + THROW_HR_IF(E_INVALIDARG, column >= _data.size()); + + const auto glyph = *GlyphAt(column).begin(); + if (glyph <= UNICODE_SPACE) + { + return DelimiterClass::ControlChar; + } + else if (wordDelimiters.find(glyph) != std::wstring_view::npos) + { + return DelimiterClass::DelimiterChar; + } + else + { + return DelimiterClass::RegularChar; + } +} + UnicodeStorage& CharRow::GetUnicodeStorage() noexcept { return _pParent->GetUnicodeStorage(); diff --git a/src/buffer/out/CharRow.hpp b/src/buffer/out/CharRow.hpp index e1b802d06..c0f8f19e8 100644 --- a/src/buffer/out/CharRow.hpp +++ b/src/buffer/out/CharRow.hpp @@ -27,6 +27,13 @@ Revision History: class ROW; +enum class DelimiterClass +{ + ControlChar, + DelimiterChar, + RegularChar +}; + // the characters of one row of screen buffer // we keep the following values so that we don't write // more pixels to the screen than we have to: @@ -64,6 +71,8 @@ public: void ClearGlyph(const size_t column); std::wstring GetText() const; + const DelimiterClass DelimiterClassAt(const size_t column, const std::wstring_view wordDelimiters) const; + // working with glyphs const reference GlyphAt(const size_t column) const; reference GlyphAt(const size_t column); diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp index bff427d8f..a6b332407 100644 --- a/src/buffer/out/textBuffer.cpp +++ b/src/buffer/out/textBuffer.cpp @@ -951,6 +951,19 @@ Microsoft::Console::Render::IRenderTarget& TextBuffer::GetRenderTarget() noexcep return _renderTarget; } +// Method Description: +// - get delimiter class for buffer cell position +// - used for double click selection and uia word navigation +// Arguments: +// - pos: the buffer cell under observation +// - wordDelimiters: the delimiters defined as a part of the DelimiterClass::DelimiterChar +// Return Value: +// - the delimiter class for the given char +const DelimiterClass TextBuffer::_GetDelimiterClassAt(const COORD pos, const std::wstring_view wordDelimiters) const +{ + return GetRowByOffset(pos.Y).GetCharRow().DelimiterClassAt(pos.X, wordDelimiters); +} + // Method Description: // - Get the COORD for the beginning of the word you are on // Arguments: @@ -1001,16 +1014,11 @@ const COORD TextBuffer::_GetWordStartForAccessibility(const COORD target, const COORD result = target; const auto bufferSize = GetSize(); bool stayAtOrigin = false; - auto bufferIterator = GetTextDataAt(result); // ignore left boundary. Continue until readable text found - while (_GetDelimiterClass(*bufferIterator, wordDelimiters) != DelimiterClass::RegularChar) + while (_GetDelimiterClassAt(result, wordDelimiters) != DelimiterClass::RegularChar) { - if (bufferSize.DecrementInBounds(result)) - { - --bufferIterator; - } - else + if (!bufferSize.DecrementInBounds(result)) { // first char in buffer is a DelimiterChar or ControlChar // we can't move any further back @@ -1020,13 +1028,9 @@ const COORD TextBuffer::_GetWordStartForAccessibility(const COORD target, const } // make sure we expand to the left boundary or the beginning of the word - while (_GetDelimiterClass(*bufferIterator, wordDelimiters) == DelimiterClass::RegularChar) + while (_GetDelimiterClassAt(result, wordDelimiters) == DelimiterClass::RegularChar) { - if (bufferSize.DecrementInBounds(result)) - { - --bufferIterator; - } - else + if (!bufferSize.DecrementInBounds(result)) { // first char in buffer is a RegularChar // we can't move any further back @@ -1035,7 +1039,7 @@ const COORD TextBuffer::_GetWordStartForAccessibility(const COORD target, const } // move off of delimiter and onto word start - if (!stayAtOrigin && _GetDelimiterClass(*bufferIterator, wordDelimiters) != DelimiterClass::RegularChar) + if (!stayAtOrigin && _GetDelimiterClassAt(result, wordDelimiters) != DelimiterClass::RegularChar) { bufferSize.IncrementInBounds(result); } @@ -1054,17 +1058,16 @@ const COORD TextBuffer::_GetWordStartForSelection(const COORD target, const std: { COORD result = target; const auto bufferSize = GetSize(); - auto bufferIterator = GetTextDataAt(result); - const auto initialDelimiter = _GetDelimiterClass(*bufferIterator, wordDelimiters); + + const auto initialDelimiter = _GetDelimiterClassAt(result, wordDelimiters); // expand left until we hit the left boundary or a different delimiter class - while (result.X > bufferSize.Left() && (_GetDelimiterClass(*bufferIterator, wordDelimiters) == initialDelimiter)) + while (result.X > bufferSize.Left() && (_GetDelimiterClassAt(result, wordDelimiters) == initialDelimiter)) { bufferSize.DecrementInBounds(result); - --bufferIterator; } - if (_GetDelimiterClass(*bufferIterator, wordDelimiters) != initialDelimiter) + if (_GetDelimiterClassAt(result, wordDelimiters) != initialDelimiter) { // move off of delimiter bufferSize.IncrementInBounds(result); @@ -1116,31 +1119,20 @@ const COORD TextBuffer::_GetWordEndForAccessibility(const COORD target, const st { const auto bufferSize = GetSize(); COORD result = target; - auto bufferIterator = GetTextDataAt(result); // ignore right boundary. Continue through readable text found - while (_GetDelimiterClass(*bufferIterator, wordDelimiters) == DelimiterClass::RegularChar) + while (_GetDelimiterClassAt(result, wordDelimiters) == DelimiterClass::RegularChar) { - if (bufferSize.IncrementInBounds(result, true)) + if (!bufferSize.IncrementInBounds(result, true)) { - ++bufferIterator; - } - else - { - // last char in buffer is a RegularChar - // we can't move any further forward break; } } // make sure we expand to the beginning of the NEXT word - while (_GetDelimiterClass(*bufferIterator, wordDelimiters) != DelimiterClass::RegularChar) + while (_GetDelimiterClassAt(result, wordDelimiters) != DelimiterClass::RegularChar) { - if (bufferSize.IncrementInBounds(result, true)) - { - ++bufferIterator; - } - else + if (!bufferSize.IncrementInBounds(result, true)) { // we are at the EndInclusive COORD // this signifies that we must include the last char in the buffer @@ -1162,25 +1154,23 @@ const COORD TextBuffer::_GetWordEndForAccessibility(const COORD target, const st const COORD TextBuffer::_GetWordEndForSelection(const COORD target, const std::wstring_view wordDelimiters) const { const auto bufferSize = GetSize(); - COORD result = target; - auto bufferIterator = GetTextDataAt(result); // can't expand right if (target.X == bufferSize.RightInclusive()) { - return result; + return target; } - const auto initialDelimiter = _GetDelimiterClass(*bufferIterator, wordDelimiters); + COORD result = target; + const auto initialDelimiter = _GetDelimiterClassAt(result, wordDelimiters); // expand right until we hit the right boundary or a different delimiter class - while (result.X < bufferSize.RightInclusive() && (_GetDelimiterClass(*bufferIterator, wordDelimiters) == initialDelimiter)) + while (result.X < bufferSize.RightInclusive() && (_GetDelimiterClassAt(result, wordDelimiters) == initialDelimiter)) { bufferSize.IncrementInBounds(result); - ++bufferIterator; } - if (_GetDelimiterClass(*bufferIterator, wordDelimiters) != initialDelimiter) + if (_GetDelimiterClassAt(result, wordDelimiters) != initialDelimiter) { // move off of delimiter bufferSize.DecrementInBounds(result); @@ -1203,11 +1193,8 @@ bool TextBuffer::MoveToNextWord(COORD& pos, const std::wstring_view wordDelimite auto copy = pos; const auto bufferSize = GetSize(); - auto text = GetTextDataAt(copy)->data(); - auto delimiterClass = _GetDelimiterClass(text, wordDelimiters); - // started on a word, continue until the end of the word - while (delimiterClass == DelimiterClass::RegularChar) + while (_GetDelimiterClassAt(copy, wordDelimiters) == DelimiterClass::RegularChar) { if (!bufferSize.IncrementInBounds(copy)) { @@ -1215,8 +1202,6 @@ bool TextBuffer::MoveToNextWord(COORD& pos, const std::wstring_view wordDelimite // thus there is no next word return false; } - text = GetTextDataAt(copy)->data(); - delimiterClass = _GetDelimiterClass(text, wordDelimiters); } // we are already on/past the last RegularChar @@ -1226,7 +1211,7 @@ bool TextBuffer::MoveToNextWord(COORD& pos, const std::wstring_view wordDelimite } // on whitespace, continue until the beginning of the next word - while (delimiterClass != DelimiterClass::RegularChar) + while (_GetDelimiterClassAt(copy, wordDelimiters) != DelimiterClass::RegularChar) { if (!bufferSize.IncrementInBounds(copy)) { @@ -1234,8 +1219,6 @@ bool TextBuffer::MoveToNextWord(COORD& pos, const std::wstring_view wordDelimite // there is no next word return false; } - text = GetTextDataAt(copy)->data(); - delimiterClass = _GetDelimiterClass(text, wordDelimiters); } // successful move, copy result out @@ -1256,11 +1239,8 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters auto copy = pos; auto bufferSize = GetSize(); - auto text = GetTextDataAt(copy)->data(); - auto delimiterClass = _GetDelimiterClass(text, wordDelimiters); - // started on whitespace/delimiter, continue until the end of the previous word - while (delimiterClass != DelimiterClass::RegularChar) + while (_GetDelimiterClassAt(copy, wordDelimiters) != DelimiterClass::RegularChar) { if (!bufferSize.DecrementInBounds(copy)) { @@ -1268,12 +1248,10 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters // there is no previous word return false; } - text = GetTextDataAt(copy)->data(); - delimiterClass = _GetDelimiterClass(text, wordDelimiters); } // on a word, continue until the beginning of the word - while (delimiterClass == DelimiterClass::RegularChar) + while (_GetDelimiterClassAt(copy, wordDelimiters) == DelimiterClass::RegularChar) { if (!bufferSize.DecrementInBounds(copy)) { @@ -1281,8 +1259,6 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters // there is no previous word return false; } - text = GetTextDataAt(copy)->data(); - delimiterClass = _GetDelimiterClass(text, wordDelimiters); } // successful move, copy result out @@ -1290,30 +1266,6 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters return true; } -// Method Description: -// - get delimiter class for buffer cell data -// - used for double click selection and uia word navigation -// Arguments: -// - cellChar: the char saved to the buffer cell under observation -// - wordDelimiters: the delimiters defined as a part of the DelimiterClass::DelimiterChar -// Return Value: -// - the delimiter class for the given char -TextBuffer::DelimiterClass TextBuffer::_GetDelimiterClass(const std::wstring_view cellChar, const std::wstring_view wordDelimiters) const noexcept -{ - if (cellChar.at(0) <= UNICODE_SPACE) - { - return DelimiterClass::ControlChar; - } - else if (wordDelimiters.find(cellChar) != std::wstring_view::npos) - { - return DelimiterClass::DelimiterChar; - } - else - { - return DelimiterClass::RegularChar; - } -} - // 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 3e870152d..6949b0f2a 100644 --- a/src/buffer/out/textBuffer.hpp +++ b/src/buffer/out/textBuffer.hpp @@ -197,13 +197,7 @@ private: void _ExpandTextRow(SMALL_RECT& selectionRow) const; - enum class DelimiterClass - { - ControlChar, - DelimiterChar, - RegularChar - }; - DelimiterClass _GetDelimiterClass(const std::wstring_view cellChar, const std::wstring_view wordDelimiters) const noexcept; + const DelimiterClass _GetDelimiterClassAt(const COORD pos, const std::wstring_view wordDelimiters) const; const COORD _GetWordStartForAccessibility(const COORD target, const std::wstring_view wordDelimiters) const; const COORD _GetWordStartForSelection(const COORD target, const std::wstring_view wordDelimiters) const; const COORD _GetWordEndForAccessibility(const COORD target, const std::wstring_view wordDelimiters) const; diff --git a/src/types/ScreenInfoUiaProviderBase.cpp b/src/types/ScreenInfoUiaProviderBase.cpp index 875286754..5f37c6af0 100644 --- a/src/types/ScreenInfoUiaProviderBase.cpp +++ b/src/types/ScreenInfoUiaProviderBase.cpp @@ -265,7 +265,7 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetSelection(_Outptr_result_maybenull_ return hr; } - UiaTracing::TextProvider::GetSelection(*this); + UiaTracing::TextProvider::GetSelection(*this, *range.Get()); return S_OK; } diff --git a/src/types/UiaTextRangeBase.cpp b/src/types/UiaTextRangeBase.cpp index 690c1fd26..0d43c26d4 100644 --- a/src/types/UiaTextRangeBase.cpp +++ b/src/types/UiaTextRangeBase.cpp @@ -1045,6 +1045,10 @@ void UiaTextRangeBase::_moveEndpointByUnitWord(_In_ const int moveCount, resultPos = bufferEnd; (*pAmountMoved)++; } + else + { + success = false; + } break; } case MovementDirection::Backward: diff --git a/src/types/UiaTracing.cpp b/src/types/UiaTracing.cpp index aed65e2ea..d416c715f 100644 --- a/src/types/UiaTracing.cpp +++ b/src/types/UiaTracing.cpp @@ -88,429 +88,529 @@ inline std::wstring UiaTracing::_getValue(const TextUnit unit) noexcept void UiaTracing::TextRange::Constructor(const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::Constructor", - TraceLoggingValue(_getValue(result).c_str(), "UiaTextRange"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::Constructor", + TraceLoggingValue(_getValue(result).c_str(), "UiaTextRange"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::Clone(const UiaTextRangeBase& utr, const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::Clone", - TraceLoggingValue(_getValue(utr).c_str(), "base"), - TraceLoggingValue(_getValue(result).c_str(), "clone"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::Clone", + TraceLoggingValue(_getValue(utr).c_str(), "base"), + TraceLoggingValue(_getValue(result).c_str(), "clone"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::Compare(const UiaTextRangeBase& utr, const UiaTextRangeBase& other, bool result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::Compare", - TraceLoggingValue(_getValue(utr).c_str(), "base"), - TraceLoggingValue(_getValue(other).c_str(), "other"), - TraceLoggingValue(result, "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::Compare", + TraceLoggingValue(_getValue(utr).c_str(), "base"), + TraceLoggingValue(_getValue(other).c_str(), "other"), + TraceLoggingValue(result, "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::CompareEndpoints(const UiaTextRangeBase& utr, const TextPatternRangeEndpoint endpoint, const UiaTextRangeBase& other, TextPatternRangeEndpoint otherEndpoint, int result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::CompareEndpoints", - TraceLoggingValue(_getValue(utr).c_str(), "base"), - TraceLoggingValue(_getValue(endpoint).c_str(), "baseEndpoint"), - TraceLoggingValue(_getValue(other).c_str(), "other"), - TraceLoggingValue(_getValue(otherEndpoint).c_str(), "otherEndpoint"), - TraceLoggingValue(result, "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::CompareEndpoints", + TraceLoggingValue(_getValue(utr).c_str(), "base"), + TraceLoggingValue(_getValue(endpoint).c_str(), "baseEndpoint"), + TraceLoggingValue(_getValue(other).c_str(), "other"), + TraceLoggingValue(_getValue(otherEndpoint).c_str(), "otherEndpoint"), + TraceLoggingValue(result, "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::ExpandToEnclosingUnit(TextUnit unit, const UiaTextRangeBase& utr) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::ExpandToEnclosingUnit", - TraceLoggingValue(_getValue(unit).c_str(), "textUnit"), - TraceLoggingValue(_getValue(utr).c_str(), "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::ExpandToEnclosingUnit", + TraceLoggingValue(_getValue(unit).c_str(), "textUnit"), + TraceLoggingValue(_getValue(utr).c_str(), "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::FindAttribute(const UiaTextRangeBase& utr) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::FindAttribute (UNSUPPORTED)", - TraceLoggingValue(_getValue(utr).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::FindAttribute (UNSUPPORTED)", + TraceLoggingValue(_getValue(utr).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::FindText(const UiaTextRangeBase& base, std::wstring text, bool searchBackward, bool ignoreCase, const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::FindText", - TraceLoggingValue(_getValue(base).c_str(), "base"), - TraceLoggingValue(text.c_str(), "text"), - TraceLoggingValue(searchBackward, "searchBackward"), - TraceLoggingValue(ignoreCase, "ignoreCase"), - TraceLoggingValue(_getValue(result).c_str(), "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::FindText", + TraceLoggingValue(_getValue(base).c_str(), "base"), + TraceLoggingValue(text.c_str(), "text"), + TraceLoggingValue(searchBackward, "searchBackward"), + TraceLoggingValue(ignoreCase, "ignoreCase"), + TraceLoggingValue(_getValue(result).c_str(), "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::GetAttributeValue(const UiaTextRangeBase& base, TEXTATTRIBUTEID id, VARIANT result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::GetAttributeValue", - TraceLoggingValue(_getValue(base).c_str(), "base"), - TraceLoggingValue(id, "textAttributeId"), - TraceLoggingValue(result.vt, "result (type)"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::GetAttributeValue", + TraceLoggingValue(_getValue(base).c_str(), "base"), + TraceLoggingValue(id, "textAttributeId"), + TraceLoggingValue(result.vt, "result (type)"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::GetBoundingRectangles(const UiaTextRangeBase& utr) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::GetBoundingRectangles", - TraceLoggingValue(_getValue(utr).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::GetBoundingRectangles", + TraceLoggingValue(_getValue(utr).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::GetEnclosingElement(const UiaTextRangeBase& utr) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::GetEnclosingElement", - TraceLoggingValue(_getValue(utr).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::GetEnclosingElement", + TraceLoggingValue(_getValue(utr).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::GetText(const UiaTextRangeBase& utr, int maxLength, std::wstring result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::GetText", - TraceLoggingValue(_getValue(utr).c_str(), "base"), - TraceLoggingValue(maxLength, "maxLength"), - TraceLoggingValue(result.c_str(), "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::GetText", + TraceLoggingValue(_getValue(utr).c_str(), "base"), + TraceLoggingValue(maxLength, "maxLength"), + TraceLoggingValue(result.c_str(), "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::Move(TextUnit unit, int count, int resultCount, const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::Move", - TraceLoggingValue(_getValue(unit).c_str(), "textUnit"), - TraceLoggingValue(count, "count"), - TraceLoggingValue(resultCount, "resultCount"), - TraceLoggingValue(_getValue(result).c_str(), "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::Move", + TraceLoggingValue(_getValue(unit).c_str(), "textUnit"), + TraceLoggingValue(count, "count"), + TraceLoggingValue(resultCount, "resultCount"), + TraceLoggingValue(_getValue(result).c_str(), "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count, int resultCount, const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::MoveEndpointByUnit", - TraceLoggingValue(_getValue(endpoint).c_str(), "endpoint"), - TraceLoggingValue(_getValue(unit).c_str(), "textUnit"), - TraceLoggingValue(count, "count"), - TraceLoggingValue(resultCount, "resultCount"), - TraceLoggingValue(_getValue(result).c_str(), "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::MoveEndpointByUnit", + TraceLoggingValue(_getValue(endpoint).c_str(), "endpoint"), + TraceLoggingValue(_getValue(unit).c_str(), "textUnit"), + TraceLoggingValue(count, "count"), + TraceLoggingValue(resultCount, "resultCount"), + TraceLoggingValue(_getValue(result).c_str(), "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::MoveEndpointByRange(TextPatternRangeEndpoint endpoint, const UiaTextRangeBase& other, TextPatternRangeEndpoint otherEndpoint, const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::MoveEndpointByRange", - TraceLoggingValue(_getValue(endpoint).c_str(), "endpoint"), - TraceLoggingValue(_getValue(other).c_str(), "other"), - TraceLoggingValue(_getValue(otherEndpoint).c_str(), "otherEndpoint"), - TraceLoggingValue(_getValue(result).c_str(), "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::MoveEndpointByRange", + TraceLoggingValue(_getValue(endpoint).c_str(), "endpoint"), + TraceLoggingValue(_getValue(other).c_str(), "other"), + TraceLoggingValue(_getValue(otherEndpoint).c_str(), "otherEndpoint"), + TraceLoggingValue(_getValue(result).c_str(), "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::Select(const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::Select", - TraceLoggingValue(_getValue(result).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::Select", + TraceLoggingValue(_getValue(result).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::AddToSelection(const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::AddToSelection (UNSUPPORTED)", - TraceLoggingValue(_getValue(result).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::AddToSelection (UNSUPPORTED)", + TraceLoggingValue(_getValue(result).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::RemoveFromSelection(const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::RemoveFromSelection (UNSUPPORTED)", - TraceLoggingValue(_getValue(result).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::RemoveFromSelection (UNSUPPORTED)", + TraceLoggingValue(_getValue(result).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } + void UiaTracing::TextRange::ScrollIntoView(bool alignToTop, const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::ScrollIntoView", - TraceLoggingValue(alignToTop, "alignToTop"), - TraceLoggingValue(_getValue(result).c_str(), "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::ScrollIntoView", + TraceLoggingValue(alignToTop, "alignToTop"), + TraceLoggingValue(_getValue(result).c_str(), "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextRange::GetChildren(const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "UiaTextRange::AddToSelection (UNSUPPORTED)", - TraceLoggingValue(_getValue(result).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "UiaTextRange::AddToSelection (UNSUPPORTED)", + TraceLoggingValue(_getValue(result).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::Constructor(const ScreenInfoUiaProviderBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::Constructor", - TraceLoggingValue(_getValue(result).c_str(), "ScreenInfoUiaProvider"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::Constructor", + TraceLoggingValue(_getValue(result).c_str(), "ScreenInfoUiaProvider"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::get_ProviderOptions(const ScreenInfoUiaProviderBase& siup, ProviderOptions options) noexcept { - auto getOptions = [options]() { - switch (options) - { - case ProviderOptions_ServerSideProvider: - return L"ServerSideProvider"; - default: - return L"UNKNOWN VALUE"; - } - }; + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + auto getOptions = [options]() { + switch (options) + { + case ProviderOptions_ServerSideProvider: + return L"ServerSideProvider"; + default: + return L"UNKNOWN VALUE"; + } + }; - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::get_ProviderOptions", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingValue(getOptions(), "providerOptions"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::get_ProviderOptions", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingValue(getOptions(), "providerOptions"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::GetPatternProvider(const ScreenInfoUiaProviderBase& siup, PATTERNID patternId) noexcept { - auto getPattern = [patternId]() { - switch (patternId) - { - case UIA_TextPatternId: - return L"TextPattern"; - default: - return L"UNKNOWN VALUE"; - } - }; + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + auto getPattern = [patternId]() { + switch (patternId) + { + case UIA_TextPatternId: + return L"TextPattern"; + default: + return L"UNKNOWN VALUE"; + } + }; - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::get_ProviderOptions", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingValue(getPattern(), "patternId"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::get_ProviderOptions", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingValue(getPattern(), "patternId"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::GetPropertyValue(const ScreenInfoUiaProviderBase& siup, PROPERTYID propertyId) noexcept { - auto getProperty = [propertyId]() { - switch (propertyId) - { - case UIA_ControlTypePropertyId: - return L"ControlTypePropertyId"; - case UIA_NamePropertyId: - return L"NamePropertyId"; - case UIA_AutomationIdPropertyId: - return L"AutomationIdPropertyId"; - case UIA_IsControlElementPropertyId: - return L"IsControlElementPropertyId"; - case UIA_IsContentElementPropertyId: - return L"IsContentElementPropertyId"; - case UIA_IsKeyboardFocusablePropertyId: - return L"IsKeyboardFocusablePropertyId"; - case UIA_HasKeyboardFocusPropertyId: - return L"HasKeyboardFocusPropertyId"; - case UIA_ProviderDescriptionPropertyId: - return L"ProviderDescriptionPropertyId"; - case UIA_IsEnabledPropertyId: - return L"IsEnabledPropertyId"; - default: - return L"UNKNOWN VALUE"; - } - }; + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + auto getProperty = [propertyId]() { + switch (propertyId) + { + case UIA_ControlTypePropertyId: + return L"ControlTypePropertyId"; + case UIA_NamePropertyId: + return L"NamePropertyId"; + case UIA_AutomationIdPropertyId: + return L"AutomationIdPropertyId"; + case UIA_IsControlElementPropertyId: + return L"IsControlElementPropertyId"; + case UIA_IsContentElementPropertyId: + return L"IsContentElementPropertyId"; + case UIA_IsKeyboardFocusablePropertyId: + return L"IsKeyboardFocusablePropertyId"; + case UIA_HasKeyboardFocusPropertyId: + return L"HasKeyboardFocusPropertyId"; + case UIA_ProviderDescriptionPropertyId: + return L"ProviderDescriptionPropertyId"; + case UIA_IsEnabledPropertyId: + return L"IsEnabledPropertyId"; + default: + return L"UNKNOWN VALUE"; + } + }; - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::GetPropertyValue", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingValue(getProperty(), "propertyId"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::GetPropertyValue", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingValue(getProperty(), "propertyId"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::get_HostRawElementProvider(const ScreenInfoUiaProviderBase& siup) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::get_HostRawElementProvider (UNSUPPORTED)", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::get_HostRawElementProvider (UNSUPPORTED)", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::GetRuntimeId(const ScreenInfoUiaProviderBase& siup) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::GetRuntimeId", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::GetRuntimeId", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::GetEmbeddedFragmentRoots(const ScreenInfoUiaProviderBase& siup) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::GetEmbeddedFragmentRoots (UNSUPPORTED)", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::GetEmbeddedFragmentRoots (UNSUPPORTED)", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::SetFocus(const ScreenInfoUiaProviderBase& siup) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::SetFocus", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::SetFocus", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } -void UiaTracing::TextProvider::GetSelection(const ScreenInfoUiaProviderBase& siup) noexcept +void UiaTracing::TextProvider::GetSelection(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept { - // TODO GH #4466: there's currently a PR out for this. Once that gets fixed, I'll update this appropriately - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::GetSelection", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::GetSelection", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::GetVisibleRanges(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::GetVisibleRanges", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::GetVisibleRanges", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::RangeFromChild(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::GetVisibleRanges", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::GetVisibleRanges", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::RangeFromPoint(const ScreenInfoUiaProviderBase& siup, UiaPoint point, const UiaTextRangeBase& result) noexcept { - auto getPoint = [point]() { - std::wstringstream stream; - stream << "{ " << point.x << ", " << point.y << " }"; - return stream.str(); - }; + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + auto getPoint = [point]() { + std::wstringstream stream; + stream << "{ " << point.x << ", " << point.y << " }"; + return stream.str(); + }; - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::RangeFromPoint", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingValue(getPoint().c_str(), "uiaPoint"), - TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::RangeFromPoint", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingValue(getPoint().c_str(), "uiaPoint"), + TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::get_DocumentRange(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept { - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::GetVisibleRanges", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::GetVisibleRanges", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } void UiaTracing::TextProvider::get_SupportedTextSelection(const ScreenInfoUiaProviderBase& siup, SupportedTextSelection result) noexcept { - auto getResult = [result]() { - switch (result) - { - case SupportedTextSelection_Single: - return L"Single"; - default: - return L"UNKNOWN VALUE"; - } - }; + if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0)) + { + auto getResult = [result]() { + switch (result) + { + case SupportedTextSelection_Single: + return L"Single"; + default: + return L"UNKNOWN VALUE"; + } + }; - EnsureRegistration(); - TraceLoggingWrite( - g_UiaProviderTraceProvider, - "ScreenInfoUiaProvider::get_SupportedTextSelection", - TraceLoggingValue(_getValue(siup).c_str(), "base"), - TraceLoggingValue(getResult(), "result"), - TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + EnsureRegistration(); + TraceLoggingWrite( + g_UiaProviderTraceProvider, + "ScreenInfoUiaProvider::get_SupportedTextSelection", + TraceLoggingValue(_getValue(siup).c_str(), "base"), + TraceLoggingValue(getResult(), "result"), + TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); + } } #pragma warning(pop) diff --git a/src/types/UiaTracing.h b/src/types/UiaTracing.h index d054cd5b9..12c353c86 100644 --- a/src/types/UiaTracing.h +++ b/src/types/UiaTracing.h @@ -64,7 +64,7 @@ namespace Microsoft::Console::Types static void GetRuntimeId(const ScreenInfoUiaProviderBase& base) noexcept; static void GetEmbeddedFragmentRoots(const ScreenInfoUiaProviderBase& base) noexcept; static void SetFocus(const ScreenInfoUiaProviderBase& base) noexcept; - static void GetSelection(const ScreenInfoUiaProviderBase& base) noexcept; + static void GetSelection(const ScreenInfoUiaProviderBase& base, const UiaTextRangeBase& result) noexcept; static void GetVisibleRanges(const ScreenInfoUiaProviderBase& base, const UiaTextRangeBase& result) noexcept; static void RangeFromChild(const ScreenInfoUiaProviderBase& base, const UiaTextRangeBase& result) noexcept; static void RangeFromPoint(const ScreenInfoUiaProviderBase& base, UiaPoint point, const UiaTextRangeBase& result) noexcept;