def getLocalState(self, element, state=None): """ Get the state local to an element. """ if state is None: state = self.state current = dict(state) element_items = [(k,v) for (k,v) in element.items() if v != 'inherit'] current.update(element_items) style_items = [(k,v) for (k,v) in css.inlineStyle(element.get("style", "")).items() if v != 'inherit'] current.update(style_items) return current
def processElement(self, element): """ Process one element of the XML tree. Returns the path representing the node, and an operation list for drawing the node. Parent nodes should return a path (for hittesting), but no draw operations """ #copy the current state current = dict(self.state) current.update(element.items()) current.update(css.inlineStyle(element.get("style", ""))) self.stateStack.append(current) handler = self.handlers.get(element.tag, lambda *any: (None, None)) path, ops = handler(element) self.paths[element] = path self.stateStack.pop() return path, ops