mirror of
https://github.com/reactos/wine.git
synced 2024-12-04 09:53:54 +00:00
dwrite: Use [0,~0u) as initial range for strikethrough settings.
This commit is contained in:
parent
9d74a11efb
commit
ffeba2348a
@ -2175,9 +2175,6 @@ static HRESULT WINAPI dwritetextlayout_GetStrikethrough(IDWriteTextLayout2 *ifac
|
||||
|
||||
TRACE("(%p)->(%u %p %p)\n", This, position, strikethrough, r);
|
||||
|
||||
if (position >= This->len)
|
||||
return S_OK;
|
||||
|
||||
range = (struct layout_range_bool*)get_layout_range_header_by_pos(&This->strike_ranges, position);
|
||||
*strikethrough = range->value;
|
||||
|
||||
@ -3252,7 +3249,7 @@ static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, I
|
||||
static HRESULT init_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, FLOAT maxwidth, FLOAT maxheight, struct dwrite_textlayout *layout)
|
||||
{
|
||||
struct layout_range_header *range, *strike;
|
||||
DWRITE_TEXT_RANGE r;
|
||||
DWRITE_TEXT_RANGE r = { 0, ~0u };
|
||||
HRESULT hr;
|
||||
|
||||
layout->IDWriteTextLayout2_iface.lpVtbl = &dwritetextlayoutvtbl;
|
||||
@ -3296,11 +3293,7 @@ static HRESULT init_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *
|
||||
if (FAILED(hr))
|
||||
goto fail;
|
||||
|
||||
r.startPosition = 0;
|
||||
r.length = ~0u;
|
||||
range = alloc_layout_range(layout, &r, LAYOUT_RANGE_REGULAR);
|
||||
r.startPosition = 0;
|
||||
r.length = len;
|
||||
strike = alloc_layout_range(layout, &r, LAYOUT_RANGE_STRIKETHROUGH);
|
||||
if (!range || !strike) {
|
||||
free_layout_range(range);
|
||||
|
@ -1174,6 +1174,10 @@ static const struct drawcall_entry draw_seq5[] = {
|
||||
{ DRAW_LAST_KIND }
|
||||
};
|
||||
|
||||
static const struct drawcall_entry draw_seq6[] = {
|
||||
{ DRAW_LAST_KIND }
|
||||
};
|
||||
|
||||
static void test_Draw(void)
|
||||
{
|
||||
static const WCHAR strW[] = {'s','t','r','i','n','g',0};
|
||||
@ -1274,6 +1278,16 @@ static void test_Draw(void)
|
||||
ok_sequence(sequences, RENDERER_ID, draw_seq5, "draw test 5", FALSE);
|
||||
IDWriteTextLayout_Release(layout);
|
||||
|
||||
/* empty string */
|
||||
hr = IDWriteFactory_CreateTextLayout(factory, strW, 0, format, 500.0, 100.0, &layout);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
flush_sequence(sequences, RENDERER_ID);
|
||||
hr = IDWriteTextLayout_Draw(layout, NULL, &testrenderer, 0.0, 0.0);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok_sequence(sequences, RENDERER_ID, draw_seq6, "draw test 6", FALSE);
|
||||
IDWriteTextLayout_Release(layout);
|
||||
|
||||
IDWriteTextFormat_Release(format);
|
||||
IDWriteFactory_Release(factory);
|
||||
}
|
||||
@ -1532,6 +1546,17 @@ todo_wine
|
||||
|
||||
IDWriteTextLayout_Release(layout);
|
||||
|
||||
/* zero length string */
|
||||
hr = IDWriteFactory_CreateTextLayout(factory, strW, 0, format, 1000.0, 1000.0, &layout);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
count = 1;
|
||||
memset(metrics, 0, sizeof(metrics));
|
||||
hr = IDWriteTextLayout_GetClusterMetrics(layout, metrics, 3, &count);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(count == 0, "got %u\n", count);
|
||||
IDWriteTextLayout_Release(layout);
|
||||
|
||||
IDWriteInlineObject_Release(trimm);
|
||||
IDWriteTextFormat_Release(format);
|
||||
IDWriteFactory_Release(factory);
|
||||
@ -2141,6 +2166,67 @@ static void test_SetFontStretch(void)
|
||||
IDWriteTextFormat_Release(format);
|
||||
}
|
||||
|
||||
static void test_SetStrikethrough(void)
|
||||
{
|
||||
static const WCHAR strW[] = {'a','b','c','d',0};
|
||||
IDWriteTextFormat *format;
|
||||
IDWriteTextLayout *layout;
|
||||
IDWriteFactory *factory;
|
||||
DWRITE_TEXT_RANGE r;
|
||||
BOOL value;
|
||||
HRESULT hr;
|
||||
|
||||
factory = create_factory();
|
||||
|
||||
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IDWriteFactory_CreateTextLayout(factory, strW, 4, format, 1000.0, 1000.0, &layout);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
r.startPosition = 1;
|
||||
r.length = 0;
|
||||
value = TRUE;
|
||||
hr = IDWriteTextLayout_GetStrikethrough(layout, 0, &value, &r);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(r.startPosition == 0 && r.length == ~0u, "got %u, %u\n", r.startPosition, r.length);
|
||||
ok(value == FALSE, "got %d\n", value);
|
||||
|
||||
r.startPosition = 1;
|
||||
r.length = 1;
|
||||
hr = IDWriteTextLayout_SetStrikethrough(layout, TRUE, r);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
value = FALSE;
|
||||
hr = IDWriteTextLayout_GetStrikethrough(layout, 1, &value, &r);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(value == TRUE, "got %d\n", value);
|
||||
ok(r.startPosition == 1 && r.length == 1, "got %u, %u\n", r.startPosition, r.length);
|
||||
|
||||
value = TRUE;
|
||||
r.startPosition = r.length = 0;
|
||||
hr = IDWriteTextLayout_GetStrikethrough(layout, 20, &value, &r);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(r.startPosition == 2 && r.length == ~0u-2, "got %u, %u\n", r.startPosition, r.length);
|
||||
ok(value == FALSE, "got %d\n", value);
|
||||
|
||||
r.startPosition = 100;
|
||||
r.length = 4;
|
||||
hr = IDWriteTextLayout_SetStrikethrough(layout, TRUE, r);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
value = FALSE;
|
||||
r.startPosition = r.length = 0;
|
||||
hr = IDWriteTextLayout_GetStrikethrough(layout, 100, &value, &r);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(r.startPosition == 100 && r.length == 4, "got %u, %u\n", r.startPosition, r.length);
|
||||
ok(value == TRUE, "got %d\n", value);
|
||||
|
||||
IDWriteTextLayout_Release(layout);
|
||||
IDWriteTextFormat_Release(format);
|
||||
}
|
||||
|
||||
START_TEST(layout)
|
||||
{
|
||||
static const WCHAR ctrlstrW[] = {0x202a,0};
|
||||
@ -2176,6 +2262,7 @@ START_TEST(layout)
|
||||
test_SetFontFamilyName();
|
||||
test_SetFontStyle();
|
||||
test_SetFontStretch();
|
||||
test_SetStrikethrough();
|
||||
|
||||
IDWriteFactory_Release(factory);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user