Skip to content

Commit

Permalink
Draw borders before content
Browse files Browse the repository at this point in the history
This reverses 8e0de9a, which I probably had a good reason for at the
time but for some reason didn't document. The behavior introduced by
that commit broke table cells inside stretchy bounds, because the
absolute location of the y-position depends on when the bounds are
stretched (prawnpdf#153).

Introduced a spec to cover the new behavior and prevent regressions.
Closes prawnpdf#153.
  • Loading branch information
bradediger committed Sep 25, 2010
1 parent 7461cb5 commit c8fbc73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/prawn/table/cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,14 @@ def natural_content_height
#
def draw(pt=[x, y])
set_width_constraints

draw_background(pt)
draw_borders(pt)
@pdf.bounding_box([pt[0] + padding_left, pt[1] - padding_top],
:width => content_width + FPTolerance,
:height => content_height + FPTolerance) do
draw_content
end
draw_borders(pt)
end

# x-position of the cell within the parent bounds.
Expand Down
10 changes: 10 additions & 0 deletions spec/cell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@ def close?(actual, expected, epsilon=0.01)
end
@pdf.cell(:content => "text", :borders => [:right])
end

it "should draw borders at the same location when in or out of bbox" do
@pdf.expects(:stroke_line).checking do |from, to|
@pdf.map_to_absolute(from).map{|x| x.round}.should == [36, 756]
@pdf.map_to_absolute(to).map{|x| x.round}.should == [65, 756]
end
@pdf.bounding_box([0, @pdf.cursor], :width => @pdf.bounds.width) do
@pdf.cell(:content => "text", :borders => [:top])
end
end
end

describe "Text cell attributes" do
Expand Down

0 comments on commit c8fbc73

Please sign in to comment.