Improve Word Navigation/Selection Performance (#4797)

## Summary of the Pull Request
1) Improves the performance of word-recognition operations such as word
   navigation in UIA and selection.

2) Fixes a bug where attempting to find the next word in UIA, when none
   exists, would hang

3) TraceLogging code only runs when somebody is listening

## Detailed Description of the Pull Request / Additional comments
- The concept of a delimiter class got moved to the CharRow.
- The buffer iterator used to save a lot more information than we needed
- I missed updating a tracing function after making GetSelection return
  one text range. That is fixed now.


## Validation Steps Performed
Performed Word Navigation under Narrator and NVDA.
NOTE: The release build should be used when testing to optimize
performance

Closes #4703
This commit is contained in:
msftbot[bot] 2020-03-04 23:10:10 +00:00 committed by GitHub
parent c6879d75af
commit 267deaaf70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 471 additions and 385 deletions

View file

@ -269,6 +269,33 @@ std::wstring CharRow::GetText() const
return wstr; 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 UnicodeStorage& CharRow::GetUnicodeStorage() noexcept
{ {
return _pParent->GetUnicodeStorage(); return _pParent->GetUnicodeStorage();

View file

@ -27,6 +27,13 @@ Revision History:
class ROW; class ROW;
enum class DelimiterClass
{
ControlChar,
DelimiterChar,
RegularChar
};
// the characters of one row of screen buffer // the characters of one row of screen buffer
// we keep the following values so that we don't write // we keep the following values so that we don't write
// more pixels to the screen than we have to: // more pixels to the screen than we have to:
@ -64,6 +71,8 @@ public:
void ClearGlyph(const size_t column); void ClearGlyph(const size_t column);
std::wstring GetText() const; std::wstring GetText() const;
const DelimiterClass DelimiterClassAt(const size_t column, const std::wstring_view wordDelimiters) const;
// working with glyphs // working with glyphs
const reference GlyphAt(const size_t column) const; const reference GlyphAt(const size_t column) const;
reference GlyphAt(const size_t column); reference GlyphAt(const size_t column);

View file

@ -951,6 +951,19 @@ Microsoft::Console::Render::IRenderTarget& TextBuffer::GetRenderTarget() noexcep
return _renderTarget; 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: // Method Description:
// - Get the COORD for the beginning of the word you are on // - Get the COORD for the beginning of the word you are on
// Arguments: // Arguments:
@ -1001,16 +1014,11 @@ const COORD TextBuffer::_GetWordStartForAccessibility(const COORD target, const
COORD result = target; COORD result = target;
const auto bufferSize = GetSize(); const auto bufferSize = GetSize();
bool stayAtOrigin = false; bool stayAtOrigin = false;
auto bufferIterator = GetTextDataAt(result);
// ignore left boundary. Continue until readable text found // ignore left boundary. Continue until readable text found
while (_GetDelimiterClass(*bufferIterator, wordDelimiters) != DelimiterClass::RegularChar) while (_GetDelimiterClassAt(result, wordDelimiters) != DelimiterClass::RegularChar)
{ {
if (bufferSize.DecrementInBounds(result)) if (!bufferSize.DecrementInBounds(result))
{
--bufferIterator;
}
else
{ {
// first char in buffer is a DelimiterChar or ControlChar // first char in buffer is a DelimiterChar or ControlChar
// we can't move any further back // 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 // 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)) if (!bufferSize.DecrementInBounds(result))
{
--bufferIterator;
}
else
{ {
// first char in buffer is a RegularChar // first char in buffer is a RegularChar
// we can't move any further back // 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 // 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); bufferSize.IncrementInBounds(result);
} }
@ -1054,17 +1058,16 @@ const COORD TextBuffer::_GetWordStartForSelection(const COORD target, const std:
{ {
COORD result = target; COORD result = target;
const auto bufferSize = GetSize(); 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 // 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); bufferSize.DecrementInBounds(result);
--bufferIterator;
} }
if (_GetDelimiterClass(*bufferIterator, wordDelimiters) != initialDelimiter) if (_GetDelimiterClassAt(result, wordDelimiters) != initialDelimiter)
{ {
// move off of delimiter // move off of delimiter
bufferSize.IncrementInBounds(result); bufferSize.IncrementInBounds(result);
@ -1116,31 +1119,20 @@ const COORD TextBuffer::_GetWordEndForAccessibility(const COORD target, const st
{ {
const auto bufferSize = GetSize(); const auto bufferSize = GetSize();
COORD result = target; COORD result = target;
auto bufferIterator = GetTextDataAt(result);
// ignore right boundary. Continue through readable text found // 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; break;
} }
} }
// make sure we expand to the beginning of the NEXT word // 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)) if (!bufferSize.IncrementInBounds(result, true))
{
++bufferIterator;
}
else
{ {
// we are at the EndInclusive COORD // we are at the EndInclusive COORD
// this signifies that we must include the last char in the buffer // 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 COORD TextBuffer::_GetWordEndForSelection(const COORD target, const std::wstring_view wordDelimiters) const
{ {
const auto bufferSize = GetSize(); const auto bufferSize = GetSize();
COORD result = target;
auto bufferIterator = GetTextDataAt(result);
// can't expand right // can't expand right
if (target.X == bufferSize.RightInclusive()) 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 // 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); bufferSize.IncrementInBounds(result);
++bufferIterator;
} }
if (_GetDelimiterClass(*bufferIterator, wordDelimiters) != initialDelimiter) if (_GetDelimiterClassAt(result, wordDelimiters) != initialDelimiter)
{ {
// move off of delimiter // move off of delimiter
bufferSize.DecrementInBounds(result); bufferSize.DecrementInBounds(result);
@ -1203,11 +1193,8 @@ bool TextBuffer::MoveToNextWord(COORD& pos, const std::wstring_view wordDelimite
auto copy = pos; auto copy = pos;
const auto bufferSize = GetSize(); 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 // 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)) if (!bufferSize.IncrementInBounds(copy))
{ {
@ -1215,8 +1202,6 @@ bool TextBuffer::MoveToNextWord(COORD& pos, const std::wstring_view wordDelimite
// thus there is no next word // thus there is no next word
return false; return false;
} }
text = GetTextDataAt(copy)->data();
delimiterClass = _GetDelimiterClass(text, wordDelimiters);
} }
// we are already on/past the last RegularChar // 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 // on whitespace, continue until the beginning of the next word
while (delimiterClass != DelimiterClass::RegularChar) while (_GetDelimiterClassAt(copy, wordDelimiters) != DelimiterClass::RegularChar)
{ {
if (!bufferSize.IncrementInBounds(copy)) if (!bufferSize.IncrementInBounds(copy))
{ {
@ -1234,8 +1219,6 @@ bool TextBuffer::MoveToNextWord(COORD& pos, const std::wstring_view wordDelimite
// there is no next word // there is no next word
return false; return false;
} }
text = GetTextDataAt(copy)->data();
delimiterClass = _GetDelimiterClass(text, wordDelimiters);
} }
// successful move, copy result out // successful move, copy result out
@ -1256,11 +1239,8 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters
auto copy = pos; auto copy = pos;
auto bufferSize = GetSize(); 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 // 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)) if (!bufferSize.DecrementInBounds(copy))
{ {
@ -1268,12 +1248,10 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters
// there is no previous word // there is no previous word
return false; return false;
} }
text = GetTextDataAt(copy)->data();
delimiterClass = _GetDelimiterClass(text, wordDelimiters);
} }
// on a word, continue until the beginning of the word // on a word, continue until the beginning of the word
while (delimiterClass == DelimiterClass::RegularChar) while (_GetDelimiterClassAt(copy, wordDelimiters) == DelimiterClass::RegularChar)
{ {
if (!bufferSize.DecrementInBounds(copy)) if (!bufferSize.DecrementInBounds(copy))
{ {
@ -1281,8 +1259,6 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters
// there is no previous word // there is no previous word
return false; return false;
} }
text = GetTextDataAt(copy)->data();
delimiterClass = _GetDelimiterClass(text, wordDelimiters);
} }
// successful move, copy result out // successful move, copy result out
@ -1290,30 +1266,6 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters
return true; 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: // Method Description:
// - Determines the line-by-line rectangles based on two COORDs // - Determines the line-by-line rectangles based on two COORDs
// - expands the rectangles to support wide glyphs // - expands the rectangles to support wide glyphs

View file

@ -197,13 +197,7 @@ private:
void _ExpandTextRow(SMALL_RECT& selectionRow) const; void _ExpandTextRow(SMALL_RECT& selectionRow) const;
enum class DelimiterClass const DelimiterClass _GetDelimiterClassAt(const COORD pos, const std::wstring_view wordDelimiters) const;
{
ControlChar,
DelimiterChar,
RegularChar
};
DelimiterClass _GetDelimiterClass(const std::wstring_view cellChar, const std::wstring_view wordDelimiters) const noexcept;
const COORD _GetWordStartForAccessibility(const COORD target, 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 _GetWordStartForSelection(const COORD target, const std::wstring_view wordDelimiters) const;
const COORD _GetWordEndForAccessibility(const COORD target, const std::wstring_view wordDelimiters) const; const COORD _GetWordEndForAccessibility(const COORD target, const std::wstring_view wordDelimiters) const;

View file

@ -265,7 +265,7 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetSelection(_Outptr_result_maybenull_
return hr; return hr;
} }
UiaTracing::TextProvider::GetSelection(*this); UiaTracing::TextProvider::GetSelection(*this, *range.Get());
return S_OK; return S_OK;
} }

View file

@ -1045,6 +1045,10 @@ void UiaTextRangeBase::_moveEndpointByUnitWord(_In_ const int moveCount,
resultPos = bufferEnd; resultPos = bufferEnd;
(*pAmountMoved)++; (*pAmountMoved)++;
} }
else
{
success = false;
}
break; break;
} }
case MovementDirection::Backward: case MovementDirection::Backward:

View file

@ -88,429 +88,529 @@ inline std::wstring UiaTracing::_getValue(const TextUnit unit) noexcept
void UiaTracing::TextRange::Constructor(const UiaTextRangeBase& result) noexcept void UiaTracing::TextRange::Constructor(const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::Constructor", TraceLoggingWrite(
TraceLoggingValue(_getValue(result).c_str(), "UiaTextRange"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "UiaTextRange::Constructor",
TraceLoggingValue(_getValue(result).c_str(), "UiaTextRange"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::Clone(const UiaTextRangeBase& utr, const UiaTextRangeBase& result) noexcept void UiaTracing::TextRange::Clone(const UiaTextRangeBase& utr, const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::Clone", TraceLoggingWrite(
TraceLoggingValue(_getValue(utr).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(result).c_str(), "clone"), "UiaTextRange::Clone",
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 void UiaTracing::TextRange::Compare(const UiaTextRangeBase& utr, const UiaTextRangeBase& other, bool result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::Compare", TraceLoggingWrite(
TraceLoggingValue(_getValue(utr).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(other).c_str(), "other"), "UiaTextRange::Compare",
TraceLoggingValue(result, "result"), TraceLoggingValue(_getValue(utr).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 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))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::CompareEndpoints", TraceLoggingWrite(
TraceLoggingValue(_getValue(utr).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(endpoint).c_str(), "baseEndpoint"), "UiaTextRange::CompareEndpoints",
TraceLoggingValue(_getValue(other).c_str(), "other"), TraceLoggingValue(_getValue(utr).c_str(), "base"),
TraceLoggingValue(_getValue(otherEndpoint).c_str(), "otherEndpoint"), TraceLoggingValue(_getValue(endpoint).c_str(), "baseEndpoint"),
TraceLoggingValue(result, "result"), TraceLoggingValue(_getValue(other).c_str(), "other"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingValue(_getValue(otherEndpoint).c_str(), "otherEndpoint"),
TraceLoggingValue(result, "result"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::ExpandToEnclosingUnit(TextUnit unit, const UiaTextRangeBase& utr) noexcept void UiaTracing::TextRange::ExpandToEnclosingUnit(TextUnit unit, const UiaTextRangeBase& utr) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::ExpandToEnclosingUnit", TraceLoggingWrite(
TraceLoggingValue(_getValue(unit).c_str(), "textUnit"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(utr).c_str(), "result"), "UiaTextRange::ExpandToEnclosingUnit",
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingValue(_getValue(unit).c_str(), "textUnit"),
TraceLoggingValue(_getValue(utr).c_str(), "result"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::FindAttribute(const UiaTextRangeBase& utr) noexcept void UiaTracing::TextRange::FindAttribute(const UiaTextRangeBase& utr) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::FindAttribute (UNSUPPORTED)", TraceLoggingWrite(
TraceLoggingValue(_getValue(utr).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "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 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))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::FindText", TraceLoggingWrite(
TraceLoggingValue(_getValue(base).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingValue(text.c_str(), "text"), "UiaTextRange::FindText",
TraceLoggingValue(searchBackward, "searchBackward"), TraceLoggingValue(_getValue(base).c_str(), "base"),
TraceLoggingValue(ignoreCase, "ignoreCase"), TraceLoggingValue(text.c_str(), "text"),
TraceLoggingValue(_getValue(result).c_str(), "result"), TraceLoggingValue(searchBackward, "searchBackward"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 void UiaTracing::TextRange::GetAttributeValue(const UiaTextRangeBase& base, TEXTATTRIBUTEID id, VARIANT result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::GetAttributeValue", TraceLoggingWrite(
TraceLoggingValue(_getValue(base).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingValue(id, "textAttributeId"), "UiaTextRange::GetAttributeValue",
TraceLoggingValue(result.vt, "result (type)"), TraceLoggingValue(_getValue(base).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingValue(id, "textAttributeId"),
TraceLoggingValue(result.vt, "result (type)"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::GetBoundingRectangles(const UiaTextRangeBase& utr) noexcept void UiaTracing::TextRange::GetBoundingRectangles(const UiaTextRangeBase& utr) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::GetBoundingRectangles", TraceLoggingWrite(
TraceLoggingValue(_getValue(utr).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "UiaTextRange::GetBoundingRectangles",
TraceLoggingValue(_getValue(utr).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::GetEnclosingElement(const UiaTextRangeBase& utr) noexcept void UiaTracing::TextRange::GetEnclosingElement(const UiaTextRangeBase& utr) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::GetEnclosingElement", TraceLoggingWrite(
TraceLoggingValue(_getValue(utr).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "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 void UiaTracing::TextRange::GetText(const UiaTextRangeBase& utr, int maxLength, std::wstring result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::GetText", TraceLoggingWrite(
TraceLoggingValue(_getValue(utr).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingValue(maxLength, "maxLength"), "UiaTextRange::GetText",
TraceLoggingValue(result.c_str(), "result"), TraceLoggingValue(_getValue(utr).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 void UiaTracing::TextRange::Move(TextUnit unit, int count, int resultCount, const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::Move", TraceLoggingWrite(
TraceLoggingValue(_getValue(unit).c_str(), "textUnit"), g_UiaProviderTraceProvider,
TraceLoggingValue(count, "count"), "UiaTextRange::Move",
TraceLoggingValue(resultCount, "resultCount"), TraceLoggingValue(_getValue(unit).c_str(), "textUnit"),
TraceLoggingValue(_getValue(result).c_str(), "result"), TraceLoggingValue(count, "count"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 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))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::MoveEndpointByUnit", TraceLoggingWrite(
TraceLoggingValue(_getValue(endpoint).c_str(), "endpoint"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(unit).c_str(), "textUnit"), "UiaTextRange::MoveEndpointByUnit",
TraceLoggingValue(count, "count"), TraceLoggingValue(_getValue(endpoint).c_str(), "endpoint"),
TraceLoggingValue(resultCount, "resultCount"), TraceLoggingValue(_getValue(unit).c_str(), "textUnit"),
TraceLoggingValue(_getValue(result).c_str(), "result"), TraceLoggingValue(count, "count"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 void UiaTracing::TextRange::MoveEndpointByRange(TextPatternRangeEndpoint endpoint, const UiaTextRangeBase& other, TextPatternRangeEndpoint otherEndpoint, const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::MoveEndpointByRange", TraceLoggingWrite(
TraceLoggingValue(_getValue(endpoint).c_str(), "endpoint"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(other).c_str(), "other"), "UiaTextRange::MoveEndpointByRange",
TraceLoggingValue(_getValue(otherEndpoint).c_str(), "otherEndpoint"), TraceLoggingValue(_getValue(endpoint).c_str(), "endpoint"),
TraceLoggingValue(_getValue(result).c_str(), "result"), TraceLoggingValue(_getValue(other).c_str(), "other"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingValue(_getValue(otherEndpoint).c_str(), "otherEndpoint"),
TraceLoggingValue(_getValue(result).c_str(), "result"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::Select(const UiaTextRangeBase& result) noexcept void UiaTracing::TextRange::Select(const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::Select", TraceLoggingWrite(
TraceLoggingValue(_getValue(result).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "UiaTextRange::Select",
TraceLoggingValue(_getValue(result).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::AddToSelection(const UiaTextRangeBase& result) noexcept void UiaTracing::TextRange::AddToSelection(const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::AddToSelection (UNSUPPORTED)", TraceLoggingWrite(
TraceLoggingValue(_getValue(result).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "UiaTextRange::AddToSelection (UNSUPPORTED)",
TraceLoggingValue(_getValue(result).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::RemoveFromSelection(const UiaTextRangeBase& result) noexcept void UiaTracing::TextRange::RemoveFromSelection(const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::RemoveFromSelection (UNSUPPORTED)", TraceLoggingWrite(
TraceLoggingValue(_getValue(result).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "UiaTextRange::RemoveFromSelection (UNSUPPORTED)",
TraceLoggingValue(_getValue(result).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::ScrollIntoView(bool alignToTop, const UiaTextRangeBase& result) noexcept void UiaTracing::TextRange::ScrollIntoView(bool alignToTop, const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::ScrollIntoView", TraceLoggingWrite(
TraceLoggingValue(alignToTop, "alignToTop"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(result).c_str(), "result"), "UiaTextRange::ScrollIntoView",
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingValue(alignToTop, "alignToTop"),
TraceLoggingValue(_getValue(result).c_str(), "result"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextRange::GetChildren(const UiaTextRangeBase& result) noexcept void UiaTracing::TextRange::GetChildren(const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"UiaTextRange::AddToSelection (UNSUPPORTED)", TraceLoggingWrite(
TraceLoggingValue(_getValue(result).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "UiaTextRange::AddToSelection (UNSUPPORTED)",
TraceLoggingValue(_getValue(result).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextProvider::Constructor(const ScreenInfoUiaProviderBase& result) noexcept void UiaTracing::TextProvider::Constructor(const ScreenInfoUiaProviderBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"ScreenInfoUiaProvider::Constructor", TraceLoggingWrite(
TraceLoggingValue(_getValue(result).c_str(), "ScreenInfoUiaProvider"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "ScreenInfoUiaProvider::Constructor",
TraceLoggingValue(_getValue(result).c_str(), "ScreenInfoUiaProvider"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextProvider::get_ProviderOptions(const ScreenInfoUiaProviderBase& siup, ProviderOptions options) noexcept void UiaTracing::TextProvider::get_ProviderOptions(const ScreenInfoUiaProviderBase& siup, ProviderOptions options) noexcept
{ {
auto getOptions = [options]() { if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
switch (options) {
{ auto getOptions = [options]() {
case ProviderOptions_ServerSideProvider: switch (options)
return L"ServerSideProvider"; {
default: case ProviderOptions_ServerSideProvider:
return L"UNKNOWN VALUE"; return L"ServerSideProvider";
} default:
}; return L"UNKNOWN VALUE";
}
};
EnsureRegistration(); EnsureRegistration();
TraceLoggingWrite( TraceLoggingWrite(
g_UiaProviderTraceProvider, g_UiaProviderTraceProvider,
"ScreenInfoUiaProvider::get_ProviderOptions", "ScreenInfoUiaProvider::get_ProviderOptions",
TraceLoggingValue(_getValue(siup).c_str(), "base"), TraceLoggingValue(_getValue(siup).c_str(), "base"),
TraceLoggingValue(getOptions(), "providerOptions"), TraceLoggingValue(getOptions(), "providerOptions"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextProvider::GetPatternProvider(const ScreenInfoUiaProviderBase& siup, PATTERNID patternId) noexcept void UiaTracing::TextProvider::GetPatternProvider(const ScreenInfoUiaProviderBase& siup, PATTERNID patternId) noexcept
{ {
auto getPattern = [patternId]() { if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
switch (patternId) {
{ auto getPattern = [patternId]() {
case UIA_TextPatternId: switch (patternId)
return L"TextPattern"; {
default: case UIA_TextPatternId:
return L"UNKNOWN VALUE"; return L"TextPattern";
} default:
}; return L"UNKNOWN VALUE";
}
};
EnsureRegistration(); EnsureRegistration();
TraceLoggingWrite( TraceLoggingWrite(
g_UiaProviderTraceProvider, g_UiaProviderTraceProvider,
"ScreenInfoUiaProvider::get_ProviderOptions", "ScreenInfoUiaProvider::get_ProviderOptions",
TraceLoggingValue(_getValue(siup).c_str(), "base"), TraceLoggingValue(_getValue(siup).c_str(), "base"),
TraceLoggingValue(getPattern(), "patternId"), TraceLoggingValue(getPattern(), "patternId"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextProvider::GetPropertyValue(const ScreenInfoUiaProviderBase& siup, PROPERTYID propertyId) noexcept void UiaTracing::TextProvider::GetPropertyValue(const ScreenInfoUiaProviderBase& siup, PROPERTYID propertyId) noexcept
{ {
auto getProperty = [propertyId]() { if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
switch (propertyId) {
{ auto getProperty = [propertyId]() {
case UIA_ControlTypePropertyId: switch (propertyId)
return L"ControlTypePropertyId"; {
case UIA_NamePropertyId: case UIA_ControlTypePropertyId:
return L"NamePropertyId"; return L"ControlTypePropertyId";
case UIA_AutomationIdPropertyId: case UIA_NamePropertyId:
return L"AutomationIdPropertyId"; return L"NamePropertyId";
case UIA_IsControlElementPropertyId: case UIA_AutomationIdPropertyId:
return L"IsControlElementPropertyId"; return L"AutomationIdPropertyId";
case UIA_IsContentElementPropertyId: case UIA_IsControlElementPropertyId:
return L"IsContentElementPropertyId"; return L"IsControlElementPropertyId";
case UIA_IsKeyboardFocusablePropertyId: case UIA_IsContentElementPropertyId:
return L"IsKeyboardFocusablePropertyId"; return L"IsContentElementPropertyId";
case UIA_HasKeyboardFocusPropertyId: case UIA_IsKeyboardFocusablePropertyId:
return L"HasKeyboardFocusPropertyId"; return L"IsKeyboardFocusablePropertyId";
case UIA_ProviderDescriptionPropertyId: case UIA_HasKeyboardFocusPropertyId:
return L"ProviderDescriptionPropertyId"; return L"HasKeyboardFocusPropertyId";
case UIA_IsEnabledPropertyId: case UIA_ProviderDescriptionPropertyId:
return L"IsEnabledPropertyId"; return L"ProviderDescriptionPropertyId";
default: case UIA_IsEnabledPropertyId:
return L"UNKNOWN VALUE"; return L"IsEnabledPropertyId";
} default:
}; return L"UNKNOWN VALUE";
}
};
EnsureRegistration(); EnsureRegistration();
TraceLoggingWrite( TraceLoggingWrite(
g_UiaProviderTraceProvider, g_UiaProviderTraceProvider,
"ScreenInfoUiaProvider::GetPropertyValue", "ScreenInfoUiaProvider::GetPropertyValue",
TraceLoggingValue(_getValue(siup).c_str(), "base"), TraceLoggingValue(_getValue(siup).c_str(), "base"),
TraceLoggingValue(getProperty(), "propertyId"), TraceLoggingValue(getProperty(), "propertyId"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextProvider::get_HostRawElementProvider(const ScreenInfoUiaProviderBase& siup) noexcept void UiaTracing::TextProvider::get_HostRawElementProvider(const ScreenInfoUiaProviderBase& siup) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"ScreenInfoUiaProvider::get_HostRawElementProvider (UNSUPPORTED)", TraceLoggingWrite(
TraceLoggingValue(_getValue(siup).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "ScreenInfoUiaProvider::get_HostRawElementProvider (UNSUPPORTED)",
TraceLoggingValue(_getValue(siup).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextProvider::GetRuntimeId(const ScreenInfoUiaProviderBase& siup) noexcept void UiaTracing::TextProvider::GetRuntimeId(const ScreenInfoUiaProviderBase& siup) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"ScreenInfoUiaProvider::GetRuntimeId", TraceLoggingWrite(
TraceLoggingValue(_getValue(siup).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "ScreenInfoUiaProvider::GetRuntimeId",
TraceLoggingValue(_getValue(siup).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextProvider::GetEmbeddedFragmentRoots(const ScreenInfoUiaProviderBase& siup) noexcept void UiaTracing::TextProvider::GetEmbeddedFragmentRoots(const ScreenInfoUiaProviderBase& siup) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"ScreenInfoUiaProvider::GetEmbeddedFragmentRoots (UNSUPPORTED)", TraceLoggingWrite(
TraceLoggingValue(_getValue(siup).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "ScreenInfoUiaProvider::GetEmbeddedFragmentRoots (UNSUPPORTED)",
TraceLoggingValue(_getValue(siup).c_str(), "base"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextProvider::SetFocus(const ScreenInfoUiaProviderBase& siup) noexcept void UiaTracing::TextProvider::SetFocus(const ScreenInfoUiaProviderBase& siup) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"ScreenInfoUiaProvider::SetFocus", TraceLoggingWrite(
TraceLoggingValue(_getValue(siup).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); "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 if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
EnsureRegistration(); {
TraceLoggingWrite( EnsureRegistration();
g_UiaProviderTraceProvider, TraceLoggingWrite(
"ScreenInfoUiaProvider::GetSelection", g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(siup).c_str(), "base"), "ScreenInfoUiaProvider::GetSelection",
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 void UiaTracing::TextProvider::GetVisibleRanges(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"ScreenInfoUiaProvider::GetVisibleRanges", TraceLoggingWrite(
TraceLoggingValue(_getValue(siup).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), "ScreenInfoUiaProvider::GetVisibleRanges",
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 void UiaTracing::TextProvider::RangeFromChild(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"ScreenInfoUiaProvider::GetVisibleRanges", TraceLoggingWrite(
TraceLoggingValue(_getValue(siup).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), "ScreenInfoUiaProvider::GetVisibleRanges",
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 void UiaTracing::TextProvider::RangeFromPoint(const ScreenInfoUiaProviderBase& siup, UiaPoint point, const UiaTextRangeBase& result) noexcept
{ {
auto getPoint = [point]() { if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
std::wstringstream stream; {
stream << "{ " << point.x << ", " << point.y << " }"; auto getPoint = [point]() {
return stream.str(); std::wstringstream stream;
}; stream << "{ " << point.x << ", " << point.y << " }";
return stream.str();
};
EnsureRegistration(); EnsureRegistration();
TraceLoggingWrite( TraceLoggingWrite(
g_UiaProviderTraceProvider, g_UiaProviderTraceProvider,
"ScreenInfoUiaProvider::RangeFromPoint", "ScreenInfoUiaProvider::RangeFromPoint",
TraceLoggingValue(_getValue(siup).c_str(), "base"), TraceLoggingValue(_getValue(siup).c_str(), "base"),
TraceLoggingValue(getPoint().c_str(), "uiaPoint"), TraceLoggingValue(getPoint().c_str(), "uiaPoint"),
TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), TraceLoggingValue(_getValue(result).c_str(), "result (utr)"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
void UiaTracing::TextProvider::get_DocumentRange(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept void UiaTracing::TextProvider::get_DocumentRange(const ScreenInfoUiaProviderBase& siup, const UiaTextRangeBase& result) noexcept
{ {
EnsureRegistration(); if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
TraceLoggingWrite( {
g_UiaProviderTraceProvider, EnsureRegistration();
"ScreenInfoUiaProvider::GetVisibleRanges", TraceLoggingWrite(
TraceLoggingValue(_getValue(siup).c_str(), "base"), g_UiaProviderTraceProvider,
TraceLoggingValue(_getValue(result).c_str(), "result (utr)"), "ScreenInfoUiaProvider::GetVisibleRanges",
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); 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 void UiaTracing::TextProvider::get_SupportedTextSelection(const ScreenInfoUiaProviderBase& siup, SupportedTextSelection result) noexcept
{ {
auto getResult = [result]() { if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
switch (result) {
{ auto getResult = [result]() {
case SupportedTextSelection_Single: switch (result)
return L"Single"; {
default: case SupportedTextSelection_Single:
return L"UNKNOWN VALUE"; return L"Single";
} default:
}; return L"UNKNOWN VALUE";
}
};
EnsureRegistration(); EnsureRegistration();
TraceLoggingWrite( TraceLoggingWrite(
g_UiaProviderTraceProvider, g_UiaProviderTraceProvider,
"ScreenInfoUiaProvider::get_SupportedTextSelection", "ScreenInfoUiaProvider::get_SupportedTextSelection",
TraceLoggingValue(_getValue(siup).c_str(), "base"), TraceLoggingValue(_getValue(siup).c_str(), "base"),
TraceLoggingValue(getResult(), "result"), TraceLoggingValue(getResult(), "result"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE)); TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
} }
#pragma warning(pop) #pragma warning(pop)

View file

@ -64,7 +64,7 @@ namespace Microsoft::Console::Types
static void GetRuntimeId(const ScreenInfoUiaProviderBase& base) noexcept; static void GetRuntimeId(const ScreenInfoUiaProviderBase& base) noexcept;
static void GetEmbeddedFragmentRoots(const ScreenInfoUiaProviderBase& base) noexcept; static void GetEmbeddedFragmentRoots(const ScreenInfoUiaProviderBase& base) noexcept;
static void SetFocus(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 GetVisibleRanges(const ScreenInfoUiaProviderBase& base, const UiaTextRangeBase& result) noexcept;
static void RangeFromChild(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; static void RangeFromPoint(const ScreenInfoUiaProviderBase& base, UiaPoint point, const UiaTextRangeBase& result) noexcept;