user32: Check for bad scroll value and fix return values inEDIT_EM_Scroll

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Thu Jan 15 17:30:38 CST 2009


Hi,

Can I get some feedback on this please?

Best Regards
  Alistair Leslie-Hughes


"Alistair Leslie-Hughes" <leslie_alistair at hotmail.com> wrote in message 
news:496DB2F4.2020505 at hotmail.com...
> Hi,
>
> Based on a patch by David Hedberg and later Austin English.
> Fixes bug 1517.
> Corrected test and corrected tab/space issues.
>
>
> Changelog:
> user32: Check for bad scroll value and fix return values in EDIT_EM_Scroll
>
> Best Regards
>  Alistair Leslie-Hughes
>
>
>
>
>
>


--------------------------------------------------------------------------------


> From 398cc9b765070ee10dd429b55f6c3b0cdb5bcc46 Mon Sep 17 00:00:00 2001
> From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
> Date: Wed, 14 Jan 2009 20:33:08 +1100
> Subject: [PATCH] Check for bad scroll value and fix return values in 
> EDIT_EM_Scroll
> To: wine-patches <wine-patches at winehq.org>
>
> ---
> dlls/user32/edit.c       |   18 +++++++++++---
> dlls/user32/tests/edit.c |   55 
> ++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 69 insertions(+), 4 deletions(-)
>
> diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
> index 6914906..4cd1497 100644
> --- a/dlls/user32/edit.c
> +++ b/dlls/user32/edit.c
> @@ -3430,13 +3430,23 @@ static LRESULT EDIT_EM_Scroll(EDITSTATE *es, INT 
> action)
>      INT vlc = get_vertical_line_count(es);
>      /* check if we are going to move too far */
>      if(es->y_offset + dy > es->line_count - vlc)
> - dy = es->line_count - vlc - es->y_offset;
> + {
> + dy = es->line_count - vlc - es->y_offset;
> +
> + /* Make sure we're not trying to scroll backwards here */
> + if(es->y_offset + dy < 0)
> + dy = 0;
> + }
>
> -     /* Notification is done in EDIT_EM_LineScroll */
> -     if(dy)
> + /* Notification is done in EDIT_EM_LineScroll */
> + if(dy)
>  EDIT_EM_LineScroll(es, 0, dy);
>  }
> - return MAKELONG((INT16)dy, (BOOL16)TRUE);
> +
> + if(dy)
> + return MAKELONG((INT16)dy, (BOOL16)TRUE);
> + else
> + return (LRESULT)FALSE;
> }
>
>
> diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
> index b1a9820..ec4759e 100644
> --- a/dlls/user32/tests/edit.c
> +++ b/dlls/user32/tests/edit.c
> @@ -1205,6 +1205,60 @@ static void test_edit_control_5(void)
>     DestroyWindow(hWnd);
> }
>
> +static void test_edit_control_6(void)
> +{
> +    HWND hwEdit;
> +    LONG r;
> +
> +    static const char *single_line_str = "a";
> +    static const char *multiline_str = "Test\nText";
> +
> +    /* Check the return value when EM_SCROLL doesn't actually scroll 
> anything. */
> +
> +    hwEdit = CreateWindow(
> +              "EDIT",
> +              single_line_str,
> +              WS_VSCROLL | ES_MULTILINE,
> +              1, 1, 35, 35,
> +              NULL, NULL, hinst, NULL);
> +
> +    assert(hwEdit);
> +
> +    trace("EDIT: Scrolling down one page \n");
> +    r = SendMessage(hwEdit, EM_SCROLL, SB_PAGEDOWN, 0);
> +    ok(!r, "Returned %x\n", r);
> +
> +    trace("EDIT: Scrolling up one page \n");
> +    r = SendMessage(hwEdit, EM_SCROLL, SB_PAGEUP, 0);
> +    ok(!r, "Returned %x\n", r);
> +
> +    trace("EDIT: Scrolling up one line\n");
> +    r = SendMessage(hwEdit, EM_SCROLL, SB_LINEUP, 0);
> +    ok(!r, "Returned %x\n", r);
> +
> +    trace("EDIT: Scrolling down one line\n");
> +    r = SendMessage(hwEdit, EM_SCROLL, SB_LINEDOWN, 0);
> +    ok(!r, "Returned %x\n", r);
> +
> +    DestroyWindow (hwEdit);
> +
> +    /* Check for bug in wine where sending SB_PAGEDOWN causes
> +       EDIT_EM_Scroll to return a negative amount of scrolled lines. */
> +
> +    hwEdit = CreateWindow(
> +                "EDIT",
> +                multiline_str,
> +                ES_MULTILINE,
> +                0, 0, 50, 1000,
> +                NULL, NULL, hinst, NULL);
> +    assert(hwEdit);
> +
> +    r = SendMessage(hwEdit, EM_SCROLL, SB_PAGEDOWN, 0);
> +    ok(!r, "Returned %x\n", r);
> +
> +    DestroyWindow (hwEdit);
> +}
> +
> static void test_edit_control_limittext(void)
> {
>     HWND hwEdit;
> @@ -2058,6 +2112,7 @@ START_TEST(edit)
>     test_edit_control_3();
>     test_edit_control_4();
>     test_edit_control_5();
> +    test_edit_control_6();
>     test_edit_control_limittext();
>     test_margins();
>     test_margins_font_change();
> -- 
> 1.5.4.3
>
>


--------------------------------------------------------------------------------


>
> 





More information about the wine-devel mailing list