Bug 435948 "pixman_region32_init_rect: Invalid rectangle passed" on
StyledText#setTopIndex(1)/scroll 

Change-Id: Ib154c1ecb282564956254a2e8799608e0ef59c4f
Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index 9107e15..3a58669 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -609,8 +609,8 @@
 		if (disjoint) {
 			rect.x = srcX;
 			rect.y = srcY;
-			rect.width = width;
-			rect.height = height;
+			rect.width = Math.max (0, width);
+			rect.height = Math.max (0, height);
 			OS.gdk_window_invalidate_rect (drawable, rect, false);
 //			OS.gdk_window_clear_area_e(drawable, srcX, srcY, width, height);
 		} else {
@@ -620,7 +620,7 @@
 				rect.x = newX;
 				rect.y = srcY;
 				rect.width = Math.abs(deltaX);
-				rect.height = height;
+				rect.height = Math.max (0, height);
 				OS.gdk_window_invalidate_rect (drawable, rect, false);
 //				OS.gdk_window_clear_area_e(drawable, newX, srcY, Math.abs(deltaX), height);
 			}
@@ -629,7 +629,7 @@
 				if (deltaY < 0) newY = destY + height;
 				rect.x = srcX;
 				rect.y = newY;
-				rect.width = width;
+				rect.width = Math.max (0, width);
 				rect.height = Math.abs(deltaY);
 				OS.gdk_window_invalidate_rect (drawable, rect, false);
 //				OS.gdk_window_clear_area_e(drawable, srcX, newY, width, Math.abs(deltaY));
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 24a88c6..2919e2f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -3773,8 +3773,8 @@
 	} else {
 		rect.x = x;
 		rect.y = y;
-		rect.width = width;
-		rect.height = height;
+		rect.width = Math.max (0, width);
+		rect.height = Math.max (0, height);
 	}
 	OS.gdk_window_invalidate_rect (window, rect, all);
 }
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 5062a8d..4d6ddd4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -819,8 +819,8 @@
 		case OS.GraphicsExpose: {
 			flushRect.x = exposeEvent.x;
 			flushRect.y = exposeEvent.y;
-			flushRect.width = exposeEvent.width;
-			flushRect.height = exposeEvent.height;
+			flushRect.width = Math.max (0, exposeEvent.width);
+			flushRect.height = Math.max (0, exposeEvent.height);
 			OS.gdk_window_invalidate_rect (window, flushRect, true);
 			exposeEvent.type = -1;
 			OS.memmove (xEvent, exposeEvent, XExposeEvent.sizeof);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
index a3de27e..1506dee 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -401,8 +401,8 @@
 		OS.gtk_widget_translate_coordinates (paintHandle, topHandle, x, y, destX, destY);
 		rect.x = destX [0];
 		rect.y = destY [0];
-		rect.width = width;
-		rect.height = height;
+		rect.width = Math.max (0, width);
+		rect.height = Math.max (0, height);
 	}
 	OS.gdk_window_invalidate_rect (window, rect, all);
 }