summaryrefslogtreecommitdiff
path: root/lib/elements/element.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/elements/element.py')
-rw-r--r--lib/elements/element.py39
1 files changed, 6 insertions, 33 deletions
diff --git a/lib/elements/element.py b/lib/elements/element.py
index bcb59bf4..17ed9167 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -7,7 +7,6 @@ import sys
from copy import deepcopy
import inkex
-import tinycss2
from inkex import bezier
from ..commands import find_commands
@@ -15,8 +14,7 @@ from ..i18n import _
from ..patterns import apply_patterns
from ..svg import (PIXELS_PER_MM, apply_transforms, convert_length,
get_node_transform)
-from ..svg.tags import (EMBROIDERABLE_TAGS, INKSCAPE_LABEL, INKSTITCH_ATTRIBS,
- SVG_GROUP_TAG, SVG_LINK_TAG, SVG_USE_TAG)
+from ..svg.tags import INKSCAPE_LABEL, INKSTITCH_ATTRIBS
from ..utils import Point, cache
@@ -96,7 +94,7 @@ class EmbroideryElement(object):
elif legacy_tie == "False":
self.set_param('ties', 3)
- # defaut setting for fill_underlay has changed
+ # default setting for fill_underlay has changed
if legacy_attribs and not self.get_param('fill_underlay', ""):
self.set_param('fill_underlay', False)
@@ -166,37 +164,12 @@ class EmbroideryElement(object):
self.node.set(param, str(value))
@cache
- def parse_style(self, node=None):
- if node is None:
- node = self.node
- element_style = node.get("style", "")
- if element_style is None:
- return None
- declarations = tinycss2.parse_declaration_list(node.get("style", ""))
- style = {declaration.lower_name: declaration.value[0].serialize() for declaration in declarations}
- return style
-
- @cache
- def _get_style_raw(self, style_name):
- if self.node is None:
- return None
- if self.node.tag not in [SVG_GROUP_TAG, SVG_LINK_TAG, SVG_USE_TAG] and self.node.tag not in EMBROIDERABLE_TAGS:
- return None
-
- style = self.parse_style()
- if style:
- style = style.get(style_name) or self.node.get(style_name)
- parent = self.node.getparent()
- # style not found, get inherited style elements
- while not style and parent is not None:
- style = self.parse_style(parent)
- if style:
- style = style.get(style_name) or parent.get(style_name)
- parent = parent.getparent()
- return style
+ def _get_specified_style(self):
+ # We want to cache this, because it's quite expensive to generate.
+ return self.node.specified_style()
def get_style(self, style_name, default=None):
- style = self._get_style_raw(style_name) or default
+ style = self._get_specified_style().get(style_name, default)
if style == 'none':
style = None
return style