def convert_prefixed_properties(self, doc, filename): """ Searches a BeautifulSoup |doc| for any CSS properties requiring the -webkit- prefix and converts them. Returns the list of converted properties and the modified document as a string """ converted_properties = [] # Look for inline and document styles. inline_styles = doc.findAll(style=re.compile('.*')) style_tags = doc.findAll('style') all_styles = inline_styles + style_tags for tag in all_styles: # Get the text whether in a style tag or style attribute. style_text = '' if tag.name == 'style': if not tag.contents: continue style_text = tag.contents[0] else: style_text = tag['style'] updated_style_text = self.add_webkit_prefix_to_unprefixed_properties(style_text, filename) # Rewrite tag only if changes were made. if updated_style_text[0]: converted_properties.extend(updated_style_text[0]) new_tag = Tag(doc, tag.name, tag.attrs) new_tag.insert(0, updated_style_text[1]) self.replace_tag(tag, new_tag) return (converted_properties, doc.prettify())
def convert_prefixed_properties(self, doc, filename): """ Searches a BeautifulSoup |doc| for any CSS properties requiring the -webkit- prefix and converts them. Returns the list of converted properties and the modified document as a string """ converted_properties = [] # Look for inline and document styles. inline_styles = doc.findAll(style=re.compile('.*')) style_tags = doc.findAll('style') all_styles = inline_styles + style_tags for tag in all_styles: # Get the text whether in a style tag or style attribute. style_text = '' if tag.name == 'style': if not tag.contents: continue style_text = tag.contents[0] else: style_text = tag['style'] updated_style_text = self.add_webkit_prefix_to_unprefixed_properties( style_text, filename) # Rewrite tag only if changes were made. if updated_style_text[0]: converted_properties.extend(list(updated_style_text[0])) new_tag = Tag(doc, tag.name, tag.attrs) new_tag.insert(0, updated_style_text[1]) self.replace_tag(tag, new_tag) # FIXME: Doing the replace in the parsed document and then writing it back out # is normalizing the HTML, which may in fact alter the intent of some tests. # We should probably either just do basic string-replaces, or have some other # way of flagging tests that are sensitive to being rewritten. # https://bugs.webkit.org/show_bug.cgi?id=119159 return (converted_properties, doc.prettify())
def convert_prefixed_properties(self, doc, filename): """ Searches a BeautifulSoup |doc| for any CSS properties requiring the -webkit- prefix and converts them. Returns the list of converted properties and the modified document as a string """ converted_properties = [] # Look for inline and document styles. inline_styles = doc.findAll(style=re.compile('.*')) style_tags = doc.findAll('style') all_styles = inline_styles + style_tags for tag in all_styles: # Get the text whether in a style tag or style attribute. style_text = '' if tag.name == 'style': if not tag.contents: continue style_text = tag.contents[0] else: style_text = tag['style'] updated_style_text = self.add_webkit_prefix_to_unprefixed_properties(style_text, filename) # Rewrite tag only if changes were made. if updated_style_text[0]: converted_properties.extend(list(updated_style_text[0])) new_tag = Tag(doc, tag.name, tag.attrs) new_tag.insert(0, updated_style_text[1]) self.replace_tag(tag, new_tag) # FIXME: Doing the replace in the parsed document and then writing it back out # is normalizing the HTML, which may in fact alter the intent of some tests. # We should probably either just do basic string-replaces, or have some other # way of flagging tests that are sensitive to being rewritten. # https://bugs.webkit.org/show_bug.cgi?id=119159 return (converted_properties, doc.prettify())