+
+// This gives the minimum distance between the top of the
+// printable area (ie. the bottom of the top-margin) and
+// the extent box of the topmost system.
+Real
+Page_breaking::min_whitespace_at_top_of_page (Line_details const &line) const
+{
+ SCM first_system_spacing = book_->paper_->c_variable ("top-system-spacing");
+ if (line.title_)
+ first_system_spacing = book_->paper_->c_variable ("top-title-spacing");
+
+ Real min_distance = -infinity_f;
+ Real padding = 0;
+
+ Page_layout_problem::read_spacing_spec (first_system_spacing,
+ &min_distance,
+ ly_symbol2scm ("minimum-distance"));
+ Page_layout_problem::read_spacing_spec (first_system_spacing,
+ &padding,
+ ly_symbol2scm ("padding"));
+
+ // FIXME: take into account the height of the header
+ return max (0.0, max (padding, min_distance - line.extent_[UP]));
+}
+
+Real
+Page_breaking::min_whitespace_at_bottom_of_page (Line_details const &line) const
+{
+ SCM last_system_spacing = book_->paper_->c_variable ("bottom-system-spacing");
+ Real min_distance = -infinity_f;
+ Real padding = 0;
+
+ Page_layout_problem::read_spacing_spec (last_system_spacing,
+ &min_distance,
+ ly_symbol2scm ("minimum-distance"));
+ Page_layout_problem::read_spacing_spec (last_system_spacing,
+ &padding,
+ ly_symbol2scm ("padding"));
+
+ // FIXME: take into account the height of the footer
+ return max (0.0, max (padding, min_distance + line.extent_[DOWN]));
+}
+
+int
+Page_breaking::orphan_penalty () const
+{
+ return orphan_penalty_;
+}