+ for (vsize i = 0; i < elts.size (); ++i)
+ {
+ Grob *g = elts[i];
+
+ if (to_boolean (g->get_property ("cross-staff")))
+ continue;
+
+ bool outside_staff = scm_is_number (g->get_property ("outside-staff-priority"));
+ Real padding = robust_scm2double (g->get_property ("outside-staff-padding"), 0.5);
+
+ // When we encounter the first outside-staff grob, make a copy
+ // of the current heights to use as an estimate for the staff heights.
+ // Note that the outside-staff approximation that we use here doesn't
+ // consider any collisions that might occur between outside-staff grobs,
+ // but only the fact that outside-staff grobs may need to be raised above
+ // the staff.
+ if (outside_staff && begin_line_staff_heights.empty ())
+ {
+ begin_line_staff_heights = begin_line_heights;
+ mid_line_staff_heights = mid_line_heights;
+ }
+
+ // TODO: consider a pure version of get_grob_direction?
+ Direction d = to_dir (g->get_property_data ("direction"));
+ d = (d == CENTER) ? UP : d;
+
+ Interval_t<int> rank_span = g->spanned_rank_interval ();
+ vsize first_break = lower_bound (ranks, (vsize)rank_span[LEFT], less<vsize> ());
+ if (first_break > 0 && ranks[first_break] >= (vsize)rank_span[LEFT])
+ first_break--;
+
+ for (vsize j = first_break; j + 1 < ranks.size () && (int)ranks[j] <= rank_span[RIGHT]; ++j)
+ {
+ int start = ranks[j];
+ int end = ranks[j + 1];
+
+ // Take grobs that are visible with respect to a slightly longer line.
+ // Otherwise, we will never include grobs at breakpoints which aren't
+ // end-of-line-visible.
+ int visibility_end = j + 2 < ranks.size () ? ranks[j + 2] : end;
+
+ if (g->pure_is_visible (start, visibility_end))
+ {
+ Interval dims = g->pure_height (common, start, end);
+ if (!dims.is_empty ())
+ {
+ if (rank_span[LEFT] <= start)
+ {
+ if (outside_staff)
+ begin_line_heights[j].unite (begin_line_staff_heights[j].union_disjoint (dims, padding, d));
+ else
+ begin_line_heights[j].unite (dims);
+ }
+ if (rank_span[RIGHT] > start)
+ {
+ if (outside_staff)
+ mid_line_heights[j].unite (mid_line_staff_heights[j].union_disjoint (dims, padding, d));
+ else
+ mid_line_heights[j].unite (dims);
+ }
+ }
+ }
+ }
+ }
+
+ // Convert begin_line_heights and min_line_heights to SCM.
+ SCM begin_scm = scm_c_make_vector (ranks.size () - 1, SCM_EOL);
+ SCM mid_scm = scm_c_make_vector (ranks.size () - 1, SCM_EOL);
+ for (vsize i = 0; i < begin_line_heights.size (); ++i)