     /////////////////////////////  end  /////////////////////////////////////
 
     for s in childrenList {
-      let e = s.element!
+      var candidateSize = s
+      if s.height > contentHeight {
+        candidateSize.height = contentHeight
+      }
       if s.expandWidth || s.width > w {
-        var expandedOrClippedSize = s
-        expandedOrClippedSize.width = w
-        e.draw(ap.x, y: ap.y, size: expandedOrClippedSize)
-      } else {
-        e.draw(ap.x, y: ap.y, size: s)
-      }
+        candidateSize.width = w
+      }
+      s.element!.draw(ap.x, y: ap.y, size: candidateSize)
       ap.y += s.height
+      contentHeight -= s.height
+      if contentHeight <= 0 {
+        break
+      }
     }
   }
 


  public func drawBackground(x: Int, y: Int, width: Int, height: Int,
      strings: [String]) {
    let blen = strings.count
    if blen == 0 || strings[0].isEmpty {
      return

    if expandHeight {
      size.height = height
    }
    let w = size.width - size.borderLeft - size.borderRight
    var contentHeight = size.height - size.borderTop - size.borderBottom
    if w <= 0 || contentHeight <= 0 {
      return
    }
    var ap = drawBorder(x, y: y, size: size)
    drawBackground(ap.x, y: ap.y, width: w, height: contentHeight,
        strings: backgroundStrings)

