From e285acda8eb370e7159258fc76a816a6366813f1 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Mon, 15 Aug 2016 03:34:40 +0200 Subject: [PATCH] Draw column rules --- weasyprint/css/__init__.py | 3 ++- weasyprint/draw.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/weasyprint/css/__init__.py b/weasyprint/css/__init__.py index 10c80e4b..76e3def0 100644 --- a/weasyprint/css/__init__.py +++ b/weasyprint/css/__init__.py @@ -67,7 +67,8 @@ PAGE_PSEUDOCLASS_TARGETS = { # A test function that returns True if the given property name has an # initial value that is not always the same when computed. RE_INITIAL_NOT_COMPUTED = re.compile( - '^(display|column_gap|(border_[a-z]+|outline)_(width|color))$').match + '^(display|column_gap|' + '(border_[a-z]+|outline|column_rule)_(width|color))$').match class StyleDict(object): diff --git a/weasyprint/draw.py b/weasyprint/draw.py index 5cd7bd5e..9a3be28e 100644 --- a/weasyprint/draw.py +++ b/weasyprint/draw.py @@ -396,6 +396,26 @@ def draw_border(context, box, enable_hinting): # We need a plan to draw beautiful borders, and that's difficult, no need # to lie. Let's try to find the cases that we can handle in a smart way. + # Draw column borders + columns = ( + box.style.column_width != 'auto' or + box.style.column_count != 'auto') + if columns and box.style.column_rule_width: + for child in box.children[1:]: + with stacked(context): + position_x = (child.position_x - ( + box.style.column_rule_width + box.style.column_gap) / 2) + border_box = ( + position_x, child.position_y, box.style.column_rule_width, + box.height) + clip_border_segment( + context, enable_hinting, box.style.column_rule_style, + box.style.column_rule_width, 'left', border_box) + draw_rect_border( + context, border_box, + (0, 0, 0, box.style.column_rule_width), + box.style.column_rule_style, box.style.column_rule_color) + # The box is hidden, easy. if box.style.visibility != 'visible': return