diff --git a/gtk/gtkroundedbox.c b/gtk/gtkroundedbox.c
index 5b1eefc..9b84526 100644
--- a/gtk/gtkroundedbox.c
+++ b/gtk/gtkroundedbox.c
@@ -48,6 +48,47 @@ _gtk_rounded_box_init_rect (GtkRoundedBox *box,
   memset (&box->border_radius, 0, sizeof (GtkCssBorderRadius));
 }
 
+/* clamp border radius, following CSS specs */
+static void
+gtk_rounded_box_clamp_border_radius (GtkRoundedBox *box)
+{
+  gdouble factor = 1.0;
+
+  /* left */
+  if (box->border_radius.top_left.vertical + box->border_radius.bottom_left.vertical > 0 &&
+      box->border_radius.top_left.vertical + box->border_radius.bottom_left.vertical > box->box.height)
+    factor = MIN (factor, box->box.height / (box->border_radius.top_left.vertical +
+                                             box->border_radius.bottom_left.vertical));
+
+  /* top */
+  if (box->border_radius.top_left.horizontal + box->border_radius.top_right.horizontal > 0 &&
+      box->border_radius.top_left.horizontal + box->border_radius.top_right.horizontal > box->box.width)
+    factor = MIN (factor, box->box.width / (box->border_radius.top_left.horizontal +
+                                            box->border_radius.top_right.horizontal));
+
+  /* right */
+  if (box->border_radius.top_right.vertical + box->border_radius.bottom_right.horizontal > 0 &&
+      box->border_radius.top_right.vertical + box->border_radius.bottom_right.horizontal > box->box.height)
+    factor = MIN (factor, box->box.height / (box->border_radius.top_right.vertical +
+                                             box->border_radius.bottom_right.horizontal));
+
+  /* bottom */
+  if (box->border_radius.bottom_right.horizontal + box->border_radius.bottom_left.horizontal > 0 &&
+      box->border_radius.bottom_right.horizontal + box->border_radius.bottom_left.horizontal > box->box.width)
+    factor = MIN (factor, box->box.width / (box->border_radius.bottom_right.horizontal +
+                                            box->border_radius.bottom_left.horizontal));
+
+  /* scale border radius */
+  box->border_radius.top_left.horizontal *= factor;
+  box->border_radius.top_left.vertical *= factor;
+  box->border_radius.top_right.horizontal *= factor;
+  box->border_radius.top_right.vertical *= factor;
+  box->border_radius.bottom_right.horizontal *= factor;
+  box->border_radius.bottom_right.vertical *= factor;
+  box->border_radius.bottom_left.horizontal *= factor;
+  box->border_radius.bottom_left.vertical *= factor;
+}
+
 void
 _gtk_rounded_box_apply_border_radius (GtkRoundedBox    *box,
                                       GtkThemingEngine *engine,
@@ -75,6 +116,8 @@ _gtk_rounded_box_apply_border_radius (GtkRoundedBox    *box,
   if (bottom_left_radius && (junction & GTK_JUNCTION_CORNER_BOTTOMLEFT) == 0)
     box->border_radius.bottom_left = *bottom_left_radius;
 
+  gtk_rounded_box_clamp_border_radius (box);
+
   g_free (top_left_radius);
   g_free (top_right_radius);
   g_free (bottom_right_radius);
@@ -128,6 +171,8 @@ _gtk_rounded_box_grow (GtkRoundedBox *box,
   gtk_css_border_radius_grow (&box->border_radius.top_right, right, bottom);
   gtk_css_border_radius_grow (&box->border_radius.bottom_right, right, top);
   gtk_css_border_radius_grow (&box->border_radius.bottom_left, left, bottom);
+
+  gtk_rounded_box_clamp_border_radius (box);
 }
 
 void
