diff options
-rw-r--r-- | src/css/cascade.nim | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim index d1927721..fc82e7ef 100644 --- a/src/css/cascade.nim +++ b/src/css/cascade.nim @@ -273,14 +273,14 @@ proc add(map: var CSSValueEntryObj; rules: seq[CSSRuleDef]) = map.important.add(rule.importantVals) proc applyDeclarations(styledNode: StyledNode; parent: CSSComputedValues; - map: RuleListMap) = + map: RuleListMap; styling: bool) = var rules: CSSValueEntryMap var presHints: CSSComputedValues = nil rules[coUserAgent].add(map.ua[peNone]) rules[coUser].add(map.user[peNone]) for rule in map.author: rules[coAuthor].add(rule[peNone]) - if styledNode.node != nil: + if styling and styledNode.node != nil: let element = Element(styledNode.node) let style = element.cachedStyle if style != nil: @@ -337,12 +337,13 @@ func calcRules(styledNode: StyledNode; ua, user: CSSStylesheet; author: authordecls ) -proc applyStyle(parent, styledNode: StyledNode; map: RuleListMap) = +proc applyStyle(parent, styledNode: StyledNode; map: RuleListMap; + styling: bool) = let parentComputed = if parent != nil: parent.computed else: rootProperties() - styledNode.applyDeclarations(parentComputed, map) + styledNode.applyDeclarations(parentComputed, map, styling) type CascadeFrame = object styledParent: StyledNode @@ -374,7 +375,8 @@ proc applyRulesFrameValid(frame: var CascadeFrame): StyledNode = return cachedChild proc applyRulesFrameInvalid(frame: CascadeFrame; ua, user: CSSStylesheet; - author: seq[CSSStylesheet]; declmap: var RuleListMap): StyledNode = + author: seq[CSSStylesheet]; declmap: var RuleListMap; styling: bool): + StyledNode = var styledChild: StyledNode = nil let pseudo = frame.pseudo let styledParent = frame.styledParent @@ -442,7 +444,7 @@ proc applyRulesFrameInvalid(frame: CascadeFrame; ua, user: CSSStylesheet; styledChild = styledParent.newStyledElement(element) styledParent.children.add(styledChild) declmap = styledChild.calcRules(ua, user, author) - applyStyle(styledParent, styledChild, declmap) + styledParent.applyStyle(styledChild, declmap, styling) elif child of Text: let text = Text(child) styledChild = styledParent.newStyledText(text) @@ -452,7 +454,7 @@ proc applyRulesFrameInvalid(frame: CascadeFrame; ua, user: CSSStylesheet; let element = Element(child) styledChild = newStyledElement(element) declmap = styledChild.calcRules(ua, user, author) - applyStyle(styledParent, styledChild, declmap) + styledParent.applyStyle(styledChild, declmap, styling) return styledChild proc stackAppend(styledStack: var seq[CascadeFrame]; frame: CascadeFrame; @@ -556,7 +558,8 @@ proc applyRules(document: Document; ua, user: CSSStylesheet; # From here on, computed values of this node's children are invalid # because of property inheritance. frame.cachedChild = nil - frame.applyRulesFrameInvalid(ua, user, author, declmap) + frame.applyRulesFrameInvalid(ua, user, author, declmap, + document.window.styling) if styledChild != nil: if styledParent == nil: # Root element |