def getStyleAttributeFromRegion_(region: Element, styles, attribute): ttsNs = styleNs_ if not region: return None attr = region.getAttributeNS(ttsNs, attribute) if attr: return attr return TtmlTextParser.getInheritedStyleAttribute_(region, styles, attribute)
def getInheritedAttribute_(element: Element, attributeName: str, nsName: str): ret = None while element: if nsName: ret = element.getAttributeNS(nsName, attributeName) else: ret = element.getAttribute(attributeName) if ret: break parentNode = element.parentNode if isinstance(parentNode, Element): element = parentNode else: break return ret
def getStyleAttributeFromElement_(cueElement: Element, styles, attribute: str): ttsNs = styleNs_ elementAttribute = cueElement.getAttributeNS(ttsNs, attribute) if elementAttribute: return elementAttribute return TtmlTextParser.getInheritedStyleAttribute_(cueElement, styles, attribute)