[3/3] richedit: Correct limitations on values for setting zoom ratio.

Dylan Smith dylan.ah.smith at gmail.com
Tue Jan 13 12:39:39 CST 2009


I corrected ME_SetZoom based on the tests that I wrote for zooming,
since I found the limits on the values to be inconsistent with native
richedit controls.
---
 dlls/riched20/paint.c        |   17 +++++++++--------
 dlls/riched20/tests/editor.c |   16 ++++++++--------
 2 files changed, 17 insertions(+), 16 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index b6430e4..c1323d7 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -1229,18 +1229,19 @@ ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator)
 {
   /* TODO: Zoom images and objects */
 
-  if (numerator != 0)
+  if (numerator == 0 && denominator == 0)
   {
-    if (denominator == 0)
-      return FALSE;
-    if (1.0 / 64.0 > (float)numerator / (float)denominator
-        || (float)numerator / (float)denominator > 64.0)
-      return FALSE;
+    editor->nZoomNumerator = editor->nZoomDenominator = 0;
+    return TRUE;
   }
-  
+  if (numerator <= 0 || denominator <= 0)
+    return FALSE;
+  if (numerator * 64 <= denominator || numerator / denominator >= 64)
+    return FALSE;
+
   editor->nZoomNumerator = numerator;
   editor->nZoomDenominator = denominator;
-  
+
   ME_RewrapRepaint(editor);
   return TRUE;
 }
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 4165f5e..633620b 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -6376,27 +6376,27 @@ static void test_zoom(void)
     ok(ret == TRUE, "EM_SETZOOM rejected valid values (%d).\n", ret);
 
     ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)2, (LPARAM)128);
-    todo_wine ok(ret == FALSE, "EM_SETZOOM accepted invalid values (%d).\n", ret);
+    ok(ret == FALSE, "EM_SETZOOM accepted invalid values (%d).\n", ret);
 
     ret = SendMessage(hwnd, EM_GETZOOM, (WPARAM)&numerator, (LPARAM)&denominator);
-    todo_wine ok(numerator == 127, "incorrect numerator is %d\n", numerator);
-    todo_wine ok(denominator == 2, "incorrect denominator is %d\n", denominator);
+    ok(numerator == 127, "incorrect numerator is %d\n", numerator);
+    ok(denominator == 2, "incorrect denominator is %d\n", denominator);
     ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret);
 
     ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)128, (LPARAM)2);
-    todo_wine ok(ret == FALSE, "EM_SETZOOM accepted invalid values (%d).\n", ret);
+    ok(ret == FALSE, "EM_SETZOOM accepted invalid values (%d).\n", ret);
 
     /* See if negative numbers are accepted. */
     ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)-100, (LPARAM)-100);
-    todo_wine ok(ret == FALSE, "EM_SETZOOM accepted invalid values (%d).\n", ret);
+    ok(ret == FALSE, "EM_SETZOOM accepted invalid values (%d).\n", ret);
 
     /* See if negative numbers are accepted. */
     ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)0, (LPARAM)100);
-    todo_wine ok(ret == FALSE, "EM_SETZOOM failed (%d).\n", ret);
+    ok(ret == FALSE, "EM_SETZOOM failed (%d).\n", ret);
 
     ret = SendMessage(hwnd, EM_GETZOOM, (WPARAM)&numerator, (LPARAM)&denominator);
-    todo_wine ok(numerator == 127, "incorrect numerator is %d\n", numerator);
-    todo_wine ok(denominator == 2, "incorrect denominator is %d\n", denominator);
+    ok(numerator == 127, "incorrect numerator is %d\n", numerator);
+    ok(denominator == 2, "incorrect denominator is %d\n", denominator);
     ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret);
 
     /* Reset the zoom value */


More information about the wine-patches mailing list