[Win32SS|RTL]

- Fix clipping for Draw Text. Inspired by Katayama Hirofumi MZ patch and ComCtl32/RichEd20/UxThmems. See CORE-2201.

svn path=/trunk/; revision=73475
This commit is contained in:
James Tabor 2016-12-22 16:39:33 +00:00
parent 7761bf28ba
commit 527c11cf4d

View file

@ -986,6 +986,9 @@ INT WINAPI DrawTextExWorker( HDC hdc,
int prefix_offset;
ellipsis_data ellip;
BOOL invert_y=FALSE;
HRGN hrgn = 0;
#ifdef _WIN32K_
TRACE("%S, %d, %08x\n", str, count, flags);
#else
@ -1072,7 +1075,40 @@ INT WINAPI DrawTextExWorker( HDC hdc,
}
if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
#ifndef _WIN32K_ ///// Fix CORE-2201.
if (!(flags & DT_NOCLIP) )
{
int hasClip;
hrgn = CreateRectRgn(0,0,0,0);
if (hrgn)
{
hasClip = GetClipRgn(hdc, hrgn);
// If the region to be retrieved is NULL, the return value is 0.
if (hasClip != 1)
{
DeleteObject(hrgn);
hrgn = NULL;
}
IntersectClipRect(hdc, rect->left, rect->top, rect->right, rect->bottom);
}
}
#else
if (!(flags & DT_NOCLIP) )
{
int hasClip;
hrgn = NtGdiCreateRectRgn(0,0,0,0);
if (hrgn)
{
hasClip = NtGdiGetRandomRgn(hdc, hrgn, CLIPRGN);
if (hasClip != 1)
{
GreDeleteObject(hrgn);
hrgn = NULL;
}
NtGdiIntersectClipRect(hdc, rect->left, rect->top, rect->right, rect->bottom);
}
}
#endif /////
if (flags & DT_MODIFYSTRING)
{
size_retstr = (count + 4) * sizeof (WCHAR);
@ -1226,6 +1262,26 @@ INT WINAPI DrawTextExWorker( HDC hdc,
}
while (strPtr && !last_line);
#ifndef _WIN32K_
if (!(flags & DT_NOCLIP) )
{
SelectClipRgn(hdc, hrgn);
if (hrgn)
{
DeleteObject(hrgn);
}
}
#else
if (!(flags & DT_NOCLIP) )
{
NtGdiExtSelectClipRgn(hdc, hrgn, RGN_COPY);
if (hrgn)
{
GreDeleteObject(hrgn);
}
}
#endif
if (flags & DT_CALCRECT)
{
rect->right = rect->left + max_width;