C26429, symbols not tested for nullness.
This commit is contained in:
parent
4f1157c044
commit
30e8e7f3a3
|
@ -584,9 +584,9 @@ COORD TextBuffer::GetLastNonSpaceCharacter(const Microsoft::Console::Types::View
|
|||
// Search the given viewport by starting at the bottom.
|
||||
coordEndOfText.Y = viewport.BottomInclusive();
|
||||
|
||||
const ROW* pCurrRow = &GetRowByOffset(coordEndOfText.Y);
|
||||
const auto& currRow = GetRowByOffset(coordEndOfText.Y);
|
||||
// The X position of the end of the valid text is the Right draw boundary (which is one beyond the final valid character)
|
||||
coordEndOfText.X = gsl::narrow<short>(pCurrRow->GetCharRow().MeasureRight()) - 1;
|
||||
coordEndOfText.X = gsl::narrow<short>(currRow.GetCharRow().MeasureRight()) - 1;
|
||||
|
||||
// If the X coordinate turns out to be -1, the row was empty, we need to search backwards for the real end of text.
|
||||
const auto viewportTop = viewport.Top();
|
||||
|
@ -594,10 +594,10 @@ COORD TextBuffer::GetLastNonSpaceCharacter(const Microsoft::Console::Types::View
|
|||
while (fDoBackUp)
|
||||
{
|
||||
coordEndOfText.Y--;
|
||||
pCurrRow = &GetRowByOffset(coordEndOfText.Y);
|
||||
const auto& backupRow = GetRowByOffset(coordEndOfText.Y);
|
||||
// We need to back up to the previous row if this line is empty, AND there are more rows
|
||||
|
||||
coordEndOfText.X = gsl::narrow<short>(pCurrRow->GetCharRow().MeasureRight()) - 1;
|
||||
coordEndOfText.X = gsl::narrow<short>(backupRow.GetCharRow().MeasureRight()) - 1;
|
||||
fDoBackUp = (coordEndOfText.X < 0 && coordEndOfText.Y > viewportTop);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
|||
_runIndex{ 0 },
|
||||
_width{ width }
|
||||
{
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, format);
|
||||
|
||||
// Fetch the locale name out once now from the format
|
||||
_localeName.resize(gsl::narrow_cast<size_t>(format->GetLocaleNameLength()) + 1); // +1 for null
|
||||
THROW_IF_FAILED(format->GetLocaleName(_localeName.data(), gsl::narrow<UINT32>(_localeName.size())));
|
||||
|
@ -58,6 +60,7 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
|||
// - S_OK or suitable DirectX/DirectWrite/Direct2D result code.
|
||||
[[nodiscard]] HRESULT STDMETHODCALLTYPE CustomTextLayout::GetColumns(_Out_ UINT32* columns)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, columns);
|
||||
*columns = 0;
|
||||
|
||||
RETURN_IF_FAILED(_AnalyzeRuns());
|
||||
|
@ -467,6 +470,8 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
|||
IDWriteTextRenderer* renderer,
|
||||
const D2D_POINT_2F origin) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, renderer);
|
||||
|
||||
try
|
||||
{
|
||||
// We're going to start from the origin given and walk to the right for each
|
||||
|
@ -561,6 +566,9 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
|||
_Outptr_result_buffer_(*textLength) WCHAR const** textString,
|
||||
_Out_ UINT32* textLength)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, textString);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, textLength);
|
||||
|
||||
*textString = nullptr;
|
||||
*textLength = 0;
|
||||
|
||||
|
@ -587,6 +595,9 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
|||
_Outptr_result_buffer_(*textLength) WCHAR const** textString,
|
||||
_Out_ UINT32* textLength) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, textString);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, textLength);
|
||||
|
||||
*textString = nullptr;
|
||||
*textLength = 0;
|
||||
|
||||
|
@ -624,6 +635,9 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
|||
_Out_ UINT32* textLength,
|
||||
_Outptr_result_z_ WCHAR const** localeName) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, textLength);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, localeName);
|
||||
|
||||
*localeName = _localeName.data();
|
||||
*textLength = gsl::narrow<UINT32>(_text.size()) - textPosition;
|
||||
|
||||
|
@ -643,6 +657,9 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
|||
_Out_ UINT32* textLength,
|
||||
_COM_Outptr_ IDWriteNumberSubstitution** numberSubstitution) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, textLength);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, numberSubstitution);
|
||||
|
||||
*numberSubstitution = nullptr;
|
||||
*textLength = gsl::narrow<UINT32>(_text.size()) - textPosition;
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ using namespace Microsoft::Console::Render;
|
|||
[[nodiscard]] HRESULT CustomTextRenderer::IsPixelSnappingDisabled(void* /*clientDrawingContext*/,
|
||||
_Out_ BOOL* isDisabled) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, isDisabled);
|
||||
|
||||
*isDisabled = false;
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -40,7 +42,10 @@ using namespace Microsoft::Console::Render;
|
|||
[[nodiscard]] HRESULT CustomTextRenderer::GetPixelsPerDip(void* clientDrawingContext,
|
||||
_Out_ FLOAT* pixelsPerDip) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pixelsPerDip);
|
||||
|
||||
DrawingContext* drawingContext = static_cast<DrawingContext*>(clientDrawingContext);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, drawingContext);
|
||||
|
||||
float dpiX, dpiY;
|
||||
drawingContext->renderTarget->GetDpi(&dpiX, &dpiY);
|
||||
|
@ -60,7 +65,10 @@ using namespace Microsoft::Console::Render;
|
|||
[[nodiscard]] HRESULT CustomTextRenderer::GetCurrentTransform(void* clientDrawingContext,
|
||||
DWRITE_MATRIX* transform) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, transform);
|
||||
|
||||
DrawingContext* drawingContext = static_cast<DrawingContext*>(clientDrawingContext);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, drawingContext);
|
||||
|
||||
// Matrix structures are defined identically
|
||||
drawingContext->renderTarget->GetTransform(reinterpret_cast<D2D1_MATRIX_3X2_F*>(transform));
|
||||
|
@ -90,15 +98,14 @@ using namespace Microsoft::Console::Render;
|
|||
_In_ const DWRITE_UNDERLINE* underline,
|
||||
IUnknown* clientDrawingEffect) noexcept
|
||||
{
|
||||
_FillRectangle(clientDrawingContext,
|
||||
clientDrawingEffect,
|
||||
baselineOriginX,
|
||||
baselineOriginY + underline->offset,
|
||||
underline->width,
|
||||
underline->thickness,
|
||||
underline->readingDirection,
|
||||
underline->flowDirection);
|
||||
return S_OK;
|
||||
return _FillRectangle(clientDrawingContext,
|
||||
clientDrawingEffect,
|
||||
baselineOriginX,
|
||||
baselineOriginY + underline->offset,
|
||||
underline->width,
|
||||
underline->thickness,
|
||||
underline->readingDirection,
|
||||
underline->flowDirection);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -122,15 +129,14 @@ using namespace Microsoft::Console::Render;
|
|||
_In_ const DWRITE_STRIKETHROUGH* strikethrough,
|
||||
IUnknown* clientDrawingEffect) noexcept
|
||||
{
|
||||
_FillRectangle(clientDrawingContext,
|
||||
clientDrawingEffect,
|
||||
baselineOriginX,
|
||||
baselineOriginY + strikethrough->offset,
|
||||
strikethrough->width,
|
||||
strikethrough->thickness,
|
||||
strikethrough->readingDirection,
|
||||
strikethrough->flowDirection);
|
||||
return S_OK;
|
||||
return _FillRectangle(clientDrawingContext,
|
||||
clientDrawingEffect,
|
||||
baselineOriginX,
|
||||
baselineOriginY + strikethrough->offset,
|
||||
strikethrough->width,
|
||||
strikethrough->thickness,
|
||||
strikethrough->readingDirection,
|
||||
strikethrough->flowDirection);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -146,16 +152,17 @@ using namespace Microsoft::Console::Render;
|
|||
// - flowDirection - textual flow information that could affect the rectangle
|
||||
// Return Value:
|
||||
// - S_OK
|
||||
void CustomTextRenderer::_FillRectangle(void* clientDrawingContext,
|
||||
IUnknown* clientDrawingEffect,
|
||||
float x,
|
||||
float y,
|
||||
float width,
|
||||
float thickness,
|
||||
DWRITE_READING_DIRECTION /*readingDirection*/,
|
||||
DWRITE_FLOW_DIRECTION /*flowDirection*/) noexcept
|
||||
[[nodiscard]] HRESULT CustomTextRenderer::_FillRectangle(void* clientDrawingContext,
|
||||
IUnknown* clientDrawingEffect,
|
||||
float x,
|
||||
float y,
|
||||
float width,
|
||||
float thickness,
|
||||
DWRITE_READING_DIRECTION /*readingDirection*/,
|
||||
DWRITE_FLOW_DIRECTION /*flowDirection*/) noexcept
|
||||
{
|
||||
DrawingContext* drawingContext = static_cast<DrawingContext*>(clientDrawingContext);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, drawingContext);
|
||||
|
||||
// Get brush
|
||||
ID2D1Brush* brush = drawingContext->foregroundBrush;
|
||||
|
@ -191,6 +198,8 @@ void CustomTextRenderer::_FillRectangle(void* clientDrawingContext,
|
|||
BOOL isRightToLeft,
|
||||
IUnknown* clientDrawingEffect) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, inlineObject);
|
||||
|
||||
return inlineObject->Draw(clientDrawingContext,
|
||||
this,
|
||||
originX,
|
||||
|
@ -254,7 +263,7 @@ void CustomTextRenderer::_FillRectangle(void* clientDrawingContext,
|
|||
{
|
||||
rect.right += advance;
|
||||
}
|
||||
|
||||
|
||||
d2dContext->FillRectangle(rect, drawingContext->backgroundBrush);
|
||||
|
||||
// Now go onto drawing the text.
|
||||
|
@ -284,13 +293,13 @@ void CustomTextRenderer::_FillRectangle(void* clientDrawingContext,
|
|||
// there are, glyphRunEnumerator can be used to iterate through them.
|
||||
::Microsoft::WRL::ComPtr<IDWriteColorGlyphRunEnumerator1> glyphRunEnumerator;
|
||||
const HRESULT hr = dwriteFactory4->TranslateColorGlyphRun(baselineOrigin,
|
||||
glyphRun,
|
||||
glyphRunDescription,
|
||||
supportedFormats,
|
||||
measuringMode,
|
||||
nullptr,
|
||||
0,
|
||||
&glyphRunEnumerator);
|
||||
glyphRun,
|
||||
glyphRunDescription,
|
||||
supportedFormats,
|
||||
measuringMode,
|
||||
nullptr,
|
||||
0,
|
||||
&glyphRunEnumerator);
|
||||
|
||||
// If the analysis found no color glyphs in the run, just draw normally.
|
||||
if (hr == DWRITE_E_NOCOLOR)
|
||||
|
@ -414,6 +423,11 @@ void CustomTextRenderer::_FillRectangle(void* clientDrawingContext,
|
|||
_In_ const DWRITE_GLYPH_RUN_DESCRIPTION* glyphRunDescription,
|
||||
ID2D1Brush* brush)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, clientDrawingContext);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, glyphRun);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, glyphRunDescription);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, brush);
|
||||
|
||||
::Microsoft::WRL::ComPtr<ID2D1DeviceContext> d2dContext;
|
||||
RETURN_IF_FAILED(clientDrawingContext->renderTarget->QueryInterface(d2dContext.GetAddressOf()));
|
||||
|
||||
|
@ -435,6 +449,9 @@ void CustomTextRenderer::_FillRectangle(void* clientDrawingContext,
|
|||
_In_ const DWRITE_GLYPH_RUN* glyphRun,
|
||||
_In_ const DWRITE_GLYPH_RUN_DESCRIPTION* /*glyphRunDescription*/) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, clientDrawingContext);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, glyphRun);
|
||||
|
||||
// This is regular text but manually
|
||||
::Microsoft::WRL::ComPtr<ID2D1Factory> d2dFactory;
|
||||
clientDrawingContext->renderTarget->GetFactory(d2dFactory.GetAddressOf());
|
||||
|
@ -475,6 +492,9 @@ void CustomTextRenderer::_FillRectangle(void* clientDrawingContext,
|
|||
_In_ const DWRITE_GLYPH_RUN* glyphRun,
|
||||
_In_ const DWRITE_GLYPH_RUN_DESCRIPTION* /*glyphRunDescription*/) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, clientDrawingContext);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, glyphRun);
|
||||
|
||||
// This is glow text manually
|
||||
::Microsoft::WRL::ComPtr<ID2D1Factory> d2dFactory;
|
||||
clientDrawingContext->renderTarget->GetFactory(d2dFactory.GetAddressOf());
|
||||
|
|
|
@ -81,14 +81,14 @@ namespace Microsoft::Console::Render
|
|||
IUnknown* clientDrawingEffect) noexcept override;
|
||||
|
||||
private:
|
||||
void _FillRectangle(void* clientDrawingContext,
|
||||
IUnknown* clientDrawingEffect,
|
||||
float x,
|
||||
float y,
|
||||
float width,
|
||||
float thickness,
|
||||
DWRITE_READING_DIRECTION readingDirection,
|
||||
DWRITE_FLOW_DIRECTION flowDirection) noexcept;
|
||||
[[nodiscard]] HRESULT _FillRectangle(void* clientDrawingContext,
|
||||
IUnknown* clientDrawingEffect,
|
||||
float x,
|
||||
float y,
|
||||
float width,
|
||||
float thickness,
|
||||
DWRITE_READING_DIRECTION readingDirection,
|
||||
DWRITE_FLOW_DIRECTION flowDirection) noexcept;
|
||||
|
||||
[[nodiscard]] HRESULT _DrawBasicGlyphRun(DrawingContext* clientDrawingContext,
|
||||
D2D1_POINT_2F baselineOrigin,
|
||||
|
|
|
@ -444,6 +444,8 @@ Microsoft::WRL::ComPtr<IDXGISwapChain1> DxEngine::GetSwapChain()
|
|||
// - S_OK
|
||||
[[nodiscard]] HRESULT DxEngine::Invalidate(const SMALL_RECT* const psrRegion) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, psrRegion);
|
||||
|
||||
_InvalidOr(*psrRegion);
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -456,6 +458,8 @@ Microsoft::WRL::ComPtr<IDXGISwapChain1> DxEngine::GetSwapChain()
|
|||
// - S_OK
|
||||
[[nodiscard]] HRESULT DxEngine::InvalidateCursor(const COORD* const pcoordCursor) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pcoordCursor);
|
||||
|
||||
const SMALL_RECT sr = Microsoft::Console::Types::Viewport::FromCoord(*pcoordCursor).ToInclusive();
|
||||
return Invalidate(&sr);
|
||||
}
|
||||
|
@ -468,6 +472,8 @@ Microsoft::WRL::ComPtr<IDXGISwapChain1> DxEngine::GetSwapChain()
|
|||
// - S_OK
|
||||
[[nodiscard]] HRESULT DxEngine::InvalidateSystem(const RECT* const prcDirtyClient) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, prcDirtyClient);
|
||||
|
||||
_InvalidOr(*prcDirtyClient);
|
||||
|
||||
return S_OK;
|
||||
|
@ -564,6 +570,8 @@ Microsoft::WRL::ComPtr<IDXGISwapChain1> DxEngine::GetSwapChain()
|
|||
// - S_FALSE because we don't use this.
|
||||
[[nodiscard]] HRESULT DxEngine::InvalidateCircling(_Out_ bool* const pForcePaint) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pForcePaint);
|
||||
|
||||
*pForcePaint = false;
|
||||
return S_FALSE;
|
||||
}
|
||||
|
@ -709,6 +717,8 @@ void DxEngine::_InvalidOr(RECT rc) noexcept
|
|||
// - S_FALSE because this is unused.
|
||||
[[nodiscard]] HRESULT DxEngine::PrepareForTeardown(_Out_ bool* const pForcePaint) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pForcePaint);
|
||||
|
||||
*pForcePaint = false;
|
||||
return S_FALSE;
|
||||
}
|
||||
|
@ -1382,6 +1392,8 @@ float DxEngine::GetScaling() const noexcept
|
|||
// - S_OK or relevant DirectWrite error.
|
||||
[[nodiscard]] HRESULT DxEngine::IsGlyphWideByFont(const std::wstring_view glyph, _Out_ bool* const pResult) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pResult);
|
||||
|
||||
try
|
||||
{
|
||||
const Cluster cluster(glyph, 0); // columns don't matter, we're doing analysis not layout.
|
||||
|
@ -1532,6 +1544,8 @@ float DxEngine::GetScaling() const noexcept
|
|||
[[nodiscard]] std::wstring DxEngine::_GetFontFamilyName(IDWriteFontFamily* const fontFamily,
|
||||
std::wstring& localeName) const
|
||||
{
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, fontFamily);
|
||||
|
||||
// See: https://docs.microsoft.com/en-us/windows/win32/api/dwrite/nn-dwrite-idwritefontcollection
|
||||
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> familyNames;
|
||||
THROW_IF_FAILED(fontFamily->GetFamilyNames(&familyNames));
|
||||
|
|
|
@ -98,6 +98,8 @@ ScreenInfoUiaProviderBase::Release()
|
|||
IFACEMETHODIMP ScreenInfoUiaProviderBase::QueryInterface(_In_ REFIID riid,
|
||||
_COM_Outptr_result_maybenull_ void** ppInterface)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppInterface);
|
||||
|
||||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||
//Tracing::s_TraceUia(this, ApiCall::QueryInterface, nullptr);
|
||||
if (riid == __uuidof(IUnknown))
|
||||
|
@ -135,6 +137,8 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::QueryInterface(_In_ REFIID riid,
|
|||
// Gets UI Automation provider options.
|
||||
IFACEMETHODIMP ScreenInfoUiaProviderBase::get_ProviderOptions(_Out_ ProviderOptions* pOptions) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pOptions);
|
||||
|
||||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||
//Tracing::s_TraceUia(this, ApiCall::GetProviderOptions, nullptr);
|
||||
*pOptions = ProviderOptions_ServerSideProvider;
|
||||
|
@ -302,7 +306,7 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetSelection(_Outptr_result_maybenull_
|
|||
_UnlockConsole();
|
||||
});
|
||||
|
||||
RETURN_HR_IF(E_INVALIDARG, ppRetVal == nullptr);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppRetVal);
|
||||
*ppRetVal = nullptr;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
|
@ -324,6 +328,14 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetSelection(_Outptr_result_maybenull_
|
|||
|
||||
IRawElementProviderSimple* pProvider;
|
||||
hr = this->QueryInterface(IID_PPV_ARGS(&pProvider));
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
if (pProvider == nullptr)
|
||||
{
|
||||
hr = E_POINTER;
|
||||
}
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
SafeArrayDestroy(*ppRetVal);
|
||||
|
@ -365,6 +377,7 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetSelection(_Outptr_result_maybenull_
|
|||
std::deque<UiaTextRangeBase*> ranges;
|
||||
IRawElementProviderSimple* pProvider;
|
||||
RETURN_IF_FAILED(QueryInterface(IID_PPV_ARGS(&pProvider)));
|
||||
RETURN_HR_IF_NULL(E_POINTER, pProvider);
|
||||
try
|
||||
{
|
||||
ranges = GetSelectionRanges(pProvider);
|
||||
|
@ -399,7 +412,10 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetSelection(_Outptr_result_maybenull_
|
|||
{
|
||||
UiaTextRangeBase* pRange = ranges.at(0);
|
||||
ranges.pop_front();
|
||||
pRange->Release();
|
||||
if (pRange)
|
||||
{
|
||||
pRange->Release();
|
||||
}
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
@ -421,7 +437,7 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetVisibleRanges(_Outptr_result_mayben
|
|||
_UnlockConsole();
|
||||
});
|
||||
|
||||
RETURN_HR_IF(E_INVALIDARG, ppRetVal == nullptr);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppRetVal);
|
||||
*ppRetVal = nullptr;
|
||||
|
||||
const auto viewport = _getViewport();
|
||||
|
@ -446,6 +462,14 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetVisibleRanges(_Outptr_result_mayben
|
|||
|
||||
IRawElementProviderSimple* pProvider;
|
||||
HRESULT hr = this->QueryInterface(IID_PPV_ARGS(&pProvider));
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
if (pProvider == nullptr)
|
||||
{
|
||||
hr = E_POINTER;
|
||||
}
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
SafeArrayDestroy(*ppRetVal);
|
||||
|
@ -493,11 +517,12 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::RangeFromChild(_In_ IRawElementProvide
|
|||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||
//Tracing::s_TraceUia(this, ApiCall::RangeFromChild, nullptr);
|
||||
|
||||
RETURN_HR_IF(E_INVALIDARG, ppRetVal == nullptr);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppRetVal);
|
||||
*ppRetVal = nullptr;
|
||||
|
||||
IRawElementProviderSimple* pProvider;
|
||||
RETURN_IF_FAILED(this->QueryInterface(IID_PPV_ARGS(&pProvider)));
|
||||
RETURN_HR_IF_NULL(E_POINTER, pProvider);
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
try
|
||||
|
@ -520,11 +545,12 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::RangeFromPoint(_In_ UiaPoint point,
|
|||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||
//Tracing::s_TraceUia(this, ApiCall::RangeFromPoint, nullptr);
|
||||
|
||||
RETURN_HR_IF(E_INVALIDARG, ppRetVal == nullptr);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppRetVal);
|
||||
*ppRetVal = nullptr;
|
||||
|
||||
IRawElementProviderSimple* pProvider;
|
||||
RETURN_IF_FAILED(this->QueryInterface(IID_PPV_ARGS(&pProvider)));
|
||||
RETURN_HR_IF_NULL(E_POINTER, pProvider);
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
try
|
||||
|
@ -547,11 +573,12 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::get_DocumentRange(_COM_Outptr_result_m
|
|||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||
//Tracing::s_TraceUia(this, ApiCall::GetDocumentRange, nullptr);
|
||||
|
||||
RETURN_HR_IF(E_INVALIDARG, ppRetVal == nullptr);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppRetVal);
|
||||
*ppRetVal = nullptr;
|
||||
|
||||
IRawElementProviderSimple* pProvider;
|
||||
RETURN_IF_FAILED(this->QueryInterface(IID_PPV_ARGS(&pProvider)));
|
||||
RETURN_HR_IF_NULL(E_POINTER, pProvider);
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
try
|
||||
|
@ -575,6 +602,8 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::get_DocumentRange(_COM_Outptr_result_m
|
|||
|
||||
IFACEMETHODIMP ScreenInfoUiaProviderBase::get_SupportedTextSelection(_Out_ SupportedTextSelection* pRetVal) noexcept
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pRetVal);
|
||||
|
||||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||
//Tracing::s_TraceUia(this, ApiCall::GetSupportedTextSelection, nullptr);
|
||||
|
||||
|
|
|
@ -1017,6 +1017,7 @@ IFACEMETHODIMP UiaTextRangeBase::GetChildren(_Outptr_result_maybenull_ SAFEARRAY
|
|||
|
||||
const COORD UiaTextRangeBase::_getScreenBufferCoords(IUiaData* pData)
|
||||
{
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
return pData->GetTextBuffer().GetSize().Dimensions();
|
||||
}
|
||||
|
||||
|
@ -1037,8 +1038,9 @@ const COORD UiaTextRangeBase::_getScreenFontSize() const
|
|||
// - <none>
|
||||
// Return Value:
|
||||
// - The number of rows
|
||||
const unsigned int UiaTextRangeBase::_getTotalRows(IUiaData* pData) noexcept
|
||||
const unsigned int UiaTextRangeBase::_getTotalRows(IUiaData* pData)
|
||||
{
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
return pData->GetTextBuffer().TotalRowCount();
|
||||
}
|
||||
|
||||
|
@ -1109,8 +1111,9 @@ const unsigned int UiaTextRangeBase::_rowCountInRange(IUiaData* pData) const
|
|||
// Return Value:
|
||||
// - the equivalent ScreenInfoRow.
|
||||
const ScreenInfoRow UiaTextRangeBase::_textBufferRowToScreenInfoRow(IUiaData* pData,
|
||||
const TextBufferRow row) noexcept
|
||||
const TextBufferRow row)
|
||||
{
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
const int firstRowIndex = pData->GetTextBuffer().GetFirstRowIndex();
|
||||
return _normalizeRow(pData, row - firstRowIndex);
|
||||
}
|
||||
|
@ -1122,8 +1125,9 @@ const ScreenInfoRow UiaTextRangeBase::_textBufferRowToScreenInfoRow(IUiaData* pD
|
|||
// - row - the ScreenInfoRow to convert
|
||||
// Return Value:
|
||||
// - the equivalent ViewportRow.
|
||||
const ViewportRow UiaTextRangeBase::_screenInfoRowToViewportRow(IUiaData* pData, const ScreenInfoRow row) noexcept
|
||||
const ViewportRow UiaTextRangeBase::_screenInfoRowToViewportRow(IUiaData* pData, const ScreenInfoRow row)
|
||||
{
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
const SMALL_RECT viewport = pData->GetViewport().ToInclusive();
|
||||
return _screenInfoRowToViewportRow(row, viewport);
|
||||
}
|
||||
|
@ -1192,8 +1196,9 @@ const unsigned int UiaTextRangeBase::_getViewportWidth(const SMALL_RECT viewport
|
|||
// Return Value:
|
||||
// - true if the row is within the bounds of the viewport
|
||||
const bool UiaTextRangeBase::_isScreenInfoRowInViewport(IUiaData* pData,
|
||||
const ScreenInfoRow row) noexcept
|
||||
{
|
||||
const ScreenInfoRow row)
|
||||
{
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
return _isScreenInfoRowInViewport(row, pData->GetViewport().ToInclusive());
|
||||
}
|
||||
|
||||
|
@ -1219,8 +1224,9 @@ const bool UiaTextRangeBase::_isScreenInfoRowInViewport(const ScreenInfoRow row,
|
|||
// Return Value:
|
||||
// - the equivalent TextBufferRow.
|
||||
const TextBufferRow UiaTextRangeBase::_screenInfoRowToTextBufferRow(IUiaData* pData,
|
||||
const ScreenInfoRow row) noexcept
|
||||
const ScreenInfoRow row)
|
||||
{
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
const TextBufferRow firstRowIndex = pData->GetTextBuffer().GetFirstRowIndex();
|
||||
return _normalizeRow(pData, row + firstRowIndex);
|
||||
}
|
||||
|
@ -1444,6 +1450,8 @@ std::pair<Endpoint, Endpoint> UiaTextRangeBase::_moveByCharacterForward(IUiaData
|
|||
const MoveState moveState,
|
||||
_Out_ int* const pAmountMoved)
|
||||
{
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
||||
*pAmountMoved = 0;
|
||||
const int count = moveCount;
|
||||
ScreenInfoRow currentScreenInfoRow = moveState.StartScreenInfoRow;
|
||||
|
@ -1490,7 +1498,8 @@ std::pair<Endpoint, Endpoint> UiaTextRangeBase::_moveByCharacterBackward(IUiaDat
|
|||
const MoveState moveState,
|
||||
_Out_ int* const pAmountMoved)
|
||||
{
|
||||
THROW_HR_IF(E_INVALIDARG, pAmountMoved == nullptr);
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
||||
*pAmountMoved = 0;
|
||||
const int count = moveCount;
|
||||
ScreenInfoRow currentScreenInfoRow = moveState.StartScreenInfoRow;
|
||||
|
@ -1643,7 +1652,8 @@ UiaTextRangeBase::_moveEndpointByUnitCharacterForward(IUiaData* pData,
|
|||
const MoveState moveState,
|
||||
_Out_ int* const pAmountMoved)
|
||||
{
|
||||
THROW_HR_IF(E_INVALIDARG, pAmountMoved == nullptr);
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
||||
*pAmountMoved = 0;
|
||||
const int count = moveCount;
|
||||
ScreenInfoRow currentScreenInfoRow;
|
||||
|
@ -1733,7 +1743,8 @@ UiaTextRangeBase::_moveEndpointByUnitCharacterBackward(IUiaData* pData,
|
|||
const MoveState moveState,
|
||||
_Out_ int* const pAmountMoved)
|
||||
{
|
||||
THROW_HR_IF(E_INVALIDARG, pAmountMoved == nullptr);
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pData);
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
||||
*pAmountMoved = 0;
|
||||
const int count = moveCount;
|
||||
ScreenInfoRow currentScreenInfoRow;
|
||||
|
@ -2073,6 +2084,7 @@ RECT UiaTextRangeBase::_getTerminalRect() const
|
|||
|
||||
IRawElementProviderFragment* pRawElementProviderFragment;
|
||||
THROW_IF_FAILED(_pProvider->QueryInterface<IRawElementProviderFragment>(&pRawElementProviderFragment));
|
||||
THROW_HR_IF_NULL(E_POINTER, pRawElementProviderFragment);
|
||||
pRawElementProviderFragment->get_BoundingRectangle(&result);
|
||||
|
||||
return {
|
||||
|
|
|
@ -262,7 +262,7 @@ namespace Microsoft::Console::Types
|
|||
static const COORD _getScreenBufferCoords(IUiaData* pData);
|
||||
virtual const COORD _getScreenFontSize() const;
|
||||
|
||||
static const unsigned int _getTotalRows(IUiaData* pData) noexcept;
|
||||
static const unsigned int _getTotalRows(IUiaData* pData);
|
||||
static const unsigned int _getRowWidth(IUiaData* pData);
|
||||
|
||||
static const unsigned int _getFirstScreenInfoRowIndex() noexcept;
|
||||
|
@ -276,10 +276,10 @@ namespace Microsoft::Console::Types
|
|||
static const TextBufferRow _endpointToTextBufferRow(IUiaData* pData,
|
||||
const Endpoint endpoint);
|
||||
static const ScreenInfoRow _textBufferRowToScreenInfoRow(IUiaData* pData,
|
||||
const TextBufferRow row) noexcept;
|
||||
const TextBufferRow row);
|
||||
|
||||
static const TextBufferRow _screenInfoRowToTextBufferRow(IUiaData* pData,
|
||||
const ScreenInfoRow row) noexcept;
|
||||
const ScreenInfoRow row);
|
||||
static const Endpoint _textBufferRowToEndpoint(IUiaData* pData, const TextBufferRow row);
|
||||
|
||||
static const ScreenInfoRow _endpointToScreenInfoRow(IUiaData* pData,
|
||||
|
@ -298,12 +298,12 @@ namespace Microsoft::Console::Types
|
|||
static const Row _normalizeRow(IUiaData* pData, const Row row) noexcept;
|
||||
|
||||
static const ViewportRow _screenInfoRowToViewportRow(IUiaData* pData,
|
||||
const ScreenInfoRow row) noexcept;
|
||||
const ScreenInfoRow row);
|
||||
static const ViewportRow _screenInfoRowToViewportRow(const ScreenInfoRow row,
|
||||
const SMALL_RECT viewport) noexcept;
|
||||
|
||||
static const bool _isScreenInfoRowInViewport(IUiaData* pData,
|
||||
const ScreenInfoRow row) noexcept;
|
||||
const ScreenInfoRow row);
|
||||
static const bool _isScreenInfoRowInViewport(const ScreenInfoRow row,
|
||||
const SMALL_RECT viewport) noexcept;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ WindowUiaProviderBase::Release()
|
|||
|
||||
IFACEMETHODIMP WindowUiaProviderBase::QueryInterface(_In_ REFIID riid, _COM_Outptr_result_maybenull_ void** ppInterface)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppInterface);
|
||||
if (riid == __uuidof(IUnknown))
|
||||
{
|
||||
*ppInterface = static_cast<IRawElementProviderSimple*>(this);
|
||||
|
@ -71,6 +72,7 @@ IFACEMETHODIMP WindowUiaProviderBase::QueryInterface(_In_ REFIID riid, _COM_Outp
|
|||
// Gets UI Automation provider options.
|
||||
IFACEMETHODIMP WindowUiaProviderBase::get_ProviderOptions(_Out_ ProviderOptions* pOptions)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pOptions);
|
||||
RETURN_IF_FAILED(_EnsureValidHwnd());
|
||||
|
||||
*pOptions = ProviderOptions_ServerSideProvider;
|
||||
|
@ -82,6 +84,7 @@ IFACEMETHODIMP WindowUiaProviderBase::get_ProviderOptions(_Out_ ProviderOptions*
|
|||
IFACEMETHODIMP WindowUiaProviderBase::GetPatternProvider(_In_ PATTERNID /*patternId*/,
|
||||
_COM_Outptr_result_maybenull_ IUnknown** ppInterface)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppInterface);
|
||||
*ppInterface = nullptr;
|
||||
RETURN_IF_FAILED(_EnsureValidHwnd());
|
||||
|
||||
|
@ -92,6 +95,7 @@ IFACEMETHODIMP WindowUiaProviderBase::GetPatternProvider(_In_ PATTERNID /*patter
|
|||
// Gets custom properties.
|
||||
IFACEMETHODIMP WindowUiaProviderBase::GetPropertyValue(_In_ PROPERTYID propertyId, _Out_ VARIANT* pVariant)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pVariant);
|
||||
RETURN_IF_FAILED(_EnsureValidHwnd());
|
||||
|
||||
pVariant->vt = VT_EMPTY;
|
||||
|
@ -148,6 +152,7 @@ IFACEMETHODIMP WindowUiaProviderBase::GetPropertyValue(_In_ PROPERTYID propertyI
|
|||
// supplies many properties.
|
||||
IFACEMETHODIMP WindowUiaProviderBase::get_HostRawElementProvider(_COM_Outptr_result_maybenull_ IRawElementProviderSimple** ppProvider)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppProvider);
|
||||
try
|
||||
{
|
||||
const HWND hwnd = GetWindowHandle();
|
||||
|
@ -164,6 +169,7 @@ IFACEMETHODIMP WindowUiaProviderBase::get_HostRawElementProvider(_COM_Outptr_res
|
|||
|
||||
IFACEMETHODIMP WindowUiaProviderBase::GetRuntimeId(_Outptr_result_maybenull_ SAFEARRAY** ppRuntimeId)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppRuntimeId);
|
||||
RETURN_IF_FAILED(_EnsureValidHwnd());
|
||||
// Root defers this to host, others must implement it...
|
||||
*ppRuntimeId = nullptr;
|
||||
|
@ -173,6 +179,7 @@ IFACEMETHODIMP WindowUiaProviderBase::GetRuntimeId(_Outptr_result_maybenull_ SAF
|
|||
|
||||
IFACEMETHODIMP WindowUiaProviderBase::get_BoundingRectangle(_Out_ UiaRect* pRect)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, pRect);
|
||||
RETURN_IF_FAILED(_EnsureValidHwnd());
|
||||
|
||||
const IUiaWindow* const pConsoleWindow = _baseWindow;
|
||||
|
@ -195,6 +202,7 @@ IFACEMETHODIMP WindowUiaProviderBase::get_BoundingRectangle(_Out_ UiaRect* pRect
|
|||
|
||||
IFACEMETHODIMP WindowUiaProviderBase::GetEmbeddedFragmentRoots(_Outptr_result_maybenull_ SAFEARRAY** ppRoots)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppRoots);
|
||||
RETURN_IF_FAILED(_EnsureValidHwnd());
|
||||
|
||||
*ppRoots = nullptr;
|
||||
|
@ -203,6 +211,7 @@ IFACEMETHODIMP WindowUiaProviderBase::GetEmbeddedFragmentRoots(_Outptr_result_ma
|
|||
|
||||
IFACEMETHODIMP WindowUiaProviderBase::get_FragmentRoot(_COM_Outptr_result_maybenull_ IRawElementProviderFragmentRoot** ppProvider)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, ppProvider);
|
||||
RETURN_IF_FAILED(_EnsureValidHwnd());
|
||||
|
||||
*ppProvider = this;
|
||||
|
|
Loading…
Reference in a new issue