Skip to content

Commit

Permalink
Remove the Running class
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Sep 27, 2019
1 parent 6b3ce39 commit d9432a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
1 change: 0 additions & 1 deletion weasyprint/css/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from tinycss2.color3 import parse_color

Dimension = collections.namedtuple('Dimension', ['value', 'unit'])
Running = collections.namedtuple('Running', ['element'])


# See http://www.w3.org/TR/CSS21/propidx.html
Expand Down
10 changes: 4 additions & 6 deletions weasyprint/css/validation/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from ...formatting_structure import counters
from .. import computed_values
from ..properties import KNOWN_PROPERTIES, Dimension, Running
from ..properties import KNOWN_PROPERTIES, Dimension
from ..utils import (
InvalidValues, check_var_function, comma_separated_list, get_angle,
get_content_list, get_content_list_token, get_custom_ident, get_image,
Expand Down Expand Up @@ -970,11 +970,9 @@ def text_overflow(keyword):
@single_token
def position(token):
"""``position`` property validation."""
if (
token.type == 'function' and token.name == 'running' and
len(token.arguments) == 1 and token.arguments[0].type == 'ident'
):
return Running(token.arguments[0].value)
if token.type == 'function' and token.name == 'running':
if len(token.arguments) == 1 and token.arguments[0].type == 'ident':
return ('running()', token.arguments[0].value)
keyword = get_single_keyword([token])
if keyword in ('static', 'relative', 'absolute', 'fixed'):
return keyword
Expand Down
10 changes: 4 additions & 6 deletions weasyprint/formatting_structure/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import itertools

from ..css import computed_from_cascaded
from ..css.properties import Dimension, Running
from ..css.properties import Dimension


class Box(object):
Expand Down Expand Up @@ -279,16 +279,14 @@ def is_absolutely_positioned(self):
return self.style['position'] in ('absolute', 'fixed')

def is_running(self):
"""Return whether this box is a running element.
(https://www.w3.org/TR/css-gcpm-3/#running-elements)"""
return isinstance(self.style['position'], Running)
"""Return whether this box is a running element."""
return self.style['position'][0] == 'running()'

def is_in_normal_flow(self):
"""Return whether this box is in normal flow."""
return not (
self.is_floated() or self.is_absolutely_positioned() or
self.is_running()
)
self.is_running())

# Start and end page values for named pages

Expand Down
4 changes: 2 additions & 2 deletions weasyprint/layout/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ def block_container_layout(context, box, max_position_y, skip_stack,
break
elif child.is_running():
placeholder = boxes.RunningPlaceholder(
child.style['position'].element, child.style,
child.style['position'][1], child.style,
)
placeholder.index = index
new_children.append(placeholder)
context.running_elements.setdefault(
child.style['position'].element, {}
child.style['position'][1], {}
)[placeholder] = child
continue

Expand Down

0 comments on commit d9432a7

Please sign in to comment.