Changeset 2859:db084139c35a in livinglogic.python.xist

Show
Ignore:
Timestamp:
08/07/07 17:52:09 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Speed optimization in html.applycss().

Return the CSSStyleDeclaration inside the rule instead of the CSSStyleRule
in the local iterstyles() function. As the result is looped over more often
the it is created this should be faster.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/ns/html.py

    r2858 r2859  
    14851485                    xfind.CSSWeight(1, 0, 0), 
    14861486                    xfind.IsSelector(node), 
    1487                     cssutils.parseString(u"*{%s}" % style).cssRules[0] # parse the style out of the style attribute 
     1487                    cssutils.parseString(u"*{%s}" % style).cssRules[0].style # parse the style out of the style attribute 
    14881488                ) 
    14891489                # put the style attribute into the order as the last of the selectors with ID weight (see http://www.w3.org/TR/REC-CSS1#cascading-order) 
     
    15041504        for selector in rule.selectorList: 
    15051505            selector = xfind.css(selector) 
    1506             rules.append((selector.cssweight(), selector, rule)) 
     1506            rules.append((selector.cssweight(), selector, rule.style)) 
    15071507    rules.sort(key=operator.itemgetter(0)) 
    15081508    count = 0 
     
    15111511        if path[-1].Attrs.isallowed("style"): 
    15121512            styles = {} 
    1513             for (weight, selector, rule) in iterstyles(path[-1], rules): 
     1513            for (weight, selector, style) in iterstyles(path[-1], rules): 
    15141514                if selector.match(path): 
    1515                     for prop in rule.style.seq: 
     1515                    for prop in style.seq: 
    15161516                        if not isinstance(prop, css.CSSComment): 
    15171517                            for value in prop: